From bc90f2f7f618de2f96364783a9c12b22890e617b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Macio=C5=82ek?= Date: Fri, 24 May 2024 19:53:04 +0200 Subject: [PATCH] modified indicator added --- src/app.rs | 4 ++-- src/ui.rs | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/app.rs b/src/app.rs index 52cc258..aeb253f 100644 --- a/src/app.rs +++ b/src/app.rs @@ -26,7 +26,7 @@ pub struct App { pub cursor_offset: Position, pub opened_filename: String, pub window_size: Rect, - dirty: bool, + pub dirty: bool, quit_times: i8, pub is_prompt: bool, pub prompt: String, @@ -40,7 +40,7 @@ impl Default for App { content: vec![String::new()], cursor_position: Position { x: 0, y: 0 }, cursor_offset: Position { x: 0, y: 0 }, - opened_filename: String::new(), + opened_filename: "Empty".into(), window_size: Rect::new(0, 0, 0, 0), dirty: false, quit_times: QUIT_TIMES, diff --git a/src/ui.rs b/src/ui.rs index 7e255b3..d3f6684 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -57,7 +57,13 @@ pub fn render(app: &mut App, frame: &mut Frame) { }) .collect(); - let filename_status = Line::from(format!("Filename: {}", app.opened_filename)) + let filename_content: String = if app.dirty { + format!("Filename: {} (modified)", app.opened_filename) + } else { + format!("Filename: {} ", app.opened_filename) + }; + + let filename_status = Line::from(filename_content) .left_aligned() .style(Style::default().bg(Color::Rgb(128, 192, 255)).bold());