diff options
Diffstat (limited to 'src/layout.zig')
| -rw-r--r-- | src/layout.zig | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/layout.zig b/src/layout.zig index 8739122c..e674ccbf 100644 --- a/src/layout.zig +++ b/src/layout.zig @@ -70,9 +70,10 @@ pub fn nearest(p: *const Pardes, from: usize, dir: Dir) ?usize { } /// Window mode's labels, one a pane in reading order (columns left to -/// right, each top to bottom); h, j, k and l move instead. ponytail: a -/// pane past the 22nd has no label and is reached by moving. -pub const window_labels = "asdfgqwertyuiopzxcvbnm"; +/// right, each top to bottom); h, j, k and l move instead, d deletes and c +/// collapses. ponytail: a pane past the 20th has no label and is reached +/// by moving. +pub const window_labels = "asfgqwertyuiopzxvbnm"; /// The letter window mode shows on pane `id`. pub fn windowLabel(p: *const Pardes, id: usize) ?u8 { @@ -88,8 +89,11 @@ pub fn windowLabel(p: *const Pardes, id: usize) ?u8 { /// Window mode (SPC w, Ctrl-w): h/j/k/l (or the arrows) move an outline /// from pane to pane and nothing else gets the keys; Enter or Esc focuses /// the outlined pane, `:` its tag, and a pane's label letter that one. Up past a -/// column's top pane goes on to its tag, as the Up word does. Any other -/// key changes nothing. +/// column's top pane goes on to its tag, as the Up word does. `d` is Del +/// on the outlined pane and `c` Collapse, and the mode stays: a Del that +/// closes it moves the outline to the pane its rows went to (after the k/j +/// question, when Del asks one; Pardes.answerQuestion). Any other key +/// changes nothing. pub fn windowKey(p: *Pardes, key: pardes.Key) void { const at = p.window_pick orelse return; if (p.panes[at] == null) { @@ -113,6 +117,15 @@ pub fn windowKey(p: *Pardes, key: pardes.Key) void { } return; }; + if (pardes.hit(key, config.window_collapse)) return pardes.exec.runBuiltin(p, .Collapse, at, "", null); + if (pardes.hit(key, config.window_delete)) { + // Del's focus follows the rows from the pane it closes, so the + // outlined pane is the active one while it runs. + p.active = at; + pardes.exec.runBuiltin(p, .Del, at, "", null); + if (p.panes[at] == null) p.window_pick = if (p.header_focus) null else p.active; + return; + } const chosen = if (key.cp == pardes.Key.enter or key.cp == pardes.Key.escape or key.cp == ':') at else for (0..p.panes.len) |id| { if (p.panes[id] != null and key.cp < 128 and windowLabel(p, id) == @as(u8, @intCast(key.cp))) break id; } else return; |
