Skip to content

Add configurable Next/Previous Pane keybindings#84

Merged
thdxg merged 3 commits into
mainfrom
claude/quirky-bose-900b06
Jun 12, 2026
Merged

Add configurable Next/Previous Pane keybindings#84
thdxg merged 3 commits into
mainfrom
claude/quirky-bose-900b06

Conversation

@thdxg

@thdxg thdxg commented Jun 12, 2026

Copy link
Copy Markdown
Owner

Closes #83.

Why

⌘] / ⌘[ cycle through projects in Macterm, so the issue asked for a separate, rebindable way to move between the panes within a tab — matching Ghostty's goto_split:next / goto_split:previous.

Ghostty's next/previous walk panes in creation order — its docs describe them as "the adjacent split in the order of creation", and the source (src/datastruct/split_tree.zig) implements them as next_wrapped/previous_wrapped: an in-order traversal of the split tree with wraparound (the directional left/right/up/down variants are the spatial ones). This PR mirrors that: Macterm's SplitNode.allPanes() is the same in-order leaf traversal, so cycling presents as creation order.

What changed

  • HotkeyAction — new nextPane / previousPane cases, defaulting to "none" (unbound, like splitAuto) so they don't clash with existing shortcuts. The user binds them in Settings.
  • AppCommand — matching "Next Pane" / "Previous Pane" commands in the Panes category. This single registration surfaces them in the command palette, menu bar, and Settings keymaps automatically.
  • AppState.cyclePane(forward:projectID:) — steps through splitRoot.allPanes() (in-order tree traversal) from the focused pane with modulo wraparound; no-op for a single pane. Focus restoration to the NSView rides the existing TerminalPane.updateNSView path, same as directional focus.
  • Wired through AppCommandActions and Responders.

Notes for reviewers

  • The actions are unbound by default — the issue specifically wanted users to set their own keymap rather than impose new defaults that could collide. They appear ready to bind under the Panes section in Settings.
  • The branch history contains an exploratory detour into a focus-history (back/forward) navigator, then a revert back to this creation-order behavior after confirming against Ghostty's docs and source. The net diff is the positional implementation.

Tests

AppStateTests cases: forward advance in tree order, forward/backward wrap, single-pane no-op. mise run test, format, and lint all pass.

⌘] / ⌘[ cycle projects, so issue #83 asks for a separate, rebindable
way to cycle focus through the panes within the current tab. Adds
nextPane/previousPane actions (unbound by default) that walk the active
tab's panes in tree order with wraparound; the palette, menu bar, and
Settings keymaps pick them up automatically via AppCommand.allCases.

Closes #83
@github-actions github-actions Bot added area:state AppState, models, persistence area:hotkeys Key routing, hotkeys area:tests Test changes labels Jun 12, 2026
The first cut cycled panes in spatial tree order. What's actually wanted
is browser-style Back/Forward over the panes you've visited: Previous
Pane returns to where you came from, Next Pane redoes a step you went
back from.

Adds PaneNavigator, a linear trail with a cursor (a normal focus change
truncates the forward path, like a browser). TerminalTab seeds the trail
with the pane being left so Back works from the very first focus move,
and prunes closed panes by position so duplicate ids in the trail don't
mis-anchor the cursor. Kept separate from the MRU paneFocusHistory that
drives next-focus-after-close.
@thdxg thdxg changed the title Add configurable next/previous pane keybindings Add configurable Previous/Next Pane navigation (focus history) Jun 12, 2026
Ghostty's goto_split:next/previous walk panes in creation order (an
in-order traversal of the split tree with wraparound), per its docs and
source (src/datastruct/split_tree.zig: next_wrapped/previous_wrapped) —
not focus history. Drop PaneNavigator and restore the positional cycle
so Macterm matches the behavior the issue asked for.
@thdxg thdxg changed the title Add configurable Previous/Next Pane navigation (focus history) Add configurable Next/Previous Pane keybindings Jun 12, 2026
@thdxg thdxg merged commit 424278c into main Jun 12, 2026
5 checks passed
@thdxg thdxg deleted the claude/quirky-bose-900b06 branch June 12, 2026 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:hotkeys Key routing, hotkeys area:state AppState, models, persistence area:tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add next/previous pane keymap

1 participant