working but some functionality is missing now
This commit is contained in:
@@ -78,7 +78,7 @@ impl EventHandler {
|
||||
// Mode transitions between edit mode and read-only mode
|
||||
if self.is_edit_mode {
|
||||
// Check for exiting edit mode
|
||||
if config.get_edit_action_for_key(key.code, key.modifiers) == Some("exit_edit_mode") {
|
||||
if config.is_exit_edit_mode(key.code, key.modifiers) {
|
||||
if form_state.has_unsaved_changes {
|
||||
self.command_message = "Unsaved changes! Use :w to save or :q! to discard".to_string();
|
||||
return Ok((false, self.command_message.clone()));
|
||||
@@ -109,20 +109,26 @@ impl EventHandler {
|
||||
return Ok((false, result));
|
||||
} else {
|
||||
// Check for entering edit mode from read-only mode
|
||||
if config.get_read_only_action_for_key(key.code, key.modifiers) == Some("enter_edit_mode_before") {
|
||||
if config.get_read_only_action_for_key(key.code, key.modifiers) == Some("enter_edit_mode_after") {
|
||||
let current_input = form_state.get_current_input();
|
||||
if !current_input.is_empty() && form_state.current_cursor_pos < current_input.len() {
|
||||
form_state.current_cursor_pos += 1;
|
||||
self.ideal_cursor_column = form_state.current_cursor_pos;
|
||||
}
|
||||
}
|
||||
if config.is_enter_edit_mode_before(key.code, key.modifiers) {
|
||||
self.is_edit_mode = true;
|
||||
self.edit_mode_cooldown = true;
|
||||
self.command_message = "Edit mode".to_string();
|
||||
app_terminal.set_cursor_style(SetCursorStyle::BlinkingBar)?;
|
||||
return Ok((false, self.command_message.clone()));
|
||||
}
|
||||
|
||||
if config.is_enter_edit_mode_after(key.code, key.modifiers) {
|
||||
let current_input = form_state.get_current_input();
|
||||
if !current_input.is_empty() && form_state.current_cursor_pos < current_input.len() {
|
||||
form_state.current_cursor_pos += 1;
|
||||
self.ideal_cursor_column = form_state.current_cursor_pos;
|
||||
}
|
||||
self.is_edit_mode = true;
|
||||
self.edit_mode_cooldown = true;
|
||||
self.command_message = "Edit mode (after cursor)".to_string();
|
||||
app_terminal.set_cursor_style(SetCursorStyle::BlinkingBar)?;
|
||||
return Ok((false, self.command_message.clone()));
|
||||
}
|
||||
|
||||
// Handle read-only mode events
|
||||
return read_only::handle_read_only_event(
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// src/modes/handlers/read_only.rs
|
||||
|
||||
use crossterm::event::{KeyEvent};
|
||||
use crate::config::config::Config;
|
||||
use crate::ui::handlers::form::FormState;
|
||||
@@ -24,13 +26,13 @@ pub async fn handle_read_only_event(
|
||||
ideal_cursor_column: &mut usize,
|
||||
) -> Result<(bool, String), Box<dyn std::error::Error>> {
|
||||
// Check for entering Edit mode from Read-Only mode
|
||||
if config.get_read_only_action_for_key(key.code, key.modifiers) == Some("enter_edit_mode_before") {
|
||||
if config.is_enter_edit_mode_before(key.code, key.modifiers) {
|
||||
*edit_mode_cooldown = true;
|
||||
*command_message = "Entering Edit mode".to_string();
|
||||
return Ok((false, command_message.clone()));
|
||||
}
|
||||
|
||||
if config.get_read_only_action_for_key(key.code, key.modifiers) == Some("enter_edit_mode_after") {
|
||||
if config.is_enter_edit_mode_after(key.code, key.modifiers) {
|
||||
let current_input = form_state.get_current_input();
|
||||
if !current_input.is_empty() && form_state.current_cursor_pos < current_input.len() {
|
||||
form_state.current_cursor_pos += 1;
|
||||
|
||||
Reference in New Issue
Block a user