MCPcopy Create free account
hub / github.com/GCWing/BitFun / render_input

Method render_input

src/apps/cli/src/ui/startup.rs:520–603  ·  view source on GitHub ↗
(&mut self, frame: &mut Frame, area: Rect)

Source from the content-addressed store, hash-verified

518 }
519
520 fn render_input(&mut self, frame: &mut Frame, area: Rect) {
521 let highlight_color = self.theme.primary;
522 let input_bg = self.input_background();
523
524 // Split: 2 cols for left bar, rest for content
525 let h_chunks = Layout::default()
526 .direction(Direction::Horizontal)
527 .constraints([
528 Constraint::Length(2), // left bar
529 Constraint::Min(1), // content
530 ])
531 .split(area);
532
533 // Left bar: full-height ┃
534 let bar_lines: Vec<Line> = (0..area.height)
535 .map(|_| {
536 Line::from(Span::styled(
537 " ┃",
538 Style::default().fg(highlight_color).bg(input_bg),
539 ))
540 })
541 .collect();
542 let bar = Paragraph::new(bar_lines).style(Style::default().bg(input_bg));
543 frame.render_widget(bar, h_chunks[0]);
544
545 // Content area with background
546 let content_area = h_chunks[1];
547
548 // Fill background
549 let bg = Paragraph::new(vec![Line::from(""); content_area.height as usize])
550 .style(Style::default().bg(input_bg));
551 frame.render_widget(bg, content_area);
552
553 // Inner content with padding
554 let inner = Rect {
555 x: content_area.x + 2,
556 y: content_area.y + 1,
557 width: content_area.width.saturating_sub(4),
558 height: content_area.height.saturating_sub(1),
559 };
560
561 // Calculate how many lines are available for text input
562 // Reserve 2 lines at the bottom: 1 gap + 1 agent label
563 let text_height = inner.height.saturating_sub(2).max(1);
564 let text_area = Rect {
565 x: inner.x,
566 y: inner.y,
567 width: inner.width,
568 height: text_height,
569 };
570
571 // Render text input using shared TextInput component
572 let style = TextInputStyle {
573 first_line_prefix: "",
574 continuation_prefix: "",
575 placeholder: "Ask anything... or type / for commands".to_string(),
576 text_style: Style::default().fg(self.theme.command_text).bg(input_bg),
577 placeholder_style: Style::default().fg(self.theme.muted).bg(input_bg),

Callers 1

render_mainMethod · 0.45

Calls 6

input_backgroundMethod · 0.80
collectMethod · 0.80
styleMethod · 0.80
renderMethod · 0.65
is_emptyMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected