exit in the general mode is on esc and select is not escaping in the add_table anymore
This commit is contained in:
@@ -15,6 +15,7 @@ toggle_sidebar = ["ctrl+t"]
|
||||
toggle_buffer_list = ["ctrl+b"]
|
||||
next_field = ["Tab"]
|
||||
prev_field = ["Shift+Tab"]
|
||||
exit_table_scroll = ["esc"]
|
||||
|
||||
[keybindings.common]
|
||||
save = ["ctrl+s"]
|
||||
|
||||
@@ -271,22 +271,50 @@ pub fn render_add_table(
|
||||
};
|
||||
|
||||
// --- Add Button Rendering ---
|
||||
let add_button = Paragraph::new(" Add ")
|
||||
.style(get_button_style(
|
||||
AddTableFocus::AddColumnButton,
|
||||
add_table_state.current_focus,
|
||||
))
|
||||
.alignment(Alignment::Center)
|
||||
.block(
|
||||
Block::default()
|
||||
.borders(Borders::ALL)
|
||||
.border_type(BorderType::Rounded)
|
||||
.border_style(get_button_border_style(
|
||||
AddTableFocus::AddColumnButton,
|
||||
add_table_state.current_focus,
|
||||
)),
|
||||
);
|
||||
f.render_widget(add_button, add_button_area);
|
||||
let is_add_button_focused =
|
||||
add_table_state.current_focus == AddTableFocus::AddColumnButton;
|
||||
|
||||
// 1. Define the block with ONLY border styling (no background here)
|
||||
let add_button_block = Block::default()
|
||||
.borders(Borders::ALL)
|
||||
.border_type(BorderType::Rounded)
|
||||
.border_style(if is_add_button_focused {
|
||||
Style::default().fg(theme.highlight) // Highlighted border
|
||||
} else {
|
||||
Style::default().fg(theme.secondary) // Normal border
|
||||
});
|
||||
// DO NOT add .style(Style::default().bg(...)) here
|
||||
|
||||
// 2. Render the border block first
|
||||
// Need to clone the block because inner() consumes it
|
||||
let inner_add_button_area = add_button_block.clone().inner(add_button_area);
|
||||
f.render_widget(add_button_block, add_button_area);
|
||||
|
||||
// 3. If focused, render a background fill widget INSIDE the inner area
|
||||
if is_add_button_focused {
|
||||
let background_fill = Block::default() // Or Paragraph::new("")
|
||||
.style(Style::default().bg(theme.highlight));
|
||||
f.render_widget(background_fill, inner_add_button_area);
|
||||
}
|
||||
|
||||
// 4. Define the paragraph text style (FG color and bold only)
|
||||
let mut add_button_text_style = Style::default().fg(if is_add_button_focused {
|
||||
theme.bg // Reversed text color for contrast on highlight bg
|
||||
} else {
|
||||
theme.secondary // Normal text color
|
||||
});
|
||||
|
||||
if is_add_button_focused {
|
||||
add_button_text_style = add_button_text_style.add_modifier(Modifier::BOLD);
|
||||
}
|
||||
|
||||
let add_button_paragraph = Paragraph::new(" Add ")
|
||||
.style(add_button_text_style) // Style without BG
|
||||
.alignment(Alignment::Center);
|
||||
|
||||
// 5. Render the text paragraph inside the inner area (on top of the background fill)
|
||||
f.render_widget(add_button_paragraph, inner_add_button_area);
|
||||
|
||||
|
||||
// --- Indexes Table Rendering ---
|
||||
let indexes_focused = matches!(add_table_state.current_focus, AddTableFocus::IndexesTable | AddTableFocus::InsideIndexesTable);
|
||||
|
||||
@@ -37,6 +37,30 @@ pub fn handle_add_table_navigation(
|
||||
);
|
||||
|
||||
match action.as_deref() {
|
||||
// --- Handle Exiting Table Scroll Mode ---
|
||||
Some("exit_table_scroll") => {
|
||||
match current_focus {
|
||||
AddTableFocus::InsideColumnsTable => {
|
||||
new_focus = AddTableFocus::ColumnsTable;
|
||||
*command_message = "Exited Columns Table".to_string();
|
||||
}
|
||||
AddTableFocus::InsideIndexesTable => {
|
||||
new_focus = AddTableFocus::IndexesTable;
|
||||
*command_message = "Exited Indexes Table".to_string();
|
||||
}
|
||||
AddTableFocus::InsideLinksTable => {
|
||||
new_focus = AddTableFocus::LinksTable;
|
||||
*command_message = "Exited Links Table".to_string();
|
||||
}
|
||||
_ => {
|
||||
// Action triggered but not applicable in this focus state
|
||||
handled = false;
|
||||
}
|
||||
}
|
||||
// If handled (i.e., focus changed), handled remains true.
|
||||
// If not handled, handled becomes false.
|
||||
}
|
||||
|
||||
// --- Vertical Navigation (Up/Down) ---
|
||||
Some("move_up") => {
|
||||
match current_focus {
|
||||
@@ -184,12 +208,20 @@ pub fn handle_add_table_navigation(
|
||||
*command_message = "Entered Links Table (Scroll with Up/Down, Select to toggle/exit)".to_string();
|
||||
}
|
||||
AddTableFocus::InsideColumnsTable => {
|
||||
new_focus = AddTableFocus::ColumnsTable; // Exit back to block focus
|
||||
*command_message = "Exited Columns Table".to_string();
|
||||
// Select does nothing here anymore, only Esc exits.
|
||||
if let Some(index) = add_table_state.column_table_state.selected() {
|
||||
*command_message = format!("Selected column index {} (Press Esc to exit scroll mode)", index);
|
||||
} else {
|
||||
*command_message = "No column selected (Press Esc to exit scroll mode)".to_string();
|
||||
}
|
||||
}
|
||||
AddTableFocus::InsideIndexesTable => {
|
||||
new_focus = AddTableFocus::IndexesTable; // Exit back to block focus
|
||||
*command_message = "Exited Indexes Table".to_string();
|
||||
// Select does nothing here anymore, only Esc exits.
|
||||
if let Some(index) = add_table_state.index_table_state.selected() {
|
||||
*command_message = format!("Selected index index {} (Press Esc to exit scroll mode)", index);
|
||||
} else {
|
||||
*command_message = "No index selected (Press Esc to exit scroll mode)".to_string();
|
||||
}
|
||||
}
|
||||
AddTableFocus::InsideLinksTable => {
|
||||
// Toggle selection when pressing select *inside* the links table
|
||||
|
||||
Reference in New Issue
Block a user