is edit mode is gone from the codebase
This commit is contained in:
@@ -148,19 +148,17 @@ impl Config {
|
||||
/// Context-aware keybinding resolution
|
||||
pub fn get_action_for_current_context(
|
||||
&self,
|
||||
is_edit_mode: bool,
|
||||
command_mode: bool,
|
||||
key: KeyCode,
|
||||
modifiers: KeyModifiers
|
||||
) -> Option<&str> {
|
||||
match (command_mode, is_edit_mode) {
|
||||
(true, _) => self.get_command_action_for_key(key, modifiers),
|
||||
(_, true) => self.get_edit_action_for_key(key, modifiers)
|
||||
.or_else(|| self.get_common_action(key, modifiers)),
|
||||
_ => self.get_read_only_action_for_key(key, modifiers)
|
||||
if command_mode {
|
||||
self.get_command_action_for_key(key, modifiers)
|
||||
} else {
|
||||
// fallback: read-only + common + global
|
||||
self.get_read_only_action_for_key(key, modifiers)
|
||||
.or_else(|| self.get_common_action(key, modifiers))
|
||||
// Add global bindings check for read-only mode
|
||||
.or_else(|| self.get_action_for_key_in_mode(&self.keybindings.global, key, modifiers)),
|
||||
.or_else(|| self.get_action_for_key_in_mode(&self.keybindings.global, key, modifiers))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@ pub fn render_login(
|
||||
// FIX: take &LoginState (reference), not owned
|
||||
login_state: &LoginState,
|
||||
app_state: &AppState,
|
||||
is_edit_mode: bool,
|
||||
) {
|
||||
// Main container
|
||||
let block = Block::default()
|
||||
|
||||
@@ -21,7 +21,6 @@ pub fn render_register(
|
||||
theme: &Theme,
|
||||
state: &RegisterState,
|
||||
app_state: &AppState,
|
||||
is_edit_mode: bool,
|
||||
) {
|
||||
let block = Block::default()
|
||||
.borders(Borders::ALL)
|
||||
|
||||
@@ -121,6 +121,10 @@ impl AppState {
|
||||
pub fn form_state_mut(&mut self) -> Option<&mut FormState> {
|
||||
self.form_editor.as_mut().map(|e| e.data_provider_mut())
|
||||
}
|
||||
|
||||
pub fn is_canvas_edit_mode(&self) -> bool {
|
||||
matches!(self.form_editor.as_ref().map(|e| e.mode()), Some(canvas::AppMode::Edit))
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for UiState {
|
||||
|
||||
@@ -82,7 +82,6 @@ pub fn render_ui(
|
||||
theme,
|
||||
state,
|
||||
app_state,
|
||||
state.current_field() < 2,
|
||||
),
|
||||
Page::Register(state) => render_register(
|
||||
f,
|
||||
@@ -90,7 +89,6 @@ pub fn render_ui(
|
||||
theme,
|
||||
state,
|
||||
app_state,
|
||||
state.current_field() < 4,
|
||||
),
|
||||
Page::Admin(state) => crate::components::admin::admin_panel::render_admin_panel(
|
||||
f,
|
||||
|
||||
@@ -544,7 +544,7 @@ pub async fn run_ui() -> Result<()> {
|
||||
|
||||
if let Page::Form(form_state) = &mut router.current {
|
||||
if !table_just_switched {
|
||||
if position_changed && !matches!(app_state.form_editor.as_ref().map(|e| e.mode()), Some(canvas::AppMode::Edit)) {
|
||||
if position_changed && !app_state.is_canvas_edit_mode() {
|
||||
position_logic_needs_redraw = true;
|
||||
|
||||
if let Some(form_state) = app_state.form_state_mut() {
|
||||
@@ -582,7 +582,7 @@ pub async fn run_ui() -> Result<()> {
|
||||
form_state.current_cursor_pos =
|
||||
event_handler.ideal_cursor_column.min(max_cursor_pos);
|
||||
}
|
||||
} else if !position_changed && !matches!(app_state.form_editor.as_ref().map(|e| e.mode()), Some(canvas::AppMode::Edit)) {
|
||||
} else if !position_changed && !app_state.is_canvas_edit_mode() {
|
||||
if let Some(form_state) = app_state.form_state_mut() {
|
||||
let current_input_str = form_state.get_current_input();
|
||||
let current_input_len = current_input_str.chars().count();
|
||||
@@ -597,7 +597,7 @@ pub async fn run_ui() -> Result<()> {
|
||||
}
|
||||
}
|
||||
} else if let Page::Register(state) = &mut router.current {
|
||||
if !matches!(app_state.form_editor.as_ref().map(|e| e.mode()), Some(canvas::AppMode::Edit)) {
|
||||
if !app_state.is_canvas_edit_mode() {
|
||||
let current_input = state.get_current_input();
|
||||
let max_cursor_pos =
|
||||
if !current_input.is_empty() { current_input.len() - 1 } else { 0 };
|
||||
@@ -605,7 +605,7 @@ pub async fn run_ui() -> Result<()> {
|
||||
event_handler.ideal_cursor_column.min(max_cursor_pos);
|
||||
}
|
||||
} else if let Page::Login(state) = &mut router.current {
|
||||
if !matches!(app_state.form_editor.as_ref().map(|e| e.mode()), Some(canvas::AppMode::Edit)) {
|
||||
if !app_state.is_canvas_edit_mode() {
|
||||
let current_input = state.get_current_input();
|
||||
let max_cursor_pos =
|
||||
if !current_input.is_empty() { current_input.len() - 1 } else { 0 };
|
||||
|
||||
Reference in New Issue
Block a user