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

Function draw_title_bar

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

Source from the content-addressed store, hash-verified

124// ---------------------------------------------------------------------------
125
126fn draw_title_bar(frame: &mut Frame<'_>, app: &App, area: Rect) {
127 let t = &app.theme;
128 let status_span = match app.status_text.as_str() {
129 s if s.contains("Healthy") => Span::styled(&app.status_text, t.status_ok),
130 s if s.contains("Degraded") => Span::styled(&app.status_text, t.status_warn),
131 s if s.contains("Unhealthy") => Span::styled(&app.status_text, t.status_err),
132 _ => Span::styled(&app.status_text, t.muted),
133 };
134
135 let active_gateway_source = app
136 .gateways
137 .iter()
138 .find(|gateway| gateway.name == app.gateway_name)
139 .map_or("unknown", app::GatewayEntry::source_label);
140
141 let mut parts: Vec<Span<'_>> = vec![
142 Span::styled(" >_ OpenShell ", t.accent_bold),
143 Span::styled(" ALPHA ", t.badge),
144 Span::styled(" | ", t.muted),
145 Span::styled("Current Gateway: ", t.text),
146 Span::styled(&app.gateway_name, t.heading),
147 Span::styled(" [", t.muted),
148 Span::styled(active_gateway_source, t.muted),
149 Span::styled("] (", t.muted),
150 status_span,
151 Span::styled(")", t.muted),
152 Span::styled(" | ", t.muted),
153 ];
154
155 match app.screen {
156 Screen::Splash => unreachable!("splash handled before draw_title_bar"),
157 Screen::Dashboard => {
158 parts.push(Span::styled("Dashboard", t.text));
159 }
160 Screen::Sandbox => {
161 let name = app
162 .sandbox_names
163 .get(app.sandbox_selected)
164 .map_or("-", String::as_str);
165 parts.push(Span::styled("Sandbox: ", t.text));
166 parts.push(Span::styled(name, t.heading));
167 }
168 }
169
170 let title = Line::from(parts);
171 frame.render_widget(Paragraph::new(title).style(t.title_bar), area);
172}
173
174fn draw_nav_bar(frame: &mut Frame<'_>, app: &App, area: Rect) {
175 let t = &app.theme;

Callers 1

drawFunction · 0.85

Calls 3

pushMethod · 0.80
as_strMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected