aboutsummaryrefslogtreecommitdiff
path: root/src/app/input
diff options
context:
space:
mode:
authorOgulcan Celik <ogulcancelik@gmail.com>2026-06-04 23:28:36 +0300
committerOgulcan Celik <ogulcancelik@gmail.com>2026-06-04 23:29:08 +0300
commit6b3f6462810e400fbbfbc21240b677732b0549ec (patch)
tree67596cbf125f56dad39f22d35c4598a5463367da /src/app/input
parent9b2749776a97bf373e50819dd8a66f290e421551 (diff)
fix: use live workspace labels in navigator
refs #377
Diffstat (limited to 'src/app/input')
-rw-r--r--src/app/input/mod.rs4
-rw-r--r--src/app/input/modal.rs72
-rw-r--r--src/app/input/navigate.rs2
-rw-r--r--src/app/input/overlays.rs48
4 files changed, 82 insertions, 44 deletions
diff --git a/src/app/input/mod.rs b/src/app/input/mod.rs
index 1da647e8..e8761a35 100644
--- a/src/app/input/mod.rs
+++ b/src/app/input/mod.rs
@@ -86,7 +86,9 @@ impl App {
Mode::Settings => self.handle_settings_key(key_event),
Mode::GlobalMenu => handle_global_menu_key(&mut self.state, key_event),
Mode::KeybindHelp => handle_keybind_help_key(&mut self.state, key_event),
- Mode::Navigator => handle_navigator_key(&mut self.state, key_event),
+ Mode::Navigator => {
+ handle_navigator_key(&mut self.state, &self.terminal_runtimes, key_event)
+ }
Mode::Terminal => unreachable!(),
}
}
diff --git a/src/app/input/modal.rs b/src/app/input/modal.rs
index aedc3adb..334b008e 100644
--- a/src/app/input/modal.rs
+++ b/src/app/input/modal.rs
@@ -152,7 +152,11 @@ pub(crate) fn handle_global_menu_key(state: &mut AppState, key: KeyEvent) {
}
}
-pub(crate) fn handle_navigator_key(state: &mut AppState, key: KeyEvent) {
+pub(crate) fn handle_navigator_key(
+ state: &mut AppState,
+ terminal_runtimes: &crate::terminal::TerminalRuntimeRegistry,
+ key: KeyEvent,
+) {
if state.navigator.search_focused {
match key.code {
KeyCode::Esc => {
@@ -163,36 +167,36 @@ pub(crate) fn handle_navigator_key(state: &mut AppState, key: KeyEvent) {
state.navigator.query.clear();
state.navigator.state_filter = None;
state.navigator.search_focused = false;
- state.clamp_navigator_selection();
+ state.clamp_navigator_selection_from(terminal_runtimes);
}
}
KeyCode::Enter => {
- state.accept_navigator_selection();
+ state.accept_navigator_selection_from(terminal_runtimes);
}
KeyCode::Backspace => {
state.navigator.state_filter = None;
state.navigator.query.pop();
- state.clamp_navigator_selection();
+ state.clamp_navigator_selection_from(terminal_runtimes);
}
- KeyCode::Up => state.move_navigator_selection(-1),
- KeyCode::Down => state.move_navigator_selection(1),
+ KeyCode::Up => state.move_navigator_selection_from(terminal_runtimes, -1),
+ KeyCode::Down => state.move_navigator_selection_from(terminal_runtimes, 1),
KeyCode::Char('n') if key.modifiers == KeyModifiers::CONTROL => {
- state.move_navigator_selection(1)
+ state.move_navigator_selection_from(terminal_runtimes, 1)
}
KeyCode::Char('p') if key.modifiers == KeyModifiers::CONTROL => {
- state.move_navigator_selection(-1)
+ state.move_navigator_selection_from(terminal_runtimes, -1)
}
KeyCode::Char('u') if key.modifiers == KeyModifiers::CONTROL => {
state.navigator.query.clear();
state.navigator.state_filter = None;
- state.clamp_navigator_selection();
+ state.clamp_navigator_selection_from(terminal_runtimes);
}
KeyCode::Char(c)
if key.modifiers.is_empty() || key.modifiers == KeyModifiers::SHIFT =>
{
state.navigator.state_filter = None;
state.navigator.query.push(c);
- state.clamp_navigator_selection();
+ state.clamp_navigator_selection_from(terminal_runtimes);
}
_ => {}
}
@@ -206,62 +210,74 @@ pub(crate) fn handle_navigator_key(state: &mut AppState, key: KeyEvent) {
} else {
state.navigator.query.clear();
state.navigator.state_filter = None;
- state.clamp_navigator_selection();
+ state.clamp_navigator_selection_from(terminal_runtimes);
}
}
KeyCode::Enter => {
- state.accept_navigator_selection();
+ state.accept_navigator_selection_from(terminal_runtimes);
}
KeyCode::Char('/') => {
state.navigator.query.clear();
state.navigator.state_filter = None;
state.navigator.search_focused = true;
- state.clamp_navigator_selection();
+ state.clamp_navigator_selection_from(terminal_runtimes);
}
KeyCode::Backspace if state.navigator.state_filter.is_some() => {
state.navigator.state_filter = None;
- state.clamp_navigator_selection();
+ state.clamp_navigator_selection_from(terminal_runtimes);
}
KeyCode::Char('a') if key.modifiers.is_empty() => {
state.navigator.query.clear();
state.navigator.state_filter = None;
- state.clamp_navigator_selection();
+ state.clamp_navigator_selection_from(terminal_runtimes);
}
KeyCode::Char('b') if key.modifiers.is_empty() => {
state.navigator.query.clear();
state.navigator.state_filter = Some(NavigatorStateFilter::Blocked);
- state.clamp_navigator_selection();
+ state.clamp_navigator_selection_from(terminal_runtimes);
}
KeyCode::Char('w') if key.modifiers.is_empty() => {
state.navigator.query.clear();
state.navigator.state_filter = Some(NavigatorStateFilter::Working);
- state.clamp_navigator_selection();
+ state.clamp_navigator_selection_from(terminal_runtimes);
}
KeyCode::Char('i') if key.modifiers.is_empty() => {
state.navigator.query.clear();
state.navigator.state_filter = Some(NavigatorStateFilter::Idle);
- state.clamp_navigator_selection();
+ state.clamp_navigator_selection_from(terminal_runtimes);
}
KeyCode::Char('d') if key.modifiers.is_empty() => {
state.navigator.query.clear();
state.navigator.state_filter = Some(NavigatorStateFilter::Done);
- state.clamp_navigator_selection();
+ state.clamp_navigator_selection_from(terminal_runtimes);
}
- KeyCode::Char('j') | KeyCode::Down => state.move_navigator_selection(1),
- KeyCode::Char('k') | KeyCode::Up => state.move_navigator_selection(-1),
- KeyCode::Char('d') if key.modifiers == KeyModifiers::CONTROL => {
- state.move_navigator_selection((state.navigator_body_rect().height / 2).max(1) as isize)
+ KeyCode::Char('j') | KeyCode::Down => {
+ state.move_navigator_selection_from(terminal_runtimes, 1)
}
+ KeyCode::Char('k') | KeyCode::Up => {
+ state.move_navigator_selection_from(terminal_runtimes, -1)
+ }
+ KeyCode::Char('d') if key.modifiers == KeyModifiers::CONTROL => state
+ .move_navigator_selection_from(
+ terminal_runtimes,
+ (state.navigator_body_rect().height / 2).max(1) as isize,
+ ),
KeyCode::Char('u') if key.modifiers == KeyModifiers::CONTROL => state
- .move_navigator_selection(-((state.navigator_body_rect().height / 2).max(1) as isize)),
- KeyCode::Char(' ') => state.toggle_selected_navigator_workspace(),
+ .move_navigator_selection_from(
+ terminal_runtimes,
+ -((state.navigator_body_rect().height / 2).max(1) as isize),
+ ),
+ KeyCode::Char(' ') => state.toggle_selected_navigator_workspace_from(terminal_runtimes),
KeyCode::Home => {
state.navigator.selected = 0;
- state.ensure_navigator_selection_visible();
+ state.ensure_navigator_selection_visible_from(terminal_runtimes);
}
KeyCode::End | KeyCode::Char('G') => {
- state.navigator.selected = state.navigator_rows().len().saturating_sub(1);
- state.ensure_navigator_selection_visible();
+ state.navigator.selected = state
+ .navigator_rows_from(terminal_runtimes)
+ .len()
+ .saturating_sub(1);
+ state.ensure_navigator_selection_visible_from(terminal_runtimes);
}
_ => {}
}
diff --git a/src/app/input/navigate.rs b/src/app/input/navigate.rs
index 4bd69f1c..2ac86aeb 100644
--- a/src/app/input/navigate.rs
+++ b/src/app/input/navigate.rs
@@ -830,7 +830,7 @@ pub(super) fn execute_navigate_action_in_context(
super::modal::request_detach(state);
leave_navigate_mode(state);
}
- NavigateAction::OpenNavigator => state.open_navigator(),
+ NavigateAction::OpenNavigator => state.open_navigator_from(terminal_runtimes),
}
finish_action_context(state, context, previous_mode);
diff --git a/src/app/input/overlays.rs b/src/app/input/overlays.rs
index 423334b9..20944080 100644
--- a/src/app/input/overlays.rs
+++ b/src/app/input/overlays.rs
@@ -126,9 +126,14 @@ impl App {
if self.state.mode == Mode::Navigator {
match mouse.kind {
MouseEventKind::Moved => {
- if let Some(idx) = self.state.navigator_row_index_at(mouse.column, mouse.row) {
+ if let Some(idx) = self.state.navigator_row_index_at_from(
+ &self.terminal_runtimes,
+ mouse.column,
+ mouse.row,
+ ) {
self.state.navigator.selected = idx;
- self.state.ensure_navigator_selection_visible();
+ self.state
+ .ensure_navigator_selection_visible_from(&self.terminal_runtimes);
}
}
MouseEventKind::Down(MouseButton::Left) => {
@@ -137,23 +142,29 @@ impl App {
.navigator_search_contains(mouse.column, mouse.row)
{
self.state.navigator.search_focused = true;
- } else if let Some(idx) =
- self.state.navigator_row_index_at(mouse.column, mouse.row)
- {
+ } else if let Some(idx) = self.state.navigator_row_index_at_from(
+ &self.terminal_runtimes,
+ mouse.column,
+ mouse.row,
+ ) {
self.state.navigator.selected = idx;
let target = self
.state
- .navigator_rows()
+ .navigator_rows_from(&self.terminal_runtimes)
.get(idx)
.map(|row| (row.target.clone(), row.is_workspace));
if let Some((NavigatorTarget::Workspace { .. }, true)) = target {
if self.state.navigator_row_caret_at(mouse.column) {
- self.state.toggle_selected_navigator_workspace();
+ self.state.toggle_selected_navigator_workspace_from(
+ &self.terminal_runtimes,
+ );
} else {
- self.state.accept_navigator_selection();
+ self.state
+ .accept_navigator_selection_from(&self.terminal_runtimes);
}
} else {
- self.state.accept_navigator_selection();
+ self.state
+ .accept_navigator_selection_from(&self.terminal_runtimes);
}
} else if !self.state.navigator_popup_contains(mouse.column, mouse.row) {
leave_modal(&mut self.state);
@@ -162,15 +173,19 @@ impl App {
MouseEventKind::ScrollUp => {
self.state.navigator.scroll = self.state.navigator.scroll.saturating_sub(3);
self.state.navigator.selected = self.state.navigator.scroll;
- self.state.clamp_navigator_selection();
+ self.state
+ .clamp_navigator_selection_from(&self.terminal_runtimes);
}
MouseEventKind::ScrollDown => {
let viewport = self.state.navigator_body_rect().height as usize;
- let max = self.state.navigator_max_scroll(viewport);
+ let max = self
+ .state
+ .navigator_max_scroll_from(&self.terminal_runtimes, viewport);
self.state.navigator.scroll =
self.state.navigator.scroll.saturating_add(3).min(max);
self.state.navigator.selected = self.state.navigator.scroll;
- self.state.clamp_navigator_selection();
+ self.state
+ .clamp_navigator_selection_from(&self.terminal_runtimes);
}
_ => {}
}
@@ -312,7 +327,12 @@ impl AppState {
rect_contains(self.navigator_search_rect(), col, row)
}
- pub(crate) fn navigator_row_index_at(&self, col: u16, row: u16) -> Option<usize> {
+ pub(crate) fn navigator_row_index_at_from(
+ &self,
+ terminal_runtimes: &crate::terminal::TerminalRuntimeRegistry,
+ col: u16,
+ row: u16,
+ ) -> Option<usize> {
let body = self.navigator_body_rect();
if !rect_contains(body, col, row) {
return None;
@@ -321,7 +341,7 @@ impl AppState {
.navigator
.scroll
.saturating_add(row.saturating_sub(body.y) as usize);
- (idx < self.navigator_rows().len()).then_some(idx)
+ (idx < self.navigator_rows_from(terminal_runtimes).len()).then_some(idx)
}
pub(crate) fn navigator_row_caret_at(&self, col: u16) -> bool {