canvas now working properly well
This commit is contained in:
@@ -198,10 +198,14 @@ pub fn handle_add_table_navigation(
|
|||||||
add_table_state.current_focus = new_focus;
|
add_table_state.current_focus = new_focus;
|
||||||
*command_message = format!("Focus set to {:?}", add_table_state.current_focus);
|
*command_message = format!("Focus set to {:?}", add_table_state.current_focus);
|
||||||
|
|
||||||
|
// --- THIS IS THE KEY PART ---
|
||||||
|
// Check if the *new* focus target is one of the canvas input fields
|
||||||
let new_is_canvas_input_focus = matches!(new_focus,
|
let new_is_canvas_input_focus = matches!(new_focus,
|
||||||
AddTableFocus::InputTableName | AddTableFocus::InputColumnName | AddTableFocus::InputColumnType
|
AddTableFocus::InputTableName | AddTableFocus::InputColumnName | AddTableFocus::InputColumnType
|
||||||
);
|
);
|
||||||
app_state.ui.focus_outside_canvas = !new_is_canvas_input_focus;
|
// Set focus_outside_canvas based on whether the new focus is NOT an input field
|
||||||
|
app_state.ui.focus_outside_canvas = !new_is_canvas_input_focus; // <--- Sets the flag correctly
|
||||||
|
// --- END KEY PART ---
|
||||||
|
|
||||||
|
|
||||||
// Select first item when focusing a table
|
// Select first item when focusing a table
|
||||||
@@ -214,15 +218,12 @@ pub fn handle_add_table_navigation(
|
|||||||
}
|
}
|
||||||
AddTableFocus::LinksTable if add_table_state.link_table_state.selected().is_none() && !add_table_state.links.is_empty() => {
|
AddTableFocus::LinksTable if add_table_state.link_table_state.selected().is_none() && !add_table_state.links.is_empty() => {
|
||||||
add_table_state.link_table_state.select(Some(0));
|
add_table_state.link_table_state.select(Some(0));
|
||||||
}
|
}_ => {}
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
} else if !handled {
|
} else if !handled {
|
||||||
// If not handled by this specific navigation, clear the message potentially set by get_general_action
|
// ...
|
||||||
// command_message.clear(); // Optional: depends if you want default messages
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
handled
|
handled
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ use crate::state::app::buffer::BufferState;
|
|||||||
pub fn handle_admin_navigation(
|
pub fn handle_admin_navigation(
|
||||||
key: KeyEvent,
|
key: KeyEvent,
|
||||||
config: &Config,
|
config: &Config,
|
||||||
app_state: &AppState,
|
app_state: &mut AppState,
|
||||||
admin_state: &mut AdminState,
|
admin_state: &mut AdminState,
|
||||||
buffer_state: &mut BufferState,
|
buffer_state: &mut BufferState,
|
||||||
command_message: &mut String,
|
command_message: &mut String,
|
||||||
@@ -161,6 +161,7 @@ pub fn handle_admin_navigation(
|
|||||||
}
|
}
|
||||||
AdminFocus::Button2 => {
|
AdminFocus::Button2 => {
|
||||||
buffer_state.update_history(AppView::AddTable);
|
buffer_state.update_history(AppView::AddTable);
|
||||||
|
app_state.ui.focus_outside_canvas = false;
|
||||||
*command_message = "Navigating to Add Table page...".to_string();
|
*command_message = "Navigating to Add Table page...".to_string();
|
||||||
}
|
}
|
||||||
AdminFocus::Button3 => {
|
AdminFocus::Button3 => {
|
||||||
|
|||||||
@@ -79,21 +79,36 @@ pub async fn execute_action(
|
|||||||
match action {
|
match action {
|
||||||
"move_up" => {
|
"move_up" => {
|
||||||
key_sequence_tracker.reset();
|
key_sequence_tracker.reset();
|
||||||
let num_fields = AddTableState::INPUT_FIELD_COUNT; // Use the constant
|
let num_fields = AddTableState::INPUT_FIELD_COUNT;
|
||||||
if num_fields == 0 { return Ok("No fields.".to_string()); }
|
if num_fields == 0 { return Ok("No fields.".to_string()); }
|
||||||
let current_field = state.current_field();
|
let current_field = state.current_field(); // Gets the index (0, 1, or 2)
|
||||||
|
|
||||||
if current_field > 0 {
|
if current_field > 0 {
|
||||||
|
// This handles moving from field 2 -> 1, or 1 -> 0
|
||||||
let new_field = current_field - 1;
|
let new_field = current_field - 1;
|
||||||
state.set_current_field(new_field);
|
state.set_current_field(new_field);
|
||||||
let current_input = state.get_current_input();
|
// ... (rest of the logic to set cursor position) ...
|
||||||
let max_cursor_pos = current_input.len(); // Allow cursor at end
|
|
||||||
let new_pos = (*ideal_cursor_column).min(max_cursor_pos);
|
|
||||||
state.set_current_cursor_pos(new_pos);
|
|
||||||
} else {
|
} else {
|
||||||
// Optionally move focus outside canvas when moving up from the first field
|
// --- THIS IS WHERE THE FIX GOES ---
|
||||||
// app_state.ui.focus_outside_canvas = true;
|
// current_field is 0 (InputTableName), and user pressed Up.
|
||||||
// return Ok("Focus moved above canvas".to_string());
|
// We need to move focus *outside* the canvas.
|
||||||
|
|
||||||
|
// Set the flag to indicate focus is leaving the canvas
|
||||||
|
app_state.ui.focus_outside_canvas = true;
|
||||||
|
|
||||||
|
// Decide which element gets focus. Based on your layout and the
|
||||||
|
// downward navigation (CancelButton wraps to InputTableName),
|
||||||
|
// moving up from InputTableName should likely go to CancelButton.
|
||||||
|
state.current_focus = crate::state::pages::add_table::AddTableFocus::CancelButton;
|
||||||
|
|
||||||
|
// Reset the sequence tracker as the action is complete
|
||||||
|
key_sequence_tracker.reset();
|
||||||
|
|
||||||
|
// Return a message indicating the focus change
|
||||||
|
return Ok("Focus moved above canvas".to_string());
|
||||||
|
// --- END FIX ---
|
||||||
}
|
}
|
||||||
|
// If we moved within the canvas (e.g., 1 -> 0), return empty string
|
||||||
Ok("".to_string())
|
Ok("".to_string())
|
||||||
}
|
}
|
||||||
"move_down" => {
|
"move_down" => {
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ impl ModeManager {
|
|||||||
return AppMode::Highlight;
|
return AppMode::Highlight;
|
||||||
}
|
}
|
||||||
|
|
||||||
if app_state.ui.focus_outside_canvas || app_state.ui.show_add_table{
|
if app_state.ui.focus_outside_canvas {
|
||||||
return AppMode::General;
|
return AppMode::General;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user