working eidt mode perfectly well, i love it
This commit is contained in:
@@ -15,7 +15,14 @@ pub fn render_status_line(
|
||||
theme: &Theme,
|
||||
is_edit_mode: bool
|
||||
) {
|
||||
|
||||
// // Create the status line text
|
||||
// let status_line = Line::from(vec![
|
||||
// Span::styled(current_dir, Style::default().fg(theme.fg)),
|
||||
// Span::styled(
|
||||
// program_info,
|
||||
// Style::default().fg(theme.secondary).add_modifier(ratatui::style::Modifier::BOLD), // Use `secondary` color
|
||||
// ),
|
||||
// ]);
|
||||
// Program name and version
|
||||
let program_info = format!("multieko2 v{}", env!("CARGO_PKG_VERSION"));
|
||||
|
||||
|
||||
@@ -17,6 +17,10 @@ impl Config {
|
||||
|
||||
pub fn get_action_for_key(&self, key: KeyCode, modifiers: KeyModifiers) -> Option<&str> {
|
||||
for (action, bindings) in &self.keybindings {
|
||||
// Skip mode toggle actions
|
||||
if action == "enter_edit_mode" || action == "exit_edit_mode" {
|
||||
continue;
|
||||
}
|
||||
for binding in bindings {
|
||||
if Self::matches_keybinding(binding, key, modifiers) {
|
||||
return Some(action);
|
||||
@@ -36,17 +40,13 @@ impl Config {
|
||||
"ctrl" => expected_modifiers |= KeyModifiers::CONTROL,
|
||||
"shift" => expected_modifiers |= KeyModifiers::SHIFT,
|
||||
"alt" => expected_modifiers |= KeyModifiers::ALT,
|
||||
_ => {
|
||||
// Handle single character keys and special cases
|
||||
expected_key = match part.to_lowercase().as_str() {
|
||||
":" => Some(KeyCode::Char(':')),
|
||||
part if part.len() == 1 => {
|
||||
let c = part.chars().next().unwrap();
|
||||
Some(KeyCode::Char(c))
|
||||
}
|
||||
_ => None,
|
||||
};
|
||||
"esc" => expected_key = Some(KeyCode::Esc),
|
||||
":" => expected_key = Some(KeyCode::Char(':')),
|
||||
part if part.len() == 1 => {
|
||||
let c = part.chars().next().unwrap();
|
||||
expected_key = Some(KeyCode::Char(c));
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -247,6 +247,15 @@ pub async fn run_ui() -> Result<(), Box<dyn std::error::Error>> {
|
||||
current_field = (current_field + 1) % fields.len();
|
||||
}
|
||||
}
|
||||
KeyCode::Esc => {
|
||||
// Explicitly handle Esc even if not in command mode
|
||||
if config.is_exit_edit_mode(key.code, key.modifiers) {
|
||||
is_edit_mode = false;
|
||||
edit_mode_cooldown = true;
|
||||
command_message = "Read-only mode".to_string();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
KeyCode::BackTab => current_field = current_field.saturating_sub(1),
|
||||
KeyCode::Down => current_field = (current_field + 1) % fields.len(),
|
||||
KeyCode::Up => current_field = current_field.saturating_sub(1),
|
||||
|
||||
Reference in New Issue
Block a user