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

Function draw

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

Source from the content-addressed store, hash-verified

10use crate::app::{App, SandboxPolicyTab, SettingScope};
11
12pub fn draw(frame: &mut Frame<'_>, app: &App, area: Rect) {
13 let t = &app.theme;
14
15 let header = Row::new(vec![
16 Cell::from(Span::styled(" KEY", t.muted)),
17 Cell::from(Span::styled("TYPE", t.muted)),
18 Cell::from(Span::styled("VALUE", t.muted)),
19 Cell::from(Span::styled("SCOPE", t.muted)),
20 ])
21 .bottom_margin(1);
22
23 let rows: Vec<Row<'_>> = app
24 .sandbox_settings
25 .iter()
26 .enumerate()
27 .map(|(i, entry)| {
28 let selected = i == app.sandbox_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 if entry.is_globally_managed() {
45 t.status_warn
46 } else {
47 t.accent
48 }
49 } else {
50 t.muted
51 };
52
53 let scope_style = match entry.scope {
54 SettingScope::Global => t.status_warn,
55 SettingScope::Sandbox => t.accent,
56 SettingScope::Unset => t.muted,
57 };
58
59 Row::new(vec![
60 key_cell,
61 Cell::from(Span::styled(type_label, t.muted)),
62 Cell::from(Span::styled(value_display, value_style)),
63 Cell::from(Span::styled(entry.scope.label(), scope_style)),
64 ])
65 })
66 .collect();
67
68 let widths = [
69 Constraint::Percentage(30),

Callers

nothing calls this directly

Calls 9

draw_policy_tab_titleFunction · 0.85
draw_empty_messageFunction · 0.85
display_valueMethod · 0.80
is_globally_managedMethod · 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