scroll read only mode clipping cursor bug fixed
This commit is contained in:
@@ -11,5 +11,5 @@ next_position = ["Right", "8"]
|
||||
|
||||
move_left = ["h"]
|
||||
move_right = ["l"]
|
||||
# move_up = ["k", "Up"]
|
||||
# move_down = ["j", "Down"]
|
||||
move_up = ["k", "Up"]
|
||||
move_down = ["j", "Down"]
|
||||
|
||||
@@ -56,7 +56,7 @@ impl EventHandler {
|
||||
self.is_edit_mode = false;
|
||||
self.edit_mode_cooldown = true;
|
||||
self.command_message = "Read-only mode".to_string();
|
||||
app_terminal.set_cursor_style(SetCursorStyle::SteadyBlock)?; // Add this line
|
||||
app_terminal.set_cursor_style(SetCursorStyle::SteadyBlock)?;
|
||||
return Ok((false, self.command_message.clone()));
|
||||
}
|
||||
|
||||
@@ -86,7 +86,8 @@ impl EventHandler {
|
||||
form_state.skladu = response.skladu;
|
||||
form_state.fax = response.fax;
|
||||
|
||||
form_state.current_field = 0;
|
||||
let current_input = form_state.get_current_input();
|
||||
form_state.current_cursor_pos = self.ideal_cursor_column.min(current_input.len());
|
||||
form_state.has_unsaved_changes = false;
|
||||
self.command_message = format!("Loaded entry {}", *current_position);
|
||||
}
|
||||
@@ -123,7 +124,8 @@ impl EventHandler {
|
||||
form_state.skladu = response.skladu;
|
||||
form_state.fax = response.fax;
|
||||
|
||||
form_state.current_field = 0;
|
||||
let current_input = form_state.get_current_input();
|
||||
form_state.current_cursor_pos = self.ideal_cursor_column.min(current_input.len());
|
||||
form_state.has_unsaved_changes = false;
|
||||
self.command_message = format!("Loaded entry {}", *current_position);
|
||||
}
|
||||
@@ -135,6 +137,7 @@ impl EventHandler {
|
||||
// Clear form when entering new entry position
|
||||
form_state.reset_to_empty();
|
||||
form_state.current_field = 0;
|
||||
form_state.current_cursor_pos = 0;
|
||||
self.command_message = "New entry mode".to_string();
|
||||
}
|
||||
return Ok((false, self.command_message.clone()));
|
||||
@@ -145,6 +148,7 @@ impl EventHandler {
|
||||
match action {
|
||||
"move_left" => {
|
||||
form_state.current_cursor_pos = form_state.current_cursor_pos.saturating_sub(1);
|
||||
self.ideal_cursor_column = form_state.current_cursor_pos;
|
||||
return Ok((false, "".to_string()));
|
||||
}
|
||||
"move_right" => {
|
||||
@@ -152,6 +156,7 @@ impl EventHandler {
|
||||
if form_state.current_cursor_pos < current_input.len() {
|
||||
form_state.current_cursor_pos += 1;
|
||||
}
|
||||
self.ideal_cursor_column = form_state.current_cursor_pos;
|
||||
return Ok((false, "".to_string()));
|
||||
}
|
||||
"move_up" => {
|
||||
@@ -162,13 +167,13 @@ impl EventHandler {
|
||||
form_state.current_field = form_state.current_field.saturating_sub(1);
|
||||
}
|
||||
let current_input = form_state.get_current_input();
|
||||
form_state.current_cursor_pos = form_state.current_cursor_pos.min(current_input.len());
|
||||
form_state.current_cursor_pos = self.ideal_cursor_column.min(current_input.len());
|
||||
return Ok((false, "".to_string()));
|
||||
}
|
||||
"move_down" => {
|
||||
form_state.current_field = (form_state.current_field + 1) % form_state.fields.len();
|
||||
let current_input = form_state.get_current_input();
|
||||
form_state.current_cursor_pos = form_state.current_cursor_pos.min(current_input.len());
|
||||
form_state.current_cursor_pos = self.ideal_cursor_column.min(current_input.len());
|
||||
return Ok((false, "".to_string()));
|
||||
}
|
||||
_ => {}
|
||||
|
||||
Reference in New Issue
Block a user