MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / centered_rect

Function centered_rect

crates/openshell-tui/src/ui/mod.rs:504–522  ·  view source on GitHub ↗

Center a popup rectangle within `area` using absolute width and height (in terminal columns/rows).

(width: u16, height: u16, area: Rect)

Source from the content-addressed store, hash-verified

502/// Center a popup rectangle within `area` using absolute width and height (in
503/// terminal columns/rows).
504pub fn centered_rect(width: u16, height: u16, area: Rect) -> Rect {
505 let vert = Layout::default()
506 .direction(Direction::Vertical)
507 .constraints([
508 Constraint::Length((area.height.saturating_sub(height)) / 2),
509 Constraint::Length(height),
510 Constraint::Min(0),
511 ])
512 .split(area);
513 let horiz = Layout::default()
514 .direction(Direction::Horizontal)
515 .constraints([
516 Constraint::Length((area.width.saturating_sub(width)) / 2),
517 Constraint::Length(width),
518 Constraint::Min(0),
519 ])
520 .split(vert[1]);
521 horiz[1]
522}
523
524// ---------------------------------------------------------------------------
525// Shared setting-edit overlay (used by both global and sandbox settings panes)

Callers 12

draw_formFunction · 0.85
draw_creatingFunction · 0.85
draw_detail_popupFunction · 0.85
draw_select_typeFunction · 0.85
draw_choose_methodFunction · 0.85
draw_enter_keyFunction · 0.85
draw_creatingFunction · 0.85
draw_detailFunction · 0.85
draw_updateFunction · 0.85
draw_detail_popupFunction · 0.85
draw_approve_all_popupFunction · 0.85
drawFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected