working at least a bit

This commit is contained in:
filipriec
2025-02-16 21:45:25 +01:00
parent c4356dcff6
commit 50d955b966
3 changed files with 67 additions and 5 deletions

View File

@@ -11,8 +11,9 @@ pub struct Theme {
pub border: Color,
}
impl Default for Theme {
fn default() -> Self {
impl Theme {
// Default light theme
pub fn light() -> Self {
Self {
bg: Color::Rgb(245, 245, 245), // Light gray
fg: Color::Rgb(64, 64, 64), // Dark gray
@@ -22,4 +23,34 @@ impl Default for Theme {
border: Color::Rgb(220, 220, 220), // Light gray border
}
}
// High-contrast dark theme
pub fn dark() -> Self {
Self {
bg: Color::Rgb(30, 30, 30), // Dark background
fg: Color::Rgb(255, 255, 255), // White text
accent: Color::Rgb(0, 191, 255), // Bright blue
highlight: Color::Rgb(50, 205, 50), // Bright green
warning: Color::Rgb(255, 99, 71), // Bright red
border: Color::Rgb(100, 100, 100), // Medium gray border
}
}
// High-contrast light theme
pub fn high_contrast() -> Self {
Self {
bg: Color::Rgb(255, 255, 255), // White background
fg: Color::Rgb(0, 0, 0), // Black text
accent: Color::Rgb(0, 0, 255), // Blue
highlight: Color::Rgb(0, 128, 0), // Green
warning: Color::Rgb(255, 0, 0), // Red
border: Color::Rgb(0, 0, 0), // Black border
}
}
}
impl Default for Theme {
fn default() -> Self {
Self::light() // Default to light theme
}
}

View File

@@ -8,7 +8,11 @@ use ratatui::{
use crate::client::colors::Theme;
pub fn render_command_line(f: &mut Frame, area: Rect, input: &str, active: bool, theme: &Theme) {
let prompt = if active { ":" } else { "Press ':' for commands" };
let prompt = if active {
": (w = save, q = quit)"
} else {
"Press ':' for commands (w = save, q = quit)"
};
let style = if active {
Style::default().fg(theme.accent)
} else {

View File

@@ -48,7 +48,7 @@ pub async fn run_client() -> Result<(), Box<dyn std::error::Error>> {
];
let mut command_mode = false;
let mut command_input = String::new();
let theme = Theme::default();
let theme = Theme::dark();
loop {
terminal.draw(|f| {
@@ -112,7 +112,34 @@ pub async fn run_client() -> Result<(), Box<dyn std::error::Error>> {
}
continue;
}
if command_mode {
match key.code {
KeyCode::Enter => {
match command_input.as_str() {
"w" => break, // Save and exit
"q" => { // Quit without saving
disable_raw_mode()?;
execute!(terminal.backend_mut(), LeaveAlternateScreen)?;
return Ok(());
}
_ => {
command_mode = false;
command_input.clear();
}
}
}
KeyCode::Char(c) => command_input.push(c),
KeyCode::Backspace => {
command_input.pop();
}
KeyCode::Esc => {
command_mode = false;
command_input.clear();
}
_ => {}
}
continue;
}
match key.code {
KeyCode::Char(':') => {
command_mode = true;