open menu in command mode now implemented

This commit is contained in:
filipriec
2025-05-28 19:09:55 +02:00
parent f77c16dec9
commit 799d8471c9
6 changed files with 336 additions and 214 deletions

View File

@@ -6,27 +6,37 @@ use ratatui::{
Frame,
};
use crate::config::colors::themes::Theme;
pub fn render_command_line(
f: &mut Frame,
area: Rect,
input: &str, // This is event_handler.command_input
active: bool, // This is event_handler.command_mode
theme: &Theme,
message: &str, // This is event_handler.command_message
// Palette-specific parameters are removed
) {
// This function now only renders the normal command line.
// The find_file_palette_active check in render_ui ensures this is called appropriately.
pub fn render_command_line(f: &mut Frame, area: Rect, input: &str, active: bool, theme: &Theme, message: &str) {
let prompt = if active {
":"
} else {
""
};
if !active { // If not in normal command mode, render minimally or nothing
let paragraph = Paragraph::new("")
.block(Block::default().style(Style::default().bg(theme.bg)));
f.render_widget(paragraph, area);
return;
}
// Combine the prompt, input, and message
let display_text = if message.is_empty() {
let prompt = ":";
let display_text = if message.is_empty() || message == ":" {
format!("{}{}", prompt, input)
} else {
format!("{}{} | {}", prompt, input, message)
};
let style = if active {
Style::default().fg(theme.accent)
} else {
Style::default().fg(theme.fg)
if input.is_empty() { // If command was just executed, input is cleared, show message
message.to_string()
} else { // Show input and message
format!("{}{} | {}", prompt, input, message)
}
};
let style = Style::default().fg(theme.accent); // Style for active command line
let paragraph = Paragraph::new(display_text)
.block(Block::default().style(Style::default().bg(theme.bg)))
.style(style);