add key for selecting horizontal line

pull/141/head
kyoto7250 2 years ago
parent b13e4bb255
commit af0e59c9d4

@ -104,6 +104,7 @@ If you want to add connections, you need to edit your config file. For more info
| <kbd>Ctrl</kbd> + <kbd>u</kbd>, <kbd>Ctrl</kbd> + <kbd>d</kbd> | Scroll up/down multiple lines |
| <kbd>g</kbd> , <kbd>G</kbd> | Scroll to top/bottom |
| <kbd>H</kbd>, <kbd>J</kbd>, <kbd>K</kbd>, <kbd>L</kbd> | Extend selection by one cell left/down/up/right |
| <kbd>V</kbd> | Extend selection by horizontal line |
| <kbd>y</kbd> | Copy a cell value |
| <kbd></kbd>, <kbd></kbd> | Move focus to left/right |
| <kbd>c</kbd> | Move focus to connections |

@ -96,6 +96,16 @@ pub fn extend_selection_by_one_cell(key: &KeyConfig) -> CommandText {
)
}
pub fn extend_selection_by_line(key: &KeyConfig) -> CommandText {
CommandText::new(
format!(
"Extend selection by horizontal line [{}]",
key.extend_selection_by_horizontal_line,
),
CMD_GROUP_TABLE,
)
}
pub fn extend_or_shorten_widget_width(key: &KeyConfig) -> CommandText {
CommandText::new(
format!(

@ -200,6 +200,18 @@ impl TableComponent {
}
}
fn expand_selection_by_horizontal_line(&mut self, _positive: bool) {
if self.selection_area_corner.is_none() {
self.selected_column = 0;
self.selection_area_corner = Some((
self.headers.len().saturating_sub(1),
self.selected_row.selected().unwrap_or(0),
));
} else {
self.selection_area_corner = None;
}
}
pub fn selected_cells(&self) -> Option<String> {
if let Some((x, y)) = self.selection_area_corner {
let selected_row_index = self.selected_row.selected()?;
@ -522,6 +534,9 @@ impl Component for TableComponent {
out.push(CommandInfo::new(command::extend_selection_by_one_cell(
&self.key_config,
)));
out.push(CommandInfo::new(command::extend_selection_by_line(
&self.key_config,
)));
}
fn event(&mut self, key: Key) -> Result<EventState> {
@ -561,6 +576,9 @@ impl Component for TableComponent {
} else if key == self.key_config.extend_selection_by_one_cell_right {
self.expand_selected_area_x(true);
return Ok(EventState::Consumed);
} else if key == self.key_config.extend_selection_by_horizontal_line {
self.expand_selection_by_horizontal_line(true);
return Ok(EventState::Consumed);
}
Ok(EventState::NotConsumed)
}

@ -105,6 +105,7 @@ pub struct KeyConfig {
pub extend_selection_by_one_cell_right: Key,
pub extend_selection_by_one_cell_up: Key,
pub extend_selection_by_one_cell_down: Key,
pub extend_selection_by_horizontal_line: Key,
pub tab_records: Key,
pub tab_columns: Key,
pub tab_constraints: Key,
@ -144,6 +145,7 @@ impl Default for KeyConfig {
extend_selection_by_one_cell_right: Key::Char('L'),
extend_selection_by_one_cell_down: Key::Char('J'),
extend_selection_by_one_cell_up: Key::Char('K'),
extend_selection_by_horizontal_line: Key::Char('V'),
tab_records: Key::Char('1'),
tab_properties: Key::Char('2'),
tab_sql_editor: Key::Char('3'),

Loading…
Cancel
Save