From be71f1090343cff1a0b2f0a9e0cab9a9cf8e96dd Mon Sep 17 00:00:00 2001 From: Oliver Date: Mon, 10 Nov 2025 21:25:42 -0700 Subject: [PATCH] colors --- src/app/app.rs | 7 ++++--- src/app/mode.rs | 21 ++++++++++++++++----- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/app/app.rs b/src/app/app.rs index 99ea621..8bc4ff9 100644 --- a/src/app/app.rs +++ b/src/app/app.rs @@ -37,8 +37,6 @@ impl Widget for &App { x2 += 1; y2 += 1; - - if x >= x1 && x <= x2{ // in-between the Xs if y >= y1 && y <= y2 { @@ -172,7 +170,10 @@ impl App { let bottom_split = Layout::default() .direction(layout::Direction::Horizontal) - .constraints([Constraint::Percentage(50), Constraint::Percentage(50)]) + .constraints([ + Constraint::Min(30), + Constraint::Min(100), + ]) .split(cmd_line); let cmd_line_left = bottom_split[0]; diff --git a/src/app/mode.rs b/src/app/mode.rs index 123dde8..9fd0e10 100644 --- a/src/app/mode.rs +++ b/src/app/mode.rs @@ -1,12 +1,10 @@ use std::fmt::Display; use ratatui::{ - layout::Rect, - prelude, - widgets::{Paragraph, Widget}, + layout::Rect, prelude, style::{Color, Modifier, Style}, widgets::{Paragraph, Widget} }; -use crate::app::{self, app::App}; +use crate::app::{app::App}; pub enum Mode { Insert(Editor), @@ -18,7 +16,19 @@ pub enum Mode { impl Widget for &Mode { fn render(self, area: Rect, buf: &mut prelude::Buffer) { - Paragraph::new(self.to_string()).render(area, buf); + let style = match self { + // Where you are typing - italic + Mode::Insert(_) => Style::new().fg(Color::Blue).add_modifier(Modifier::ITALIC), + Mode::Command(_) => Style::new().fg(Color::LightGreen).add_modifier(Modifier::ITALIC), + Mode::Chord(_) => Style::new().fg(Color::Blue).add_modifier(Modifier::ITALIC), + // Movement-based modes + Mode::Visual(_) => Style::new().fg(Color::Yellow), + Mode::Normal => Style::new().fg(Color::Green), + }; + + Paragraph::new(self.to_string()) + .style(style) + .render(area, buf); } } @@ -143,6 +153,7 @@ pub struct Editor { cursor: usize, pub location: (usize, usize), } + impl Editor { fn new(value: String, loc: (usize, usize)) -> Self { Self {