From 044da0f75ab5fb5be0213e512741860d95dad8e5 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 29 Oct 2026 11:14:38 -0300 Subject: tape: every input the core consumes recorded in turn order, replayed into replicas that must reach the same digests; the core's leaks of render, clock and host closed The recorder (src/tape.zig) is null unless PARDES_RECORD= names a tape (.tape); the local path pays a null check a call. It records a tree at the host boundary, both ways: each call the host makes into the core (`Input`: update, serveFs, pump, perform, the shell's acknowledgements and failures, a Restore, ...) with its arguments, and each call the core makes out -- a Host function (the vtable wrapped generically while recording) or a syscall of its own (`tape.site` for every old `turn.yield()`, `tape.value` for a clock or environment read) -- with its result; `done`/`ret` close each, a 9P request served while a step is out lands inside that step's syscall, and fields a host writes between calls (native_images, present_skipped, ...) are found by a diff at every crossing. After each call the host made at the top, the session's digest (src/walk.zig), one per field of the core, its stream and each pane, file and places. `PARDES_REPLAY= pardes` (main.zig) replays it with the same build into three replicas: two at different addresses (the first's memory held while the second runs) and one that never draws. A host call answers what it answered, a site returns what it returned, nothing is performed and no syscall is made; `turn.yield` panics in a replica, so a syscall no site covers is a stack trace; a call the recording did not make, or a digest that differs, is a divergence that names the fields. The headless replica steps over the presents it does not make, applying what the host told the core inside them. What the replicas found, fixed: - Render wrote core state. The view's geometry (wrap map, context rows, body layer rows) is File.geometry, a lazy cache keyed by a hash of what it is made of (revision, scroll, size, tags, tables read, context declarations, the session's view: wrap, layered context, row metrics, rect); the render makes it afresh, a step reading it makes it on demand (wrapAt, wrapRow, ensureCursorVisible). Context declarations, notice bands and the header's reveal are the step's (sync), the tables' reading the tick's (a first look of 4096 lines, a count, wherever it is asked; the rest a frame's clock budget a tick), and a view's paint-ahead is asked of the host as the frame is drawn rather than queued as an effect. - The clock: advance's wakes are the recording session's (a picture decoding or a fade adds no tick to a replica), as are the budgets of Places, Names and Tables (`tape.over`), a message's time of day (the stamp; msg_said_ms and the unattended expiry use the session clock), File.mtime, and the pump reads its clock whether or not it waits. - The host: the session directory (getcwd, asked once at init), $SHELL and its existence, $HOME for `~`, `Shell` naming one that is not there, a missing interpreter, a directory refused above, a deleted file, a pointer seen through a sliding pane (Pardes.pointerCell). - Worker handles (futures, the Io), the 9P server's state, the store file every window shares (a replica keeps its own in memory) and Recent read from it are authority-only; frames, animations and the render's caches local. Query rows' paints count apart from a view's. Terminals replay from their taped pty bytes and are digested as their active screen, cursor and scroll; kitty images are left out until phase 5's screen-state terminals. tagnav.golden: the header's caret reveal now runs every step, as a pane's does, not once per frame drawn, so after `g l B B` typed in one burst the bar stays scrolled as a human typing it sees it. Co-Authored-By: Claude Opus 5.5 --- src/normal.zig | 1 + 1 file changed, 1 insertion(+) (limited to 'src/normal.zig') diff --git a/src/normal.zig b/src/normal.zig index 9cac18b0..f214121a 100644 --- a/src/normal.zig +++ b/src/normal.zig @@ -713,6 +713,7 @@ fn executeNormalAction(p: *Pardes, t: *Text, semantic: modal.Normal.Action) void .middle => { // helix align_view_middle: the cursor's column to the middle // of an unwrapped view + panes.File.geometry(pane); if (pane.body_wrapped) return; const line = text[modal.lineStartOffset(text, modal.lineAtOffset(text, cur))..modal.lineEndOffset(text, modal.lineAtOffset(text, cur))]; const w: usize = @intCast(@max(1, @as(i32, pane.cols) - @as(i32, panes.File.gutterWidth(pane)))); -- cgit v1.3 From fdf59131f68db19fc4818b6e5db7c9fe4cc609fd Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 29 Oct 2026 20:51:15 -0300 Subject: pdf: Esc in a PDF pane drops the selection or the search highlights the page shows, and with none goes back a pane as Esc does everywhere else; Shift-Esc still goes at once Co-Authored-By: Claude Opus 5.5 --- docs/helix-keys.md | 2 +- docs/typ/cheatsheet.typ | 2 +- docs/typ/guide.typ | 2 +- src/normal.zig | 2 ++ src/pdf_view.zig | 14 +++++++++++--- test/pdf.zig | 29 +++++++++++++++++++++++------ 6 files changed, 39 insertions(+), 12 deletions(-) (limited to 'src/normal.zig') diff --git a/docs/helix-keys.md b/docs/helix-keys.md index d47f3051..04aa60dd 100644 --- a/docs/helix-keys.md +++ b/docs/helix-keys.md @@ -122,7 +122,7 @@ language-backend queries, and the shell pipe. | `y` | yank each range's text into the register (`"` names one, else `"`), one value per range | line-yank vim-ism removed (phase 5); yank keeps selection AND cursor (helix). The system clipboard is `"+y` / `SPC y`, helix's own split: a `d` of one character never clobbers what the desktop holds | helix-verified | | `u` / `U` | undo / redo | restores the pre-edit selection (helix); snapshot granularity, `Alt-u`/`Alt-U` are the same two: helix walks a history tree by time with them, and pardes's history is linear, so earlier and later ARE undo and redo | helix-verified | | `p` (normal) | paste the register after each range: value i at range i, the last value repeated when there are fewer | helix `paste_impl`. `"+p` asks the system clipboard (`SPC p`); on a tty that read is OSC 52, which most terminals refuse: an honest no-op rather than a paste of the wrong text | helix-verified | -| `Esc` (body normal) | clear a pending modal prefix / exit select mode, keeping the selection, then run `Last`: hop to the pane you were in before this one, whichever kind it was, exactly like `SPC j j` — so held down it alternates between two panes, two files as readily as a file and its shell. A PDF pane is the ONE exception: there Esc is the document's own cancel (drop the mouse selection and the search overlay, stay where you are reading) and `Shift-Esc` is the hop out, while raw tty takes unmodified Esc as `Last` and sends Shift-Esc to the program (with `ProgramEsc on`, Esc goes to the program except at a detected shell prompt) | Pardes-specific focus binding layered on helix's cleanup. A leader path, tag, topbar or search owns Esc while it is active; raw tty forwards it | pardes-specific (cleanup helix-verified) | +| `Esc` (body normal) | clear a pending modal prefix / exit select mode, keeping the selection, then run `Last`: hop to the pane you were in before this one, whichever kind it was, exactly like `SPC j j` — so held down it alternates between two panes, two files as readily as a file and its shell. In a PDF pane Esc first drops the mouse selection and the search highlights when the page shows any, staying where you are reading, and the next Esc hops; `Shift-Esc` hops at once. Raw tty takes unmodified Esc as `Last` and sends Shift-Esc to the program (with `ProgramEsc on`, Esc goes to the program except at a detected shell prompt) | Pardes-specific focus binding layered on helix's cleanup. A leader path, tag, topbar or search owns Esc while it is active; raw tty forwards it | pardes-specific (cleanup helix-verified) | | `Esc` (insert) | back to normal mode, cursor right after the insertion (no vim left-step) | | helix-verified | | `Enter` (normal) | acme **look** chord: EXPLICIT selection, else file-ish word under cursor | pardes-specific, keep (helix normal-mode Enter unbound). Covers helix `gf`. Implicit motion residue falls back to the cursor word | pardes-specific | | `Tab` (normal) | acme **execute** chord | pardes-specific, keep; explicit-selection rule as Enter | pardes-specific | diff --git a/docs/typ/cheatsheet.typ b/docs/typ/cheatsheet.typ index 11f7c6fc..9dc9c473 100644 --- a/docs/typ/cheatsheet.typ +++ b/docs/typ/cheatsheet.typ @@ -72,7 +72,7 @@ Helix-style: motions *select*, then an edit acts on the selection. Mode box: bla == Keys: panes #pairs( [#key("Ctrl-w")], [window mode: #keys("h", "j", "k", "l") move the outline, #key("d") deletes it (then #key("k")/#key("j") between two), #key("c") collapses it, #key("Enter")/#key("Esc") or a pane's letter focuses (not in insert or raw `$`)], - [#key("Esc")], [back to the previous pane (insert: to normal)], + [#key("Esc")], [back to the previous pane (insert: to normal; a PDF: its selection and search highlights go first)], [#key("Shift-Esc")], [back to the previous pane from any mode but raw, where it is the program's Esc; needs the kitty keyboard protocol or the GUI, elsewhere a plain Esc], [#keys("Ctrl-o", "Ctrl-i")], [jump history back, forward; this file first. #key("Ctrl-i") is #key("Tab") without the kitty protocol: #key("SPC j i")], [#key("Alt-n")], [new terminal below], diff --git a/docs/typ/guide.typ b/docs/typ/guide.typ index 40802ed9..0b721658 100644 --- a/docs/typ/guide.typ +++ b/docs/typ/guide.typ @@ -43,7 +43,7 @@ steps raw, normal, insert. [#mode-box(" ") normal], [#key("Esc"): back to the previous pane (#word("Last")), unlike helix. #key("Shift-Esc"): the same.], [#mode-box("^") insert], [#key("Esc"): back to normal. #key("Shift-Esc"): out of insert and back to the previous pane.], [#mode-box("$") raw], [#key("Esc"): back to the previous pane. #key("Shift-Esc"): an Esc to the program. Either way the terminal stays raw. #word("ProgramEsc") `on` swaps them back: #key("Esc") goes to the program, except at a shell prompt with nothing typed on it, and #key("Shift-Esc") always goes back.], - [a PDF], [#key("Esc"): clears the selection and the search highlights. #key("Shift-Esc"): back to the previous pane.], + [a PDF], [#key("Esc"): clears the selection and the search highlights, and with none shown goes back to the previous pane. #key("Shift-Esc"): back at once.], ) In acme, Esc selects the text typed since the last click; here it leaves diff --git a/src/normal.zig b/src/normal.zig index f214121a..25e2deec 100644 --- a/src/normal.zig +++ b/src/normal.zig @@ -1016,6 +1016,8 @@ pub fn handlePdfNormal(p: *Pardes, pane: *Pane, key: Key) void { if (result.page_changed) panes.Pdf.resetPageChrome(pane); switch (result.host) { .none => {}, + // typed again by a macro, Esc is only the page's + .last => if (p.macro.replaying == 0) exec.runBuiltin(p, .Last, p.active, "", null), .leader => { p.leader_on = true; p.leader_n = 0; diff --git a/src/pdf_view.zig b/src/pdf_view.zig index 4ddbf299..b2b9c5a3 100644 --- a/src/pdf_view.zig +++ b/src/pdf_view.zig @@ -906,12 +906,15 @@ pub const State = if (enabled) struct { if (page) |selected_page| state.invalidateRaster(selected_page); } - pub fn cancelChrome(state: *@This(), gpa: std.mem.Allocator) void { + /// Drops the selection and the search; true when there was one. + pub fn cancelChrome(state: *@This(), gpa: std.mem.Allocator) bool { + const had = state.selection != null or state.search_query.len > 0; state.clearDrag(); state.clearSelection(gpa); - if (state.search_query.len == 0) return; + if (state.search_query.len == 0) return had; state.dropSearchQuery(gpa); state.invalidateRaster(state.page); + return had; } fn invalidatePage(state: *@This(), gpa: std.mem.Allocator) void { @@ -1230,6 +1233,7 @@ pub const ScrollResult = struct { active_page: usize }; pub const CellPixels = struct { w: u16, h: u16 }; pub const NormalHost = enum { none, + last, leader, command_line, search, @@ -2476,7 +2480,11 @@ pub fn applyNormal( if (comptime !enabled) return .{}; var result: NormalResult = .{}; switch (semantic) { - .escape => state.cancelChrome(gpa), + // Esc drops a selection or a search the page shows, else goes back + // a pane (text-only, the page shows neither). + .escape => if (!state.cancelChrome(gpa) or !native_images) { + result.host = .last; + }, .move => |move| switch (move.motion) { .down => result.page_changed = moveRows( state, diff --git a/test/pdf.zig b/test/pdf.zig index 3f84195c..a50f3bf6 100644 --- a/test/pdf.zig +++ b/test/pdf.zig @@ -1454,7 +1454,7 @@ test "PDF normal adapter consumes unsupported actions and navigates page fallbac try std.testing.expect(pane.prompt == .none); } -test "Escape cancels PDF chrome in place and Shift-Escape leaves the pane" { +test "Escape cancels PDF chrome in place, then leaves the pane; Shift-Escape leaves at once" { if (!pdf_enabled or platform == .web) return; const gpa = std.testing.allocator; @@ -1507,15 +1507,32 @@ test "Escape cancels PDF chrome in place and Shift-Escape leaves the pane" { try std.testing.expectEqual(scroll_before, pv.document_scroll_y); try std.testing.expectEqual(@as(u32, 0), pane.body.normal.count); try std.testing.expectEqual(.none, pane.body.normal.prefix); - // A second Escape on a bare document is inert rather than an exit. + // With nothing left to drop, Escape goes back a pane as anywhere else, + // and leaves the document as it found it. p.update(.{ .key = .{ .cp = Key.escape } }); - try std.testing.expectEqual(@as(usize, 0), p.active); - - // Shift-Escape is the way out, and it leaves the document as it found it. - p.update(.{ .key = .{ .cp = Key.escape, .shift = true } }); try std.testing.expectEqual(@as(usize, 1), p.active); try std.testing.expectEqual(page_before, pv.page); try std.testing.expectEqual(scroll_before, pv.document_scroll_y); + + // Shift-Escape goes at once, over a selection too. + p.update(.{ .key = .{ .cp = Key.escape } }); + try std.testing.expectEqual(@as(usize, 0), p.active); + try std.testing.expectEqual( + panes.Pdf.SelectionUpdate.changed, + pv.setSelection(p.pdf_gpa, quad.ul, quad.lr, false), + ); + p.update(.{ .key = .{ .cp = Key.escape, .shift = true } }); + try std.testing.expectEqual(@as(usize, 1), p.active); + try std.testing.expect(pv.selection != null); + + // A text-only page shows neither: one Escape drops them and goes. + p.native_images = false; + p.update(.{ .key = .{ .cp = Key.escape } }); + try std.testing.expectEqual(@as(usize, 0), p.active); + try pv.setSearchQuery(p.pdf_gpa, "Pardes"); + p.update(.{ .key = .{ .cp = Key.escape } }); + try std.testing.expectEqual(@as(usize, 1), p.active); + try std.testing.expect(pv.selection == null and pv.search_query.len == 0); } test "PDF continuous strip renders every intersecting short page" { -- cgit v1.3 From 349790339897466f323ff28748916aa48aa344f7 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 29 Oct 2026 21:00:18 -0300 Subject: keys: Esc in a column or the workspace tag in normal mode gives the keyboard back to a pane, as Shift-Esc does, instead of running Last underneath it Co-Authored-By: Claude Opus 5.5 --- src/normal.zig | 1 + src/pardes.zig | 15 +++++++++++++++ 2 files changed, 16 insertions(+) (limited to 'src/normal.zig') diff --git a/src/normal.zig b/src/normal.zig index 25e2deec..5bc24b08 100644 --- a/src/normal.zig +++ b/src/normal.zig @@ -659,6 +659,7 @@ fn executeNormalAction(p: *Pardes, t: *Text, semantic: modal.Normal.Action) void t.select = false; // typed again by a macro, Esc is only helix's if (p.macro.replaying > 0) return; + tagline.exitHeader(p); // out of a header too, as Shift-Esc return exec.runBuiltin(p, .Last, p.active, "", null); }, .goto => |go| switch (go.target) { diff --git a/src/pardes.zig b/src/pardes.zig index 5d889c86..eb09b1f2 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -8851,6 +8851,21 @@ test "Shift-Esc backs out to the previous pane in every mode, never into raw" { try std.testing.expect(p.active != 0); } +test "Esc in a column or the workspace tag gives the keyboard back to a pane, as Shift-Esc does" { + if (platform == .web) return; + const p = try Pardes.init(std.testing.allocator, .{ .cols = 80, .rows = 24, .file = "mise.toml" }); + defer p.deinit(); + p.update(.{ .key = .{ .cp = 'n', .alt = true } }); // a pane to go back to + for ([_]?usize{ 0, null }) |column| { + tagline.enterHeader(p, column); + try std.testing.expect(tagline.focusedHeader(p) != null); + const was = p.active; + p.update(.{ .key = .{ .cp = Key.escape } }); + try std.testing.expect(tagline.focusedHeader(p) == null); + try std.testing.expect(p.active != was); + } +} + test "window mode moves an outline and focuses it on Enter, Esc or a label" { const p = try Pardes.init(std.testing.allocator, .{ .cols = 120, .rows = 30 }); defer p.deinit(); -- cgit v1.3