From 08bbd9bd291ded86b4650529de4515d2fd01acab Mon Sep 17 00:00:00 2001 From: filipriec Date: Tue, 25 Feb 2025 22:04:07 +0100 Subject: [PATCH] move to top and bottom, needs redesign of config --- client/config.toml | 2 ++ client/src/ui/handlers/event.rs | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/client/config.toml b/client/config.toml index c88cf18..cd3176c 100644 --- a/client/config.toml +++ b/client/config.toml @@ -20,6 +20,8 @@ move_word_prev = ["b"] # Move to beginning of previous word move_word_end_prev = ["ge"] # Move to end of previous word move_line_start = ["0"] # Move to beginning of line move_line_end = ["$"] # Move to end of line +move_first_line = ["t"] # Move to first line of form +move_last_line = ["G"] # Move to last line of form [colors] theme = "dark" diff --git a/client/src/ui/handlers/event.rs b/client/src/ui/handlers/event.rs index 0c41adf..c812378 100644 --- a/client/src/ui/handlers/event.rs +++ b/client/src/ui/handlers/event.rs @@ -273,6 +273,30 @@ impl EventHandler { } return Ok((false, "".to_string())); } + "move_first_line" => { + // Jump to first field + form_state.current_field = 0; + let current_input = form_state.get_current_input(); + let max_cursor_pos = if !self.is_edit_mode && !current_input.is_empty() { + current_input.len() - 1 + } else { + current_input.len() + }; + form_state.current_cursor_pos = self.ideal_cursor_column.min(max_cursor_pos); + return Ok((false, "".to_string())); + } + "move_last_line" => { + // Jump to last field + form_state.current_field = form_state.fields.len() - 1; + let current_input = form_state.get_current_input(); + let max_cursor_pos = if !self.is_edit_mode && !current_input.is_empty() { + current_input.len() - 1 + } else { + current_input.len() + }; + form_state.current_cursor_pos = self.ideal_cursor_column.min(max_cursor_pos); + return Ok((false, "".to_string())); + } _ => {} } }