add alert system
This commit is contained in:
+7
-1
@@ -1,6 +1,6 @@
|
||||
use std::{env, fs::File, io::Read, path::PathBuf, process::exit};
|
||||
use crossterm::{event::{self, Event, KeyEvent}, terminal::window_size};
|
||||
use ratatui::style::Color;
|
||||
use ratatui::{style::Color, text::Span};
|
||||
use crate::{config::Config, cursor::Cursor, edit_action::EditAction};
|
||||
|
||||
mod widget;
|
||||
@@ -29,6 +29,8 @@ pub struct App {
|
||||
// the index *after* the last saved edit action
|
||||
pub last_saved_at: Option<usize>,
|
||||
|
||||
pub alert_message: Span<'static>,
|
||||
|
||||
pub logs: Vec<String>,
|
||||
}
|
||||
|
||||
@@ -111,6 +113,8 @@ impl App {
|
||||
time_traveling: None,
|
||||
last_saved_at: Some(0),
|
||||
|
||||
alert_message: "".into(),
|
||||
|
||||
logs: Vec::new(),
|
||||
}
|
||||
}
|
||||
@@ -132,6 +136,8 @@ impl App {
|
||||
}
|
||||
|
||||
fn handle_key(&mut self, event: KeyEvent) {
|
||||
self.alert_message = "".into();
|
||||
|
||||
if self.partial_action == Some(PartialAction::Replace) {
|
||||
if let Some(hex_character) = event.code.as_char() &&
|
||||
let Some(nybble) = nybble_from_hex(hex_character)
|
||||
|
||||
+6
-4
@@ -200,7 +200,7 @@ mod hex {
|
||||
let replaced_byte = self.partial_replace.unwrap_or(0) << 4;
|
||||
|
||||
self.render_byte_without_replace_preview(address, replaced_byte)
|
||||
.fg(Color::Black)
|
||||
.black()
|
||||
} else {
|
||||
self.render_byte_without_replace_preview(address, byte)
|
||||
}
|
||||
@@ -330,7 +330,7 @@ mod character_panel {
|
||||
|
||||
match self.cursor.contains(address) {
|
||||
Some(InCursor::Head) => span.bg(Color::select_grey()),
|
||||
Some(InCursor::Rest) => span.bg(Color::DarkGray),
|
||||
Some(InCursor::Rest) => span.on_dark_gray(),
|
||||
None => span,
|
||||
}
|
||||
}
|
||||
@@ -388,7 +388,9 @@ mod status_line {
|
||||
self.render_mode(),
|
||||
" ".into(),
|
||||
self.render_file_name(),
|
||||
self.modified_indicator()
|
||||
self.modified_indicator(),
|
||||
" ".into(),
|
||||
self.alert_message.clone()
|
||||
])
|
||||
)
|
||||
.bg(Color::ui_grey())
|
||||
@@ -396,7 +398,7 @@ mod status_line {
|
||||
|
||||
fn render_mode(&self) -> Span<'static> {
|
||||
Span::from(self.mode.label())
|
||||
.fg(Color::Black)
|
||||
.black()
|
||||
.bg(self.mode.color())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user