From 8db7a81fed7bfac9b0a48acc7123334caa54ecaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Macio=C5=82ek?= Date: Sat, 11 May 2024 09:55:09 +0200 Subject: [PATCH] cursor position update, colors update --- src/ui.rs | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/ui.rs b/src/ui.rs index fa92a6f..ce5f8dd 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -1,6 +1,6 @@ use ratatui::{ layout::{Alignment, Constraint, Direction, Layout}, - style::{Color, Style}, + style::{Color, Style, Stylize}, text::Line, widgets::{Block, Borders, Paragraph}, Frame, @@ -12,11 +12,12 @@ pub fn render(app: &mut App, frame: &mut Frame) { let content_lines: Vec = app.content.iter().map(|s| s.as_str().into()).collect(); let status_bar = Line::from(format!( - "{}:{}", + " {:>2}:{:<2} ", app.cursor_position.y + 1, app.cursor_position.x + 1 )) - .right_aligned(); + .right_aligned() + .style(Style::default().bg(Color::Rgb(128, 192, 255)).bold()); let layout = Layout::default() .direction(Direction::Vertical) @@ -32,17 +33,30 @@ pub fn render(app: &mut App, frame: &mut Frame) { .borders(Borders::TOP) .title("RustEdit") .title_alignment(Alignment::Center) - .style(Style::default().fg(Color::LightBlue).bg(Color::Black)), + .style( + Style::default() + .fg(Color::Rgb(128, 192, 255)) + .bg(Color::Rgb(32, 32, 64)) + .bold(), + ), layout[0], ); frame.render_widget( - Paragraph::new(content_lines).style(Style::default().fg(Color::LightBlue).bg(Color::Black)), + Paragraph::new(content_lines).style( + Style::default() + .fg(Color::Rgb(128, 192, 255)) + .bg(Color::Rgb(32, 32, 64)), + ), layout[1], ); frame.render_widget( - Paragraph::new(status_bar).style(Style::default().fg(Color::LightCyan).bg(Color::Blue)), + Paragraph::new(status_bar).style( + Style::default() + .fg(Color::Rgb(16, 16, 16)) + .bg(Color::Rgb(92, 92, 128)), + ), layout[2], );