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

Function draw_creating

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

Source from the content-addressed store, hash-verified

247// ---------------------------------------------------------------------------
248
249fn draw_creating(frame: &mut Frame<'_>, app: &App, area: Rect) {
250 let t = &app.theme;
251 let Some(form) = &app.create_form else {
252 return;
253 };
254
255 // content: header(1) + spacer(1) + animation(1)
256 // chrome: border(2) + padding top/bottom(2)
257 let content_height = 1 + 1 + 1;
258 let modal_width = 60u16.min(area.width.saturating_sub(4));
259 let modal_height = (content_height + 4).min(area.height.saturating_sub(2));
260 let popup_area = centered_rect(modal_width, modal_height, area);
261
262 frame.render_widget(Clear, popup_area);
263
264 let block = Block::default()
265 .title(Span::styled(" Creating Sandbox ", t.heading))
266 .borders(Borders::ALL)
267 .border_style(t.accent)
268 .padding(Padding::new(2, 2, 1, 1));
269
270 let inner = block.inner(popup_area);
271 frame.render_widget(block, popup_area);
272
273 let chunks = Layout::default()
274 .direction(Direction::Vertical)
275 .constraints([
276 Constraint::Length(1), // header
277 Constraint::Length(1), // spacer
278 Constraint::Length(1), // animation
279 Constraint::Min(0),
280 ])
281 .split(inner);
282
283 // Header — changes once result arrives.
284 let (header, header_style) = match &form.create_result {
285 Some(Ok(name)) => (format!("Created sandbox: {name}"), t.status_ok),
286 Some(Err(msg)) => (format!("Failed: {msg}"), t.status_err),
287 None => ("Creating sandbox...".to_string(), t.text),
288 };
289 frame.render_widget(
290 Paragraph::new(Line::from(Span::styled(header, header_style))),
291 chunks[0],
292 );
293
294 // Pacman chase animation.
295 let elapsed_ms = form.anim_start.map_or(0, |s| s.elapsed().as_millis());
296 let track_width = chunks[2].width.saturating_sub(1) as usize;
297 let anim_line = render_chase(track_width, elapsed_ms, t);
298 frame.render_widget(Paragraph::new(anim_line), chunks[2]);
299}
300
301/// Render the NVIDIA pacman chasing a maroon claw across a dot track.
302///

Callers 1

drawFunction · 0.70

Calls 2

centered_rectFunction · 0.85
render_chaseFunction · 0.85

Tested by

no test coverage detected