working entering to the edit mode

This commit is contained in:
Priec
2025-08-22 09:56:55 +02:00
parent 4ed8e7b421
commit ae8aa16208
2 changed files with 60 additions and 33 deletions

View File

@@ -665,19 +665,24 @@ impl EventHandler {
// First let the canvas editor try to handle the key
if app_state.ui.show_form {
if let Some(editor) = &mut app_state.form_editor {
match editor.handle_key_event(key_event) {
let outcome = editor.handle_key_event(key_event);
let new_mode = AppMode::from(editor.mode());
match outcome {
KeyEventOutcome::Consumed(Some(msg)) => {
app_state.update_mode(new_mode);
return Ok(EventOutcome::Ok(msg));
}
KeyEventOutcome::Consumed(None) => {
app_state.update_mode(new_mode);
return Ok(EventOutcome::Ok(String::new()));
}
KeyEventOutcome::Pending => {
// Waiting for multi-key sequence (e.g. after pressing 'g')
app_state.update_mode(new_mode);
return Ok(EventOutcome::Ok(String::new()));
}
KeyEventOutcome::NotMatched => {
// Fall through to client-level actions
app_state.update_mode(new_mode);
// Fall through
}
}
}
@@ -721,18 +726,24 @@ impl EventHandler {
AppMode::Highlight => {
if app_state.ui.show_form {
if let Some(editor) = &mut app_state.form_editor {
match editor.handle_key_event(key_event) {
let outcome = editor.handle_key_event(key_event);
let new_mode = AppMode::from(editor.mode());
match outcome {
KeyEventOutcome::Consumed(Some(msg)) => {
app_state.update_mode(new_mode);
return Ok(EventOutcome::Ok(msg));
}
KeyEventOutcome::Consumed(None) => {
app_state.update_mode(new_mode);
return Ok(EventOutcome::Ok(String::new()));
}
KeyEventOutcome::Pending => {
app_state.update_mode(new_mode);
return Ok(EventOutcome::Ok(String::new()));
}
KeyEventOutcome::NotMatched => {
// Fall through to client-level actions
app_state.update_mode(new_mode);
// Fall through
}
}
}
@@ -764,20 +775,25 @@ impl EventHandler {
// Let the canvas editor handle edit-mode keys
if app_state.ui.show_form {
if let Some(editor) = &mut app_state.form_editor {
match editor.handle_key_event(key_event) {
let outcome = editor.handle_key_event(key_event);
let new_mode = AppMode::from(editor.mode());
match outcome {
KeyEventOutcome::Consumed(Some(msg)) => {
self.command_message = msg.clone();
app_state.update_mode(new_mode);
return Ok(EventOutcome::Ok(msg));
}
KeyEventOutcome::Consumed(None) => {
app_state.update_mode(new_mode);
return Ok(EventOutcome::Ok(String::new()));
}
KeyEventOutcome::Pending => {
// Rare in edit mode, but allow multi-key sequences if defined
app_state.update_mode(new_mode);
return Ok(EventOutcome::Ok(String::new()));
}
KeyEventOutcome::NotMatched => {
// Fall through to client-level actions
app_state.update_mode(new_mode);
// Fall through
}
}
}