working at least a bit
This commit is contained in:
@@ -11,8 +11,9 @@ pub struct Theme {
|
|||||||
pub border: Color,
|
pub border: Color,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Theme {
|
impl Theme {
|
||||||
fn default() -> Self {
|
// Default light theme
|
||||||
|
pub fn light() -> Self {
|
||||||
Self {
|
Self {
|
||||||
bg: Color::Rgb(245, 245, 245), // Light gray
|
bg: Color::Rgb(245, 245, 245), // Light gray
|
||||||
fg: Color::Rgb(64, 64, 64), // Dark 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
|
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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,11 @@ use ratatui::{
|
|||||||
use crate::client::colors::Theme;
|
use crate::client::colors::Theme;
|
||||||
|
|
||||||
pub fn render_command_line(f: &mut Frame, area: Rect, input: &str, active: bool, theme: &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 {
|
let style = if active {
|
||||||
Style::default().fg(theme.accent)
|
Style::default().fg(theme.accent)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ pub async fn run_client() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
];
|
];
|
||||||
let mut command_mode = false;
|
let mut command_mode = false;
|
||||||
let mut command_input = String::new();
|
let mut command_input = String::new();
|
||||||
let theme = Theme::default();
|
let theme = Theme::dark();
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
terminal.draw(|f| {
|
terminal.draw(|f| {
|
||||||
@@ -112,7 +112,34 @@ pub async fn run_client() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
}
|
}
|
||||||
continue;
|
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 {
|
match key.code {
|
||||||
KeyCode::Char(':') => {
|
KeyCode::Char(':') => {
|
||||||
command_mode = true;
|
command_mode = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user