From a0aa305d4cd37df37ced3c94f0689f728f494ddb Mon Sep 17 00:00:00 2001 From: tauraamui Date: Wed, 7 Jan 2026 19:19:15 +0000 Subject: [PATCH 1/2] feat: add new mode for toggling navigation --- mode.v | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mode.v b/mode.v index 0b0684ef..280c7f9a 100644 --- a/mode.v +++ b/mode.v @@ -10,6 +10,7 @@ enum Mode as u8 { insert visual visual_line + navigation } fn (m Mode) color() tea.Color { @@ -20,6 +21,7 @@ fn (m Mode) color() tea.Color { .insert { palette.status_orange } .visual { palette.status_lilac } .visual_line { palette.status_lilac } + .navigation { palette.status_cyan } } } @@ -31,6 +33,7 @@ fn (m Mode) str() string { .insert { 'INSERT' } .visual { 'VISUAL' } .visual_line { 'VISUAL LINE' } + .navigation { 'NAVIGATION' } } } From a080a0468a5ff0a317e6eb8fafc529843595dbbf Mon Sep 17 00:00:00 2001 From: tauraamui Date: Wed, 7 Jan 2026 19:20:07 +0000 Subject: [PATCH 2/2] feat: define handling for subsequent direction key press in nav mode --- editor_workspace.v | 74 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/editor_workspace.v b/editor_workspace.v index d9fda8a4..eac61127 100644 --- a/editor_workspace.v +++ b/editor_workspace.v @@ -243,6 +243,77 @@ fn (mut m EditorWorkspaceModel) update(msg tea.Msg) (tea.Model, ?tea.Cmd) { } } } + // NOTE(tauraamui): + // This whole horrible event handling for 'nav' state is not intended to stay around. I cba to + // fully explain, but the reason this is here is, I personally configure my TMUX prefix bind to be + // C-w instead of C-b (the default), to allow me to use the same binds for navigating between (n)vim + // splits and TMUX splits seemlessly/together. However, I have no current method to distinguish forwarding + // C-w + h/j/k/l binds to Lilly or petal (Lilly v2), so for now it helps a lot if there's two methods/binds + // for petal to allow navigating between splits. Hope this helps. + .navigation { + match msg.k_type { + .special { + if msg.string() == 'escape' { + cmds << switch_mode(.normal) + } + } + .runes { + match msg.string() { + 'h' { + // move to previous split (left) + if m.split_tree.count() > 1 { + old_id := m.split_tree.active_editor_id + moved := m.split_tree.navigate_prev(m.tmux_wrapped) + + if moved == false { + os.execute('tmux select-pane -L') + } else { + new_id := m.split_tree.active_editor_id + m.active_editor_id = new_id + + cmds << tea.sequence( + unfocus_editor(old_id), + focus_editor(new_id), + query_editor_data(new_id), + query_pwd_git_branch + ) + } + } else { + if m.tmux_wrapped { + os.execute('tmux select-pane -L') + } + } + } + 'l' { + // move to next split (right) + if m.split_tree.count() > 1 { + old_id := m.split_tree.active_editor_id + moved := m.split_tree.navigate_next(m.tmux_wrapped) + if moved == false { + os.execute('tmux select-pane -R') + } else { + new_id := m.split_tree.active_editor_id + m.active_editor_id = new_id + + cmds << tea.sequence( + unfocus_editor(old_id), + focus_editor(new_id), + query_editor_data(new_id), + query_pwd_git_branch + ) + } + } else { + if m.tmux_wrapped { + os.execute('tmux select-pane -R') + } + } + } + else {} + } + } + } + cmds << switch_mode(.normal) + } .normal { match msg.k_type { .special { @@ -250,6 +321,9 @@ fn (mut m EditorWorkspaceModel) update(msg tea.Msg) (tea.Model, ?tea.Cmd) { "escape" { cmds << hide_error } + "ctrl+b" { + cmds << switch_mode(.navigation) + } "ctrl+w+h" { // move to previous split (left) if m.split_tree.count() > 1 {