now buffer handling is global but not allowed from edit mode
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
[keybindings]
|
||||
|
||||
enter_command_mode = [":", "ctrl+;"]
|
||||
next_buffer = ["ctrl+l"]
|
||||
previous_buffer = ["ctrl+h"]
|
||||
|
||||
[keybindings.general]
|
||||
move_up = ["k", "Up"]
|
||||
@@ -13,8 +15,6 @@ toggle_sidebar = ["ctrl+t"]
|
||||
toggle_buffer_list = ["ctrl+b"]
|
||||
next_field = ["Tab"]
|
||||
prev_field = ["Shift+Tab"]
|
||||
next_buffer = ["ctrl+l"]
|
||||
previous_buffer = ["ctrl+h"]
|
||||
|
||||
[keybindings.common]
|
||||
save = ["ctrl+s"]
|
||||
@@ -36,8 +36,6 @@ enter_edit_mode_before = ["i"]
|
||||
enter_edit_mode_after = ["a"]
|
||||
previous_entry = ["left","q"]
|
||||
next_entry = ["right","1"]
|
||||
next_buffer = ["ctrl+l"]
|
||||
previous_buffer = ["ctrl+h"]
|
||||
|
||||
move_left = ["h"]
|
||||
move_right = ["l"]
|
||||
|
||||
@@ -135,6 +135,26 @@ impl EventHandler {
|
||||
);
|
||||
return Ok(EventOutcome::Ok(message));
|
||||
}
|
||||
// --- Buffer Switching (Check Global) ---
|
||||
if !matches!(current_mode, AppMode::Edit | AppMode::Command) {
|
||||
if let Some(action) = config.get_action_for_key_in_mode(
|
||||
&config.keybindings.global, key_code, modifiers // Check global bindings
|
||||
) {
|
||||
match action {
|
||||
"next_buffer" => {
|
||||
if buffer::switch_buffer(buffer_state, true) {
|
||||
return Ok(EventOutcome::Ok("Switched to next buffer".to_string()));
|
||||
}
|
||||
}
|
||||
"previous_buffer" => {
|
||||
if buffer::switch_buffer(buffer_state, false) {
|
||||
return Ok(EventOutcome::Ok("Switched to previous buffer".to_string()));
|
||||
}
|
||||
}
|
||||
_ => {} // Other global actions could be handled here if needed
|
||||
}
|
||||
}
|
||||
}
|
||||
// --- End Global UI Toggles ---
|
||||
|
||||
match current_mode {
|
||||
@@ -153,23 +173,6 @@ impl EventHandler {
|
||||
&mut self.command_message,
|
||||
).await;
|
||||
match nav_outcome {
|
||||
Ok(EventOutcome::Ok(ref msg)) if msg.is_empty() => {
|
||||
if let Some(action) = config.get_general_action(key_code, modifiers) {
|
||||
match action {
|
||||
"next_buffer" => {
|
||||
if buffer::switch_buffer(buffer_state, true) {
|
||||
return Ok(EventOutcome::Ok("Switched to next buffer".to_string()));
|
||||
}
|
||||
}
|
||||
"previous_buffer" => {
|
||||
if buffer::switch_buffer(buffer_state, false) {
|
||||
return Ok(EventOutcome::Ok("Switched to previous buffer".to_string()));
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(EventOutcome::ButtonSelected { context, index }) => {
|
||||
let mut message = String::from("Selected"); // Default message
|
||||
match context {
|
||||
@@ -213,24 +216,6 @@ impl EventHandler {
|
||||
},
|
||||
|
||||
AppMode::ReadOnly => {
|
||||
// --- Buffer Switching Check (ReadOnly Mode) ---
|
||||
if let Some(action) = config.get_read_only_action_for_key(key_code, modifiers) {
|
||||
match action {
|
||||
"next_buffer" => {
|
||||
if buffer::switch_buffer(buffer_state, true) {
|
||||
return Ok(EventOutcome::Ok("Switched to next buffer".to_string()));
|
||||
}
|
||||
}
|
||||
"previous_buffer" => {
|
||||
if buffer::switch_buffer(buffer_state, false) {
|
||||
return Ok(EventOutcome::Ok("Switched to previous buffer".to_string()));
|
||||
}
|
||||
}
|
||||
_ => {} // Other read_only/common actions handled below
|
||||
}
|
||||
}
|
||||
// --- End Buffer Switching Check ---
|
||||
|
||||
if config.is_enter_edit_mode_before(key_code, modifiers) &&
|
||||
ModeManager::can_enter_edit_mode(current_mode) {
|
||||
self.is_edit_mode = true;
|
||||
|
||||
Reference in New Issue
Block a user