mirror of
https://github.com/ChrisTitusTech/linutil.git
synced 2024-11-25 14:30:11 +00:00
Compare commits
7 Commits
59e0986ae3
...
2cdc9582b6
Author | SHA1 | Date | |
---|---|---|---|
|
2cdc9582b6 | ||
|
544cbd4035 | ||
|
c12097de08 | ||
|
063d512bc8 | ||
|
8276d28b8d | ||
|
e3ed8bfa5a | ||
|
882c8c4b24 |
|
@ -481,17 +481,9 @@ impl AppState {
|
|||
Focus::TabList => match key.code {
|
||||
KeyCode::Enter | KeyCode::Char('l') | KeyCode::Right => self.focus = Focus::List,
|
||||
|
||||
KeyCode::Char('j') | KeyCode::Down
|
||||
if self.current_tab.selected().unwrap() + 1 < self.tabs.len() =>
|
||||
{
|
||||
self.current_tab.select_next();
|
||||
self.refresh_tab();
|
||||
}
|
||||
KeyCode::Char('j') | KeyCode::Down => self.scroll_tab_down(),
|
||||
|
||||
KeyCode::Char('k') | KeyCode::Up => {
|
||||
self.current_tab.select_previous();
|
||||
self.refresh_tab();
|
||||
}
|
||||
KeyCode::Char('k') | KeyCode::Up => self.scroll_tab_up(),
|
||||
|
||||
KeyCode::Char('/') => self.enter_search(),
|
||||
KeyCode::Char('t') => self.theme.next(),
|
||||
|
@ -501,8 +493,8 @@ impl AppState {
|
|||
},
|
||||
|
||||
Focus::List if key.kind != KeyEventKind::Release => match key.code {
|
||||
KeyCode::Char('j') | KeyCode::Down => self.selection.select_next(),
|
||||
KeyCode::Char('k') | KeyCode::Up => self.selection.select_previous(),
|
||||
KeyCode::Char('j') | KeyCode::Down => self.scroll_down(),
|
||||
KeyCode::Char('k') | KeyCode::Up => self.scroll_up(),
|
||||
KeyCode::Char('p') | KeyCode::Char('P') => self.enable_preview(),
|
||||
KeyCode::Char('d') | KeyCode::Char('D') => self.enable_description(),
|
||||
KeyCode::Enter | KeyCode::Char('l') | KeyCode::Right => self.handle_enter(),
|
||||
|
@ -521,6 +513,34 @@ impl AppState {
|
|||
true
|
||||
}
|
||||
|
||||
fn scroll_down(&mut self) {
|
||||
let len = self.filter.item_list().len();
|
||||
if len == 0 {
|
||||
return;
|
||||
}
|
||||
let current = self.selection.selected().unwrap_or(0);
|
||||
let max_index = if self.at_root() { len - 1 } else { len };
|
||||
let next = if current + 1 > max_index {
|
||||
0
|
||||
} else {
|
||||
current + 1
|
||||
};
|
||||
|
||||
self.selection.select(Some(next));
|
||||
}
|
||||
|
||||
fn scroll_up(&mut self) {
|
||||
let len = self.filter.item_list().len();
|
||||
if len == 0 {
|
||||
return;
|
||||
}
|
||||
let current = self.selection.selected().unwrap_or(0);
|
||||
let max_index = if self.at_root() { len - 1 } else { len };
|
||||
let next = if current == 0 { max_index } else { current - 1 };
|
||||
|
||||
self.selection.select(Some(next));
|
||||
}
|
||||
|
||||
fn toggle_multi_select(&mut self) {
|
||||
if self.is_current_tab_multi_selectable() {
|
||||
self.multi_select = !self.multi_select;
|
||||
|
@ -557,6 +577,13 @@ impl AppState {
|
|||
self.multi_select = false;
|
||||
self.selected_commands.clear();
|
||||
}
|
||||
let len = self.filter.item_list().len();
|
||||
if len > 0 {
|
||||
let current = self.selection.selected().unwrap_or(0);
|
||||
self.selection.select(Some(current.min(len - 1)));
|
||||
} else {
|
||||
self.selection.select(None);
|
||||
}
|
||||
}
|
||||
|
||||
/// Checks either the current tree node is the root node (can we go up the tree or no)
|
||||
|
@ -736,6 +763,24 @@ impl AppState {
|
|||
80,
|
||||
);
|
||||
}
|
||||
|
||||
fn scroll_tab_down(&mut self) {
|
||||
let len = self.tabs.len();
|
||||
let current = self.current_tab.selected().unwrap_or(0);
|
||||
let next = if current + 1 >= len { 0 } else { current + 1 };
|
||||
|
||||
self.current_tab.select(Some(next));
|
||||
self.refresh_tab();
|
||||
}
|
||||
|
||||
fn scroll_tab_up(&mut self) {
|
||||
let len = self.tabs.len();
|
||||
let current = self.current_tab.selected().unwrap_or(0);
|
||||
let next = if current == 0 { len - 1 } else { current - 1 };
|
||||
|
||||
self.current_tab.select(Some(next));
|
||||
self.refresh_tab();
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "tips")]
|
||||
|
|
Loading…
Reference in New Issue
Block a user