diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Core.zig | 92 | ||||
| -rw-r--r-- | src/Jump.zig | 129 | ||||
| -rw-r--r-- | src/Messages.zig | 6 | ||||
| -rw-r--r-- | src/Output.zig | 2 | ||||
| -rw-r--r-- | src/Query.zig | 14 | ||||
| -rw-r--r-- | src/Stream.zig | 8 | ||||
| -rw-r--r-- | src/TerminalImages.zig | 2 | ||||
| -rw-r--r-- | src/builtins.zig | 4 | ||||
| -rw-r--r-- | src/dump.zig | 2 | ||||
| -rw-r--r-- | src/edit.zig | 4 | ||||
| -rw-r--r-- | src/exec.zig | 4 | ||||
| -rw-r--r-- | src/gui/gui.zig | 12 | ||||
| -rw-r--r-- | src/host_io.zig | 10 | ||||
| -rw-r--r-- | src/keys.zig | 14 | ||||
| -rw-r--r-- | src/look.zig | 8 | ||||
| -rw-r--r-- | src/lsp/Ask.zig | 61 | ||||
| -rw-r--r-- | src/macos.zig | 18 | ||||
| -rw-r--r-- | src/mouse.zig | 14 | ||||
| -rw-r--r-- | src/ninep/ctl.zig | 16 | ||||
| -rw-r--r-- | src/ninep/pane.zig | 6 | ||||
| -rw-r--r-- | src/replica.zig | 2 | ||||
| -rw-r--r-- | src/tui/tui.zig | 16 | ||||
| -rw-r--r-- | src/views.zig | 8 |
23 files changed, 239 insertions, 213 deletions
diff --git a/src/Core.zig b/src/Core.zig index 8d88fcbd..b24eb6cc 100644 --- a/src/Core.zig +++ b/src/Core.zig @@ -23,6 +23,7 @@ const Handover = pardes.Handover; const Host = pardes.Host; const ImagePlace = pardes.ImagePlace; const Jump = pardes.Jump; +const Ask = pardes.lsp.Ask; const Key = pardes.Key; const Loc = Jump.Loc; const MAX_COLS = pardes.MAX_COLS; @@ -143,12 +144,8 @@ twin_groups: std.ArrayList(pardes.panes.File.TwinGroup) = .empty, /// what changed. mousein_buttons: u8 = 0, next_twin: u32 = 1, -jumps: [MAX_JUMPS]Loc = undefined, -njumps: usize = 0, -jcur: usize = 0, -/// The next place tracked is an entry of its own however near the last -/// (a query answered: Ctrl-o goes back to where it was asked). -jump_force: bool = false, +/// The places jumped from (Jump.zig). +jumps: Jump = .{}, look_src: [MAX_PANES]u32 = undefined, n_look_src: usize = 0, look_walk_owner: ?u32 = null, @@ -293,20 +290,9 @@ repl_ask: ?struct { from: u32, lang: u8, text: []u8, offered: [26]u32 = @splat(0 /// a click, a 9P write, a startup line or a pane's shell exiting. can_ask: bool = false, -lsp_seq: u32 = 0, -/// The last query asked (Lspwhy explains it): its kind, argument, and -/// the pane and place it was asked at. -lsp_last: ?struct { kind: lsp.Kind, arg: Effect.Buf(128), serial: u32, offset: u32 } = null, -lsp_wait: ?struct { - id: u32, - kind: lsp.Kind, - pane: usize, - serial: u32, - revision: u32, - arg: Effect.Buf(128), - row: i32 = 0, - col: i32 = 0, -} = null, +/// The question to the language servers awaited, and the last asked +/// (lsp/Ask.zig). +lsp_ask: Ask = .{}, pipe: Pipe = .{}, /// A query pane's Grep, and its Find's listing, on a worker (Stream.zig). @@ -320,13 +306,7 @@ needs_frame: bool = true, /// Set by a shell whose present was skipped (no swapchain image): the /// frame is still owed, and the next pump draws it again. present_skipped: bool = false, -/// Core time. `now_ns` is the shell's monotonic clock as `advance` was -/// last given it; `stepped_ns` is how far its timings have been -/// stepped along it, in whole frames of `frame_ns`. Idle, the two are -/// the same instant. -now_ns: u64 = 0, -stepped_ns: u64 = 0, -clock_started: bool = false, +clock: Clock = .{}, /// Builtins announce themselves on the message row. Off while startup /// configuration is applied: those lines are nobody clicking, and should /// not leave the row holding the name of the last one. @@ -435,7 +415,7 @@ pub const replica = .{ // session's closed panes, and the files of a host with no file // system of its own. .authority = .{ "host", "fs", "store", "recent", "db", "fallback" }, - .len = .{ .{ "jumps", "njumps" }, .{ "look_src", "n_look_src" }, .{ "leader_keys", "leader_n" }, .{ "col_x", "ncol" }, .{ "col_w", "ncol" }, .{ "session_dir", "session_dir_len" } }, + .len = .{ .{ "look_src", "n_look_src" }, .{ "leader_keys", "leader_n" }, .{ "col_x", "ncol" }, .{ "col_w", "ncol" }, .{ "session_dir", "session_dir_len" } }, }; /// The message row's entry points, called from everywhere as @@ -1397,7 +1377,7 @@ pub fn pump(p: *Pardes, host: Host) !void { // The clock read whether or not it is wanted: what a replica // waits on is its own (a picture decoding wakes only a frame // that draws it), and the tape has the same calls either way. - const now = if (v.now) |clock| clock(h.ctx) else p.now_ns; + const now = if (v.now) |clock| clock(h.ctx) else p.clock.now_ns; const timeout: u32 = if (p.nextWake()) |due| wake: { const ms = ((due -| now) + std.time.ns_per_ms - 1) / std.time.ns_per_ms; break :wake @intCast(std.math.clamp(ms, 1, std.math.maxInt(u32))); @@ -1445,7 +1425,7 @@ pub fn pump(p: *Pardes, host: Host) !void { p.present_skipped = false; if (v.post_present) |f| f(h.ctx); // Still moving: the next frame is owed a period from now. - const owed = if (p.nextWake()) |due| due <= p.stepped_ns + frame_ns else false; + const owed = if (p.nextWake()) |due| due <= p.clock.stepped_ns + frame_ns else false; p.frames.record(FrameStats.nowNs(), owed, skipped); } @@ -1947,7 +1927,7 @@ pub fn bodyChrome(p: *Pardes) *const ChromeTheme { /// which is what lets every shell sleep exactly as long as nothing /// changes; what moves on the screen is the frontends' own. pub fn nextWake(p: *const Pardes) ?u64 { - const next = p.stepped_ns + frame_ns; + const next = p.clock.stepped_ns + frame_ns; // Held 9P writes go in when they pause: wake for it, never before // the next frame (writes served before the shell's clock was first // seen are stamped 0, which `advance` would count back from). @@ -1965,7 +1945,7 @@ pub fn nextWake(p: *const Pardes) ?u64 { const streaming = p.stream.wake(next); if (streaming) |due| if (due <= next) return next; var frames: ?u64 = null; - if (streaming) |due| frames = @max(1, (due -| p.stepped_ns + frame_ns - 1) / frame_ns); + if (streaming) |due| frames = @max(1, (due -| p.clock.stepped_ns + frame_ns - 1) / frame_ns); if (p.look_hover_wait) |waiting| { const delay = config.look_preview_delay_frames; frames = @max(1, delay -| waiting.frames); @@ -1976,14 +1956,14 @@ pub fn nextWake(p: *const Pardes) ?u64 { }; // Del's question goes up at the end of its delay: a frame then, and // none after (stepped time has reached it). - for (p.panes) |slot| if (slot) |pane| if (pane.prompt == .del_side and pane.question_due_ns > p.stepped_ns) { - const wait = @max(1, (pane.question_due_ns - p.stepped_ns + frame_ns - 1) / frame_ns); + for (p.panes) |slot| if (slot) |pane| if (pane.prompt == .del_side and pane.question_due_ns > p.clock.stepped_ns) { + const wait = @max(1, (pane.question_due_ns - p.clock.stepped_ns + frame_ns - 1) / frame_ns); frames = if (frames) |soonest| @min(soonest, wait) else wait; }; // A paste's Enter waiting on its REPL goes at the end of its wait, // a time on the clock: the frames from `stepped_ns` that reach it. for (p.panes) |slot| if (slot) |pane| if (pane.repl_enter > 0) { - const wait = @max(1, (pane.repl_enter_due_ns -| p.stepped_ns + frame_ns - 1) / frame_ns); + const wait = @max(1, (pane.repl_enter_due_ns -| p.clock.stepped_ns + frame_ns - 1) / frame_ns); frames = if (frames) |soonest| @min(soonest, wait) else wait; }; // A terminal's kitty animation, at its next frame. Only a time still @@ -1991,12 +1971,12 @@ pub fn nextWake(p: *const Pardes) ?u64 { // and a past one would wake every frame for nothing. for (p.panes) |slot| if (slot) |pane| if (pardes.panes.terminal.animationDueMs(pane)) |due_ms| { const due = due_ms *| std.time.ns_per_ms; - if (due > p.stepped_ns) { - const wait = @max(1, (due - p.stepped_ns + frame_ns - 1) / frame_ns); + if (due > p.clock.stepped_ns) { + const wait = @max(1, (due - p.clock.stepped_ns + frame_ns - 1) / frame_ns); frames = if (frames) |soonest| @min(soonest, wait) else wait; } }; - return if (frames) |n| p.stepped_ns + n * frame_ns else null; + return if (frames) |n| p.clock.stepped_ns + n * frame_ns else null; } /// For shells that only need a yes or no: macOS, which keeps its own @@ -2015,10 +1995,10 @@ pub fn advance(p: *Pardes, now_ns: u64) void { const taped = tape.enter(p, .{ .advance = now_ns }); defer tape.leave(p, taped); // The first time a shell's clock is seen, core time starts there. - const started = p.clock_started; - p.clock_started = true; - p.now_ns = now_ns; - if (!started) p.stepped_ns = now_ns; + const started = p.clock.started; + p.clock.started = true; + p.clock.now_ns = now_ns; + if (!started) p.clock.stepped_ns = now_ns; const frame = frame_ns; var moving: u32 = 0; // The session's ticks are the recording session's: a picture still @@ -2027,34 +2007,34 @@ pub fn advance(p: *Pardes, now_ns: u64) void { while (tape.value(.wake, nextWake, .{p})) |due| { if (due > now_ns) break; // Only waiting until `due`: its counters move there at once. - const held = (due - p.stepped_ns) / frame; + const held = (due - p.clock.stepped_ns) / frame; if (held > 1) { Messages.holdMessages(p, held - 1); if (p.look_hover_wait) |*waiting| waiting.frames +|= @intCast(@min(held - 1, std.math.maxInt(u16))); - p.stepped_ns += (held - 1) * frame; + p.clock.stepped_ns += (held - 1) * frame; } // Back from a stall, the moving frames it missed are not all // run at once: the rest are stepped from now, at their pace. if (moving == max_catch_up_frames) { - p.stepped_ns = now_ns; + p.clock.stepped_ns = now_ns; return; } moving += 1; - p.stepped_ns += frame; + p.clock.stepped_ns += frame; p.update(.tick); // A stepped frame is a frame to draw. (A `.tick` does not ask // for one itself: the last frame of a fade used never to be // drawn.) p.needs_frame = true; } else { - p.stepped_ns = now_ns; + p.clock.stepped_ns = now_ns; return; } // A 60 Hz display frame is 16.67 ms and ours 16: without this, every // 24th display frame would take two steps, a hitch in every fade. // An overshoot this small is let go; a larger one (144 Hz lands 4.8 // ms past) is kept, so the average rate stays right. - if (moving > 0 and now_ns - p.stepped_ns < vsync_slack_ns) p.stepped_ns = now_ns; + if (moving > 0 and now_ns - p.clock.stepped_ns < vsync_slack_ns) p.clock.stepped_ns = now_ns; } pub const vsync_slack_ns = 1500 * std.time.ns_per_us; @@ -2099,6 +2079,16 @@ pub const Column = struct { serial: u32 = 0, }; +/// Core time. `now_ns` is the shell's monotonic clock as `advance` was +/// last given it; `stepped_ns` is how far its timings have been stepped +/// along it, in whole frames of `frame_ns`. Idle, the two are the same +/// instant. +pub const Clock = struct { + now_ns: u64 = 0, + stepped_ns: u64 = 0, + started: bool = false, +}; + pub const Boot = enum { /// the document named on the command line, or the pane explaining why not document, @@ -2848,7 +2838,7 @@ test "a REPL bound for a language takes the exec made on a body in it; tags, Exe // Python's echo only restarts a short wait: the Enter goes once the // echo of the whole paste has gone quiet. try std.testing.expectEqualStrings("", Sent.said(1)); - p.now_ns = p.panes[1].?.repl_enter_due_ns; + p.clock.now_ns = p.panes[1].?.repl_enter_due_ns; p.update(.tick); Sent.drain(p); try std.testing.expectEqualStrings("\r", Sent.said(1)); @@ -2856,7 +2846,7 @@ test "a REPL bound for a language takes the exec made on a body in it; tags, Exe _ = exec.executeFrom(p, 0, "print(11)\nprint(22)", true); Sent.drain(p); try std.testing.expectEqualStrings("\x1b[200~print(11)\nprint(22)\x1b[201~", Sent.said(1)); - p.now_ns = p.panes[1].?.repl_enter_due_ns; + p.clock.now_ns = p.panes[1].?.repl_enter_due_ns; p.update(.tick); Sent.drain(p); try std.testing.expectEqualStrings("\r\r", Sent.said(1)); @@ -2865,7 +2855,7 @@ test "a REPL bound for a language takes the exec made on a body in it; tags, Exe p.update(.tick); // on the clock: not yet, however old core time is Sent.drain(p); try std.testing.expect(std.mem.endsWith(u8, Sent.said(1), "\x1b[200~print(2)\x1b[201~")); - p.now_ns = p.panes[1].?.repl_enter_due_ns; // the clock reaches its wait + p.clock.now_ns = p.panes[1].?.repl_enter_due_ns; // the clock reaches its wait p.update(.tick); Sent.drain(p); try std.testing.expectEqualStrings("\r", Sent.said(1)); diff --git a/src/Jump.zig b/src/Jump.zig index 237be82a..131d7e9d 100644 --- a/src/Jump.zig +++ b/src/Jump.zig @@ -15,6 +15,19 @@ const Pane = panes.Pane; const MAX_PANES = pardes.MAX_PANES; const MAX_JUMPS = pardes.MAX_JUMPS; const BOX_H = pardes.BOX_H; + +const Jump = @This(); + +/// The places, oldest first, `n` of them, and the one Back and Forward +/// are at. +list: [MAX_JUMPS]Loc = undefined, +n: usize = 0, +cur: usize = 0, +/// The next place tracked is an entry of its own however near the last +/// (a query answered: Ctrl-o goes back to where it was asked). +force: bool = false, + +pub const replica = .{ .len = .{.{ "list", "n" }} }; const Mouse = pardes.Mouse; const recent_path_cap = limits.host_path_cap; @@ -68,7 +81,7 @@ const JumpsTest = struct { for (order, 0..) |letter, i| { const which = std.mem.indexOfScalar(u8, letters, letter).?; const pane = p.panes[t.ids[which]].?; - p.jumps[i] = .{ + p.jumps.list[i] = .{ .pane = @intCast(t.ids[which]), .serial = pane.serial, .line = 10 + 40 * seen[which], @@ -77,9 +90,9 @@ const JumpsTest = struct { }; seen[which] += 1; } - p.njumps = order.len; - p.jcur = order.len - 1; - look.focusPaneLine(p, p.jumps[p.jcur].pane, .{ .line = p.jumps[p.jcur].line, .col = 1 }, .center); + p.jumps.n = order.len; + p.jumps.cur = order.len - 1; + look.focusPaneLine(p, p.jumps.list[p.jumps.cur].pane, .{ .line = p.jumps.list[p.jumps.cur].line, .col = 1 }, .center); p.sync(); return t; } @@ -101,9 +114,9 @@ const JumpsTest = struct { fn walk(t: JumpsTest, way: Way, delta: i32, buf: []u8) ![]const u8 { var out: std.Io.Writer = .fixed(buf); for (0..2 * MAX_JUMPS) |_| { - const before = t.p.jcur; + const before = t.p.jumps.cur; t.step(way, delta); - if (t.p.jcur == before) break; + if (t.p.jumps.cur == before) break; const pane = t.p.panes[t.p.active].?; const which = std.mem.indexOfScalar(usize, &t.ids, t.p.active).?; try out.print("{s}{c}{d}", .{ if (out.end > 0) " " else "", letters[which], pane.body.cur_row + 1 }); @@ -139,8 +152,8 @@ fn samePlace(p: *const Pardes, a: Loc, b: Loc) bool { pub fn trackJump(p: *Pardes) void { var w: usize = 0; var cur: usize = 0; - for (p.jumps[0..p.njumps], 0..) |j, i| { - if (i == p.jcur) cur = w; // survives -> lands at w; dies -> the next one does + for (p.jumps.list[0..p.jumps.n], 0..) |j, i| { + if (i == p.jumps.cur) cur = w; // survives -> lands at w; dies -> the next one does var kept = j; const live = if (j.serial == 0) false else if (p.panes[j.pane]) |pane| pane.serial == j.serial else false; // A file's pane closed: its entry stays, closed, and a jump to it @@ -161,22 +174,22 @@ pub fn trackJump(p: *Pardes) void { } // Two in a row the same (a closed one reopened beside its own, // or the entry between them gone): one entry, one step. - if (w > 0 and std.meta.eql(p.jumps[w - 1], kept)) { - if (i == p.jcur) cur = w - 1; + if (w > 0 and std.meta.eql(p.jumps.list[w - 1], kept)) { + if (i == p.jumps.cur) cur = w - 1; continue; } - p.jumps[w] = kept; + p.jumps.list[w] = kept; w += 1; } - p.njumps = w; - p.jcur = @min(cur, w -| 1); + p.jumps.n = w; + p.jumps.cur = @min(cur, w -| 1); const pane = p.panes[p.active] orelse return; // A query being typed moves the owner's selection to show, never a // jump; its pane is no place to come back to either. if (pane.query) |q| if (!q.frozen) return; - const force = p.jump_force; - p.jump_force = false; + const force = p.jumps.force; + p.jumps.force = false; const pdf_place = panes.Pdf.place(pane); const now: Loc = .{ .pane = @intCast(p.active), @@ -186,26 +199,26 @@ pub fn trackJump(p: *Pardes) void { .path_hash = if (jumpPath(pane)) |path| std.hash.Wyhash.hash(0, path) else 0, .pdf = pdf_place != null, }; - if (!force and p.njumps > 0 and samePlace(p, p.jumps[p.jcur], now)) { - p.jumps[p.jcur] = now; // same visit; the entry IS where you are + if (!force and p.jumps.n > 0 and samePlace(p, p.jumps.list[p.jumps.cur], now)) { + p.jumps.list[p.jumps.cur] = now; // same visit; the entry IS where you are return; } // a new jump made from the middle of the list drops everything ahead of // it, the way vim's does: the future you did not take is not history. - if (p.njumps > 0) p.njumps = p.jcur + 1; - if (!force and p.njumps >= 2 and samePlace(p, p.jumps[p.njumps - 2], now)) { - p.jumps[p.njumps - 2] = p.jumps[p.njumps - 1]; - p.jumps[p.njumps - 1] = now; - p.jcur = p.njumps - 1; + if (p.jumps.n > 0) p.jumps.n = p.jumps.cur + 1; + if (!force and p.jumps.n >= 2 and samePlace(p, p.jumps.list[p.jumps.n - 2], now)) { + p.jumps.list[p.jumps.n - 2] = p.jumps.list[p.jumps.n - 1]; + p.jumps.list[p.jumps.n - 1] = now; + p.jumps.cur = p.jumps.n - 1; return; } - if (p.njumps == MAX_JUMPS) { - std.mem.copyForwards(Loc, p.jumps[0 .. MAX_JUMPS - 1], p.jumps[1..]); - p.njumps -= 1; + if (p.jumps.n == MAX_JUMPS) { + std.mem.copyForwards(Loc, p.jumps.list[0 .. MAX_JUMPS - 1], p.jumps.list[1..]); + p.jumps.n -= 1; } - p.jumps[p.njumps] = now; - p.jcur = p.njumps; - p.njumps += 1; + p.jumps.list[p.jumps.n] = now; + p.jumps.cur = p.jumps.n; + p.jumps.n += 1; } /// One step through the jumplist, older for a negative `delta`, newer @@ -222,19 +235,19 @@ pub fn trackJump(p: *Pardes) void { pub fn jumpBy(p: *Pardes, delta: i32) void { const older = delta < 0; // At an end of the list: said, not a step that silently does nothing. - if (p.njumps == 0 or (older and p.jcur == 0) or (!older and p.jcur + 1 >= p.njumps)) + if (p.jumps.n == 0 or (older and p.jumps.cur == 0) or (!older and p.jumps.cur + 1 >= p.jumps.n)) return p.setMessage(p.active, if (older) "Back: nothing further back" else "Forward: nothing further on"); - var next = if (older) p.jcur - 1 else p.jcur + 1; + var next = if (older) p.jumps.cur - 1 else p.jumps.cur + 1; // A terminal or a scratch has no file to keep to: the step is global. if (p.settings.jump_scope == .file) if (p.panes[p.active]) |here| if (Pardes.recentPlace(here)) |place| if (place.path.len > 0) { const hash = if (jumpPath(here)) |path| std.hash.Wyhash.hash(0, path) else 0; // The nearest of this pane's own wins over a nearer one of this // file in another pane: the step does not move the keyboard. var pick: ?usize = null; - var i = p.jcur; - while (if (older) i > 0 else i + 1 < p.njumps) { + var i = p.jumps.cur; + while (if (older) i > 0 else i + 1 < p.jumps.n) { i = if (older) i - 1 else i + 1; - const k = p.jumps[i]; + const k = p.jumps.list[i]; if (k.pane == p.active and k.serial == here.serial) { pick = i; break; @@ -243,7 +256,7 @@ pub fn jumpBy(p: *Pardes, delta: i32) void { } next = pick orelse next; }; - const j = p.jumps[next]; + const j = p.jumps.list[next]; if (j.pane >= MAX_PANES) return; // A closed file's entry: opened again at its dot, placed as a look // places it, and the entry is that pane from here on. @@ -257,17 +270,17 @@ pub fn jumpBy(p: *Pardes, delta: i32) void { if (found) |e| p.setMessage(p.active, std.fmt.bufPrint(&said, "{s}: deleted, skipped", .{e.path}) catch "deleted, skipped"); const hash = j.path_hash; var w: usize = 0; - var cur = p.jcur; - for (p.jumps[0..p.njumps], 0..) |k, i| { + var cur = p.jumps.cur; + for (p.jumps.list[0..p.jumps.n], 0..) |k, i| { if (k.serial == 0 and k.path_hash == hash) { - if (i < p.jcur) cur -= 1; + if (i < p.jumps.cur) cur -= 1; continue; } - p.jumps[w] = k; + p.jumps.list[w] = k; w += 1; } - p.njumps = w; - p.jcur = @min(cur, w -| 1); + p.jumps.n = w; + p.jumps.cur = @min(cur, w -| 1); // The same step again, over the list without them: each // round takes one file's entries away, so it ends. return jumpBy(p, delta); @@ -281,18 +294,18 @@ pub fn jumpBy(p: *Pardes, delta: i32) void { if (j.pdf) panes.Pdf.landAt(p, opened, .{ .page = j.line -| 1, .at = j.col }); // Every entry of that file is the reopened pane from here on, so // a step onto another of them moves in it rather than reopening. - for (p.jumps[0..p.njumps]) |*k| if (k.serial == 0 and k.path_hash == j.path_hash) { + for (p.jumps.list[0..p.jumps.n]) |*k| if (k.serial == 0 and k.path_hash == j.path_hash) { k.pane = @intCast(p.active); k.serial = opened.serial; }; - p.jcur = next; + p.jumps.cur = next; return; } const pane = p.panes[j.pane] orelse return; if (pane.serial != j.serial) return; if (p.panes[p.active]) |source| look.clearNavigationSelection(p, source); if (p.active != j.pane) look.clearNavigationSelection(p, pane); - p.jcur = next; + p.jumps.cur = next; if (pane.pdfPath() != null) { look.focusPaneLine(p, j.pane, .{ .line = 0, .col = 0 }, .keep); panes.Pdf.landAt(p, pane, .{ .page = j.line -| 1, .at = if (j.pdf) j.col else 0 }); @@ -307,36 +320,36 @@ test "the jump list never holds two entries in a row the same, when the one betw const pane = try p.setTestFile(std.mem.asBytes(&@as([200][2]u8, @splat("a\n".*)))); const at: Loc = .{ .pane = 0, .serial = pane.serial, .line = 1, .col = 1 }; // A, a pane long closed with no file to keep it, A again, then far on. - p.jumps[0] = at; - p.jumps[1] = .{ .pane = 5, .serial = 999, .line = 1, .col = 1 }; - p.jumps[2] = at; - p.jumps[3] = .{ .pane = 0, .serial = pane.serial, .line = 150, .col = 1 }; - p.njumps = 4; - p.jcur = 3; + p.jumps.list[0] = at; + p.jumps.list[1] = .{ .pane = 5, .serial = 999, .line = 1, .col = 1 }; + p.jumps.list[2] = at; + p.jumps.list[3] = .{ .pane = 0, .serial = pane.serial, .line = 150, .col = 1 }; + p.jumps.n = 4; + p.jumps.cur = 3; pane.body.cur_row = 80; // where you are now: far from both trackJump(p); - for (1..p.njumps) |i| try std.testing.expect(!std.meta.eql(p.jumps[i - 1], p.jumps[i])); - try std.testing.expectEqual(@as(usize, 3), p.njumps); - try std.testing.expectEqual(@as(u32, 1), p.jumps[0].line); - try std.testing.expectEqual(@as(u32, 150), p.jumps[1].line); + for (1..p.jumps.n) |i| try std.testing.expect(!std.meta.eql(p.jumps.list[i - 1], p.jumps.list[i])); + try std.testing.expectEqual(@as(usize, 3), p.jumps.n); + try std.testing.expectEqual(@as(u32, 1), p.jumps.list[0].line); + try std.testing.expectEqual(@as(u32, 150), p.jumps.list[1].line); } test "jump history skips an entry whose pane slot or serial is gone, leaving the selection" { const p = try Pardes.init(std.testing.allocator, .{ .cols = 60, .rows = 12 }); defer p.deinit(); const pane = try p.setTestFile("alpha beta\ngamma delta\nepsilon zeta\n"); - p.njumps = 2; - p.jcur = 1; - p.jumps[1] = .{ .pane = 0, .serial = pane.serial, .line = 1, .col = 1 }; + p.jumps.n = 2; + p.jumps.cur = 1; + p.jumps.list[1] = .{ .pane = 0, .serial = pane.serial, .line = 1, .col = 1 }; pane.body.setRange(pane.file.?.content, 0, .{ .anchor = 1, .head = 5 }, true); const selected = pane.body.primaryRange(pane.file.?.content, 0); for ([_]Loc{ .{ .pane = 15, .serial = pane.serial, .line = 1, .col = 1 }, .{ .pane = 0, .serial = pane.serial + 1, .line = 1, .col = 1 }, }) |missing| { - p.jumps[0] = missing; + p.jumps.list[0] = missing; jumpBy(p, -1); - try std.testing.expectEqual(@as(usize, 1), p.jcur); + try std.testing.expectEqual(@as(usize, 1), p.jumps.cur); try std.testing.expectEqualDeep(selected, pane.body.primaryRange(pane.file.?.content, 0)); } } diff --git a/src/Messages.zig b/src/Messages.zig index 8fa89125..fbcc0343 100644 --- a/src/Messages.zig +++ b/src/Messages.zig @@ -525,7 +525,7 @@ fn collectBands(p: *Pardes, pane: *Pane, r: Rect, id: usize) void { if (id == p.active and p.leader_on) pane.notices.push(.leader); // Del's question shows once its delay is up: answered before that, it // was never there. - const del_waiting = pane.prompt == .del_side and pane.question_due_ns > p.now_ns; + const del_waiting = pane.prompt == .del_side and pane.question_due_ns > p.clock.now_ns; if (pane.promptText()) |text| if (text.len > 0 and !del_waiting) pane.notices.push(.prompt); // A pane only has so many rows to give. When they do not all fit the // LAST ones survive, because the prompt is last and it is the one @@ -886,7 +886,7 @@ test "an idle core wants no wake and a lingering message sleeps to its linger's p.update(.{ .key = .{ .cp = 'x' } }); try std.testing.expectEqual(Pane.MessagePhase.lingering, pane.msg_life.phase); const linger = messageFrames(p.settings.message_linger_ms); - const due = p.stepped_ns + linger * frame; + const due = p.clock.stepped_ns + linger * frame; try std.testing.expectEqual(@as(?u64, due), p.nextWake()); p.needs_frame = false; p.advance(due - frame); @@ -901,7 +901,7 @@ test "an idle core wants no wake and a lingering message sleeps to its linger's try std.testing.expect(p.executeBuiltinLine(p.active, "MessageLinger 5000")); try std.testing.expect(p.executeBuiltinLine(p.active, "Msg again")); p.update(.{ .key = .{ .cp = 'x' } }); - const long_due = p.stepped_ns + messageFrames(5000) * frame; + const long_due = p.clock.stepped_ns + messageFrames(5000) * frame; try std.testing.expectEqual(@as(?u64, long_due), p.nextWake()); p.advance(long_due); try std.testing.expectEqual(@as(usize, 0), pane.msg_len); diff --git a/src/Output.zig b/src/Output.zig index 3c04aff8..027502bc 100644 --- a/src/Output.zig +++ b/src/Output.zig @@ -626,7 +626,7 @@ pub fn diffSource(p: *Pardes, f: *const File.State) ?[]const u8 { pub fn openJumps(p: *Pardes, id: usize) !void { var out: std.Io.Writer.Allocating = .init(p.gpa); errdefer out.deinit(); - for (p.jumps[0..p.njumps]) |j| { + for (p.jumps.list[0..p.jumps.n]) |j| { // A closed file's entry: marked, and a look at it opens it again. if (j.serial == 0) { const e = p.recentByHash(j.path_hash) orelse continue; diff --git a/src/Query.zig b/src/Query.zig index 7347b21c..9865001b 100644 --- a/src/Query.zig +++ b/src/Query.zig @@ -1422,7 +1422,7 @@ fn makeListRows(p: *Pardes, id: usize, pat: []const u8) !void { const owner = p.panes[oid].?; // Current: the first place after where it was asked (the answer // may come after the cursor moved), shown in the owner. - const asked_at: usize = if (p.lsp_last) |last| (if (last.serial == owner.serial) last.offset else owner.places.origin(owner)) else owner.places.origin(owner); + const asked_at: usize = if (p.lsp_ask.last) |last| (if (last.serial == owner.serial) last.offset else owner.places.origin(owner)) else owner.places.origin(owner); const hits = owner.places.hits.items; var next: ?usize = null; for (hits, 0..) |h, i| if (h.start > asked_at) { @@ -1814,7 +1814,7 @@ pub fn land(p: *Pardes, id: usize, row: ?usize) void { p.registers.last_search = '/'; set.provenance = .search; } - p.jump_force = true; + p.jumps.force = true; p.active = oid; return; } @@ -1829,7 +1829,7 @@ pub fn land(p: *Pardes, id: usize, row: ?usize) void { }; const it = q.items.items[c]; const meta = f.location_rows[c + 1]; - p.jump_force = true; + p.jumps.force = true; if (it.serial != 0) { if (p.paneBySerial(it.serial)) |tid| { p.active = tid; @@ -2323,7 +2323,7 @@ fn leader(p: *Pardes, keys: []const u8) void { fn settle(p: *Pardes) void { // a typed Grep's pause run out on the clock - p.advance(p.now_ns + Stream.debounce_ns + std.time.ns_per_ms); + p.advance(p.clock.now_ns + Stream.debounce_ns + std.time.ns_per_ms); var frames: usize = 0; while (busy(p) and frames < 2000) : (frames += 1) p.update(.tick); p.update(.tick); @@ -2492,7 +2492,7 @@ test "a language server's list: one answer lands with no pane, several open the }.of; // One: the keyboard on it, no pane, the place tinted and n's. p.lspRequest(0, .references, ""); - p.update(.{ .lsp_resp = .{ .id = p.lsp_wait.?.id, .rows = "/test.txt:3:1-5 alpha two\n" } }); + p.update(.{ .lsp_resp = .{ .id = p.lsp_ask.wait.?.id, .rows = "/test.txt:3:1-5 alpha two\n" } }); try std.testing.expectEqual(@as(usize, 1), npanes(p)); try std.testing.expectEqual(@as(usize, 0), p.active); try std.testing.expectEqual(@as(i32, 2), pane.body.cur_row); @@ -2500,7 +2500,7 @@ test "a language server's list: one answer lands with no pane, several open the try std.testing.expectEqual(Places.Hit{ .start = 15, .end = 20 }, pane.places.hits.items[0]); // None: a message, no pane. p.lspRequest(0, .diagnostics, ""); - p.update(.{ .lsp_resp = .{ .id = p.lsp_wait.?.id, .rows = "" } }); + p.update(.{ .lsp_resp = .{ .id = p.lsp_ask.wait.?.id, .rows = "" } }); try std.testing.expectEqual(@as(usize, 1), npanes(p)); try std.testing.expect(std.mem.indexOf(u8, pane.msg[0..pane.msg_len], "none") != null); // Several: the list open, the keyboard in it in normal mode on the @@ -2508,7 +2508,7 @@ test "a language server's list: one answer lands with no pane, several open the pane.body.cur_row = 0; pane.body.cur_col = 0; p.lspRequest(0, .references, ""); - p.update(.{ .lsp_resp = .{ .id = p.lsp_wait.?.id, .rows = "/test.txt:1:1-5 alpha one\n/test.txt:3:1-5 alpha two\n/test.txt:5:1-5 alpha three\n" } }); + p.update(.{ .lsp_resp = .{ .id = p.lsp_ask.wait.?.id, .rows = "/test.txt:1:1-5 alpha one\n/test.txt:3:1-5 alpha two\n/test.txt:5:1-5 alpha three\n" } }); const qid = queryPane(p).?; const qp = p.panes[qid].?; const q = qp.query.?; diff --git a/src/Stream.zig b/src/Stream.zig index dabc283c..90ab2a1d 100644 --- a/src/Stream.zig +++ b/src/Stream.zig @@ -503,7 +503,7 @@ pub fn query(p: *Pardes, target: u32, kind: Kind, pattern: []const u8, dir: []co s.dir.appendSlice(p.gpa, dir) catch return; s.skipped = 0; s.state = .waiting; - s.due_ns = if (how == .typed) p.now_ns + debounce_ns else p.now_ns; + s.due_ns = if (how == .typed) p.clock.now_ns + debounce_ns else p.clock.now_ns; if (kind == .grep) s.rows_asked = @splat(0); } @@ -549,7 +549,7 @@ pub fn busyFor(s: *const Stream, serial: u32) bool { pub fn step(p: *Pardes) void { const s = &p.stream; const due = s.due_ns orelse return; - if (p.now_ns < due) return; + if (p.clock.now_ns < due) return; s.due_ns = null; s.state = .searching; // A script's write (whose answer says whether it found anything) and a @@ -1213,7 +1213,7 @@ test "Stream: a stale generation's rows never land in the query pane, however tw if (round % 4 == 3) { query(p, qp.serial, .grep, b, root, .typed); try testing.expectEqual(State.waiting, p.stream.state); - p.advance(p.now_ns + debounce_ns + std.time.ns_per_ms); + p.advance(p.clock.now_ns + debounce_ns + std.time.ns_per_ms); } else query(p, qp.serial, .grep, b, root, .now); try testing.expect(p.stream.gen != rogue.gen); const thread = try std.Thread.spawn(.{}, Rogue.run, .{&rogue}); @@ -1382,7 +1382,7 @@ test "Stream: a Grep stops at its 2000 lines and waits; More in the query pane's if (slot) |qp| if (qp.query != null) break i; } else return error.NoQueryPane; const qp = p.panes[qid].?; - p.advance(p.now_ns + debounce_ns + std.time.ns_per_ms); + p.advance(p.clock.now_ns + debounce_ns + std.time.ns_per_ms); const until = std.Io.Clock.awake.now(testing.io).toMilliseconds() + 20_000; while (p.stream.state != .capped) { if (std.Io.Clock.awake.now(testing.io).toMilliseconds() > until) return error.Timeout; diff --git a/src/TerminalImages.zig b/src/TerminalImages.zig index ab8ee099..06b96f4b 100644 --- a/src/TerminalImages.zig +++ b/src/TerminalImages.zig @@ -153,7 +153,7 @@ pub fn draw( // Animations step on the core's clock, as this frame shows them; the // shown frame is `renderData()` (a new `generation` each step, which // the caches key on). - const now_ms = p.stepped_ns / std.time.ns_per_ms; + const now_ms = p.clock.stepped_ns / std.time.ns_per_ms; ti.animation_due_ms = if (storage.animationTick(vt.io(), now_ms)) |delay| now_ms +| delay else null; const pages = &screen.pages; const top = pages.getTopLeft(.viewport); diff --git a/src/builtins.zig b/src/builtins.zig index a12ddebe..a924396d 100644 --- a/src/builtins.zig +++ b/src/builtins.zig @@ -1842,10 +1842,10 @@ pub const LookPrev = struct { /// Go back to the last place jumped from in another pane. pub const Last = struct { pub fn run(c: Ctx) void { - var i = c.p.njumps; + var i = c.p.jumps.n; while (i > 0) { i -= 1; - const j = c.p.jumps[i]; + const j = c.p.jumps.list[i]; if (j.serial == 0) continue; // a closed file's: Back reopens it, Last goes to a pane // Restore the cursor without recentering the pane's retained view. if (j.pane != c.id) return look.focusPaneLine(c.p, j.pane, .{ .line = j.line, .col = j.col }, .keep); diff --git a/src/dump.zig b/src/dump.zig index 55be8d58..faf6fb23 100644 --- a/src/dump.zig +++ b/src/dump.zig @@ -522,7 +522,7 @@ fn reviveSession(p: *Pardes, previous: ?*Pardes, resumed: bool) !void { // Never a serial or a request number the old session gave out. p.next_serial = @max(p.next_serial, old.next_serial); p.next_column_serial = @max(p.next_column_serial, old.next_column_serial); - p.lsp_seq = @max(p.lsp_seq, old.lsp_seq); + p.lsp_ask.seq = @max(p.lsp_ask.seq, old.lsp_ask.seq); p.pipe.seq = @max(p.pipe.seq, old.pipe.seq); // The host's facts, as this host told them. p.cell_pixels = old.cell_pixels; diff --git a/src/edit.zig b/src/edit.zig index 834911f6..85718293 100644 --- a/src/edit.zig +++ b/src/edit.zig @@ -1026,9 +1026,9 @@ fn insertEdit(p: *Pardes, t: *Text, key: Key) void { if (t.what != .body) break :dot; const f = (t.pane() orelse break :dot).file orelse break :dot; if (f.output != null or !lsp.speaks(f.path)) break :dot; - const seq = p.lsp_seq; + const seq = p.lsp_ask.seq; p.lspRequest(p.active, .completion, ""); - if (p.lsp_seq != seq) return; + if (p.lsp_ask.seq != seq) return; } // helix smart_tab: after text, Tab leaves the syntax node the // cursor is in; only where the file has a grammar, since the diff --git a/src/exec.zig b/src/exec.zig index 63bb4c1c..3b68a6fd 100644 --- a/src/exec.zig +++ b/src/exec.zig @@ -552,7 +552,7 @@ const repl_quiet_ns: u64 = 100 * std.time.ns_per_ms; /// The host's clock now; core time (`now_ns`, `stepped_ns`) is as old as /// the last frame, seconds in an idle session. pub fn clockNow(p: *Pardes) u64 { - return if (p.host.vtable.now) |clock| clock(p.host.ctx) else p.now_ns; + return if (p.host.vtable.now) |clock| clock(p.host.ctx) else p.clock.now_ns; } /// Sends the Enters a paste into pane `id`'s REPL is owed: when the REPL @@ -567,7 +567,7 @@ pub fn flushReplEnter(p: *Pardes, id: usize, answered: bool) void { pane.repl_enter_due_ns = clockNow(p) + repl_quiet_ns; return; } - if (!answered and p.now_ns < pane.repl_enter_due_ns) return; + if (!answered and p.clock.now_ns < pane.repl_enter_due_ns) return; for (0..pane.repl_enter) |_| p.emitWrite(id, "\r"); pane.repl_enter = 0; } diff --git a/src/gui/gui.zig b/src/gui/gui.zig index cf35a5fa..a54a4b7b 100644 --- a/src/gui/gui.zig +++ b/src/gui/gui.zig @@ -824,7 +824,7 @@ test "GUI completion failure survives backlog and leaves the document unchanged" const pane = try core.setTestFile("abc"); pane.body.cur_col = 1; core.lspRequest(core.active, .completion, ""); - const id = core.lsp_wait.?.id; + const id = core.lsp_ask.wait.?.id; var queue: Queue = .{ .io = std.testing.io, .gpa = gpa, .lsp_allocator = gpa, .lsp_id = id }; defer queue.deinit(); queue.acceptReader(0, 1); @@ -844,7 +844,7 @@ test "GUI completion failure survives backlog and leaves the document unchanged" shell.gens = &gens; shell.ptys = &ptys; shell.drainQueue(); - try std.testing.expect(core.lsp_wait == null); + try std.testing.expect(core.lsp_ask.wait == null); try std.testing.expectEqualStrings("abc", pane.file.?.content); try std.testing.expectEqual(@as(i32, 1), pane.body.cur_col); } @@ -899,7 +899,7 @@ test "GUI worker setup failures finish matching LSP and pipe requests" { var tasks: PipeTasks = .{}; core.lspRequest(core.active, .status, ""); const req: host_io.Lsp.Request = .{ - .id = core.lsp_wait.?.id, + .id = core.lsp_ask.wait.?.id, .kind = .status, .pane = @intCast(core.active), .offset = 0, @@ -919,7 +919,7 @@ test "GUI worker setup failures finish matching LSP and pipe requests" { shell.threads_ok = false; lsp(&shell, req); } - try std.testing.expect(core.lsp_wait == null); + try std.testing.expect(core.lsp_ask.wait == null); try std.testing.expectEqualStrings("abc", pane.file.?.content); pane.body.cur_col = 2; @@ -4133,7 +4133,7 @@ fn guiNow(ctx: ?*anyopaque) u64 { const s = shellOf(ctx); if (s.waited) { s.waited = false; - if (s.mail_only and s.peers.count() > 0 and s.core.clock_started) return s.core.now_ns; + if (s.mail_only and s.peers.count() > 0 and s.core.clock.started) return s.core.clock.now_ns; } return s.test_clock orelse s.paced_ns orelse c.SDL_GetTicksNS(); } @@ -4797,7 +4797,7 @@ const GlideRun = struct { frames: usize = 0, fn play(seq: *GlideRun, g: *Gui, core: *pardes.Pardes, gpa: std.mem.Allocator, arena: *std.heap.ArenaAllocator, script: []const Step, frames: usize) !void { - var now: u64 = core.now_ns; + var now: u64 = core.clock.now_ns; var next: usize = 0; for (0..frames) |frame| { while (next < script.len and script[next].frame == frame) : (next += 1) core.update(.{ .key = script[next].key }); diff --git a/src/host_io.zig b/src/host_io.zig index bbf72d8c..b7e58506 100644 --- a/src/host_io.zig +++ b/src/host_io.zig @@ -916,7 +916,7 @@ pub const Lsp = struct { failing.fail_index = std.math.maxInt(usize); core.lspRequest(core.active, kind, "renamed"); const job = try snapshot(failing.allocator(), core, .{ - .id = core.lsp_wait.?.id, + .id = core.lsp_ask.wait.?.id, .kind = kind, .pane = @intCast(core.active), .offset = 6, @@ -925,7 +925,7 @@ pub const Lsp = struct { if (fail) failing.fail_index = failing.alloc_index; work(std.testing.io, failing.allocator(), job, &sink, Sink.take); try std.testing.expectEqual(fail, sink.failed); - try std.testing.expect(core.lsp_wait == null); + try std.testing.expect(core.lsp_ask.wait == null); if (fail) { try std.testing.expectEqualStrings("const value=1;\n", pane.file.?.content); try std.testing.expectEqual(revision, pane.file.?.revision); @@ -3759,9 +3759,9 @@ test "LSP query answers, and a newer one cancels it" { defer queue.deinit(); for (0..2) |_| { core.lspRequest(core.active, .status, ""); - queue.startLsp(core, .{ .id = core.lsp_wait.?.id, .kind = .status, .pane = @intCast(core.active), .offset = 0, .arg = "" }); + queue.startLsp(core, .{ .id = core.lsp_ask.wait.?.id, .kind = .status, .pane = @intCast(core.active), .offset = 0, .arg = "" }); } - const last = core.lsp_wait.?.id; + const last = core.lsp_ask.wait.?.id; queue.lsp_task.?.future.await(io); queue.lsp_task = null; var batch = queue.take(); @@ -3770,5 +3770,5 @@ test "LSP query answers, and a newer one cancels it" { try std.testing.expectEqual(last, batch.items[0].lsp.id); try std.testing.expect(batch.items[0].lsp.rows != null); core.update(.{ .lsp_resp = .{ .id = last, .rows = batch.items[0].lsp.rows } }); - try std.testing.expect(core.lsp_wait == null); + try std.testing.expect(core.lsp_ask.wait == null); } diff --git a/src/keys.zig b/src/keys.zig index 60e6fa0f..264eb95e 100644 --- a/src/keys.zig +++ b/src/keys.zig @@ -524,7 +524,7 @@ test "Del from a key asks which neighbour takes the rows; nothing else asks" { p.update(.{ .key = .{ .cp = 'd' } }); try std.testing.expect(p.panes[mid] != null); try std.testing.expectEqual(Pane.Prompt.del_side, p.panes[mid].?.prompt); - p.now_ns = p.panes[mid].?.question_due_ns; // shown once its delay is up + p.clock.now_ns = p.panes[mid].?.question_due_ns; // shown once its delay is up _ = try p.render(frame.allocator()); try std.testing.expectEqual(Pane.Notices.Kind.prompt, p.panes[mid].?.notices.kinds[p.panes[mid].?.notices.len - 1]); try std.testing.expectEqualStrings(config.del_question, p.panes[mid].?.promptText().?); @@ -687,9 +687,9 @@ test "the Del question shows only once its delay is up: a quick SPC d j never se p.newScratchBelow(mid); p.sync(); p.active = mid; - p.now_ns = 5 * std.time.ns_per_s; - p.stepped_ns = p.now_ns; - const asked_at = p.now_ns; + p.clock.now_ns = 5 * std.time.ns_per_s; + p.clock.stepped_ns = p.clock.now_ns; + const asked_at = p.clock.now_ns; p.update(.{ .key = .{ .cp = ' ' } }); p.update(.{ .key = .{ .cp = 'd' } }); const pane = p.panes[mid].?; @@ -701,13 +701,13 @@ test "the Del question shows only once its delay is up: a quick SPC d j never se // The loop wakes for it, at the end of the delay and not before. const wake = p.nextWake().?; try std.testing.expect(wake >= pane.question_due_ns and wake < pane.question_due_ns + frame_ns); - p.now_ns = pane.question_due_ns - 1; + p.clock.now_ns = pane.question_due_ns - 1; _ = try p.render(frame.allocator()); for (pane.notices.kinds[0..pane.notices.len]) |kind| try std.testing.expect(kind != .prompt); // Its time come, it is the band's last line; stepped past it, nothing // more to wake for. - p.now_ns = wake; - p.stepped_ns = wake; + p.clock.now_ns = wake; + p.clock.stepped_ns = wake; _ = try p.render(frame.allocator()); try std.testing.expectEqual(Pane.Notices.Kind.prompt, pane.notices.kinds[pane.notices.len - 1]); try std.testing.expect(p.nextWake() == null); diff --git a/src/look.zig b/src/look.zig index 25ec029d..31b80948 100644 --- a/src/look.zig +++ b/src/look.zig @@ -1085,8 +1085,8 @@ fn resolveLookTarget(p: *Pardes, id: usize, txt: []const u8, realbuf: *[4096]u8) var seen: [MAX_PANES][]const u8 = undefined; var nseen: usize = 0; var n: usize = 0; - cand: while (n <= p.njumps) : (n += 1) { - const k: usize = if (n == 0) id else p.jumps[p.njumps - n].pane; + cand: while (n <= p.jumps.n) : (n += 1) { + const k: usize = if (n == 0) id else p.jumps.list[p.jumps.n - n].pane; if (n > 0 and k == id) continue; // tried first, skip the rerun const op = p.panes[k] orelse continue; const dir = Pardes.paneDir(op); @@ -1930,7 +1930,7 @@ test "Look hover waits without mutating the pane and input cancels it" { const selections_before = pane.sel; const active_before = p.active; const cursor_before = .{ pane.body.cur_row, pane.body.cur_col }; - const jumps_before = .{ p.njumps, p.jcur, p.n_look_src }; + const jumps_before = .{ p.jumps.n, p.jumps.cur, p.n_look_src }; const effects_before = p.effects_len; p.update(motion); @@ -1957,7 +1957,7 @@ test "Look hover waits without mutating the pane and input cancels it" { try std.testing.expect(std.meta.eql(selections_before, pane.sel)); try std.testing.expectEqual(active_before, p.active); try std.testing.expectEqual(cursor_before, .{ pane.body.cur_row, pane.body.cur_col }); - try std.testing.expectEqual(jumps_before, .{ p.njumps, p.jcur, p.n_look_src }); + try std.testing.expectEqual(jumps_before, .{ p.jumps.n, p.jumps.cur, p.n_look_src }); try std.testing.expectEqual(effects_before, p.effects_len); _ = frame.reset(.retain_capacity); diff --git a/src/lsp/Ask.zig b/src/lsp/Ask.zig index c658593d..f071cf7b 100644 --- a/src/lsp/Ask.zig +++ b/src/lsp/Ask.zig @@ -17,6 +17,25 @@ const config = @import("../config.zig"); const memory = @import("../memory.zig"); const Pardes = pardes.Pardes; const Pane = panes.Pane; +const Effect = pardes.Effect; + +const Ask = @This(); + +seq: u32 = 0, +/// The last query asked (Lspwhy explains it): its kind, argument, and the +/// pane and place it was asked at. +last: ?struct { kind: lsp.Kind, arg: Effect.Buf(128), serial: u32, offset: u32 } = null, +/// The query whose answer is awaited. +wait: ?struct { + id: u32, + kind: lsp.Kind, + pane: usize, + serial: u32, + revision: u32, + arg: Effect.Buf(128), + row: i32 = 0, + col: i32 = 0, +} = null, const TAG_TEXT_INSET = pardes.TAG_TEXT_INSET; pub fn lspRequest(p: *Pardes, asked: usize, kind: lsp.Kind, arg_in: []const u8) void { @@ -24,7 +43,7 @@ pub fn lspRequest(p: *Pardes, asked: usize, kind: lsp.Kind, arg_in: []const u8) if (!normal.multiOnce(p)) return; // one question per keystroke, from the primary // Lspwhy narrates the last query where it was asked -- that pane's // file, place and argument -- from wherever it is run. - const last_pane: ?usize = if (kind == .explain) (if (p.lsp_last) |last| p.paneBySerial(last.serial) else null) else null; + const last_pane: ?usize = if (kind == .explain) (if (p.lsp_ask.last) |last| p.paneBySerial(last.serial) else null) else null; const id = last_pane orelse asked; var said: [128]u8 = undefined; if (!lsp.supports.contains(kind)) @@ -73,16 +92,16 @@ pub fn lspRequest(p: *Pardes, asked: usize, kind: lsp.Kind, arg_in: []const u8) var sent = arg; var at = off; if (kind == .explain) { - if (p.lsp_last) |last| { + if (p.lsp_ask.last) |last| { sent = std.fmt.bufPrint(&explained, "{s} {s}", .{ @tagName(last.kind), last.arg.slice() }) catch ""; if (last_pane != null) at = last.offset; } - } else if (kind != .status) p.lsp_last = .{ .kind = kind, .arg = .from(arg), .serial = pane.serial, .offset = @intCast(off) }; - p.lsp_seq +%= 1; + } else if (kind != .status) p.lsp_ask.last = .{ .kind = kind, .arg = .from(arg), .serial = pane.serial, .offset = @intCast(off) }; + p.lsp_ask.seq +%= 1; // A 9P write that asked it is answered once the answer is in. if (p.fs.serving) p.fs.lsp_answer_at = pardes.turn.lsp_answers; - p.lsp_wait = .{ - .id = p.lsp_seq, + p.lsp_ask.wait = .{ + .id = p.lsp_ask.seq, .kind = kind, .pane = id, .serial = pane.serial, @@ -92,7 +111,7 @@ pub fn lspRequest(p: *Pardes, asked: usize, kind: lsp.Kind, arg_in: []const u8) .col = pane.body.cur_col, }; p.emit(.{ .lsp = .{ - .id = p.lsp_seq, + .id = p.lsp_ask.seq, .kind = kind, .pane = @intCast(id), .offset = @intCast(at), @@ -246,9 +265,9 @@ fn lspWord(kind: lsp.Kind) []const u8 { pub fn lspResponse(p: *Pardes, id: u32, response: ?[]const u8) void { defer pardes.turn.bump(&pardes.turn.lsp_answers); - const w = p.lsp_wait orelse return; + const w = p.lsp_ask.wait orelse return; if (w.id != id) return; // superseded by a newer press, or the pane died - p.lsp_wait = null; + p.lsp_ask.wait = null; const pane = p.panes[w.pane] orelse return; if (pane.serial != w.serial) return; // Whatever fails from here -- no answer, nothing found, no room for @@ -414,7 +433,7 @@ test "Lspwhy after a Hover asks to explain that hover, in its file at its place, }; pane.body.cur_row = 0; pane.body.cur_col = 0; - p.lsp_wait = null; + p.lsp_ask.wait = null; // Run from another file's pane: still the hover's file and place. const other = p.freeSlot().?; _ = try panes.openTutorView(p, other); @@ -452,7 +471,7 @@ test "Def and Refs are a speaking file's tag words; gd, gr and a 2-1 chord all r try std.testing.expect(at == null); at = e.lsp.offset; }; - q.lsp_wait = null; + q.lsp_ask.wait = null; return at orelse error.NothingAsked; } }; @@ -509,7 +528,7 @@ test "Callstack always opens and focuses its own pane, reusing it for another sy _ = try p.setTestFile("fn work() {}\n"); const source = p.panes[0].?; p.lspRequest(0, .callstack, ""); - const first = p.lsp_wait orelse return error.NoRequest; + const first = p.lsp_ask.wait orelse return error.NoRequest; lspResponse(p, first.id, "╰──┬ /test.txt:1:4-7 work\n@callstack-match ╰─ /test.txt:1:4-7 fn work() {}\n"); const report = p.panes[p.active].?; try std.testing.expect(report != source); @@ -534,7 +553,7 @@ test "Callstack always opens and focuses its own pane, reusing it for another sy try std.testing.expectEqual(@as(usize, 0), report.body.nsel); const serial = report.serial; p.lspRequest(0, .callstack, ""); - const second = p.lsp_wait orelse return error.NoRequest; + const second = p.lsp_ask.wait orelse return error.NoRequest; lspResponse(p, second.id, "No callers reported\n"); try std.testing.expectEqual(serial, p.panes[p.active].?.serial); try std.testing.expectEqualStrings("No callers reported\n", p.panes[p.active].?.file.?.content); @@ -546,7 +565,7 @@ test "Callers with one answer jumps to it and says where, in a msg" { defer p.deinit(); const pane = try p.setTestFile("fn a() {}\nfn b() { a(); }\n"); p.lspRequest(p.active, .incoming_calls, ""); - const wait = p.lsp_wait.?; + const wait = p.lsp_ask.wait.?; p.update(.{ .lsp_resp = .{ .id = wait.id, .rows = "/test.txt:2:10 b\n" } }); try std.testing.expectEqual(@as(i32, 1), pane.body.cur_row); try std.testing.expectEqualStrings("Callers: the one, /test.txt:2:10", pane.msg[0..pane.msg_len]); @@ -558,7 +577,7 @@ test "a Rename the language server finds nothing for says so, and changes nothin defer p.deinit(); const pane = try p.setTestFile("const value=1;\n"); p.lspRequest(p.active, .rename, "renamed"); - const wait = p.lsp_wait.?; + const wait = p.lsp_ask.wait.?; p.update(.{ .lsp_resp = .{ .id = wait.id, .rows = "" } }); try std.testing.expectEqualStrings("Rename: nothing here to rename", pane.msg[0..pane.msg_len]); try std.testing.expectEqualStrings("const value=1;\n", pane.file.?.content); @@ -573,19 +592,19 @@ test "LSP failure clears only its matching wait without completion indentation" pane.body.cur_col = 1; p.lspRequest(p.active, .completion, ""); - const old_id = p.lsp_wait.?.id; + const old_id = p.lsp_ask.wait.?.id; p.lspRequest(p.active, .completion, ""); - const current_id = p.lsp_wait.?.id; + const current_id = p.lsp_ask.wait.?.id; p.update(.{ .lsp_resp = .{ .id = old_id, .rows = null } }); - try std.testing.expectEqual(current_id, p.lsp_wait.?.id); + try std.testing.expectEqual(current_id, p.lsp_ask.wait.?.id); p.update(.{ .lsp_resp = .{ .id = current_id, .rows = null } }); - try std.testing.expect(p.lsp_wait == null); + try std.testing.expect(p.lsp_ask.wait == null); try std.testing.expectEqualStrings("x", pane.file.?.content); try std.testing.expectEqual(@as(i32, 1), pane.body.cur_col); p.lspRequest(p.active, .completion, ""); - p.update(.{ .lsp_resp = .{ .id = p.lsp_wait.?.id, .rows = "" } }); - try std.testing.expect(p.lsp_wait == null); + p.update(.{ .lsp_resp = .{ .id = p.lsp_ask.wait.?.id, .rows = "" } }); + try std.testing.expect(p.lsp_ask.wait == null); try std.testing.expectEqualStrings("x ", pane.file.?.content); try std.testing.expectEqual(@as(i32, 4), pane.body.cur_col); } diff --git a/src/macos.zig b/src/macos.zig index 9956d706..d7e9f454 100644 --- a/src/macos.zig +++ b/src/macos.zig @@ -314,9 +314,9 @@ test "mac queued results never cancel a newer LSP request" { defer st.config_arena.deinit(); defer st.inbox.close(); core.lspRequest(0, .status, ""); - const old_id = core.lsp_wait.?.id; + const old_id = core.lsp_ask.wait.?.id; core.lspRequest(0, .status, ""); - const current_id = core.lsp_wait.?.id; + const current_id = core.lsp_ask.wait.?.id; st.inbox.lsp_id = current_id; st.inbox.lsp_task = .{ .id = current_id, .future = .{ .any_future = null, .result = {} } }; // The inbox turns the superseded answer away. @@ -325,11 +325,11 @@ test "mac queued results never cancel a newer LSP request" { _ = drainInbox(&st); try std.testing.expect(st.inbox.lsp_task != null); try std.testing.expectEqual(current_id, st.inbox.lsp_task.?.id); - try std.testing.expectEqual(current_id, core.lsp_wait.?.id); + try std.testing.expectEqual(current_id, core.lsp_ask.wait.?.id); st.inbox.push(.{ .lsp = .{ .id = current_id, .rows = try gpa.dupe(u8, "") } }); try std.testing.expect(drainInbox(&st)); try std.testing.expect(st.inbox.lsp_task == null); - try std.testing.expect(core.lsp_wait == null); + try std.testing.expect(core.lsp_ask.wait == null); } test "mac worker setup failures finish matching LSP and pipe requests" { @@ -358,14 +358,14 @@ test "mac worker setup failures finish matching LSP and pipe requests" { defer st.inbox.close(); core.lspRequest(core.active, .status, ""); const req: host_io.Lsp.Request = .{ - .id = core.lsp_wait.?.id, + .id = core.lsp_ask.wait.?.id, .kind = .status, .pane = @intCast(core.active), .offset = 0, .arg = "", }; lspRequest(&st, req); - try std.testing.expect(core.lsp_wait == null); + try std.testing.expect(core.lsp_ask.wait == null); try std.testing.expectEqualStrings("abc", pane.file.?.content); pane.body.cur_col = 2; @@ -1229,7 +1229,7 @@ test "mac Restore keeps host state and rejects callbacks from the old core" { try std.testing.expect(st.rotate_coasting); core.lspRequest(0, .status, ""); - const old_request = core.lsp_wait.?.id; + const old_request = core.lsp_ask.wait.?.id; st.inbox.lsp_id = old_request; st.inbox.lsp_task = .{ .id = old_request, .future = .{ .any_future = null, .result = {} } }; st.inbox.push(.{ .lsp = .{ .id = old_request, .rows = try gpa.dupe(u8, "old result") } }); @@ -1263,14 +1263,14 @@ test "mac Restore keeps host state and rejects callbacks from the old core" { try std.testing.expect(!st.cwd_stale[0]); st.core.lspRequest(0, .status, ""); - const new_request = st.core.lsp_wait.?.id; + const new_request = st.core.lsp_ask.wait.?.id; try std.testing.expect(new_request > old_request); st.inbox.lsp_id = new_request; st.inbox.lsp_task = .{ .id = new_request, .future = .{ .any_future = null, .result = {} } }; st.inbox.push(.{ .lsp = .{ .id = new_request, .rows = &.{} } }); try std.testing.expect(drainInbox(&st)); try std.testing.expect(st.inbox.lsp_task == null); - try std.testing.expect(st.core.lsp_wait == null); + try std.testing.expect(st.core.lsp_ask.wait == null); const pane = st.core.panes[0].?; pane.body.cur_col = 4; diff --git a/src/mouse.zig b/src/mouse.zig index 43d66e0b..56a1b378 100644 --- a/src/mouse.zig +++ b/src/mouse.zig @@ -1143,7 +1143,7 @@ fn mirrorTtySelection(p: *Pardes, pane: *Pane) void { fn doubleClick(p: *Pardes, id: usize, t: *panes.Text, on_tag: bool, row: i32, col: i32) void { // The host's clock, which every host keeps and a test's virtual one // replaces. - const now: i64 = @intCast(p.now_ns / std.time.ns_per_ms); + const now: i64 = @intCast(p.clock.now_ns / std.time.ns_per_ms); const prev = p.last_click; p.last_click = .{ .id = id, .on_tag = on_tag, .row = row, .col = col, .ms = now }; const c = prev orelse return; @@ -1677,18 +1677,18 @@ test "mouse thumb buttons navigate once and clear selection gestures" { defer p.deinit(); const pane = try p.setTestFile("alpha beta\ngamma delta\nepsilon zeta\n"); pane.body.setRange(pane.file.?.content, 0, .{ .anchor = 1, .head = 5 }, true); - p.njumps = 3; - p.jcur = 2; - for (0..3) |i| p.jumps[i] = .{ .pane = 0, .serial = pane.serial, .line = @intCast(i + 1), .col = 1 }; + p.jumps.n = 3; + p.jumps.cur = 2; + for (0..3) |i| p.jumps.list[i] = .{ .pane = 0, .serial = pane.serial, .line = @intCast(i + 1), .col = 1 }; p.drag = .{ .select = .{ .id = 0, .button = config.select_button } }; p.update(.{ .mouse = .{ .button = .back, .kind = .press, .col = 0, .row = 0 } }); - try std.testing.expectEqual(@as(usize, 1), p.jcur); + try std.testing.expectEqual(@as(usize, 1), p.jumps.cur); for ([_]Mouse.Kind{ .drag, .release, .motion }) |kind| p.update(.{ .mouse = .{ .button = .back, .kind = kind, .col = 0, .row = 0 } }); - try std.testing.expectEqual(@as(usize, 1), p.jcur); + try std.testing.expectEqual(@as(usize, 1), p.jumps.cur); p.update(.{ .mouse = .{ .button = .forward, .kind = .press, .col = 0, .row = 0 } }); p.update(.{ .mouse = .{ .button = .forward, .kind = .release, .col = 0, .row = 0 } }); - try std.testing.expectEqual(@as(usize, 2), p.jcur); + try std.testing.expectEqual(@as(usize, 2), p.jumps.cur); try std.testing.expect(!pane.body.vsel.active); try std.testing.expectEqual(.none, p.drag); } diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig index dc95e0ec..04ac1cbf 100644 --- a/src/ninep/ctl.zig +++ b/src/ninep/ctl.zig @@ -2118,23 +2118,23 @@ test "a language server question that finds nothing, cannot be answered, or is a // Nothing found: Callers says so, and the waiting write hears it. p.fs.late_failure_len = 0; p.lspRequest(id, .incoming_calls, ""); - try testing.expect(p.lsp_wait != null); - Ask.lspResponse(p, p.lsp_wait.?.id, ""); + try testing.expect(p.lsp_ask.wait != null); + Ask.lspResponse(p, p.lsp_ask.wait.?.id, ""); try testing.expectEqualStrings("Callers: callers not found", p.fs.late_failure[0..p.fs.late_failure_len]); // A backend that cannot answer says why. p.fs.late_failure_len = 0; p.lspRequest(id, .outgoing_calls, ""); - Ask.lspResponse(p, p.lsp_wait.?.id, "@none zls does not answer call hierarchy\n"); + Ask.lspResponse(p, p.lsp_ask.wait.?.id, "@none zls does not answer call hierarchy\n"); try testing.expectEqualStrings("Callees: zls does not answer call hierarchy", p.fs.late_failure[0..p.fs.late_failure_len]); // No answer at all. p.fs.late_failure_len = 0; p.lspRequest(id, .hover, ""); - Ask.lspResponse(p, p.lsp_wait.?.id, null); + Ask.lspResponse(p, p.lsp_ask.wait.?.id, null); try testing.expectEqualStrings("Hover: the language server did not answer", p.fs.late_failure[0..p.fs.late_failure_len]); // No diagnostics is no failure. p.fs.late_failure_len = 0; p.lspRequest(id, .diagnostics, ""); - Ask.lspResponse(p, p.lsp_wait.?.id, ""); + Ask.lspResponse(p, p.lsp_ask.wait.?.id, ""); try testing.expectEqual(@as(u16, 0), p.fs.late_failure_len); // An image's body takes no write. const slot = p.freeSlot().?; @@ -2803,7 +2803,7 @@ test "a Rename that reaches other files previews them, says so, and is the pane const id = p.active; p.fs.lsp_result = null; p.lspRequest(id, .rename, "sum"); - Ask.lspResponse(p, p.lsp_wait.?.id, "lib.rs:2:8 sum\nmain.rs:4:13-15 sum\n"); + Ask.lspResponse(p, p.lsp_ask.wait.?.id, "lib.rs:2:8 sum\nmain.rs:4:13-15 sum\n"); const preview = p.panes[p.panes[id].?.search_pane.?].?; try testing.expectEqual(preview.serial, p.fs.lsp_result.?); try testing.expect(th.logHas(p, "Rename: 2 edit(s) across files, previewed, not applied")); @@ -2850,7 +2850,7 @@ test "a Rename the server answered for this file alone, with other open files sa const p = try withFile(testing.allocator, "x\n"); defer p.deinit(); p.lspRequest(p.active, .rename, "sum"); - Ask.lspResponse(p, p.lsp_wait.?.id, "util.zig:1:8 sum\nmain.zig: also says add, which the server did not rename\n"); + Ask.lspResponse(p, p.lsp_ask.wait.?.id, "util.zig:1:8 sum\nmain.zig: also says add, which the server did not rename\n"); try testing.expect(th.logHas(p, "Rename: previewed, not applied: the server renamed in this file only, and 1 other open file(s) say the name")); } @@ -2890,7 +2890,7 @@ test "Lspinfo's answer is the +Lsp pane it fills, as a Rename preview's is its + defer p.deinit(); p.fs.lsp_result = null; p.lspRequest(p.active, .status, ""); - Ask.lspResponse(p, p.lsp_wait.?.id, "language servers:\n"); + Ask.lspResponse(p, p.lsp_ask.wait.?.id, "language servers:\n"); const shown = p.paneBySerial(p.fs.lsp_result.?).?; try testing.expect(std.mem.endsWith(u8, p.panes[shown].?.file.?.path, "+Lsp")); } diff --git a/src/ninep/pane.zig b/src/ninep/pane.zig index ab4b2d7d..4595d02d 100644 --- a/src/ninep/pane.zig +++ b/src/ninep/pane.zig @@ -564,7 +564,7 @@ pub const batch_pause_ns: u64 = 20 * std.time.ns_per_ms; pub fn flushPausedBatch(p: *Pardes) void { const b = &p.fs.batch; if (b.bytes.items.len == 0) return; - if (p.now_ns != 0 and p.now_ns -| b.last_ns < batch_pause_ns) return; + if (p.clock.now_ns != 0 and p.clock.now_ns -| b.last_ns < batch_pause_ns) return; flushBatch(p); } @@ -606,7 +606,7 @@ fn holdWrite(p: *Pardes, req: Req, pane: *Pane, at: usize) error{OutOfMemory}!?u if (b.bytes.items.len == 0) b.* = .{ .serial = pane.serial, .node = req.node, .handle = req.handle, .at = at, .bytes = b.bytes }; const take = wholeUtf8(req.data); try b.bytes.appendSlice(p.gpa, req.data[0..take]); - b.last_ns = p.now_ns; + b.last_ns = p.clock.now_ns; return take; } @@ -1083,7 +1083,7 @@ test "writes held before the shell's clock is first seen go in at its first step const p = try withFile(testing.allocator, "one\n"); defer p.deinit(); const body = Node.of(serialOf(p), .body); - try testing.expect(!p.clock_started); + try testing.expect(!p.clock.started); const h = call(p, .{ .tag = 1, .op = .open, .node = body, .omode = 1 }).reply.handle; const revision = p.panes[0].?.file.?.revision; _ = call(p, .{ .tag = 2, .op = .write, .node = body, .handle = h, .data = "x\n" }); diff --git a/src/replica.zig b/src/replica.zig index 71528fc4..d30d0e8a 100644 --- a/src/replica.zig +++ b/src/replica.zig @@ -3743,7 +3743,7 @@ test "a replica joined after a pane closed: the session's jump to it, its Panes _ = try a.local(.{ .command = try std.fmt.bufPrint(&line, "Look {s}/build.zig.zon", .{dir}) }); _ = try a.local(.{ .command = "Del" }); try std.testing.expectEqual(@as(usize, 1), a.core.store.closed.items.len); - try std.testing.expect(a.core.njumps > 1); + try std.testing.expect(a.core.jumps.n > 1); // What another window of the user's wrote to the store, which the // session read (src/variants_test.zig's case, the variant hunt's). a.core.recent.opened(a.core.recentGpa(), try std.fmt.bufPrint(&line, "{s}/build.zig", .{dir})); diff --git a/src/tui/tui.zig b/src/tui/tui.zig index 05d29272..1e4b238e 100644 --- a/src/tui/tui.zig +++ b/src/tui/tui.zig @@ -1949,7 +1949,7 @@ const Shell = struct { const s = of(ctx); if (s.waited) { s.waited = false; - if (s.mail_only and s.peers.count() > 0 and s.core.clock_started) return s.core.now_ns; + if (s.mail_only and s.peers.count() > 0 and s.core.clock.started) return s.core.clock.now_ns; } return s.test_clock orelse @intCast(std.Io.Clock.awake.now(s.io).nanoseconds); } @@ -2286,7 +2286,7 @@ const Shell = struct { if (wait != 0) { // A virtual clock moves a frame a wake while the tty's own // motions move (the glide), as the real one would. - s.wake_to = s.core.nextWake() orelse if (s.moving()) s.core.now_ns + pardes.frame_ns else 0; + s.wake_to = s.core.nextWake() orelse if (s.moving()) s.core.clock.now_ns + pardes.frame_ns else 0; requestWake(s.io, wait); } pardes.turn.rest(); @@ -2958,17 +2958,17 @@ test "TTY queued results reject old PTY generations and LSP request IDs" { try std.testing.expect(std.mem.indexOf(u8, text, "current session") != null); core.lspRequest(0, .status, ""); - const old_id = core.lsp_wait.?.id; + const old_id = core.lsp_ask.wait.?.id; core.lspRequest(0, .status, ""); - const current_id = core.lsp_wait.?.id; + const current_id = core.lsp_ask.wait.?.id; shell.lsp_task = .{ .id = current_id, .future = .{ .any_future = null, .result = {} } }; _ = shell.apply(.{ .lsp_done = .{ .id = old_id, .rows = try gpa.dupe(u8, "stale result\n") } }); try std.testing.expect(shell.lsp_task != null); try std.testing.expectEqual(current_id, shell.lsp_task.?.id); - try std.testing.expectEqual(current_id, core.lsp_wait.?.id); + try std.testing.expectEqual(current_id, core.lsp_ask.wait.?.id); _ = shell.apply(.{ .lsp_done = .{ .id = current_id, .rows = try gpa.dupe(u8, "") } }); try std.testing.expect(shell.lsp_task == null); - try std.testing.expect(core.lsp_wait == null); + try std.testing.expect(core.lsp_ask.wait == null); } test "TTY worker setup failures finish matching LSP and pipe requests" { @@ -2997,14 +2997,14 @@ test "TTY worker setup failures finish matching LSP and pipe requests" { }; core.lspRequest(core.active, .status, ""); const req: host_io.Lsp.Request = .{ - .id = core.lsp_wait.?.id, + .id = core.lsp_ask.wait.?.id, .kind = .status, .pane = @intCast(core.active), .offset = 0, .arg = "", }; Shell.lsp(&shell, req); - try std.testing.expect(core.lsp_wait == null); + try std.testing.expect(core.lsp_ask.wait == null); try std.testing.expectEqualStrings("abc", pane.file.?.content); pane.body.cur_col = 2; diff --git a/src/views.zig b/src/views.zig index 46959783..dcd11b2c 100644 --- a/src/views.zig +++ b/src/views.zig @@ -35,7 +35,7 @@ pub const fields = [_][:0]const u8{ "screen_w", "screen_h", "cell_pixels", "row_metrics", "ncol", "cols", "col_tags", "finder", "rects", "col_x", "col_w", "active", - "jumps", "njumps", "jcur", "jump_force", + "jumps", "active_column", "native_images", "native_image_patches", "windowed", "drag", "mouse_grab", "window_focused", "focus_told", @@ -436,6 +436,8 @@ pub fn open(p: *Pardes) ?u8 { slot.* = .{ .view = .{ .screen_w = p.screen_w, .screen_h = p.screen_h } }; inline for (sized ++ laid_out ++ .{ "windowed", "native_images", "native_image_patches" }) |name| @field(slot.view, name) = @field(p, name); + // A query's mark on the jumps is the view's that asked it. + slot.view.jumps.force = false; slot.view.col_tags = @splat(.{ .what = .column, .gpa = p.gpa }); for (p.panes, 0..) |s, id| { const pane = s orelse continue; @@ -449,7 +451,7 @@ pub fn open(p: *Pardes) ?u8 { /// How a view is laid out and focused: what a new one takes of the live /// one (`open`), and what one going leaves the view that stays (`closeKeeping`). -const laid_out = .{ "ncol", "cols", "finder", "active", "active_column", "jumps", "njumps", "jcur" }; +const laid_out = .{ "ncol", "cols", "finder", "active", "active_column", "jumps" }; const sized = .{ "screen_w", "screen_h", "cell_pixels", "row_metrics" }; /// View `k` gone, and the view that stays live laid out as `k` was: its @@ -465,7 +467,9 @@ pub fn closeKeeping(p: *Pardes, k: u8) void { const slot = p.parked[other].?; // Its size too: the terminals it sized keep theirs, no shell redrawn for // a size it is given back at the rejoin. + const force = slot.view.jumps.force; inline for (sized ++ laid_out) |name| @field(slot.view, name) = @field(p, name); + slot.view.jumps.force = force; for (p.panes, 0..) |s, id| { const pane = s orelse { slot.serials[id] = 0; |
