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

Function draw

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

Source from the content-addressed store, hash-verified

9use crate::app::App;
10
11pub fn draw(frame: &mut Frame<'_>, app: &App, area: Rect, focused: bool) {
12 let t = &app.theme;
13 if app.providers_v2_enabled {
14 draw_v2(frame, app, area, focused);
15 return;
16 }
17
18 let header = Row::new(vec![
19 Cell::from(Span::styled(" NAME", t.muted)),
20 Cell::from(Span::styled("TYPE", t.muted)),
21 Cell::from(Span::styled("CRED KEY", t.muted)),
22 ])
23 .bottom_margin(1);
24
25 let rows: Vec<Row<'_>> = (0..app.provider_count)
26 .map(|i| {
27 let name = app.provider_names.get(i).map_or("", String::as_str);
28 let ptype = app.provider_types.get(i).map_or("", String::as_str);
29 let cred_key = app.provider_cred_keys.get(i).map_or("", String::as_str);
30
31 let selected = focused && i == app.provider_selected;
32 let name_cell = if selected {
33 Cell::from(Line::from(vec![
34 Span::styled("> ", t.accent),
35 Span::styled(name, t.text),
36 ]))
37 } else {
38 Cell::from(Line::from(vec![
39 Span::raw(" "),
40 Span::styled(name, t.text),
41 ]))
42 };
43
44 Row::new(vec![
45 name_cell,
46 Cell::from(Span::styled(ptype, t.muted)),
47 Cell::from(Span::styled(cred_key, t.muted)),
48 ])
49 })
50 .collect();
51
52 let widths = [
53 Constraint::Percentage(40),
54 Constraint::Percentage(25),
55 Constraint::Percentage(35),
56 ];
57
58 let border_style = if focused { t.border_focused } else { t.border };
59
60 // Show delete confirmation in the title area if active.
61 let title = if focused && app.confirm_provider_delete {
62 let name = app
63 .provider_names
64 .get(app.provider_selected)
65 .map_or("-", String::as_str);
66 Line::from(vec![
67 Span::styled(" Delete '", t.status_err),
68 Span::styled(name, t.status_err),

Callers

nothing calls this directly

Calls 4

draw_v2Function · 0.85
draw_tab_titleFunction · 0.85
draw_empty_messageFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected