36 lines
886 B
Rust
36 lines
886 B
Rust
// src/client/components/command_line.rs
|
|
use ratatui::{
|
|
widgets::{Block, Paragraph},
|
|
style::Style,
|
|
layout::Rect,
|
|
Frame,
|
|
};
|
|
use crate::config::colors::themes::Theme;
|
|
|
|
pub fn render_command_line(f: &mut Frame, area: Rect, input: &str, active: bool, theme: &Theme, message: &str) {
|
|
let prompt = if active {
|
|
":"
|
|
} else {
|
|
""
|
|
};
|
|
|
|
// Combine the prompt, input, and message
|
|
let display_text = if message.is_empty() {
|
|
format!("{}{}", prompt, input)
|
|
} else {
|
|
format!("{}{} | {}", prompt, input, message)
|
|
};
|
|
|
|
let style = if active {
|
|
Style::default().fg(theme.accent)
|
|
} else {
|
|
Style::default().fg(theme.fg)
|
|
};
|
|
|
|
let paragraph = Paragraph::new(display_text)
|
|
.block(Block::default().style(Style::default().bg(theme.bg)))
|
|
.style(style);
|
|
|
|
f.render_widget(paragraph, area);
|
|
}
|