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

Function draw

crates/openshell-tui/src/ui/global_settings.rs:13–94  ·  view source on GitHub ↗
(frame: &mut Frame<'_>, app: &App, area: Rect, focused: bool)

Source from the content-addressed store, hash-verified

11use crate::app::{App, MiddlePaneTab};
12
13pub fn draw(frame: &mut Frame<'_>, app: &App, area: Rect, focused: bool) {
14 let t = &app.theme;
15
16 let header = Row::new(vec![
17 Cell::from(Span::styled(" KEY", t.muted)),
18 Cell::from(Span::styled("TYPE", t.muted)),
19 Cell::from(Span::styled("VALUE", t.muted)),
20 ])
21 .bottom_margin(1);
22
23 let rows: Vec<Row<'_>> = app
24 .global_settings
25 .iter()
26 .enumerate()
27 .map(|(i, entry)| {
28 let selected = focused && i == app.global_settings_selected;
29 let key_cell = if selected {
30 Cell::from(Line::from(vec![
31 Span::styled("> ", t.accent),
32 Span::styled(&entry.key, t.text),
33 ]))
34 } else {
35 Cell::from(Line::from(vec![
36 Span::raw(" "),
37 Span::styled(&entry.key, t.text),
38 ]))
39 };
40
41 let type_label = entry.kind.as_str();
42 let value_display = entry.display_value();
43 let value_style = if entry.value.is_some() {
44 t.accent
45 } else {
46 t.muted
47 };
48
49 Row::new(vec![
50 key_cell,
51 Cell::from(Span::styled(type_label, t.muted)),
52 Cell::from(Span::styled(value_display, value_style)),
53 ])
54 })
55 .collect();
56
57 let widths = [
58 Constraint::Percentage(35),
59 Constraint::Percentage(15),
60 Constraint::Percentage(50),
61 ];
62
63 let border_style = if focused { t.border_focused } else { t.border };
64
65 let title = draw_tab_title(app, focused);
66
67 let block = Block::default()
68 .title(title)
69 .borders(Borders::ALL)
70 .border_style(border_style)

Callers

nothing calls this directly

Calls 8

draw_tab_titleFunction · 0.85
draw_empty_messageFunction · 0.85
display_valueMethod · 0.80
draw_edit_overlayFunction · 0.70
draw_confirm_setFunction · 0.70
draw_confirm_deleteFunction · 0.70
as_strMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected