diff options
Diffstat (limited to 'src/builtins.zig')
| -rw-r--r-- | src/builtins.zig | 44 |
1 files changed, 9 insertions, 35 deletions
diff --git a/src/builtins.zig b/src/builtins.zig index 9fa459f2..b1380203 100644 --- a/src/builtins.zig +++ b/src/builtins.zig @@ -526,40 +526,6 @@ pub const Right = struct { } }; -/// The file<->terminal hop. "Latest" is already recorded: the jump stack runs -/// oldest-first and a closing pane hands focus back through the same list — so -/// this walks it instead of keeping a second one. Which side is which: only a -/// shell is a terminal; a file, an image and an output buffer (+Search/+Help) -/// are all DOCS you read, so isTerminal is the whole test. Landing pushes this -/// pane onto that same history, which is why the hop back is the same key. -pub const Toggleterm = struct { - pub fn run(c: Ctx) void { - const want_term = !c.pane.isTerminal(); - var t: ?usize = null; - // any live pane of the other kind: a pane you have never focused (the - // file you started with) is in no history at all - for (c.p.panes, 0..) |slot, k| { - const op = slot orelse continue; - if (k != c.id and op.isTerminal() == want_term) t = k; - } - // ...but the most recently focused one wins - var i = c.p.njumps; - while (i > 0) { - i -= 1; - const hid = c.p.jumps[i].pane; - const hp = c.p.panes[hid] orelse continue; - if (hid != c.id and hp.isTerminal() == want_term) { - t = hid; - break; - } - } - if (t) |target| { - c.p.active = target; - c.p.panes[target].?.pending = 0; - } - } -}; - // ---- the jump group ---- // Where focus HAS BEEN, as three verbs and a list over the one stack pardes @@ -583,12 +549,20 @@ pub const Forward = struct { }; /// vim's Ctrl-^: the pane you were in before this one, whichever it was — the -/// hop you press twice a minute and never want to count steps for. +/// hop you press twice a minute and never want to count steps for. Body-normal +/// Esc is this, which is what makes alternating between two panes one key you +/// hold down: two files, or a file and its shell, or a file and a +Search. /// /// It does NOT move the stack cursor: it goes somewhere, so trackJump records /// it like any other move, and that is exactly what makes it an involution — /// after the hop, the pane you came from is the newest OTHER pane, so pressing /// it again comes straight back. Back/Forward walk history; this one makes it. +/// +/// It replaced a `Toggleterm` that hopped specifically between the newest DOC +/// and the newest TERMINAL. That distinction never earned its keep: it made Esc +/// unpredictable (which of three panes you landed on depended on their kinds), +/// and it could not alternate between two files at all — the case you hit most. +/// "The pane before this one" needs no kinds and is the same key twice. pub const Last = struct { pub fn run(c: Ctx) void { var i = c.p.njumps; |
