Skip to content

Feat/close split pane - #92

Merged
chi11321 merged 10 commits into
devfrom
feat/close-split-pane
Nov 15, 2026
Merged

chi11321 merged 10 commits into
devfrom
feat/close-split-pane

Conversation

@chi11321

Copy link
Copy Markdown
Owner

No description provided.

ch1ll321 and others added 10 commits November 12, 2026 13:20
The static bindings for arrows/Home/End/PageUp/PageDown/Insert/Delete and
F1-F12 can only ever send the unmodified CSI forms, so they would shadow
the mode-aware encoder this branch adds; remove them here first. Also add
TerminalSession::app_cursor_mode() reading DECCKM through a try-lock.
Keys with Ctrl held that no binding covers fell through to nothing: gpui
leaves key_char unset whenever Ctrl is held, and reports the shifted
character as the key name with shift cleared, so Ctrl+Shift+- arrives as
key = "_" — a name no binding matched, and the IME path never sees control
keydowns. nano's go-to-line (^_) was unreachable.

Map the key name through the xterm control table as a fallback after
binding resolution (a-z -> 0x01..0x1a, @ [ \ ] ^ _ -> 0x00..0x1f, ? ->
0x7f); undefined keys (-, /, digits) still fall through unchanged, and an
active IME composition is never intercepted.
The static table for arrows/Home/End/PageUp/PageDown/Insert/Delete and
F1-F12 could only ever send the unmodified CSI forms. Two gaps in
full-screen programs (vim, less, htop):

- DECCKM: once a program enables application cursor keys (ESC [ ? 1 h),
  the unmodified cursor keys and Home/End must use the SS3 forms
  (ESC O A, ESC O H). Everything kept sending CSI, so vim moved by
  sentences and less scrolled wrong.
- Modifiers: Shift/Ctrl/Alt combinations of those keys were dropped
  entirely; xterm encodes them as CSI 1;{m}X / CSI {n};{m}~.

Replace the static table with keybind::encode_special_key(), which takes
the program's DECCKM state (TerminalSession::app_cursor_mode(), read
through a try-lock) and the xterm modifier parameter
(1 + shift + 2*alt + 4*ctrl). F1-F4 use SS3 unmodified and CSI with
modifiers; the ~-form keys ignore DECCKM. Cmd-chords stay with the app,
matching the kitty-protocol path.
The toolbar offered Split Right / Split Down but nothing to undo them:
leaving a split meant typing exit in that shell. The plumbing already
existed (close_pane collapses the tree, closes the tab on the last pane,
and backends already auto-close their pane on exit) — what was missing
was an affordance.

Three entries now share that one path:

- Close Pane in the terminal's right-click menu, next to Split Right /
  Split Down, shown only when the tab has more than one pane.
- A close button beside the split buttons in the top-right toolbar row,
  same condition, targeting the focused pane.
- Cmd-W closes the focused pane (or the tab when it is the last one),
  matching iTerm/Terminal muscle memory. Empty default elsewhere:
  Ctrl+W is 0x17 and must reach the shell.
Replace the toolbar close button with one inside each pane: with more
than one pane in the tab, every pane carries its own ✕ at its top-left
that closes exactly that pane — a split reads (and un-reads) like a
little window, instead of a global button closing whatever happens to
hold focus.

Placement is the top-left because the top-right corner is already taken
by the global split/panel cluster, with the search bar sliding beneath
it; the pane's close control sits where a traffic light would, and never
collides with either.  keeps the press from starting a
selection in the terminal underneath, and the click bubbles through the
pane's focus handler first, which is harmless: the pane closes anyway.

The toolbar button is gone; the right-click Close Pane item and Cmd-W
remain.
Drop the in-pane close button (it felt out of place) and answer the
actual question instead: which of these identical panes am I typing
into?

The old active-pane tint never showed — it sat on the pane container and
TerminalView paints an opaque term_bg over it, so there was no visible
difference between panes at all. The ring is painted after the view, as
an inset_0 overlay with no listeners, so it draws above the terminal and
clicks/drags still pass through to it.

The border uses input_border_focused() — the same color the UI already
gives a focused input — and only appears when the tab is split; a single
pane fills the window and needs no ring. Crossfades via the transition
registry when focus moves between panes.
Swap the flat 1px focus ring for a light wash that starts at every edge
and fades toward the centre of the pane, which reads as the pane
lighting up rather than being outlined.

gpui 0.2 has two-stop linear gradients only, so the wash is composed
from one strip per side (64pt deep, lit at the edge, transparent at
1.0); neighbouring strips overlap at the corners, pooling the light
there the way a rounded glow does. Both stops share the focus hue so
the fade never drifts gray through Hsla interpolation. The overlay
still has no listeners, so clicks and drags reach the terminal beneath,
and the whole thing crossfades when focus moves between panes.
64pt reached too far into the pane; the wash now hugs the edge and
leaves the middle of the terminal plain.
A hairline rim of light on the focused split pane; anything wider read as
a wash over the terminal.
@chi11321
chi11321 merged commit 2aeadce into dev Nov 15, 2026
0 of 7 checks passed
chi11321 pushed a commit that referenced this pull request Nov 15, 2026
Merging #91 and #92 left both versions of the unbound-key fallback in
place: the old #88 block (if !composing && let Some(byte) =
control_byte(..)) survived next to the mode-aware one, taking the closing
brace of 'if !composing {' with it, so crabport-ui did not compile
("mismatched closing delimiter" at terminal.rs:2467).

Drop the stale block and the duplicated comment; the file is now
identical to the branch that was reviewed, and the keyboard path is the
intended one: control bytes first, then mode-aware special keys.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants