Skip to content

Commit

Permalink
cursor position update, colors update
Browse files Browse the repository at this point in the history
  • Loading branch information
Kacperacy committed May 11, 2024
1 parent 0f09748 commit 8db7a81
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions src/ui.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -12,11 +12,12 @@ pub fn render(app: &mut App, frame: &mut Frame) {
let content_lines: Vec<Line> = 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)
Expand All @@ -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],
);

Expand Down

0 comments on commit 8db7a81

Please sign in to comment.