From 148e48dd9b8cd7e66aa1521daa49a64852b1650e Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 26 Nov 2026 02:28:09 -0300 Subject: syntax, Query, Pick, Names, Band, Stream, File, colors: the Symbols picker grouped by kind, a kind mark on each row (UX DESIGN N, binding; the user: "The lsp symbols should be more organized: types first then functions then fields and the rest (and some indicator to tell the kind)", "For the symbols picker"): the rows are the file's own parse's, as before, now from a symbol walk of their own (syntax.zig `SymbolWalk`, in the same walk of the tree as the sticky headers' declarations, which keep theirs: contextFromTree), by one kind table a grammar (`symbol_rules`: Zig, C, C++, Rust, Go, Python, JavaScript, Java, C#, Kotlin, Scala, Ruby, PHP, bash, Haskell, OCaml, Erlang, Elixir, Clojure, Fortran, Ada, Pascal, PowerShell; JSON, CSS, HTML, Markdown and Typst have no declarations to list), each node's kind as given or found where its grammar cannot say it (Zig's `const S = struct`, `error{...}`, `@This()`, `@Type(...)` a type and `@import(...)` a module, JavaScript's `const f = () => ...` a function, C's declaration a function where a declarator is one's and a const where `const` says so, a Python class's or Kotlin's binding a field in a type); fields and consts are listed now (the sticky headers' declarations had neither), a function's consts and vars never (its locals), each named in the types, functions and modules it is in (`Counts.lines`, `torque.Parser.Parse`; an anonymous struct's members in its owner's, a Rust `impl S`'s in `S`, no row of its own); a row is `t Counts = struct`: its kind's mark (t type, f function, m field, c const, v var, n module, · other), its qualified name, two blanks and what its name's line says after the name (its body's `{`, a trailing `,` or `;` dropped), its line the dim meta at the right end (Band's); the mark in the keyword's ink (colors.Roles.kind, the theme's keyword pushed to 4.5:1 on every tag ground and the selection, as the key ink is), the qualifier and the words after the name dim; with the field empty the rows are types, functions, fields, then the rest (consts, vars, modules, other as one group), each in the text's order; typed, they stay grouped and are scored within each group (Names: `Cand.group`, `before` orders by it, then by `better`), the cursor starts on the best match wherever its group puts it (Names.bestRow, Pick.toBest: after a key, when the parse lands, and following the best while the rest are scored), and the count says where it is; the name alone is matched (`u8` in a signature matches nothing); no header rows: every row is a symbol, ordinary text, and C-q keeps them in a +Search with the mark a word; the query pane's `Symbols` rows the same (Query.gather), its current the best; the parse's answer carries the symbols beside the declarations (Stream.Batch.symbols, an input every replica takes), ContextCache keeps both for the revision (derived, made again at a load), and every producer makes both (the worker, a sticky header's refresh, a load), so a text at a revision has the same symbols everywhere; syntax.zig's tests ran in no test program (core-test's filter `syntax context nested` matched nothing on the base): core/root.zig imports it now, and its 34 pass; RUN (TEST FIRST): syntax.zig "syntax symbols: a Zig file's types, functions, fields and the rest ...", "... C, C++, Rust, Go, Python and JavaScript by their kind tables ...", "... every kind table names nodes of its grammar ..." (23 tables), Pick.zig "Symbols (UX DESIGN N): a Zig file's rows types, functions, fields, then the rest ... the mark in the keyword's ink, the qualifier and the rest dim", "Symbols (UX DESIGN N3): typed, the rows stay grouped ... the cursor starts on the best match ...; the name alone is matched, never the signature", "Symbols (UX DESIGN N): a C++ file's rows ...", "Symbols: every row is ordinary text ..."; on the base the rows were ` 2 pub const Counts = struct {` in the text's order, no mark, no field, the cursor on the first row; core-test -Dtest-filter=ymbols 18/18, core-test 1135/1308 (173 skipped); the stack's suites, the dump fuzz, the soak and the pictures are on the change after this one MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE --- core/root.zig | 1 + 1 file changed, 1 insertion(+) (limited to 'core/root.zig') diff --git a/core/root.zig b/core/root.zig index 11cb5058..86ca62e0 100644 --- a/core/root.zig +++ b/core/root.zig @@ -461,6 +461,7 @@ test { _ = @import("FrameStats.zig"); _ = @import("Query.zig"); _ = @import("Names.zig"); + _ = @import("syntax.zig"); // its tests ran nowhere before _ = @import("Stream.zig"); _ = @import("Tables.zig"); _ = @import("Handover.zig"); -- cgit v1.3 From 280306ed779368d7e20e9678eca45e4b81e0ccbf Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 26 Nov 2026 03:03:20 -0300 Subject: Pick, Kind, look, draw, mouse: a picker previews a file an addon's kind takes through that kind in the pane it lands in, a binary no kind takes as one line naming it, and Enter on such a row lands as a Look does, never the file's bytes as text (the user: "the file preview wasn't working for images (maybe pdfs too? Didn't test)", "It should be a generic logic for addons btw, and I saw the bytes rendered as ascii"; the coordinator's W7 under SPEC principle 2); REPRODUCED with the installed build (install74, the S kit, 26 px): SPC f f from a reading main.zig, the cursor on photo.png left main.zig in the body (the previous row's file), on paper.pdf showed `%PDF-1.7 %âãÏÓ 1 0 obj …` as text (a PDF has no NUL in its first 8000 bytes, so Pick.preview's binary guard let it through), and Enter on photo.png put `�PNG … IHDR …` in the reading pane: THE BYTES-AS-TEXT PATH the user saw: Pick.land → look.open → walk → Trail.step → Trail.show → File.open, which reads any path as a text (look.resolve sends a typed or clicked `photo.png` to Kind.openFile, but look.open, every jump's way, had no kind route); THE FIX: look.open routes a path a kind takes (`kinds.forPath`, the routing resolve uses) to openKind, lookAt's kind branch made a function (the pane of it focused, else opened and placed as a Look places it), so a picker's Enter, the Walk queue and a held pane's step land as a Look; Find's row of a kind's file is the file whole (a place in it is its kind's address: line 1 made the image refuse it); Pick.preview: a file a kind takes is shown by a slot of that kind over the landing pane's text (Kind.newSlot, split from Kind.open; Pick.showKind), which stays under it unseen until the next row or the roll-up closes the slot (putBack, restore: Esc exact, nothing left), no per-kind code; any other file with a NUL is one read-only line, `blob.bin · binary · 3.0 kB` (Pick.nameLine); until the kind draws (its paint places nothing yet) the body shows `photo.png · image · 24.8 kB` (draw.zig; Kind.draw says whether it painted); a refused one is that line with its kind's why; the kind does its own work as for its pane (the image decoded on a worker); only the row the cursor rests on at a frame opens (the preview's existing tick rule), and a draw of a row passed by is dropped when it lands (Kind.Slot.drawn_from: this process's draw count when the slot was made; Kind.deliver drops older answers, which went to the next slot of the same kind on the same pane); a previewed kind says, looks at, runs and lists nothing (Kind.Call.end returns before them while Pick.previewing) and takes no mouse (mouse.kindMouse); RUN (TEST FIRST): test/behaviour/addons.zig, four tests through 9P with the fake addon (addons/fake: no kind code in Pick) and the image addon, and addons_pdf.zig one with the pdf addon: a `.fake` file previews as the fake's paint (`count 7`) and not its bytes, Esc puts the screen and /index back, Enter opens the fake's pane with the reading pane's text kept; blob.bin's one line, never other.txt's text after it, a kind's paint after the binary's; three pictures, two rows down with no frame between: one draw held per rested row (2, not 3), and the rested picture shown after the passed one's answer came last; Enter on a picture opens the image pane, the reading pane `the notes`; a PDF's pages as pictures in the landing pane, none after Esc; Session.tick (a host frame) added, as previews wait for the frame after the key; on the base they fail (the bytes `1234567` shown, no line, no image pane, `%PDF` on the screen): core-test 1128/1301 (173 skipped; the kept_out list names Kind.Slot's drawn_from and size), shell-test 1349/1352 (3 skipped), pane-test 183/184, behaviour-test 285/285 (+5) and --replay 285/285, process-test 0 of 147 failed (3 skipped), term-test 17/17, kitty-test 45/45; the gui unit-test on the stack's top (W8); no dump change (the two Slot fields are local, out of the digest and the dump); the S kit with this change's Debug gui at 26 px: the PNG and 9p.pdf previewing in the landing pane, blob.bin's line, Enter on photo.png an `img` pane with main.zig kept (.scratch/walkui/W78/png a02-a05, before r03 r05); no frame or perf gate (the user's rule of 2026-11-26); load 3.7 to 10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE --- core/Kind.zig | 55 ++++++++++++---- core/Pick.zig | 132 +++++++++++++++++++++++++++++--------- core/Trail.zig | 4 +- core/draw.zig | 9 ++- core/look.zig | 54 ++++++++++------ core/mouse.zig | 3 +- core/root.zig | 1 + test/behaviour/addons.zig | 146 ++++++++++++++++++++++++++++++++++++++++++ test/behaviour/addons_pdf.zig | 28 ++++++++ test/session.zig | 8 +++ 10 files changed, 373 insertions(+), 67 deletions(-) (limited to 'core/root.zig') diff --git a/core/Kind.zig b/core/Kind.zig index 4e1aa469..e220ead7 100644 --- a/core/Kind.zig +++ b/core/Kind.zig @@ -137,7 +137,7 @@ pub const Slot = struct { // jobs' inputs, its file's hash, a placeholder's record), and what // a frame makes (the thumb, the pointer, whether one was drawn: a // view's, never a step's). - .local = .{ "ops", "st", "gpa", "arena", "plain", "file", "opened", "reloads", "jobs", "record", "thumb_at", "thumb_span", "pointer", "painted", "over", "used" }, + .local = .{ "ops", "st", "gpa", "arena", "plain", "file", "opened", "reloads", "jobs", "record", "thumb_at", "thumb_span", "pointer", "painted", "over", "used", "drawn_from", "size" }, }; /// Its kind's code here; null in a placeholder (`live` false: its kind /// not in the registry, its record kept for the day it comes) or a @@ -215,6 +215,13 @@ pub const Slot = struct { /// A client's join: its plain kind's file, until the pane is opened /// from it (dump.plainHere). file: ?[]u8 = null, + /// This process's draws made before it (`drawn` then): an answer to + /// one of them is another slot's, of a pane that showed something + /// else (a picker's preview of the row before), and is dropped. + drawn_from: u32 = 0, + /// Its file's bytes, as a picker's line naming it says them until its + /// kind's picture is drawn (Pick.preview). + size: u64 = 0, /// Debug: the kind's allocations, which paint must leave as they are. /// The slot's allocator's, as the slot is: a client's rollback puts /// the list back with the slot that holds it (on the page allocator, @@ -259,16 +266,12 @@ fn caps(p: *const Pardes, s: *const Slot) Caps { /// word opened) from `bytes`: made whatever the kind says, with what it /// refused in `slot.refused` for the caller to say. pub fn open(p: *Pardes, id: usize, k: u8, path: ?[]const u8, bytes: ?[]const u8) !*Pane { - const e = &p.kinds.kinds[k]; - // A plain kind's slot and block are the core's (a client's epoch). - const gpa = if (e.caps.plain) p.gpa else p.image_gpa; - const s = try gpa.create(Slot); - s.* = .{ .ops = p.kinds.ops[k], .live = true, .gpa = gpa, .arena = .init(gpa), .version = e.version, .gen = e.gen, .name = e.name }; + const s = try newSlot(p, k, path orelse ""); errdefer { + const gpa = s.gpa; s.free(); gpa.destroy(s); } - s.path = try gpa.dupe(u8, path orelse ""); const pane = try p.newDocPane(id); pane.addon = s; _ = reopen(p, id, s, bytes); @@ -278,6 +281,23 @@ pub fn open(p: *Pardes, id: usize, k: u8, path: ?[]const u8, bytes: ?[]const u8) return pane; } +/// A slot of kind `k` for `path`, its kind's state not made yet (`reopen` +/// makes it): a pane's, or a picker's preview's in the pane it lands in +/// (Pick.preview), that pane's own text set aside meanwhile. +pub fn newSlot(p: *Pardes, k: u8, path: []const u8) !*Slot { + const e = &p.kinds.kinds[k]; + // A plain kind's slot and block are the core's (a client's epoch). + const gpa = if (e.caps.plain) p.gpa else p.image_gpa; + const s = try gpa.create(Slot); + s.* = .{ .ops = p.kinds.ops[k], .live = true, .gpa = gpa, .arena = .init(gpa), .version = e.version, .gen = e.gen, .name = e.name, .drawn_from = drawn }; + errdefer { + s.free(); + gpa.destroy(s); + } + s.path = try gpa.dupe(u8, path); + return s; +} + /// `open` of the file at `path`, read here (a file that cannot be read /// is no bytes: its kind may refuse it). The slot stays ours across the /// read: another request may make a pane meanwhile. @@ -418,9 +438,10 @@ pub fn close(p: *Pardes, pane: *Pane) void { /// The pane's body painted over the `cols` x `rows` cells at (x, y): /// its cells into `s`, its placements after the frame's others. A pane /// whose kind has no code here, or a placeholder, says why in a line. -pub fn draw(p: *Pardes, s: *surface.Surface, arena: std.mem.Allocator, pane: *Pane, id: usize, x: u16, y: u16, cols: u16, rows: u16) void { - const slot = pane.addon orelse return; - if (cols == 0 or rows == 0) return; +/// False when its kind painted nothing (its picture not drawn yet). +pub fn draw(p: *Pardes, s: *surface.Surface, arena: std.mem.Allocator, pane: *Pane, id: usize, x: u16, y: u16, cols: u16, rows: u16) bool { + const slot = pane.addon orelse return true; + if (cols == 0 or rows == 0) return true; const th = p.theme(); const fg: surface.Color = if (th.fg) |f| .{ .rgb = f } else .default; const bg: surface.Color = if (th.bg) |b| .{ .rgb = b } else .default; @@ -431,17 +452,17 @@ pub fn draw(p: *Pardes, s: *surface.Surface, arena: std.mem.Allocator, pane: *Pa const why = if (caps(p, slot).plain) "it is not in its addons nor the session's library at its path here, or it broke its promise here" else "its state is not plain (PA_PLAIN), so it runs in the session alone"; var line: [200]u8 = undefined; _ = s.print(x, y, cols, std.fmt.bufPrint(&line, "addon {s} {d} does not run in this client: {s}", .{ slot.nameOf(), slot.version, why }) catch &line, .{ .fg = fg, .bg = bg }); - return; + return true; } else if (slot.ops == null) { var line: [160]u8 = undefined; const why = if (slot.refused.len > 0) slot.refused.slice() else "Addon load "; // Its kind here, it waits for its file (` is not here`). const text = if (p.kinds.byName(slot.nameOf()) != null) why else std.fmt.bufPrint(&line, "addon {s} {d} is not loaded: {s}", .{ slot.nameOf(), slot.version, why }) catch &line; _ = s.print(x, y, cols, text, .{ .fg = fg, .bg = bg }); - return; + return true; } else for (0..8) |_| { if (ready.items.len > 0) deliver(p, slot, pane, id); - frame.cells = (paint(p, slot, id, arena, cols, rows, &frame) orelse return); + frame.cells = (paint(p, slot, id, arena, cols, rows, &frame) orelse return true); // No workers here (a test's, a bench's core): a draw that paint // asked was done at once, and is this frame's, painted again. if (drawer != null) break; @@ -450,9 +471,11 @@ pub fn draw(p: *Pardes, s: *surface.Surface, arena: std.mem.Allocator, pane: *Pa } else break; } if (frame.gpu.len != 0) s.gpu_frames[id] = .{ .bytes = frame.gpu, .serial = pane.serial, .dst = .{ .x = x, .y = y, .w = cols, .h = rows } }; + var painted = frame.gpu.len != 0 or frame.n > 0; for (0..@min(rows, frame.rows)) |r| for (0..@min(cols, frame.cols)) |col| { const cell = &frame.cells[r * frame.cols + col]; if (cell.flags & c.PA_PAINTED == 0) continue; + painted = true; const len = @min(cell.len, 7); s.set(x + @as(u16, @intCast(col)), y + @as(u16, @intCast(r)), if (len == 0) " " else cell.text[0..len], styleOf(cell, fg, bg)); }; @@ -471,6 +494,7 @@ pub fn draw(p: *Pardes, s: *surface.Surface, arena: std.mem.Allocator, pane: *Pa .art = slot.art, }); } + return painted; } /// A frame of a kind's pane: its cells, `cols` a row, and its placements. @@ -1012,6 +1036,9 @@ const Call = struct { return o; }; const p = cl.p orelse return o; + // A picker's preview shows its file and does nothing more: what its + // kind says, looks at or runs meanwhile is dropped (Pick.showKind). + if (pardes.Pick.previewing(p, cl.id)) return o; if (o.said.len > 0) if (o.err) p.reportFailure(cl.id, o.said) else p.setMessage(.at(cl.id), o.said); if (o.pane_name.len > 0) textPane(p, cl.id, cl.slot, o.pane_name, o.pane_text); if (o.look.len > 0) @import("look.zig").lookAt(p, cl.id, o.look); @@ -1289,7 +1316,7 @@ fn deliver(p: *const Pardes, slot: *Slot, pane: *const Pane, id: usize) void { } _ = ready.orderedRemove(i); defer j.drop(); - if (pane.serial != j.serial or slot.gen != j.gen or slot.ops != j.ops) continue; + if (pane.serial != j.serial or slot.gen != j.gen or slot.ops != j.ops or j.token & ~c.PA_DRAWN <= slot.drawn_from) continue; var cl: Call = .{ .p = null, .id = id, .slot = slot, .quiet = true, .core = p }; const prev = cl.begin("job_done"); const before = if (checked) usedHash(slot); diff --git a/core/Pick.zig b/core/Pick.zig index 1d332f25..f13278af 100644 --- a/core/Pick.zig +++ b/core/Pick.zig @@ -639,7 +639,10 @@ fn rowAt(p: *Pardes, pk: *const Pick, arena: std.mem.Allocator, i: usize) std.me var namebuf: [4096]u8 = undefined; const name = if (text.len > 1 and text[0] == '"' and text[text.len - 1] == '"') look.unquoted(&namebuf, text[1 .. text.len - 1]) else text; row.faint = @intCast(if (std.mem.lastIndexOfScalar(u8, text, '/')) |k| k + 1 else 0); - row.target = .{ .place = .{ .path = try std.Io.Dir.path.join(arena, &.{ dir, name }), .at = .{ .line = 1, .col = 1 } } }; + // A text at its first line; a kind's file whole, as a Look of + // its name opens it (a place in it is its kind's address). + const at: look.Spot = if (p.kinds.forPath(name) != null) .{} else .{ .line = 1, .col = 1 }; + row.target = .{ .place = .{ .path = try std.Io.Dir.path.join(arena, &.{ dir, name }), .at = at } }; }, .panes => { row.pre = cand.key -| 1; @@ -925,7 +928,11 @@ pub fn sentence(p: *const Pardes, w: *std.Io.Writer) ?[2]usize { /// The landing pane's body showing the current row's place (SPEC §5.3): /// a file at its line, the query's matches lit for a Grep. Its own text is /// set aside the first time, put back when the picker rolls up. A file an -/// open pane shows is taken from it; any other is read. +/// open pane shows is taken from it; any other is read. A file a kind +/// takes (an addon's: a picture, a PDF), as a Look would open it +/// (look.resolve), shows through that kind (showKind); any other that is +/// not text (a NUL in its first 8000 bytes) as one line naming it, +/// `blob.bin · binary · 3.0 kB`, never its bytes. fn preview(p: *Pardes, pk: *Pick) void { const s = &p.view().tag_state; // No row yet: none shown, so the first to come is (a Find's listing @@ -944,40 +951,22 @@ fn preview(p: *Pardes, pk: *Pick) void { const pane = p.panes[id].?; const f = if (pane.file) |*file| file else return; if (f.twin != 0) return; - if (!std.mem.eql(u8, f.path, place.path)) { + const showing = if (pane.addon) |k| k.path else f.path; + if (!std.mem.eql(u8, showing, place.path)) { if (exec.kindOf(p.tape, place.path)) |kind| if (kind != .file) return; - const bytes = openText(p, place.path) orelse (p.tape.site(.preview, p.gpa, filesystem.read, .{ p, place.path }) catch return); - if (std.mem.indexOfScalar(u8, bytes[0..@min(bytes.len, 8000)], 0) != null) { - p.gpa.free(bytes); - return; + const read = openText(p, place.path) orelse (p.tape.site(.preview, p.gpa, filesystem.read, .{ p, place.path }) catch return); + if (pane.addon != null) Kind.close(p, pane); + if (p.kinds.forPath(place.path)) |k| { + defer p.gpa.free(read); + return showKind(p, pk, id, k, place.path, read); } - const path = p.gpa.dupe(u8, place.path) catch { - p.gpa.free(bytes); - return; + const bytes = if (std.mem.indexOfScalar(u8, read[0..@min(read.len, 8000)], 0) == null) read else named: { + defer p.gpa.free(read); + break :named nameLine(p.gpa, place.path, "binary", read.len, "") catch return; }; - if (pk.aside == null and !pk.made) { - const history = File.History.create(p.gpa) catch { - p.gpa.free(bytes); - p.gpa.free(path); - return; - }; - pk.aside = pane.file; - pane.file = .{ .path = path, .content = bytes, .output = .{ .from = .preview }, .history = history }; - } else { - const pf = &pane.file.?; - p.gpa.free(pf.path); - pf.path = path; - File.setContent(p, pf, bytes); - pf.saved_revision = pf.revision; - pf.scroll = 0; - pf.scroll_row = 0; - pf.syntax_dirty = true; - pane.places.clear(p.gpa); - } - pane.hscroll = 0; - pk.previewed = true; - p.sync(); + showText(p, pk, id, place.path, bytes); } + if (pane.addon != null) return; // The body under the band from the first place it shows (previewing): // laid out again before the place is put in its rows. if (!pk.previewed) { @@ -1001,6 +990,81 @@ fn preview(p: *Pardes, pk: *Pick) void { if (pk.source == .grep) pane.places.search(p, pane, .list, pk.id, std.mem.trim(u8, s.field.text(), " "), true, null, false); } +/// Landing pane `id`'s text `bytes` (taken) as `path`: its own text set +/// aside the first time, a preview's text after that changed in place. +fn showText(p: *Pardes, pk: *Pick, id: usize, path_: []const u8, bytes: []u8) void { + const pane = p.panes[id].?; + const path = p.gpa.dupe(u8, path_) catch { + p.gpa.free(bytes); + return; + }; + if (pk.aside == null and !pk.made) { + const history = File.History.create(p.gpa) catch { + p.gpa.free(bytes); + p.gpa.free(path); + return; + }; + pk.aside = pane.file; + pane.file = .{ .path = path, .content = bytes, .output = .{ .from = .preview }, .history = history }; + } else { + const pf = &pane.file.?; + p.gpa.free(pf.path); + pf.path = path; + File.setContent(p, pf, bytes); + pf.saved_revision = pf.revision; + pf.scroll = 0; + pf.scroll_row = 0; + pf.syntax_dirty = true; + pane.places.clear(p.gpa); + } + pane.hscroll = 0; + pk.previewed = true; + p.sync(); +} + +/// Landing pane `id` showing the file at `path` through kind `k`, as a +/// Look would open it in a pane of its own: a slot of that kind over the +/// pane's text, which stays under it, unseen, until the next row or the +/// roll-up takes the slot away (Kind.close). Its kind does the work it +/// does for its own pane (an image decoded on a worker; a draw of a row +/// passed by dropped, Kind.Slot.drawn_from), and nothing more: what it +/// says, looks at or runs is not done while it previews (Kind.Call.end). +/// Until its picture is drawn, the line naming it (draw.zig); one its kind +/// refuses is that line as text, saying why. +fn showKind(p: *Pardes, pk: *Pick, id: usize, k: u8, path: []const u8, bytes: []const u8) void { + const pane = p.panes[id].?; + const slot = Kind.newSlot(p, k, path) catch |err| return p.reportError(.at(id), "pick", err); + slot.size = bytes.len; + pane.addon = slot; + pk.previewed = true; + if (!Kind.reopen(p, id, slot, bytes) and slot.refused.len > 0) { + const line = nameLine(p.gpa, path, slot.nameOf(), bytes.len, slot.refused.slice()) catch return Kind.close(p, pane); + Kind.close(p, pane); + return showText(p, pk, id, path, line); + } + p.sync(); +} + +/// The one line a file shows while a picker previews it and none of its +/// text is shown: its name, what it is (`binary`, a kind's name), its size +/// and why when it says why: `photo.png · image · 1.2 MB`. +pub fn nameLine(gpa: std.mem.Allocator, path: []const u8, what: []const u8, size: u64, why: []const u8) ![]u8 { + var out: std.Io.Writer.Allocating = .init(gpa); + errdefer out.deinit(); + const w = &out.writer; + try w.print("{s} · {s} · ", .{ std.Io.Dir.path.basename(path), what }); + if (size < 1000) try w.print("{d} B", .{size}) else { + const units = [_][]const u8{ "kB", "MB", "GB", "TB", "PB", "EB" }; + var unit: u64 = 1000; + var u: usize = 0; + while (size / unit >= 1000 and u + 1 < units.len) : (u += 1) unit *= 1000; + const tenths = size / (unit / 10); + try w.print("{d}.{d} {s}", .{ tenths / 10, tenths % 10, units[u] }); + } + if (why.len > 0) try w.print(" · {s}", .{why}); + return out.toOwnedSlice(); +} + /// The text of `path` as an open pane has it, copied: no read for it. fn openText(p: *Pardes, path: []const u8) ?[]u8 { for (p.panes) |slot| { @@ -1019,6 +1083,9 @@ fn restore(p: *Pardes, pk: *Pick) void { const id = p.paneBySerial(pk.landing) orelse return; for (p.panes) |slot| if (slot) |tp| if (tp.places.from == pk.id) tp.places.clear(p.gpa); if (pk.made) { + // A kind's file shown: its slot closed first, as a pane's text + // closing is no file closed (no Recent row). + if (p.panes[id].?.addon != null) Kind.close(p, p.panes[id].?); pk.made = false; p.removePane(id, p.paneBySerial(pk.owner)) catch |err| p.reportError(.at(id), "pick", err); return; @@ -1030,6 +1097,7 @@ fn restore(p: *Pardes, pk: *Pick) void { fn putBack(p: *Pardes, pk: *Pick) void { const id = p.paneBySerial(pk.landing) orelse return; const pane = p.panes[id].?; + if (pane.addon != null) Kind.close(p, pane); if (pk.made) return; const own = pk.aside orelse { // Its own file previewed: its caret and top as they were. diff --git a/core/Trail.zig b/core/Trail.zig index cd8eb924..9b0d64ea 100644 --- a/core/Trail.zig +++ b/core/Trail.zig @@ -250,7 +250,9 @@ fn show(p: *Pardes, id: usize, path: []const u8, at: Spot) !usize { .opened => |free| free, .shown, .none => return p.view().active, }; - if (at.line > panes.File.nlines(p.gpa, &p.panes[free].?.file.?)) { + // (A kind's pane, look.open's for a file a kind takes, has no lines.) + const nf = if (p.panes[free].?.file) |*f| f else return free; + if (at.line > panes.File.nlines(p.gpa, nf)) { try p.removePane(free, null); p.view().active = id; return error.LineMissing; diff --git a/core/draw.zig b/core/draw.zig index b666fc15..4d47f895 100644 --- a/core/draw.zig +++ b/core/draw.zig @@ -533,7 +533,14 @@ fn renderPane(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r: // painted out. Text gets the overlay; a kind's pane gives up the rows. const shown = pane.notices.span(); const body_h = (r.h -| pane.tag_rows) -| shown; - pardes.Kind.draw(p, s, arena, pane, id, tx, body_y + shown, tw, body_h); + // A picker's preview through a kind (Pick.showKind): its file named + // until its kind has drawn it. + if (!pardes.Kind.draw(p, s, arena, pane, id, tx, body_y + shown, tw, body_h) and body_h > 0 and pardes.Pick.previewing(p, id)) { + const k = pane.addon.?; + if (pardes.Pick.nameLine(arena, k.path, k.nameOf(), k.size, "")) |line| { + _ = s.print(tx, body_y + shown, tw, line, .{ .fg = if (th.fg) |c| .{ .rgb = c } else .default, .bg = pane_bg }); + } else |_| {} + } // The same one column as the real scrollbar below, running past // the notice bands so the gutter has no notch in it; its thumb // where this frame's paint said its window is in its whole (a diff --git a/core/look.zig b/core/look.zig index 41c59cf3..c7e0feb9 100644 --- a/core/look.zig +++ b/core/look.zig @@ -1522,6 +1522,9 @@ pub const Landed = union(enum) { none, shown, opened: usize }; /// `Jumps new-pane` as before the walk: a pane showing the file focused, /// else a new one. pub fn open(p: *Pardes, from: usize, path: []const u8, at: Spot, how: How) Landed { + // A file a kind takes (an addon's: a picture, a PDF) is its kind's + // pane, as a Look of it opens (resolve), never its bytes as a text. + if (p.kinds.forPath(path)) |k| return openKind(p, from, path, k, at); if (how == .replace and p.settings.jumps == .walk and path.len <= Trail.max_text and p.panes[from] != null) return walk(p, from, path, at); if (how == .replace and focusPaneByPath(p, path, at)) return .shown; return if (openNew(p, from, path, at, .doc)) |free| .{ .opened = free } else .none; @@ -1557,6 +1560,38 @@ fn walk(p: *Pardes, from: usize, path: []const u8, at: Spot) Landed { return .shown; } +/// The file at `path`, of kind `kind`, looked at from pane `id`: the pane +/// of it there is focused, else one of its kind opened as a document is +/// placed (layout.placeNew), at `at` when it says a place. +fn openKind(p: *Pardes, id: usize, path: []const u8, kind: u8, at: Spot) Landed { + var place: [41]u8 = undefined; + if (focusPaneByPath(p, path, .{})) { + if (at.line > 0) lookKind(p, id, p.view().active, spotText(at, &place), false); + return .shown; + } + const free = p.freeSlot() orelse { + p.reportError(.at(id), "look", error.NoPaneSlots); + return .none; + }; + const made = Kind.openFile(p, free, kind, path) catch |err| { + lookOpenFailed(p, id, path, err); + return .none; + }; + // One its kind refuses (an image corrupt, truncated, not what its name + // says) is said, a failure, rather than shown blank. + if (made.addon.?.refused.len > 0) { + made.vweight = 0; + p.unplaced.set(free); + var said: Kind.Buf(miss_path_cap + 160) = .{}; + var cut: [miss_path_cap + "…".len]u8 = undefined; + p.reportFailure(id, said.print("look: {s}: {s}", .{ missText(path, &cut), made.addon.?.refused.slice() })); + return .none; + } + layout.placeNew(p, id, id, free, .doc); + if (at.line > 0) lookKind(p, id, free, spotText(at, &place), true); + return .{ .opened = free }; +} + /// `path` opened at `at` in a new pane placed as `kind` places one from /// `from`, its line half its body's rows down; null when it is not /// (refused, said). @@ -1808,24 +1843,7 @@ pub fn lookAt(p: *Pardes, id: usize, operand_raw: []const u8) void { }; return missed(p, id, "{s}: the pane its list is of is gone", .{target.path}); } - if (focusPaneByPath(p, target.path, .{})) { - if (target.at.line > 0) lookKind(p, id, v.active, spotText(target.at, &place), false); - return; - } - const free = p.freeSlot() orelse return p.reportError(.at(id), "look", error.NoPaneSlots); - const made = Kind.openFile(p, free, target.kind, target.path) catch |err| - return lookOpenFailed(p, id, target.path, err); - // One its kind refuses (an image corrupt, truncated, not what - // its name says) is said, a failure, rather than shown blank. - if (made.addon.?.refused.len > 0) { - made.vweight = 0; - p.unplaced.set(free); - var said: Kind.Buf(miss_path_cap + 160) = .{}; - var cut: [miss_path_cap + "…".len]u8 = undefined; - return p.reportFailure(id, said.print("look: {s}: {s}", .{ missText(target.path, &cut), made.addon.?.refused.slice() })); - } - layout.placeNew(p, id, id, free, .doc); - if (target.at.line > 0) lookKind(p, id, free, spotText(target.at, &place), true); + _ = openKind(p, id, target.path, target.kind, target.at); }, } } diff --git a/core/mouse.zig b/core/mouse.zig index b62cec7e..37c3a97f 100644 --- a/core/mouse.zig +++ b/core/mouse.zig @@ -235,7 +235,8 @@ fn kindMouse(p: *Pardes, m: Mouse) bool { for (p.panes, 0..) |slot, id| { const pane = slot orelse continue; const k = pane.addon orelse continue; - if (!pardes.Kind.takesMouse(p, k) or pane.collapsed) continue; + // A picker's preview through a kind is shown, not handled. + if (!pardes.Kind.takesMouse(p, k) or pane.collapsed or pardes.Pick.previewing(p, id)) continue; const r = v.rects[id]; const top = p.bodyTop(pane, r) + pane.notices.span(); const x0 = r.x + config.GUTTER; diff --git a/core/root.zig b/core/root.zig index 11cb5058..8d5f8c40 100644 --- a/core/root.zig +++ b/core/root.zig @@ -791,6 +791,7 @@ const kept_out = [_]struct { []const u8, []const u8, []const u8 }{ .{ "Text.zig", "room", "a buffer's capacity" }, .{ "Kind.zig", "ops st gpa arena plain file opened reloads jobs record", "the kind's code and memory here: a plain kind's block is in the copy, and its state hash is checked at every call (Kind.Call.end)" }, .{ "Kind.zig", "thumb_at thumb_span pointer painted over used", "a frame's: written by a paint; `painted` is read by a tick of a kind that is not plain, whose calls are the authority's alone" }, + .{ "Kind.zig", "drawn_from size", "a picker's preview through a kind (Pick.showKind): this process's draw count when the slot was made, which drops the answers of draws made before it, and the file's size for the line naming it until its kind draws; both read by a frame alone" }, .{ "Places.zig", "ticks ticks_gen re", "the rail's ticks, made again when the places move (`gen`), and the compiled pattern, of the pattern" }, .{ "Plumb.zig", "parsed parsed_arena", "the rules parsed, of their text" }, .{ "Stream.zig", "parse_ns paint paint_retired paint_count ahead ahead_for painted_ahead painted_on_loop ahead_seen ahead_ask", "the workers' paints and timings: how a text looks, and numbers" }, diff --git a/test/behaviour/addons.zig b/test/behaviour/addons.zig index ce3c7b02..25b1e523 100644 --- a/test/behaviour/addons.zig +++ b/test/behaviour/addons.zig @@ -371,3 +371,149 @@ test "addons: an image pane whose file changes on disk shows the new picture, un try std.testing.expectEqual(n, try s.focused()); try std.testing.expect(has(try s.read("/screen"), "\"src\":[0,0,3,1]")); } + +/// A tmp directory's real path, kept in the session's arena. +fn dirOf(s: *Session, tmp: *std.testing.TmpDir) ![]const u8 { + var buf: [4096]u8 = undefined; + return s.arena.allocator().dupe(u8, buf[0..try tmp.dir.realPath(std.testing.io, &buf)]); +} + +test "addons: a picker shows a file of an addon's kind through its kind in the pane it lands in, Esc puts that pane back as it was, and Enter lands as a Look does" { + var tmp = std.testing.tmpDir(.{}); + defer tmp.cleanup(); + try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "notes.txt", .data = "the notes\n" }); + try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "seven.fake", .data = "1234567" }); + var s = try Session.initFile(std.testing.allocator, "x\n"); + defer s.deinit(); + try load(&s, fake.ok); + defer unload(&s, "fake"); + const dir = try dirOf(&s, &tmp); + const pane = try s.lookFile(s.at("{s}/notes.txt", .{dir})); + const body = s.at("/pane/{d}/body", .{pane}); + const a = s.arena.allocator(); + const screen = try a.dupe(u8, try s.screen()); + const index = try a.dupe(u8, try s.read("/index")); + // Its kind's paint in the reading pane's body (the fake counts the + // file's 7 bytes), not the pane's own text, nor the file's bytes. + try s.keys(" ffseven"); + s.tick(); + const shown = try s.screen(); + try std.testing.expect(has(shown, "count 7")); + try std.testing.expect(!has(shown, "the notes") and !has(shown, "1234567")); + // Esc: the pane exactly as it was, and no pane more or less. + try s.keys("\x1b"); + s.tick(); + // (The notice row says the Find ran: the session's, not the pane's.) + const after = try s.screen(); + try std.testing.expectEqualStrings(screen[0..std.mem.lastIndexOfScalar(u8, screen, '\n').?], after[0..std.mem.lastIndexOfScalar(u8, after, '\n').?]); + try s.expect(body, "the notes\n"); + try std.testing.expectEqualStrings(index, try s.read("/index")); + // Enter: the kind's pane where a Look puts it; the reading pane keeps + // its text. + try s.keys(" ffseven\n"); + s.tick(); + const opened = try paneOf(&s, "fake"); + try std.testing.expect(opened != pane); + try s.expect(body, "the notes\n"); + try std.testing.expect(has(try s.screen(), "count 7")); +} + +test "addons: a picker's row of a file no kind takes and not text shows one line naming it, and the row before's file never stays in the body" { + var tmp = std.testing.tmpDir(.{}); + defer tmp.cleanup(); + try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "notes.txt", .data = "the notes\n" }); + try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "other.txt", .data = "other text\n" }); + try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "seven.fake", .data = "1234567" }); + var blob: [3000]u8 = undefined; + for (&blob, 0..) |*b, i| b.* = @truncate(i *% 7); + try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "blob.bin", .data = &blob }); + var s = try Session.initFile(std.testing.allocator, "x\n"); + defer s.deinit(); + try load(&s, fake.ok); + defer unload(&s, "fake"); + const dir = try dirOf(&s, &tmp); + const pane = try s.lookFile(s.at("{s}/notes.txt", .{dir})); + try s.keys(" ffother"); + s.tick(); + try std.testing.expect(has(try s.screen(), "other text")); + // Onto the binary: its one line, never its bytes, nor other.txt. + try s.keys("\x08\x08\x08\x08\x08blob"); + s.tick(); + var shown = try s.screen(); + try std.testing.expect(has(shown, "blob.bin · binary · 3.0 kB")); + try std.testing.expect(!has(shown, "other text")); + // Onto a kind's file: its kind's paint, not the binary's line. + try s.keys("\x08\x08\x08\x08seven"); + s.tick(); + shown = try s.screen(); + try std.testing.expect(has(shown, "count 7")); + try std.testing.expect(!has(shown, "blob.bin · binary")); + // Back onto text, then Esc: the pane's own. + try s.keys("\x08\x08\x08\x08\x08other"); + s.tick(); + shown = try s.screen(); + try std.testing.expect(has(shown, "other text") and !has(shown, "count 7")); + try s.keys("\x1b"); + s.tick(); + try s.expect(s.at("/pane/{d}/body", .{pane}), "the notes\n"); + try std.testing.expect(has(try s.screen(), "the notes")); +} + +test "addons: moving the cursor over pictures in a picker draws only the one it rests on, and a draw of one passed by is dropped whenever it comes back" { + var tmp = std.testing.tmpDir(.{}); + defer tmp.cleanup(); + const png = "\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x01\x00\x00\x00\x01\x08\x02\x00\x00\x00\x90wS\xde\x00\x00\x00\x0cIDATx\x9cc\xf8\xcf\xc0\x00\x00\x03\x01\x01\x00\xc9\xfe\x92\xef\x00\x00\x00\x00IEND\xaeB`\x82"; + try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "notes.txt", .data = "the notes\n" }); + try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "pic1.png", .data = png }); + try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "pic2.png", .data = png }); + try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "pic3.ppm", .data = "P6\n2 1\n255\n\x0d\x4d\xe7\x0d\x4d\xe7" }); + var s = try Session.initFile(std.testing.allocator, "x\n"); + defer s.deinit(); + s.graphics(); + try load(&s, Session.image_addon); + defer unload(&s, "image"); + const dir = try dirOf(&s, &tmp); + const pane = try s.lookFile(s.at("{s}/notes.txt", .{dir})); + s.holdJobs(); + try s.keys(" ffpic"); + s.tick(); + // Until its picture is drawn, one line names it. + const first = try s.screen(); + try std.testing.expect(has(first, " · image · ")); + try std.testing.expectEqual(1, s.held.items.len); + // Two rows down with no frame between: only the row it rests on draws. + try s.keys("\u{F800}\u{F800}"); + s.tick(); + _ = try s.screen(); + try std.testing.expectEqual(2, s.held.items.len); + const rested = if (has(try s.screen(), "▶ pic3.ppm")) "\"src\":[0,0,2,1]" else "\"src\":[0,0,1,1]"; + const passed = if (std.mem.eql(u8, rested, "\"src\":[0,0,2,1]")) "\"src\":[0,0,1,1]" else "\"src\":[0,0,2,1]"; + // The rested one's answer first, the passed one's after: dropped. + std.mem.reverse(@TypeOf(s.held.items[0]), s.held.items); + s.releaseJobs(); + const screen = try s.read("/screen"); + try std.testing.expect(has(screen, s.at("\"serial\":{d},", .{pane})) and has(screen, rested)); + try std.testing.expect(!has(screen, passed)); +} + +test "addons: Enter on a picture in a picker opens its kind's pane, never its bytes as text in the reading pane (the user's report)" { + var tmp = std.testing.tmpDir(.{}); + defer tmp.cleanup(); + try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "notes.txt", .data = "the notes\n" }); + try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "pic.ppm", .data = "P6\n2 1\n255\n\x0d\x4d\xe7\x0d\x4d\xe7" }); + var s = try Session.initFile(std.testing.allocator, "x\n"); + defer s.deinit(); + s.graphics(); + try load(&s, Session.image_addon); + defer unload(&s, "image"); + const dir = try dirOf(&s, &tmp); + const pane = try s.lookFile(s.at("{s}/notes.txt", .{dir})); + try s.keys(" ffpic\n"); + s.tick(); + try s.expect(s.at("/pane/{d}/body", .{pane}), "the notes\n"); + const image = try paneOf(&s, "image"); + try std.testing.expect(image != pane); + const screen = try s.read("/screen"); + try std.testing.expect(has(screen, s.at("\"serial\":{d},", .{image})) and has(screen, "\"src\":[0,0,2,1]")); + try std.testing.expect(!has(try s.screen(), "1 P6")); +} diff --git a/test/behaviour/addons_pdf.zig b/test/behaviour/addons_pdf.zig index 0c7982d1..d773f4e2 100644 --- a/test/behaviour/addons_pdf.zig +++ b/test/behaviour/addons_pdf.zig @@ -299,3 +299,31 @@ test "addons: a PDF whose file changes on disk while a page of it renders: the p try s.keys("0"); try std.testing.expect((try shown(&s, n)).len >= 1); } + +test "addons: a PDF under a picker's cursor shows through the pdf addon in the pane it lands in, never its bytes as text, and Esc puts the pane's own text back" { + var s = try Session.initFile(std.testing.allocator, "x\n"); + defer s.deinit(); + s.graphics(); + try s.loadPdf(); + var tmp = std.testing.tmpDir(.{}); + defer tmp.cleanup(); + const pdf = try std.Io.Dir.cwd().readFileAlloc(std.testing.io, "docs/design.pdf", s.arena.allocator(), .limited(4 << 20)); + try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "paper.pdf", .data = pdf }); + try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "notes.txt", .data = "the notes\n" }); + var buf: [4096]u8 = undefined; + const dir = buf[0..try tmp.dir.realPath(std.testing.io, &buf)]; + const pane = try s.lookFile(s.at("{s}/notes.txt", .{dir})); + try s.keys(" ffpaper"); + // (Its kind told its view at the frame after the one that opened it.) + s.tick(); + s.tick(); + const screen = try s.screen(); + try std.testing.expect(!has(screen, "%PDF") and !has(screen, "the notes")); + // Its pages pictures in that pane's body, as a PDF's pane shows them. + try std.testing.expect((try shown(&s, pane)).len > 0); + try s.keys("\x1b"); + s.tick(); + try s.expect(s.at("/pane/{d}/body", .{pane}), "the notes\n"); + try std.testing.expectEqual(0, (try shown(&s, pane)).len); + try std.testing.expect(has(try s.screen(), "the notes")); +} diff --git a/test/session.zig b/test/session.zig index d437ecf2..13798753 100644 --- a/test/session.zig +++ b/test/session.zig @@ -316,6 +316,14 @@ pub const Session = struct { return true; } + /// A frame of the host's loop (its tick): what waits for the frame + /// after the keys that asked it is done (a picker's preview of the row + /// its cursor rests on). + pub fn tick(s: *Session) void { + pardesOf(s).update(.tick); + s.drain(); + } + /// Kinds' jobs and draws held from now on (`hold_jobs`), until /// `releaseJobs`. pub fn holdJobs(s: *Session) void { -- cgit v1.3 From 60e85abe53debc0c8dd8986b748e9c86086e0007 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 26 Nov 2026 02:44:20 -0300 Subject: body_layer, Places, Query, Output, Tables, File, Prompt, Pick, Core: the body draws every colour from the chrome (the themes programme's L2b; DESIGN.md R7-R12, B5, B6, G7), worked out once a theme change by Chrome.of and read by `p.chrome()`, never by a theme's own fields or the old views: ONE SELECTION FAMILY (R7): the primary range, a `gw` label and a target with no number on `page.selection` in its ink, a multi-cursor head that selection reversed; every other range, a hover, a look preview, `m a`/`m i`'s region, a selecting prompt's dimmed preview and a query pane's current row on `selection_secondary` (the page halfway toward the selection in OKLab) in the text's own ink, where they were four sRGB mixes (25 % and 50 % toward a page that was `dark`'s tag) and a secondary drew `sel_fg`; the B1, B2 and B3 sweeps the chrome's `sweeps` (select, exec on the error hue, look on the added hue; acme its own), the body's and the tags' alike, where body_layer.buttonTints tinted the selection toward the keyword, string and number; HITS (R8, G7 as the designer's position): every place, a picker's landing line, a query pane's and a results pane's match on `hit` in the text's ink (was the theme's search ink), the current place and a landing line's matched span solid in the hue with the page's ink (`hit_current`, `hit_current_text`), where Roles drew a third tone step (1.9:1) that 68 themes could not show and a query pane its search ground; a search whose field is no regex dims its last places, the current on `hit` and the rest on `hit_faint` (new: the page halfway toward the hit, R7's secondary for hits; DESIGN.md is silent); SEVERITIES (R9): a message's words and detail after its line (Messages.inkOn, new: an error, a warning and a question their severity's ink on that ground, an echo, a notice and progress its dim ink), a diagnostics list's labels, a rename's struck name and its new one, each `page.severity`, where they were the theme's raw diagnostic inks or Roles' pushed ones; DIFF GROUNDS (R10): a patch's rows, changed words and faint lines (File.recolorSyntax), a pipe prompt's and a code action's ghost rows, `add` and `del` with the page's text, where colors.Grounds mixed the page 18 %, 28 % and 7 % toward the palette's green and red once a frame; THE REST: line numbers `line_number` and the caret's `line_number_current` (R12: derived where a theme has none, it was the plain number), the wrap marker the line numbers', a tree's guides (a call stack's) and their wrap pads the page's dim ink (were the info ink: a guide is meta, B5's dim row), a location the line numbers' ink, keys, `▸` and the sam fence `page.key`, context rows, a table's header and a hover's ghost lines on the plain tag's ground (its ink for the hover), a table's rules the page's rule ink (were `border orelse lineno`), the rail and thumb the chrome's, the body's page and text `page` (a theme that leaves its page to the host leaves it its text, as before), syntax `syntax`; DELETED: Core.bodyChrome and its cache (`body_chrome`: a whole Theme compared with meta.eql for every decorated row and every wrap-pad cell, C1's A7), body_layer.buttonTints and buttonInks, the Grounds recipe (colors.Grounds is the library's view on the chrome now: lib_syntax exports it, test/consumer pins its relations), Roles.hit and hit_current with hitOf and their floors, ChromeTheme's search_fg, diagnostic_info, diagnostic_hint and lineno (nothing reads them now); every value is Chrome.of's, worked out at a theme change (finishThemeInitialization, setThemeIndex, previewTheme, loadThemeFile), never a frame, a row or a cell: the one new one, `hit_faint`, is one OKLab mix there; RUN (TEST FIRST): Places.zig "places: each on the hit ground in its text's own ink, the current one solid ... the selection over it; a search whose field is no regex dims them, the rest faint" (orchard: after `/alpha`, Enter and `j`, the current place `hit_current` in `hit_current_text`, the other `hit` in the page's text; searched again, its current under the selection; with `(` the others `hit_faint`): fails on the base at its current place (Roles' 1.9:1 step under the text's ink, where the hue in the page's ink is asked; its first version, asked during the live prompt, failed there on #3c614a: the body's selection is the current place then, drawn over it as before); Query.zig "a query pane's hits are the body's ..." (a `/alpha` query pane: the row's match `hit` in the text's ink, the owner's current place solid, the current row `selection_secondary` between its places and to its end, none below): fails on the base at Query.zig (expected #917a53, found #5e4923, the search ground); body_layer.zig "the body's selections are one family (R7) ..." (`eC` in orchard: the primary on `page.selection` in its ink, the other range on `selection_secondary` in the text's ink, its head reversed, a B2 sweep held over beta on `sweeps[1]`): fails on the base at body_layer.zig (expected #24382c, found #243a2d); body_layer.zig "the body's surfaces take every colour from the chrome: none reads a theme's own fields or the old views (DESIGN.md B6)" (the source test: body_layer, Places, Query, Output, Tables, File, Prompt, Pick, jj and ansi, their code before their tests: `theme()` read for its name alone, no chromeTheme(), bodyChrome, .roles, Grounds or LegacyTheme); re-pinned to the chrome and failing on the base: Prompt.zig's pipe ghosts (del.row #331a12, was Grounds' #302b25) and `/`'s `▸` (page.key #add38a, was Roles' #bada9d), Pick.zig's code action ghosts and its landing line, body_layer's motion targets, the build error's `✗` in `page.severity[0]`; colors.zig "line numbers stay quiet ..." (a ThemeFile with no current number: R12's derived one, 4.5:1), look.zig's hover preview on `selection_secondary`, test/output.zig and test/panes.zig's results colours (hit, page text, line numbers, the warning severity); GOLDENS re-recorded (13, orchard unless said), each class read: (1) R8 hit ink: a match on #5e4923 (orchard's own search ground, kept as its `hit`) in the text #e5eee5 where its search ink #f7e4a5 was: callstack 6 cells, psearch 15, stepgrain 26, lsprelpath 11; (2) G7 current hit: lsprelpath row 20, the owner's current place in a query row, #0d1410 on #917a53 (the hue held 4.5:1) where it was #f7e4a5 on #5e4923, 9 cells; (3) R7 secondary: #243a2d (sRGB half) to #24382c (OKLab half), the text's own ink where `sel_fg` #f5f7ee was: multicursor 2 cells and selregex 24 (secondary ranges), stepgrain 285 and lsprelpath 185 (a query pane's current row); (4) R10 diff grounds: diffview rows 12-19 (the diff pane's own rows: added #263025 to #132503, deleted #302b25 to #331a12, 558 cells; the same values the command pane's diff took in L2c), diffstack rows 26-29 (a faint added line #171f18 to #101c0b, changed words #364131 to #203900 and #453832 to #53251b), pagercolor rows 36-37 (a +Pager's faint lines: #1a1d18 to #211812, #171f18 to #101c0b); markers and syntax inks unchanged; (5) a tree's guides: callstack rows 11-21, #92d1de (the info ink) to #666f68 (the page's dim ink), 35 cells; (6) key ink: fsearch's `▸`, #bada9d (pushed over seven tag grounds) to #add38a (the accent held on the page); (7) R7 exec sweep: headersweep and headersweep-restored, a B2 sweep on the header, #f5f7ee on #5b7e5a (the selection tinted toward the string) to #e5eee5 on #4c251b (the error hue a selection step off the page), 8 and 16 cells (draw.zig's sweeps, moved with buttonTints); (8) R12: themesel row 26, the caret line's number in solarized_dark (#586e75 to #7f9193) and acme (#999980 to #74746a), themes with no current-line number of their own; no text moved, no other golden; GATES: core-test 1132/1305 (173 skipped; the merge's 1128/1301 + 4), shell-test 1353/1356 (3 skipped), pane-test 184/185 (1 skipped), behaviour-test 280/280 and --replay 20 seeds of 70 steps, 0 failures, process-test 0 of 147 failed (3 skipped; 13 re-recorded above, ttyhelp unmoved), term-test 17/17, kitty-test 45/45; gui unit-test 1957/1961 (4 skipped; its one failure the known BaselineHarnessMismatch; test/consumer's Grounds relations pass on the chrome's rows); PICTURES (the S kit, 26 px, 100x30, `Jumps walk`; before = install74's pardes-gui, after = this tree's Debug gui): .scratch/themes/L2b/png/, `--before|after.png` and `pair--.png` side by side, in dark, neonotte84, orchard and acme: `search` (a live `/words`: the current place is the body's selection, as before), `landed` (Enter, then `j`: the current place the solid chip), `selhit` (`x` over a hit), `grep` (SPC f g count: the preview's landing line and matched span), `error` (`:zig build`'s error words after report.zig's line 11: dark's were its grey text, red now), `diff` (a .diff file's rows); the dump and the digest unchanged (`body_chrome` was derived, `theme_chrome` local), so no fuzz or soak; load 3.2 to 9.7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE --- core/Core.zig | 14 +- core/File.zig | 21 ++- core/Messages.zig | 12 ++ core/Output.zig | 25 ++-- core/Pick.zig | 30 ++-- core/Places.zig | 59 ++++++-- core/Prompt.zig | 26 ++-- core/Query.zig | 62 ++++++-- core/Tables.zig | 8 +- core/body_layer.zig | 220 ++++++++++++++++++----------- core/colors.zig | 133 +++-------------- core/draw.zig | 9 +- core/look.zig | 3 +- core/root.zig | 4 +- test/output.zig | 24 ++-- test/panes.zig | 2 +- test/snapshots/callstack.golden | 24 ++-- test/snapshots/diffstack.golden | 6 +- test/snapshots/diffview.golden | 12 +- test/snapshots/fsearch.golden | 2 +- test/snapshots/headersweep-restored.golden | 4 +- test/snapshots/headersweep.golden | 2 +- test/snapshots/lsprelpath.golden | 8 +- test/snapshots/multicursor.golden | 4 +- test/snapshots/pagercolor.golden | 4 +- test/snapshots/psearch.golden | 6 +- test/snapshots/selregex.golden | 12 +- test/snapshots/stepgrain.golden | 8 +- test/snapshots/themesel.golden | 4 +- 29 files changed, 391 insertions(+), 357 deletions(-) (limited to 'core/root.zig') diff --git a/core/Core.zig b/core/Core.zig index cbcf4324..e458dab4 100644 --- a/core/Core.zig +++ b/core/Core.zig @@ -351,8 +351,6 @@ custom_theme: ?LegacyTheme = null, /// session's own theme untouched under it. theme_preview: ?u16 = null, preview_chrome: ChromeTheme = undefined, -/// bodyChrome's: the theme it was worked out for, and it. -body_chrome: ?struct { theme: LegacyTheme, chrome: ChromeTheme } = null, theme_file_path: config.Settings.Text(limits.host_path_cap) = .{}, /// The ThemeFile last loaded whole: what /ctl and DumpConfig name, and /// what a failed ThemeFile goes back to (colors.revertThemeFile). @@ -547,7 +545,7 @@ pub const replica = .{ "opts", "dump_out", "dump_export", "tape", }, - .derived = .{ "shell_rows", "diff_output", "locations_cache", "retired_panes", "tty_filter_palette", "body_chrome", "theme_preview", "preview_chrome" }, + .derived = .{ "shell_rows", "diff_output", "locations_cache", "retired_panes", "tty_filter_palette", "theme_preview", "preview_chrome" }, // The host's handles, the state file every session of the user // shares (and Recent read from it), this session's closed panes, and // the files of a host with no file system of its own. (The 9P @@ -2175,16 +2173,6 @@ pub fn chrome(p: *const Pardes) *const colors.Chrome { return &p.chromeTheme().resolved; } -/// The theme's own chrome, not a fade's (`theme()`'s, worked out once -/// per theme: its contrast searches take pow calls, too many for a -/// grapheme or a row). -pub fn bodyChrome(p: *Pardes) *const ChromeTheme { - const th = p.theme(); - if (p.body_chrome) |*cached| if (std.meta.eql(cached.theme, th.*)) return &cached.chrome; - p.body_chrome = .{ .theme = th.*, .chrome = ChromeTheme.fromTheme(th) }; - return &p.body_chrome.?.chrome; -} - /// When the core next needs a frame, on the `stepped_ns` timeline: a /// frame from now while work goes on (places to find, a picture /// decoding, a PDF page on a lane), the end of the wait while something diff --git a/core/File.zig b/core/File.zig index 332499b4..e246285c 100644 --- a/core/File.zig +++ b/core/File.zig @@ -2917,7 +2917,8 @@ pub const Layers = struct { pub const SynStyle = struct { fg: [3]u8, bold: bool }; pub fn synStyle(p: *Pardes, sy: syntax.Syn) ?SynStyle { - return .{ .fg = Colors.synInk(p.theme(), sy) orelse return null, .bold = false }; + if (sy == .none) return null; + return .{ .fg = p.chrome().syntax[@intFromEnum(sy)], .bold = false }; } /// syntax colors: recolor each content cell from its tree-sitter style byte; @@ -2940,8 +2941,8 @@ pub fn recolorSyntax(p: *Pardes, s: *Surface, pane: *Pane, f: *State, r: pardes. const tz_recolor = tracy.zone(@src(), "synRecolor"); defer tz_recolor.end(); // A row whose first byte names a hue (syntax.ground_add, _del): its - // grounds, the theme's, worked out once a frame and only for one. - var grounds: ?Colors.Grounds = null; + // grounds, the chrome's (R10). + const chrome = p.chrome(); const ink = ansi.inkOf(p); var filtered_storage: pardes.Term.Filter = undefined; const filtered: ?*pardes.Term.Filter = if (pane.tty_filter and spans.len > 0) blk: { @@ -2980,14 +2981,11 @@ pub fn recolorSyntax(p: *Pardes, s: *Surface, pane: *Pane, f: *State, r: pardes. const row_index: usize = @intCast(@max(0, pane.wrapAt(p.settings.tab, vr).line)); const metadata: ?locations.Row = if (row_index < f.location_rows.len) f.location_rows[row_index] else null; const decoration = Output.decorateRow(f.output, line, metadata); - const chrome: ?*const pardes.ChromeTheme = if (decoration.plain()) null else p.bodyChrome(); + const decorated = !decoration.plain(); // The row's first byte: its hue and its ground, on every wrapped // row of it (syntax.ground_add). const lead: u8 = if (base >= highlight_start and base - highlight_start < highlights.len) highlights[base - highlight_start] else 0; - const tint: ?Colors.Grounds.Ground = if (lead & (syntax.ground_add | syntax.ground_del) == 0) null else (grounds orelse ground: { - grounds = .of(p.theme()); - break :ground grounds.?; - }).forStyle(lead); + const tint: ?*const Colors.Chrome.Diff = if (lead & syntax.ground_add != 0) &chrome.add else if (lead & syntax.ground_del != 0) &chrome.del else null; // 2, the patch: the row's ground. if (tint) |t| if (prefix_width < tw) { const ground: ?[3]u8 = if (lead & syntax.ground_emph != 0) t.row else if (lead & syntax.ground_line != 0) t.line else null; @@ -3004,7 +3002,7 @@ pub fn recolorSyntax(p: *Pardes, s: *Surface, pane: *Pane, f: *State, r: pardes. var c: usize = 0; const pad: usize = if (vr < pane.wrap_n) pane.wrap_pad[vr] else 0; for (0..@min(pad, tw -| prefix_width)) |col| { - s.at(tx + @as(u16, @intCast(prefix_width + col)), body_y + vr).style.fg = .{ .rgb = p.bodyChrome().diagnostic_info }; + s.at(tx + @as(u16, @intCast(prefix_width + col)), body_y + vr).style.fg = .{ .rgb = chrome.page.dim }; } var screen_c: usize = pad; var table_buf: [Tables.max_pads]Tables.Pad = undefined; @@ -3052,7 +3050,7 @@ pub fn recolorSyntax(p: *Pardes, s: *Surface, pane: *Pane, f: *State, r: pardes. } // Results keep their exact live text. Only the location, // matched source range and diagnostic label gain emphasis. - if (if (chrome) |ch| decoration.styleAt(ch, hs + c) else null) |style| { + if (if (decorated) decoration.styleAt(chrome, hs + c) else null) |style| { var fill: usize = 0; while (fill < cells and prefix_width + screen_c + fill < tw) : (fill += 1) { const cell = s.at(tx + @as(u16, @intCast(prefix_width + screen_c + fill)), body_y + vr); @@ -3104,6 +3102,7 @@ pub fn paintWordSelection( word_lo: i32, word_hi: i32, bg: [3]u8, + fg: ?[3]u8, ) void { const tx = r.x + config.GUTTER; const tw = r.w - config.GUTTER; @@ -3122,7 +3121,7 @@ pub fn paintWordSelection( const c1 = @as(i32, prefix_width) + here.pad + displayEndOffset(p.settings.tab, pane, row, here.at, hi - 1); const col = @max(@as(i32, prefix_width), c0); const end = @min(c1 + 1, @as(i32, tw)); - if (col < end) s.tint(tx + @as(u16, @intCast(col)), body_y + @as(u16, @intCast(vr)), @intCast(end - col), bg, null); + if (col < end) s.tint(tx + @as(u16, @intCast(col)), body_y + @as(u16, @intCast(vr)), @intCast(end - col), bg, fg); } } diff --git a/core/Messages.zig b/core/Messages.zig index e05961b5..eca5ec9f 100644 --- a/core/Messages.zig +++ b/core/Messages.zig @@ -435,6 +435,18 @@ pub fn ink(chrome: *const pardes.colors.ChromeTheme, kind: Kind) [3]u8 { }; } +/// A message's ink on a ground of the chrome (R9): an error's, a warning's +/// and a question's their severity's held there (a question info's), an +/// echo, a notice and progress the ground's dim ink. +pub fn inkOn(inks: *const pardes.colors.Chrome.Inks, kind: Kind) [3]u8 { + return switch (kind) { + .@"error" => inks.severity[0], + .warn => inks.severity[1], + .question => inks.severity[2], + .echo, .notice, .progress => inks.dim, + }; +} + /// The places a compiler's report names put on `s`: each /// `path:line:col: error|warning|note: words` row (a relative path is /// `dir`'s), its words there, each place once, and the rows after the diff --git a/core/Output.zig b/core/Output.zig index fe1543fe..8807e55d 100644 --- a/core/Output.zig +++ b/core/Output.zig @@ -70,27 +70,20 @@ const RowDecoration = struct { return row.guide_end == 0 and !row.declaration and row.location_end == 0 and row.prefix_end == 0 and row.mark_end <= row.mark_start; } - /// `chrome` is the theme's own (Pardes.bodyChrome): body paper changes - /// immediately, so its ink must change with it even while the - /// surrounding tags are still fading. Once a frame, never a grapheme: - /// working it out takes the contrast searches' pow calls. - pub fn styleAt(row: RowDecoration, chrome: *const pardes.ChromeTheme, byte: usize) ?pardes.CellStyle { + /// On the page (`chrome`, Pardes.chrome): a tree's guides in the dim + /// ink, a location in the line numbers', the match a hit, a + /// diagnostic's label in its severity's ink (R8, R9). + pub fn styleAt(row: RowDecoration, chrome: *const pardes.colors.Chrome, byte: usize) ?pardes.CellStyle { if (row.plain()) return null; - if (byte < row.guide_end) return .{ .fg = .{ .rgb = chrome.diagnostic_info } }; + if (byte < row.guide_end) return .{ .fg = .{ .rgb = chrome.page.dim } }; if (row.declaration or byte < @max(row.location_end, row.prefix_end)) - return .{ .fg = .{ .rgb = chrome.lineno } }; + return .{ .fg = .{ .rgb = chrome.line_number } }; if (byte < row.mark_start or byte >= row.mark_end) return null; if (row.severity == .none) return .{ - .fg = .{ .rgb = chrome.search_fg }, - .bg = .{ .rgb = chrome.search_bg }, + .fg = .{ .rgb = chrome.page.text }, + .bg = .{ .rgb = chrome.hit }, }; - return .{ .fg = .{ .rgb = switch (row.severity) { - .err => chrome.diagnostic_error, - .warning => chrome.diagnostic_warning, - .info => chrome.diagnostic_info, - .hint => chrome.diagnostic_hint, - .none => unreachable, - } }, .bold = true }; + return .{ .fg = .{ .rgb = chrome.page.severity[@intFromEnum(row.severity) - 1] }, .bold = true }; } }; diff --git a/core/Pick.zig b/core/Pick.zig index 1d332f25..7c40a234 100644 --- a/core/Pick.zig +++ b/core/Pick.zig @@ -1176,8 +1176,8 @@ pub fn ghosts(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r: if (rows <= first) return; const w: usize = s.cols; const old = try arena.dupe(Cell, s.cells[(y0 + first) * w .. (y0 + rows) * w]); - const grounds = colors.Grounds.of(p.theme()); - const ink = p.theme().fg orelse p.theme().tag_fg; + const chrome = p.chrome(); + const ink = chrome.page.text; const x0 = r.x + config.GUTTER + File.gutterWidth(pane); const width = r.w -| (x0 - r.x); var out: usize = first; @@ -1194,15 +1194,15 @@ pub fn ghosts(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r: if (out >= rows) break; const y: u16 = @intCast(y0 + out); s.fill(0, y, @intCast(s.cols), 1, .{}); - s.fill(x0, y, width, 1, .{ .bg = .{ .rgb = grounds.add.row } }); - _ = s.print(x0, y, width, l, .{ .fg = .{ .rgb = ink }, .bg = .{ .rgb = grounds.add.row } }); + s.fill(x0, y, width, 1, .{ .bg = .{ .rgb = chrome.add.row } }); + _ = s.print(x0, y, width, l, .{ .fg = .{ .rgb = ink }, .bg = .{ .rgb = chrome.add.row } }); out += 1; }; } } if (out >= rows) break; @memcpy(s.cells[(y0 + out) * w ..][0..w], old[(vr - first) * w ..][0..w]); - if (g < groups.items.len and line >= groups.items[g].lo and line < groups.items[g].hi) s.tint(x0, @intCast(y0 + out), width, grounds.del.row, null); + if (g < groups.items.len and line >= groups.items[g].lo and line < groups.items[g].hi) s.tint(x0, @intCast(y0 + out), width, chrome.del.row, null); out += 1; } } @@ -2585,15 +2585,15 @@ test "code actions: a picker in the asking pane's tag, the one under the cursor const r = p.view().rects[id]; const x = r.x + config.GUTTER + File.gutterWidth(pane); const y = p.bodyTop(pane, r); - const grounds = colors.Grounds.of(p.theme()); + const chrome = p.chrome(); for ([_][]const u8{ "o", "t", "t", "t" }, [_][]const u8{ "n", "w", "w", "h" }, 0..) |c0, c1, row| { try std.testing.expectEqualStrings(c0, shot.at(x, y + @as(u16, @intCast(row))).grapheme()); try std.testing.expectEqualStrings(c1, shot.at(x + 1, y + @as(u16, @intCast(row))).grapheme()); } try std.testing.expectEqualStrings("a", shot.at(x + 4, y + 1).grapheme()); try std.testing.expectEqualStrings("s", shot.at(x + 4, y + 2).grapheme()); - try std.testing.expectEqual(pardes.Color{ .rgb = grounds.del.row }, shot.at(x, y + 1).style.bg); - try std.testing.expectEqual(pardes.Color{ .rgb = grounds.add.row }, shot.at(x, y + 2).style.bg); + try std.testing.expectEqual(pardes.Color{ .rgb = chrome.del.row }, shot.at(x, y + 1).style.bg); + try std.testing.expectEqual(pardes.Color{ .rgb = chrome.add.row }, shot.at(x, y + 2).style.bg); try std.testing.expectEqualStrings("one\ntwo add\nthree\n", pane.file.?.content); // An action lands nowhere: no landing line, no `▸` before the line it // changes, no sentence of where Enter lands (UX D7's are a jump's; an @@ -2610,10 +2610,10 @@ test "code actions: a picker in the asking pane's tag, the one under the cursor frame = std.heap.ArenaAllocator.init(std.testing.allocator); shot = try p.render(frame.allocator()); try std.testing.expectEqualStrings("/", shot.at(x, y).grapheme()); - try std.testing.expectEqual(pardes.Color{ .rgb = grounds.add.row }, shot.at(x, y).style.bg); + try std.testing.expectEqual(pardes.Color{ .rgb = chrome.add.row }, shot.at(x, y).style.bg); try std.testing.expectEqualStrings("o", shot.at(x, y + 1).grapheme()); - try std.testing.expect(!std.meta.eql(pardes.Color{ .rgb = grounds.del.row }, shot.at(x, y + 1).style.bg)); - try std.testing.expect(!std.meta.eql(pardes.Color{ .rgb = p.chromeTheme().roles.hit }, shot.at(x, y + 1).style.bg)); + try std.testing.expect(!std.meta.eql(pardes.Color{ .rgb = chrome.del.row }, shot.at(x, y + 1).style.bg)); + try std.testing.expect(!std.meta.eql(pardes.Color{ .rgb = p.chrome().hit }, shot.at(x, y + 1).style.bg)); // `3`: the rename applied, the tag at rest; one undo takes it back. p.update(.{ .key = .{ .cp = '3', .text = "3" } }); try std.testing.expectEqual(TagState.Kind.rest, s.kind); @@ -2720,16 +2720,16 @@ test "a picker's preview is legible as one (UX D7): its landing line on the hit }; try std.testing.expectEqual(@as(?u16, @intCast((pane.rows + 2) / 3)), at); const y = body_y + at.?; - const roles = &p.chromeTheme().roles; + const c = p.chrome(); const tx = r.x + pardes.config.GUTTER; const gutter = File.gutterWidth(pane); // Its text on the hit ground across the row; the row above as it was. - for (gutter..r.w - pardes.config.GUTTER) |x| try std.testing.expectEqual(pardes.Color{ .rgb = roles.hit }, s.at(tx + @as(u16, @intCast(x)), y).style.bg); - try std.testing.expect(!std.meta.eql(s.at(tx + gutter + 2, y - 1).style.bg, pardes.Color{ .rgb = roles.hit })); + for (gutter..r.w - pardes.config.GUTTER) |x| try std.testing.expectEqual(pardes.Color{ .rgb = c.hit }, s.at(tx + @as(u16, @intCast(x)), y).style.bg); + try std.testing.expect(!std.meta.eql(s.at(tx + gutter + 2, y - 1).style.bg, pardes.Color{ .rgb = c.hit })); // `▸` in the key ink in the gutter's cell after the number. const mark = s.at(tx + gutter - 1, y); try std.testing.expectEqualStrings("▸", mark.grapheme()); - try std.testing.expectEqual(pardes.Color{ .rgb = roles.key }, mark.style.fg); + try std.testing.expectEqual(pardes.Color{ .rgb = c.page.key }, mark.style.fg); // The notice row: where Enter lands, the owner's address a word in it. var buf: [pardes.Messages.notice_row_cap]u8 = undefined; const said = pardes.Messages.noticeRow(p, 120, &buf); diff --git a/core/Places.zig b/core/Places.zig index 8563d7c8..63f9ced6 100644 --- a/core/Places.zig +++ b/core/Places.zig @@ -659,19 +659,17 @@ pub fn origin(set: *const Places, pane: *Pane) usize { } /// Every place on the rows shown, tinted over the text: the hit ground, -/// the current one the current hit's (colors.Roles, UX D4, D14). +/// the current one solid in the hue with the page's ink (R8, UX D14); a +/// search prompt's pattern that is no regex, its last places dimmed: the +/// current on the hit ground, the rest faint. pub fn paint(set: *Places, p: *Pardes, s: *Surface, pane: *Pane, r: pardes.Rect, body_h: u16) void { if (!set.shows(pane)) return; const f = &pane.file.?; - const th = p.theme(); - const roles = &p.chromeTheme().roles; - var strong = roles.hit_current; - var quiet = roles.hit; - // A search prompt's pattern that is no regex: its last places, dimmed. - if (pardes.Prompt.dims(p, pane)) { - strong = quiet; - quiet = colors.mix(th.bg orelse th.tag_bg, quiet); - } + const c = p.chrome(); + const dim = pardes.Prompt.dims(p, pane); + const strong = if (dim) c.hit else c.hit_current; + const strong_ink: ?[3]u8 = if (dim) null else c.hit_current_text; + const quiet = if (dim) c.hit_faint else c.hit; const hits = set.hits.items; if (hits.len == 0) return; const nlines = File.nlines(p.gpa, f); @@ -697,7 +695,7 @@ pub fn paint(set: *Places, p: *Pardes, s: *Surface, pane: *Pane, r: pardes.Rect, const b = @min(hits[i].end, le) - ls; if (b <= a) continue; const current = set.current != null and set.current.? == i; - File.paintWordSelection(p, s, pane, r, line, @intCast(a), @intCast(b), if (current) strong else quiet); + File.paintWordSelection(p, s, pane, r, line, @intCast(a), @intCast(b), if (current) strong else quiet, if (current) strong_ink else null); } } } @@ -903,3 +901,42 @@ test "a session's places loaded from its dump find what an edit makes as the ses b.panes[b.view().active].?.file.?.mtime = a.panes[a.view().active].?.file.?.mtime; try std.testing.expectEqual(pardes.walk.digest(Pardes, a), pardes.walk.digest(Pardes, b)); } + +test "places: each on the hit ground in its text's own ink, the current one solid, the hue its ground and the page its ink (R8, G7), the selection over it; a search whose field is no regex dims them, the rest faint" { + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 24 }); + defer p.deinit(); + colors.setThemeIndex(p, colors.themeIndex("orchard").?); + const pane = try p.setTestFile("alpha beta\ngamma alpha\nb\nb\nb\nb\nb\nb\nb\nzeta alpha\n"); + // Landed on the first, the caret then moved off it: the places stay. + typeKeys(p, "/alpha"); + p.update(.{ .key = .{ .cp = pardes.Key.enter } }); + typeKeys(p, "j"); + try std.testing.expect(pane.places.shows(pane)); + try std.testing.expectEqual(@as(?usize, 0), pane.places.current); + const c = p.chrome(); + var frame: std.heap.ArenaAllocator = .init(std.testing.allocator); + defer frame.deinit(); + const r = p.view().rects[0]; + const x = r.x + pardes.config.GUTTER + File.gutterWidth(pane); + const y = p.bodyTop(pane, r); + var s = try p.render(frame.allocator()); + for (0..5) |i| { + const current = s.at(x + @as(u16, @intCast(i)), y).style; + try std.testing.expectEqual(pardes.Color{ .rgb = c.hit_current }, current.bg); + try std.testing.expectEqual(pardes.Color{ .rgb = c.hit_current_text }, current.fg); + const other = s.at(x + 6 + @as(u16, @intCast(i)), y + 1).style; + try std.testing.expectEqual(pardes.Color{ .rgb = c.hit }, other.bg); + try std.testing.expectEqual(pardes.Color{ .rgb = c.page.text }, other.fg); + } + // Searched again from line 2: its place current and selected, the + // selection over the hit; then `(`, no regex: the others faint (line + // 10's: the prompt's words lie over the top rows). + typeKeys(p, "/alpha"); + try std.testing.expectEqual(@as(?usize, 1), pane.places.current); + s = try p.render(frame.allocator()); + for (0..4) |i| try std.testing.expectEqual(pardes.Color{ .rgb = c.page.selection.ground }, s.at(x + 6 + @as(u16, @intCast(i)), y + 1).style.bg); + typeKeys(p, "("); + try std.testing.expect(pardes.Prompt.dims(p, pane)); + s = try p.render(frame.allocator()); + for (5..10) |i| try std.testing.expectEqual(pardes.Color{ .rgb = c.hit_faint }, s.at(x + @as(u16, @intCast(i)), y + 9).style.bg); +} diff --git a/core/Prompt.zig b/core/Prompt.zig index b76b2d9a..49a9645d 100644 --- a/core/Prompt.zig +++ b/core/Prompt.zig @@ -874,7 +874,7 @@ pub fn paintGutter(p: *Pardes, s: *Surface, pane: *Pane, r: pardes.Rect, body_h: const tab = p.settings.tab; const x = gutterX(pane, r); const y = p.bodyTop(pane, r); - const ink = p.chromeTheme().roles.key; + const ink = p.chrome().page.key; const nlines = File.nlines(p.gpa, f); // `▸` on the current place's line alone: the lines with places are the // rail's ticks (Places.addTicks), never glyphs of their own (UX D14). @@ -953,8 +953,8 @@ pub fn ghosts(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r: if (rows <= first) return; const w: usize = s.cols; const old = try arena.dupe(Cell, s.cells[(y0 + first) * w .. (y0 + rows) * w]); - const grounds = colors.Grounds.of(p.theme()); - const ink = p.theme().fg orelse p.theme().tag_fg; + const chrome = p.chrome(); + const ink = chrome.page.text; const x0 = r.x + config.GUTTER + File.gutterWidth(pane); const width = r.w -| (x0 - r.x); const ranges = live_run.ranges[0..live_run.nranges]; @@ -969,18 +969,18 @@ pub fn ghosts(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r: // `!`: its output before the selection's first line. var j = k; if (how == .insert and opens) while (j < ranges.len and lineAt(index, @min(ranges[j].anchor, ranges[j].head)) == line) : (j += 1) { - out = ghostRows(s, live_run, j, out, rows, y0, x0, width, grounds.add.row, ink); + out = ghostRows(s, live_run, j, out, rows, y0, x0, width, chrome.add.row, ink); }; if (out >= rows) break; @memcpy(s.cells[(y0 + out) * w ..][0..w], old[(vr - first) * w ..][0..w]); j = k; while (j < ranges.len and lineAt(index, @min(ranges[j].anchor, ranges[j].head)) <= line) : (j += 1) { - if (how == .replace and outcome(live_run, j) == 0) s.tint(x0, @intCast(y0 + out), width, grounds.del.row, null); + if (how == .replace and outcome(live_run, j) == 0) s.tint(x0, @intCast(y0 + out), width, chrome.del.row, null); } out += 1; // `|` and `A-!`: after the selection's last line. if (how != .insert and closes) while (k < ranges.len and lineAt(index, @max(ranges[k].anchor, ranges[k].head) -| 1) == line) : (k += 1) { - out = ghostRows(s, live_run, k, out, rows, y0, x0, width, grounds.add.row, ink); + out = ghostRows(s, live_run, k, out, rows, y0, x0, width, chrome.add.row, ink); }; } // What was pushed past the view leaves blank rows behind it, none. @@ -1027,7 +1027,7 @@ fn fence(p: *Pardes, s: *Surface, pane: *Pane, r: pardes.Rect, body_h: u16) void if (snap.len == 0) return; const x = gutterX(pane, r); const y = p.bodyTop(pane, r); - const ink = p.chromeTheme().box; + const ink = p.chrome().page.key; const nlines = File.nlines(p.gpa, f); const op = p.view().tag_state.prompt.op; var kept: [Text.max_selections]modal.Selection = undefined; @@ -1500,12 +1500,12 @@ test "/ searches the body as it is typed: the current place selected, `▸` in t { const s = try p.render(frame.allocator()); const r = p.view().rects[0]; - const roles = &p.chromeTheme().roles; + const c = p.chrome(); const x = r.x + config.GUTTER + File.gutterWidth(pane); const y = p.bodyTop(pane, r); - try std.testing.expectEqual(pardes.Color{ .rgb = roles.key }, s.at(x - 1 - File.laneCells(pane) - pane.layers.heat, y + 2).style.fg); + try std.testing.expectEqual(pardes.Color{ .rgb = c.page.key }, s.at(x - 1 - File.laneCells(pane) - pane.layers.heat, y + 2).style.fg); // Line 1's place (`dirty` at its start) on the hit ground. - try std.testing.expectEqual(pardes.Color{ .rgb = roles.hit }, s.at(x, y).style.bg); + try std.testing.expectEqual(pardes.Color{ .rgb = c.hit }, s.at(x, y).style.bg); } p.update(.{ .key = .{ .cp = Key.enter } }); try std.testing.expectEqual(TagState.Kind.rest, p.view().tag_state.kind); @@ -1651,8 +1651,10 @@ test "a pipe prompt runs a known filter live, a run a selection: the outputs gho const x = r.x + config.GUTTER + File.gutterWidth(pane); const y = p.bodyTop(pane, r); for ([_][]const u8{ "b", "B", "a", "A", "c" }, 0..) |want, row| try std.testing.expectEqualStrings(want, s.at(x, y + @as(u16, @intCast(row))).grapheme()); - try std.testing.expectEqual(pardes.Color{ .rgb = colors.Grounds.of(p.theme()).del.row }, s.at(x, y).style.bg); - try std.testing.expectEqual(pardes.Color{ .rgb = colors.Grounds.of(p.theme()).add.row }, s.at(x, y + 1).style.bg); + // On the chrome's diff rows (R10), the ghost in the page's text. + try std.testing.expectEqual(pardes.Color{ .rgb = p.chrome().del.row }, s.at(x, y).style.bg); + try std.testing.expectEqual(pardes.Color{ .rgb = p.chrome().add.row }, s.at(x, y + 1).style.bg); + try std.testing.expectEqual(pardes.Color{ .rgb = p.chrome().page.text }, s.at(x, y + 1).style.fg); try std.testing.expectEqualStrings("b\na\nc\n", pane.file.?.content); // Enter: what the live run made, applied. p.update(.{ .key = .{ .cp = Key.enter } }); diff --git a/core/Query.zig b/core/Query.zig index 2b2abebb..f3673dd6 100644 --- a/core/Query.zig +++ b/core/Query.zig @@ -471,8 +471,8 @@ fn makeNameRows(p: *Pardes, id: usize) !void { var rows: std.ArrayList(locations.Row) = .empty; var spans: std.ArrayList(pardes.Term.Span) = .empty; errdefer spans.deinit(p.gpa); - const chrome = p.bodyChrome(); - const tint: pardes.CellStyle = .{ .fg = .{ .rgb = chrome.search_fg }, .bg = .{ .rgb = chrome.search_bg }, .bold = true }; + const chrome = p.chrome(); + const tint: pardes.CellStyle = .{ .fg = .{ .rgb = chrome.page.text }, .bg = .{ .rgb = chrome.hit }, .bold = true }; const shown = @min(q.names.hits.items.len, Names.max_rows); var marks: [Names.max_query * 4]u16 = undefined; const base = lineOne(rp.file.?.content).len + 1; @@ -510,7 +510,7 @@ fn makeNameRows(p: *Pardes, id: usize) !void { // A closed pane's row is dimmer, the gutter's colour, between its // marks (spans are walked in order, never overlapping). const dim = q.source == .panes and p.paneBySerial(cand.ref) == null; - const dimmed: pardes.CellStyle = .{ .fg = .{ .rgb = chrome.lineno } }; + const dimmed: pardes.CellStyle = .{ .fg = .{ .rgb = chrome.line_number } }; var gap: usize = 0; var k: usize = 0; while (k < nmarks) { @@ -2092,8 +2092,7 @@ pub fn tagPrefix(q: *const Query, arena: std.mem.Allocator, path: []const u8) er pub fn paintMark(p: *Pardes, s: *Surface, pane: *Pane, r: pardes.Rect, body_h: u16) void { const q = pane.query orelse return; const c = q.current orelse return; - const th = p.theme(); - const mark = colors.mix(th.bg orelse th.tag_bg, th.sel_bg); + const mark = p.chrome().selection_secondary; const tx = r.x + config.GUTTER; const tw = r.w -| config.GUTTER; const col = File.gutterWidth(pane); @@ -2106,13 +2105,11 @@ pub fn paintMark(p: *Pardes, s: *Surface, pane: *Pane, r: pardes.Rect, body_h: u /// The other places on a hit row's line tinted, from the pane its rows are /// in (the first is the row's own mark, Output.decorateRow): the current -/// one strongest, as in that pane's text. +/// one solid, as in that pane's text (Places.paint). pub fn paint(p: *Pardes, s: *Surface, pane: *Pane, r: pardes.Rect, body_h: u16) void { const q = pane.query orelse return; const f = if (pane.file) |*file| file else return; - const th = p.theme(); - const strong = p.chromeTheme().search_bg; - const quiet = colors.mix(th.bg orelse th.tag_bg, strong); + const c = p.chrome(); var vr: i32 = 0; var last: i32 = -1; while (vr < body_h) : (vr += 1) { @@ -2144,7 +2141,7 @@ pub fn paint(p: *Pardes, s: *Surface, pane: *Pane, r: pardes.Rect, body_h: u16) const b = @min(line.len, meta.code_start + (@min(h.end, next) - ls - meta.source_column)); if (b <= a or a >= line.len) continue; const current = set.current != null and set.current.? == hi; - File.paintWordSelection(p, s, pane, r, row, @intCast(a), @intCast(b), if (current) strong else quiet); + File.paintWordSelection(p, s, pane, r, row, @intCast(a), @intCast(b), if (current) c.hit_current else c.hit, if (current) c.hit_current_text else null); } } } @@ -2815,3 +2812,48 @@ test "Grep: a row whose numbers a Found cannot hold (a column past u32) is passe // Taken or passed over, each: never cast (main: Query.zig:1267). try std.testing.expect(q.found.items.len <= 3); } + +test "a query pane's hits are the body's: a row's match on the hit ground in the text's ink, the owner's current place solid in the hue with the page's ink, the current row marked with the selection's faint half" { + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 40 }); + defer p.deinit(); + p.settings.jumps = .@"new-pane"; + colors.setThemeIndex(p, colors.themeIndex("orchard").?); + const pane = try p.setTestFile("alpha one alpha\nbeta\ngamma alpha\n"); + slash(p, "/alpha"); + const qid = queryPane(p).?; + const qp = p.panes[qid].?; + try std.testing.expectEqual(@as(?usize, 0), qp.query.?.current); + try std.testing.expectEqual(@as(?usize, 0), pane.places.current); + var frame = std.heap.ArenaAllocator.init(std.testing.allocator); + defer frame.deinit(); + const s = try p.render(frame.allocator()); + const c = p.chrome(); + const r = p.view().rects[qid]; + // Row 1 (line 1 is the query) the first place's line, row 2 the third's. + var rows: [2][]const u8 = undefined; + for (&rows, 1..) |*row, k| { + var text: std.ArrayList(u8) = .empty; + for (0..r.w) |x| try text.appendSlice(frame.allocator(), s.at(r.x + @as(u16, @intCast(x)), p.bodyTop(qp, r) + @as(u16, @intCast(k))).grapheme()); + row.* = text.items; + } + const y = p.bodyTop(qp, r) + 1; + const first = std.mem.indexOf(u8, rows[0], "alpha").?; + const second = std.mem.lastIndexOf(u8, rows[0], "alpha").?; + const third = std.mem.indexOf(u8, rows[1], "alpha").?; + try std.testing.expect(second > first + 5); + for (0..5) |i| { + const current = s.at(r.x + @as(u16, @intCast(first + i)), y).style; + try std.testing.expectEqual(pardes.Color{ .rgb = c.hit_current }, current.bg); + try std.testing.expectEqual(pardes.Color{ .rgb = c.hit_current_text }, current.fg); + const other = s.at(r.x + @as(u16, @intCast(second + i)), y).style; + try std.testing.expectEqual(pardes.Color{ .rgb = c.hit }, other.bg); + try std.testing.expectEqual(pardes.Color{ .rgb = c.page.text }, other.fg); + const below = s.at(r.x + @as(u16, @intCast(third + i)), y + 1).style; + try std.testing.expectEqual(pardes.Color{ .rgb = c.hit }, below.bg); + try std.testing.expectEqual(pardes.Color{ .rgb = c.page.text }, below.fg); + } + // The current row's mark between its places and to its end; none below. + try std.testing.expectEqual(pardes.Color{ .rgb = c.selection_secondary }, s.at(r.x + @as(u16, @intCast(first + 6)), y).style.bg); + try std.testing.expectEqual(pardes.Color{ .rgb = c.selection_secondary }, s.at(r.x + r.w - 2, y).style.bg); + try std.testing.expectEqual(pardes.Color{ .rgb = c.page.ground }, s.at(r.x + r.w - 2, y + 1).style.bg); +} diff --git a/core/Tables.zig b/core/Tables.zig index a0256d8a..99e464ac 100644 --- a/core/Tables.zig +++ b/core/Tables.zig @@ -645,16 +645,16 @@ fn glyph(cell: *Cell, g: []const u8) void { /// A pane's table rows drawn as tables: every unescaped `|` a rule, the /// delimiter row one rule across (its dashes, its blanks and its pads, its /// `:` kept in the rule's colour, since they say the alignment), the header -/// row bold on the tag's ground, as compact context rows are. Only glyphs +/// row bold on the tag's ground, as compact context rows are, the rules in +/// the page's rule ink (R11). Only glyphs /// and colours change, on the cells the row has: where each byte is and how /// wide is fillBody's, so nothing is drawn over anything, B1 on a rule is /// B1 on its `|`, and a selection's tint lies over the rules as over text. pub fn paint(p: *Pardes, s: *Surface, pane: *Pane, r: pardes.Rect, tx: u16, tw: u16, body_h: u16) void { const f = if (pane.file) |*file| file else return; if (f.tables.list.items.len == 0) return; - const th = p.theme(); - const rule_fg: Color = .{ .rgb = th.border orelse th.lineno }; - const head_bg: Color = .{ .rgb = th.tag_bg }; + const rule_fg: Color = .{ .rgb = p.chrome().page.rule }; + const head_bg: Color = .{ .rgb = p.chrome().tag[0].ground }; const prefix: usize = File.gutterWidth(pane); const body_y = p.bodyTop(pane, r); var vr: u16 = 0; diff --git a/core/body_layer.zig b/core/body_layer.zig index 513f9a6d..1eb3bf54 100644 --- a/core/body_layer.zig +++ b/core/body_layer.zig @@ -148,21 +148,12 @@ pub fn paintPointerSelection( } } -/// The selection colour of each pointer button's sweep: the select button's -/// and the look and exec buttons', each tinted toward its own accent. -pub fn buttonTints(th: *const colors.LegacyTheme) [3][3]u8 { - if (th.sweep_bg) |own| return own; - const accent2 = if (std.mem.eql(u8, &th.num, &th.str)) th.comment else th.num; - return .{ - colors.mix(th.sel_bg, colors.mix(th.sel_bg, th.kw)), - colors.mix(th.sel_bg, colors.mix(th.sel_bg, th.str)), - colors.mix(th.sel_bg, colors.mix(th.sel_bg, accent2)), - }; -} - -/// The ink over each button's sweep. -pub fn buttonInks(th: *const colors.LegacyTheme) [3][3]u8 { - return th.sweep_fg orelse @splat(th.sel_fg); +/// The rail's column in the theme's rail and thumb, and the column right +/// of it the page. +fn paintRail(c: *const colors.Chrome, s: *Surface, bar: pardes.Region) void { + s.fill(bar.rect.x, bar.rect.y, 1, bar.rect.h, .{ .bg = .{ .rgb = c.rail } }); + s.fill(bar.rect.x + 1, bar.rect.y, 1, bar.rect.h, .{ .bg = if (c.host_page) .default else .{ .rgb = c.page.ground } }); + s.fill(bar.rect.x, bar.rect.y + bar.thumb_y, 1, bar.thumb_h, .{ .bg = .{ .rgb = c.rail_thumb } }); } /// A pane's body, painted once. A file body with compact tree-sitter @@ -221,14 +212,7 @@ pub fn joinBody(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, if (layer.cursor) |cursor| if (cursor.y < viewport_rows) { s.cursor = .{ .x = body.rect.x + cursor.x, .y = body.rect.y + cursor.y, .bar = cursor.bar }; }; - const chrome = p.chromeTheme(); - const theme = p.theme(); - const pane_bg: Color = if (theme.bg) |c| .{ .rgb = c } else .default; - if (rail.rect.h > 0) { - s.fill(rail.rect.x, rail.rect.y, 1, rail.rect.h, .{ .bg = .{ .rgb = chrome.scroll_track } }); - s.fill(rail.rect.x + 1, rail.rect.y, 1, rail.rect.h, .{ .bg = pane_bg }); - s.fill(rail.rect.x, rail.rect.y + rail.thumb_y, 1, rail.thumb_h, .{ .bg = .{ .rgb = chrome.scroll_thumb } }); - } + if (rail.rect.h > 0) paintRail(p.chrome(), s, rail); } fn drawGutter(p: *Pardes, s: *Surface, pane: *Pane, r: pardes.Rect, tx: u16, tw: u16, body_h: u16, active: bool) void { @@ -239,12 +223,13 @@ fn drawGutter(p: *Pardes, s: *Surface, pane: *Pane, r: pardes.Rect, tx: u16, tw: const cur_line: i32 = if (active and typing_body) gcrow else std.math.minInt(i32); // the body's first row, the way renderPane derives it const body_y = p.bodyTop(pane, r); - const context_bg = p.theme().tag_bg; + const chrome = p.chrome(); + // The context rows on the tag's ground, as a header. for (0..@min(pane.context_rows, body_h)) |context_row| { for (0..tw) |col| { const cell = s.at(tx + @as(u16, @intCast(col)), body_y + @as(u16, @intCast(context_row))); cell.default = false; - cell.style.bg = .{ .rgb = context_bg }; + cell.style.bg = .{ .rgb = chrome.tag[0].ground }; cell.style.font_role = .tagline; } } @@ -259,10 +244,7 @@ fn drawGutter(p: *Pardes, s: *Surface, pane: *Pane, r: pardes.Rect, tx: u16, tw: while (c < prefix_width and c < tw) : (c += 1) { const cell = s.at(tx + c, body_y + vr); cell.default = false; // paints blank gutter rows too - cell.style.fg = .{ .rgb = if (on_cursor) - p.theme().lineno_active orelse p.theme().lineno - else - p.theme().lineno }; + cell.style.fg = .{ .rgb = if (on_cursor) chrome.line_number_current else chrome.line_number }; cell.style.bold = on_cursor; } } @@ -280,7 +262,7 @@ fn drawWrapMarkers( ) void { if (tw <= panes.File.gutterWidth(pane) + 1) return; const body_y = p.bodyTop(pane, r); - const marker_fg = p.chromeTheme().lineno; + const marker_fg = p.chrome().line_number; var row: u16 = 0; while (row + 1 < pane.wrap_n and row + 1 < body_h) : (row += 1) { if (pane.wrap_line[row + 1] != pane.wrap_line[row] or pane.wrap_col[row] < 0) continue; @@ -292,21 +274,20 @@ fn drawWrapMarkers( } pub fn renderBody(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r: Rect, id: usize, active: bool, rail: ?pardes.Region) !void { - const th = p.theme(); - const chrome = p.chromeTheme(); + const c = p.chrome(); const tx = r.x + config.GUTTER; const tw = r.w - config.GUTTER; // Below the notice bands: they are stacked at the top of the body the // way tree-sitter context rows are, so the body starts under them // rather than being painted over by them. const body_y = p.bodyTop(pane, r); - const pane_bg: Color = if (th.bg) |c| .{ .rgb = c } else .default; - const page_rgb = th.bg orelse th.tag_bg; + // A theme that leaves its page to the host leaves it its text too. + const pane_bg: Color = if (c.host_page) .default else .{ .rgb = c.page.ground }; // body: emulator rows, prompt rows hidden outside tty mode const body_h = r.h -| pane.tag_rows; const body_bottom = r.h; const body_style: CellStyle = .{ - .fg = if (th.fg) |c| .{ .rgb = c } else .default, + .fg = if (c.host_page) .default else .{ .rgb = c.page.text }, .bg = pane_bg, }; const tz_body = tracy.zone(@src(), "bodyText"); @@ -319,7 +300,7 @@ pub fn renderBody(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane // the rows, which paint over it. const sweep = pane.sel[pardes.sel_slot]; if (sweep.state != .none and (sweep.state != .done or pardes.sel_slot == 0) and @min(sweep.r0, sweep.r1) < pane.tag_rows) - paintPointerSelection(p, s, pane, r, sweep, pane.tag_rows, th.sel_bg, th.sel_fg); + paintPointerSelection(p, s, pane, r, sweep, pane.tag_rows, c.sweeps[pardes.sel_slot].ground, c.sweeps[pardes.sel_slot].text); { // The rows themselves. `bodyText` above is only the string BUILD; // this is what writes it into the surface. @@ -363,16 +344,14 @@ pub fn renderBody(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane tz_color.end(); if (pane.isTerminal()) ansi.images(p, s, pane, id, tx, tw, body_y, body_h); - const sel_btn = buttonTints(th); if (p.look_hover_preview) |preview| { if (preview.pane == id and preview.serial == pane.serial) { // Preserve body ink, then let every real user selection below // win over this quiet affordance. - const preview_bg = colors.mix(page_rgb, colors.mix(page_rgb, th.sel_bg)); if (preview.file_word) |word| - panes.File.paintWordSelection(p, s, pane, r, word.row, word.lo, word.hi, preview_bg) + panes.File.paintWordSelection(p, s, pane, r, word.row, word.lo, word.hi, c.selection_secondary, null) else if (preview.sel) |sel| - paintPointerSelection(p, s, pane, r, sel, pane.tag_rows, preview_bg, null); + paintPointerSelection(p, s, pane, r, sel, pane.tag_rows, c.selection_secondary, null); } } const modal_hover = if (p.look_hover_preview) |preview| @@ -385,7 +364,7 @@ pub fn renderBody(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane // A select sweep over the tag is the tag's selection, painted there // in the tag's own selection colours. if (b == pardes.sel_slot and @min(sl.r0, sl.r1) < pane.tag_rows) continue; - paintPointerSelection(p, s, pane, r, sl, pane.tag_rows, sel_btn[b], buttonInks(th)[b]); + paintPointerSelection(p, s, pane, r, sl, pane.tag_rows, c.sweeps[b].ground, c.sweeps[b].text); } // A selecting prompt's live result (Prompt.zig), dimmed while its // field is no regex. @@ -408,12 +387,11 @@ pub fn renderBody(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane } else pane.body.sels[si]; const bnd = edit.cellBounds(sr); const hover_only = primary and modal_hover and pane.body.mode != .normal and !preview; - const bg = if (hover_only or (selecting != null and selecting.?.dim)) - colors.mix(page_rgb, colors.mix(page_rgb, th.sel_bg)) - else if (primary) - th.sel_bg - else - colors.mix(th.sel_bg, page_rgb); + // The primary on the selection in its ink; every other range, + // a hover and a dimmed preview on its faint half, the text's + // own ink kept (R7). + const full = primary and !hover_only and !(selecting != null and selecting.?.dim); + const bg = if (full) c.page.selection.ground else c.selection_secondary; var vr: i32 = 0; while (vr + @as(i32, pane.tag_rows) < @as(i32, body_bottom)) : (vr += 1) { const w = pane.wrapAt(p.settings.tab, vr); @@ -452,7 +430,7 @@ pub fn renderBody(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane @as(i32, tw) - 1; const col: i32 = @max(cstart, vpfx); const end = @min(cend + 1, tw); - if (col < end) s.tint(tx + @as(u16, @intCast(col)), body_y + @as(u16, @intCast(vr)), @intCast(end - col), bg, if (hover_only) null else th.sel_fg); + if (col < end) s.tint(tx + @as(u16, @intCast(col)), body_y + @as(u16, @intCast(vr)), @intCast(end - col), bg, if (full) c.page.selection.text else null); } if (primary and !preview and !hover_only) continue; // the hardware cursor IS the primary's if (hover_only) continue; // quiet preview preserves the source ink @@ -473,8 +451,8 @@ pub fn renderBody(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane if (crow >= pane.tag_rows and crow < @as(i32, body_bottom) and ccol >= vpfx and ccol < tw) { const cell = s.at(tx + @as(u16, @intCast(ccol)), body_y + @as(u16, @intCast(crow - pane.tag_rows))); cell.default = false; - cell.style.bg = .{ .rgb = th.sel_fg }; - cell.style.fg = .{ .rgb = th.sel_bg }; + cell.style.bg = .{ .rgb = c.page.selection.text }; + cell.style.fg = .{ .rgb = c.page.selection.ground }; } } } @@ -492,7 +470,7 @@ pub fn renderBody(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane if (pane.jump.items.len > 0) labels: { const flat = edit.flatSurface(p.editor(), &pane.body) catch break :labels; const letters = config.jump_label_alphabet; - const style: CellStyle = .{ .fg = .{ .rgb = th.sel_fg }, .bg = .{ .rgb = th.sel_bg }, .bold = true }; + const style: CellStyle = .{ .fg = .{ .rgb = c.page.selection.text }, .bg = .{ .rgb = c.page.selection.ground }, .bold = true }; for (pane.jump.items, 0..) |word, i| { if (pane.jump_first) |first| if (i / letters.len != first) continue; var at = @min(word.anchor, word.head); @@ -563,14 +541,10 @@ pub fn renderBody(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane if (pane.file != null) try pardes.Prompt.ghosts(p, s, arena, pane, r, body_h); // A code action's edit, previewed (Pick.zig). if (pane.file != null) try pardes.Pick.ghosts(p, s, arena, pane, r, body_h); - if (rail) |bar| if (bar.rect.h > 0) { - // The rail covers the notice bands too: nothing else paints those - // two gutter columns, so a gap there keeps the frame-wide border - // fill and reads as a notch cut out of the scrollbar. - s.fill(bar.rect.x, bar.rect.y, 1, bar.rect.h, .{ .bg = .{ .rgb = chrome.scroll_track } }); - s.fill(bar.rect.x + 1, bar.rect.y, 1, bar.rect.h, .{ .bg = pane_bg }); - s.fill(bar.rect.x, bar.rect.y + bar.thumb_y, 1, bar.thumb_h, .{ .bg = .{ .rgb = chrome.scroll_thumb } }); - }; + // The rail covers the notice bands too: nothing else paints those two + // gutter columns, so a gap there keeps the frame-wide border fill and + // reads as a notch cut out of the scrollbar. + if (rail) |bar| if (bar.rect.h > 0) paintRail(c, s, bar); } /// A message at the lines it names, drawn and never written (SPEC §10.2, @@ -585,9 +559,8 @@ pub fn renderBody(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane fn messageGhosts(p: *Pardes, s: *Surface, pane: *Pane, tx: u16, tw: u16, body_y: u16, body_h: u16) void { const Messages = pardes.Messages; const f = pane.file.?; - const chrome = p.chromeTheme(); - const th = p.theme(); - const pane_bg: Color = if (th.bg) |c| .{ .rgb = c } else .default; + const page = &p.chrome().page; + const pane_bg: Color = if (p.chrome().host_page) .default else .{ .rgb = page.ground }; const Hit = struct { line: usize, said: *const Messages.Said, place: *const Messages.Place }; var hits: [Messages.max_live * Messages.Said.max_places]Hit = undefined; var n: usize = 0; @@ -615,7 +588,7 @@ fn messageGhosts(p: *Pardes, s: *Surface, pane: *Pane, tx: u16, tw: u16, body_y: if (at < tw) { var buf: [160]u8 = undefined; const words = std.fmt.bufPrint(&buf, "{s} {s}", .{ hit.said.kind.glyph(), hit.place.text.slice() }) catch &buf; - _ = s.print(tx + @as(u16, @intCast(at)), body_y + row, @intCast(tw - at), words, .{ .fg = .{ .rgb = Messages.ink(chrome, hit.said.kind) }, .bg = pane_bg }); + _ = s.print(tx + @as(u16, @intCast(at)), body_y + row, @intCast(tw - at), words, .{ .fg = .{ .rgb = Messages.inkOn(page, hit.said.kind) }, .bg = pane_bg }); } if (pane.ghost_rows > 0 and row == pane.ghost_at) detail = hit.said; } @@ -634,7 +607,7 @@ fn messageGhosts(p: *Pardes, s: *Surface, pane: *Pane, tx: u16, tw: u16, body_y: for (said.detail[0..k], 0..) |*text, i| { const y = body_y + under_row + 1 + @as(u16, @intCast(i)); s.fill(tx, y, tw, 1, .{ .bg = pane_bg }); - if (gutter + 2 < tw) _ = s.print(tx + gutter + 2, y, tw - gutter - 2, text.slice(), .{ .fg = .{ .rgb = Messages.ink(chrome, said.kind) }, .bg = pane_bg }); + if (gutter + 2 < tw) _ = s.print(tx + gutter + 2, y, tw - gutter - 2, text.slice(), .{ .fg = .{ .rgb = Messages.inkOn(page, said.kind) }, .bg = pane_bg }); } } @@ -682,7 +655,7 @@ fn drawnRow(p: *Pardes, arena: std.mem.Allocator, id: usize, row: usize) !?[]con /// number (the one a prompt's current place has, Prompt.paintGutter), on /// each row it wraps onto. fn paintLanding(p: *Pardes, s: *Surface, pane: *Pane, r: Rect, tx: u16, tw: u16, body_h: u16, line: usize) void { - const roles = &p.chromeTheme().roles; + const c = p.chrome(); const gutter = File.gutterWidth(pane); const number = gutter -| File.laneCells(pane) -| pane.layers.heat -| 1; const body_y = p.bodyTop(pane, r); @@ -693,18 +666,19 @@ fn paintLanding(p: *Pardes, s: *Surface, pane: *Pane, r: Rect, tx: u16, tw: u16, for (gutter..tw) |x| { const cell = s.at(tx + @as(u16, @intCast(x)), body_y + vr); cell.default = false; - cell.style.bg = .{ .rgb = roles.hit }; + cell.style.bg = .{ .rgb = c.hit }; } if (gutter > 0 and w.at == 0) { var style = s.at(tx + number, body_y + vr).style; - style.fg = .{ .rgb = roles.key }; + style.fg = .{ .rgb = c.page.key }; s.set(tx + number, body_y + vr, "▸", style); } } } -/// The landing line's matched span (a Grep's match at the row's column) on -/// the current hit's ground, over the places lit on it (UX D7). +/// The landing line's matched span (a Grep's match at the row's column) as +/// the current hit, solid in the hue with the page's ink, over the places +/// lit on it (UX D7, R8). fn paintLandingSpan(p: *Pardes, s: *Surface, pane: *Pane, r: Rect, f: *panes.File.State, line: usize) void { if (!pane.places.shows(pane)) return; const hits = pane.places.hits.items; @@ -713,7 +687,7 @@ fn paintLandingSpan(p: *Pardes, s: *Surface, pane: *Pane, r: Rect, f: *panes.Fil var i = panes.Places.firstFrom(hits, ls); while (i < hits.len and hits[i].start <= caret) : (i += 1) { if (hits[i].end <= caret) continue; - File.paintWordSelection(p, s, pane, r, @intCast(line), @intCast(hits[i].start - ls), @intCast(hits[i].end - ls), p.chromeTheme().roles.hit_current); + File.paintWordSelection(p, s, pane, r, @intCast(line), @intCast(hits[i].start - ls), @intCast(hits[i].end - ls), p.chrome().hit_current, p.chrome().hit_current_text); return; } } @@ -768,9 +742,7 @@ fn paintTargets(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, .hi = if (line == last) to - lineStart(f, line) else File.sourceLine(pane, @intCast(line)).len, .to_edge = line != last, }; - const th = p.theme(); - const page = th.bg orelse th.tag_bg; - paintSourceSelection(p, s, pane, r, rows, colors.mix(page, colors.mix(page, th.sel_bg)), null); + paintSourceSelection(p, s, pane, r, rows, p.chrome().selection_secondary, null); return; } if (cur.root != .goto and cur.root != .next and cur.root != .prev) return; @@ -796,7 +768,7 @@ fn paintTargets(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, // row's keys, as many as they hold, right-aligned to its last digit, // bold in the key ink on the gutter's ground. With no numbers, over // the line's first cells on the selection's ground. Never a shift. - const ink = p.chromeTheme().roles.key; + const ink = p.chrome().page.key; const number = File.gutterWidth(pane) -| File.laneCells(pane) -| pane.layers.heat -| 1; const cells = @min(if (number > 0) number else tw, tw); for (rows[0..n], 0..) |row, i| { @@ -811,7 +783,7 @@ fn paintTargets(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, for (rows[i..n], keys[i..n]) |other, key| { if (other != row) continue; if (x >= (if (number > 0) cells else shown)) break; - const bg = if (number > 0) s.at(tx + x, y).style.bg else pardes.Color{ .rgb = p.theme().sel_bg }; + const bg = if (number > 0) s.at(tx + x, y).style.bg else pardes.Color{ .rgb = p.chrome().page.selection.ground }; s.set(tx + x, y, bindings.keyName(key), .{ .fg = .{ .rgb = ink }, .bg = bg, .bold = true }); x += 1; } @@ -844,13 +816,14 @@ fn hoverGhosts(p: *Pardes, s: *Surface, pane: *Pane, tx: u16, tw: u16, body_y: u const from = @as(usize, body_y + dst - k) * s.cols + tx; @memcpy(s.cells[to..][0..tw], s.cells[from..][0..tw]); } - const th = p.theme(); - const style: CellStyle = .{ .fg = .{ .rgb = th.tag_fg }, .bg = .{ .rgb = th.tag_bg } }; + // On the tag's ground in its ink, as a header. + const tag = &p.chrome().tag[0]; + const style: CellStyle = .{ .fg = .{ .rgb = tag.text }, .bg = .{ .rgb = tag.ground } }; const gutter: u16 = File.gutterWidth(pane); var lines = std.mem.splitScalar(u8, text, '\n'); for (0..k) |i| { const y = body_y + at + 1 + @as(u16, @intCast(i)); - s.fill(tx, y, tw, 1, .{ .bg = .{ .rgb = th.tag_bg } }); + s.fill(tx, y, tw, 1, .{ .bg = .{ .rgb = tag.ground } }); if (gutter + 2 < tw) _ = s.print(tx + gutter + 2, y, tw - gutter - 2, lines.next() orelse "", style); } } @@ -865,9 +838,8 @@ fn renameGhosts(p: *Pardes, s: *Surface, pane: *Pane, tx: u16, tw: u16, body_y: const old = @import("lsp/Ask.zig").renamedWord(pane) orelse return; const new = p.view().tag_state.field.text(); const tab = p.settings.tab; - const chrome = p.chromeTheme(); - const th = p.theme(); - const added: CellStyle = .{ .fg = .{ .rgb = chrome.diagnostic_hint }, .bg = if (th.bg) |c| .{ .rgb = c } else .default, .bold = true }; + const chrome = p.chrome(); + const added: CellStyle = .{ .fg = .{ .rgb = chrome.page.severity[3] }, .bg = if (chrome.host_page) .default else .{ .rgb = chrome.page.ground }, .bold = true }; const wide: u16 = @intCast(@min(File.displayWidth(tab, new), tw)); const gutter: i32 = File.gutterWidth(pane); var row: u16 = pane.context_rows; @@ -894,7 +866,7 @@ fn renameGhosts(p: *Pardes, s: *Surface, pane: *Pane, tx: u16, tw: u16, body_y: while (c < c1) : (c += 1) { const cell = s.at(tx + c, y); cell.style.strikethrough = true; - cell.style.fg = .{ .rgb = chrome.diagnostic_error }; + cell.style.fg = .{ .rgb = chrome.page.severity[0] }; } const x: u16 = @intCast(c1); if (x + wide < tw) { @@ -1193,6 +1165,12 @@ test "a build error is said where its cause is: the mark on its file's tag, its // elsewhere. try std.testing.expect(std.mem.indexOf(u8, rowText(s, body.x, body.y + 2, &buf), "three \u{2717} expected 2 argument(s), found 3") != null); try std.testing.expect(std.mem.indexOf(u8, rowText(s, body.x, body.y + 3, &buf), "four") != null); + // In the error's ink on the page (R9). + const mark = for (0..body.w) |i| { + const cell = s.at(body.x + @as(u16, @intCast(i)), body.y + 2); + if (std.mem.eql(u8, cell.grapheme(), "\u{2717}")) break cell; + } else return error.TestUnexpectedResult; + try std.testing.expectEqual(pardes.Color{ .rgb = p.chrome().page.severity[0] }, mark.style.fg); // The caret on line 3 and its detail asked for (K, UX D13): under the // line, the rows below two rows down. pane.body.cur_row = 2; @@ -1312,7 +1290,7 @@ test "a motion root's level paints its targets in place of their lines' numbers, try std.testing.expectEqualStrings("p", Field.of(s, gutter, body.y + 4, number, &buf)); const key = s.at(gutter + number - 1, body.y + 4); try std.testing.expectEqualStrings("p", key.grapheme()); - try std.testing.expectEqual(pardes.Color{ .rgb = p.chromeTheme().roles.key }, key.style.fg); + try std.testing.expectEqual(pardes.Color{ .rgb = p.chrome().page.key }, key.style.fg); try std.testing.expect(key.style.bold); try std.testing.expect(std.mem.indexOfScalar(u8, Field.of(s, gutter, body.y + 5, number, &buf), 'g') != null); try std.testing.expect(std.mem.indexOfAny(u8, Field.of(s, gutter, body.y + 5, number, &buf), "0123456789") == null); @@ -1417,3 +1395,79 @@ test "a message's detail unrolls only on request (UX D13): the caret passing its p.update(.{ .key = .{ .cp = 'K' } }); try std.testing.expectEqual(pardes.TagState.Kind.prompt, p.view().tag_state.kind); } + +test "the body's selections are one family (R7): the primary on the selection in its ink, another range on its faint half in the text's own ink, its head the selection reversed, a B2 sweep on the chrome's exec sweep" { + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 20 }); + defer p.deinit(); + colors.setThemeIndex(p, colors.themeIndex("orchard").?); + const pane = try p.setTestFile("alpha beta\ngamma delta\n"); + const id = p.view().active; + pane.focus = .body; + // `e` selects alpha, `C` copies it below: gamma the primary. + for ("eC") |c| p.update(.{ .key = .{ .cp = c, .text = &[_]u8{c} } }); + try std.testing.expectEqual(@as(i32, 1), pane.body.cur_row); + try std.testing.expect(pane.body.vsel.active and pane.body.nsel == 1); + var frame = std.heap.ArenaAllocator.init(std.testing.allocator); + defer frame.deinit(); + const c = p.chrome(); + const r = p.view().rects[id]; + const x = r.x + config.GUTTER + panes.File.gutterWidth(pane); + const y = p.bodyTop(pane, r); + var s = try p.render(frame.allocator()); + for (0..5) |i| { + const primary = s.at(x + @as(u16, @intCast(i)), y + 1).style; + try std.testing.expectEqual(pardes.Color{ .rgb = c.page.selection.ground }, primary.bg); + if (i < 4) try std.testing.expectEqual(pardes.Color{ .rgb = c.page.selection.text }, primary.fg); + const other = s.at(x + @as(u16, @intCast(i)), y).style; + if (i < 4) { + try std.testing.expectEqual(pardes.Color{ .rgb = c.selection_secondary }, other.bg); + try std.testing.expectEqual(pardes.Color{ .rgb = c.page.text }, other.fg); + } else { + try std.testing.expectEqual(pardes.Color{ .rgb = c.page.selection.text }, other.bg); + try std.testing.expectEqual(pardes.Color{ .rgb = c.page.selection.ground }, other.fg); + } + } + // B2 swept over beta, not let go: the exec sweep. + p.update(.{ .mouse = .{ .button = .middle, .kind = .press, .col = x + 6, .row = y } }); + p.update(.{ .mouse = .{ .button = .middle, .kind = .drag, .col = x + 9, .row = y } }); + _ = frame.reset(.retain_capacity); + s = try p.render(frame.allocator()); + for (6..10) |i| { + const swept = s.at(x + @as(u16, @intCast(i)), y).style; + try std.testing.expectEqual(pardes.Color{ .rgb = c.sweeps[1].ground }, swept.bg); + try std.testing.expectEqual(pardes.Color{ .rgb = c.sweeps[1].text }, swept.fg); + } +} + +test "the body's surfaces take every colour from the chrome: none reads a theme's own fields or the old views (DESIGN.md B6)" { + const sources = [_]struct { []const u8, []const u8 }{ + .{ "body_layer.zig", @embedFile("body_layer.zig") }, + .{ "Places.zig", @embedFile("Places.zig") }, + .{ "Query.zig", @embedFile("Query.zig") }, + .{ "Output.zig", @embedFile("Output.zig") }, + .{ "Tables.zig", @embedFile("Tables.zig") }, + .{ "File.zig", @embedFile("File.zig") }, + .{ "Prompt.zig", @embedFile("Prompt.zig") }, + .{ "Pick.zig", @embedFile("Pick.zig") }, + .{ "jj.zig", @embedFile("jj.zig") }, + .{ "ansi.zig", @embedFile("ansi.zig") }, + }; + var wrong: usize = 0; + for (sources) |source| { + const name, const text = source; + // The code, not its tests. + const code = text[0 .. std.mem.indexOf(u8, text, "\ntest \"") orelse text.len]; + // A theme is read for its name alone. + var at: usize = 0; + while (std.mem.indexOfPos(u8, code, at, "theme()")) |i| : (at = i + 1) { + if (std.mem.startsWith(u8, code[i + "theme()".len ..], ".name")) continue; + std.debug.print("{s}: a theme's own colours read at byte {d}\n", .{ name, i }); + wrong += 1; + } + for ([_][]const u8{ "chromeTheme()", "bodyChrome", ".roles", "Grounds", "LegacyTheme" }) |old| if (std.mem.indexOf(u8, code, old)) |i| { + std.debug.print("{s}: `{s}` at byte {d}\n", .{ name, old, i }); + wrong += 1; + }; + } + try std.testing.expectEqual(@as(usize, 0), wrong); +} diff --git a/core/colors.zig b/core/colors.zig index 315d1fc9..44a2d415 100644 --- a/core/colors.zig +++ b/core/colors.zig @@ -553,10 +553,13 @@ pub const Chrome = struct { selection_secondary: [3]u8, /// The pointer buttons' sweeps: select, exec, look (acme's meanings). sweeps: [3]Theme.Sweep, - /// Search: a hit's ground, and the current one's ground and ink. + /// Search: a hit's ground, and the current one's ground and ink; a + /// search's last places while its field is no regex, dimmed: the page + /// halfway toward the hit (as `selection_secondary` is the selection's). hit: [3]u8, hit_current: [3]u8, hit_current_text: [3]u8, + hit_faint: [3]u8, add: Diff, del: Diff, /// The Changes layer's lanes, a pin each (`lanes_len` of them), and @@ -726,6 +729,7 @@ pub const Chrome = struct { // ink (vim's IncSearch): room for it in every theme. c.hit_current = hold(hue, &.{page}, text_floor); c.hit_current_text = page; + c.hit_faint = mixOklab(page, c.hit, 0.5); // Every ground's inks; on the tags and the status row, the // tag's selection rebuilt on each where it stands too near it. @@ -1061,31 +1065,17 @@ pub fn synInk(th: *const LegacyTheme, sy: @import("syntax.zig").Syn) ?[3]u8 { } /// The grounds a style byte's high bits name (syntax.ground_add and the -/// rest) in a theme: a row added or removed on a ground a little way from -/// the page toward the theme's green or red (its own ANSI ones where it has -/// a palette), a stronger one, a faint one, and the row's marker in that -/// hue, pushed toward the ink until it reads on the row's ground. Syntax -/// colours are drawn over a ground unchanged. +/// rest) in a theme, for the library: its chrome's added and deleted rows +/// (R10). Syntax colours are drawn over a ground unchanged. pub const Grounds = struct { add: Ground, del: Ground, - pub const Ground = struct { row: [3]u8, emph: [3]u8, line: [3]u8, ink: [3]u8 }; + pub const Ground = Chrome.Diff; pub fn of(th: *const LegacyTheme) Grounds { - const page = th.bg orelse th.tag_bg; - const ink = th.fg orelse th.tag_fg; - const green: [3]u8 = if (th.palette) |pal| pal[2] else .{ 0x2e, 0xa0, 0x43 }; - const red: [3]u8 = if (th.palette) |pal| pal[1] else .{ 0xcf, 0x22, 0x2e }; - return .{ .add = ground(page, ink, green), .del = ground(page, ink, red) }; - } - - fn ground(page: [3]u8, ink: [3]u8, hue: [3]u8) Ground { - const row = mixOklab(page, hue, 0.18); - var marker = hue; - var step: usize = 0; - while (step < 4 and contrast(marker, row) < 3) : (step += 1) marker = mixOklab(marker, ink, 0.4); - return .{ .row = row, .emph = mixOklab(page, hue, 0.28), .line = mixOklab(page, hue, 0.07), .ink = marker }; + const c = Chrome.of(&.fromLegacy(th.*)); + return .{ .add = c.add, .del = c.del }; } /// The ground of a byte's hue, if it has one. @@ -1294,17 +1284,13 @@ pub const ChromeTheme = struct { border: [3]u8, empty_col: [3]u8, search_bg: [3]u8, - search_fg: [3]u8, tag_reading_bg: [3]u8, diagnostic_error: [3]u8, diagnostic_warning: [3]u8, - diagnostic_info: [3]u8, - diagnostic_hint: [3]u8, box: [3]u8, box_dim: [3]u8, column_box: [3]u8, column_box_dim: [3]u8, - lineno: [3]u8, scroll_track: [3]u8, scroll_thumb: [3]u8, roles: Roles, @@ -1342,18 +1328,14 @@ pub const ChromeTheme = struct { .border = separatorOf(th), .empty_col = th.empty_col orelse separatorOf(th), .search_bg = th.search_bg orelse th.sel_bg, - .search_fg = th.search_fg orelse th.sel_fg, .tag_reading_bg = reading, // A theme's error ink, else its palette's red (UX E3). .diagnostic_error = th.diagnostic_error orelse if (th.palette) |pal| pal[1] else (th.fg orelse th.tag_fg), .diagnostic_warning = th.diagnostic_warning orelse (th.fg orelse th.tag_fg), - .diagnostic_info = th.diagnostic_info orelse (th.fg orelse th.tag_fg), - .diagnostic_hint = th.diagnostic_hint orelse (th.fg orelse th.tag_fg), .box = th.box, .box_dim = th.box_dim, .column_box = th.column_box orelse th.num, .column_box_dim = th.column_box_dim orelse mix(th.column_box orelse th.num, th.tag_bg), - .lineno = th.lineno, .scroll_track = th.scroll_track, .scroll_thumb = th.scroll_thumb, .roles = .of(th, th.tag_bg, active_bg, reading), @@ -1387,10 +1369,6 @@ pub const Roles = struct { /// The letters a query matched: an ink, never a ground, 4.5:1 on every /// tag ground and on the selection. match: [3]u8, - /// The body's places and a preview's landing line, and the current - /// one (its matched span): grounds off the page, its ink on them 4.5:1. - hit: [3]u8, - hit_current: [3]u8, /// A message's ink by its kind (Messages.ink): 4.5:1 on the tags and /// the page. err: [3]u8, @@ -1403,8 +1381,6 @@ pub const Roles = struct { pub const rule_floor: f32 = 1.8; pub const rule_ceiling: f32 = 2.5; pub const ink_floor: f32 = 4.5; - pub const hit_floor: f32 = 1.5; - pub const hit_current_floor: f32 = 1.9; pub const reading_distance: f32 = 0.04; pub fn on(r: *const Roles, ground: TagGround) *const RoleInks { @@ -1436,20 +1412,6 @@ pub const Roles = struct { r.key = pushAway(th.box, &tag_grounds, ink_floor); r.match = pushAway(matchHue(th), &tag_grounds, ink_floor); const page = th.bg orelse null_page; - const body_ink = th.fg orelse th.tag_fg; - const dark = relativeLuminance(page) < 0.18; - // The theme's search ground where it stands off the page and the - // body reads on it; else the page a little way toward its hue (the - // warm accent's without one). The current one as far past the hit - // as 32 % is past 18 % (38 past 22 on a light page). - const hue = th.search_bg orelse th.num; - const own = th.search_bg != null and contrast(hue, page) >= hit_floor and contrast(body_ink, hue) >= ink_floor; - const at: f32 = if (own) 1 else if (dark) 0.18 else 0.22; - r.hit = if (own) hue else hitOf(page, hue, body_ink, at, hit_floor); - const past: f32 = if (dark) 0.32 / 0.18 else 0.38 / 0.22; - r.hit_current = hitOf(page, hue, body_ink, at * past, hit_current_floor); - // Never fainter than the hit, where the ink holds both short. - if (contrast(r.hit_current, page) < contrast(r.hit, page)) r.hit_current = r.hit; const message_grounds = [_][3]u8{ plain, focused, reading, page }; const ink = th.fg orelse th.tag_fg; r.err = pushAway(th.diagnostic_error orelse if (th.palette) |pal| pal[1] else ink, &message_grounds, ink_floor); @@ -1552,48 +1514,6 @@ fn selectionOf(own: [3]u8, ground: [3]u8, text: [3]u8) [3]u8 { return best; } -/// A ground off `page` toward `hue` at `t` (past 1, beyond the hue, as far -/// as the gamut goes), held where the body's `ink` reads on it at 4.5:1 -/// (or its own on the page, where that is less); on toward the hue, the -/// least way that stands off the page at `floor`, where the ink still -/// reads on it; else moved on toward the ink until it stands off the page -/// at `floor`, as far as the ink allows. -fn hitOf(page: [3]u8, hue: [3]u8, ink: [3]u8, t: f32, floor: f32) [3]u8 { - const a = toOklab(page); - const b = toOklab(hue); - const ink_floor = @min(Roles.ink_floor, contrast(ink, page)); - var k = t; - var c = fromOklab(.{ a[0] + (b[0] - a[0]) * k, a[1] + (b[1] - a[1]) * k, a[2] + (b[2] - a[2]) * k }); - while (contrast(ink, c) < ink_floor and k > 0) { - k -= t / 50; - c = fromOklab(.{ a[0] + (b[0] - a[0]) * k, a[1] + (b[1] - a[1]) * k, a[2] + (b[2] - a[2]) * k }); - } - // Found by halves, seven mixes: the nearer the hue, the further off - // the page (UX E7 7b: a landing line 1.5:1, its span 1.9:1). - if (contrast(c, page) < floor and k < 1 and contrast(hue, page) >= floor) { - var lo = k; - var hi: f32 = 1; - var far = hue; - for (0..7) |_| { - const mid = (lo + hi) / 2; - const m = fromOklab(.{ a[0] + (b[0] - a[0]) * mid, a[1] + (b[1] - a[1]) * mid, a[2] + (b[2] - a[2]) * mid }); - if (contrast(m, page) < floor) lo = mid else { - hi = mid; - far = m; - } - } - if (contrast(ink, far) >= ink_floor) c = far; - } - const start = c; - var step: f32 = 1; - while (contrast(c, page) < floor and step <= 50) : (step += 1) { - const next = mixOklab(start, ink, step / 100); - if (contrast(ink, next) < ink_floor) break; - c = next; - } - return c; -} - /// A reading pane's tag (UX DESIGN.md D4): the theme's own where it stands /// off the tag, else the tag shifted toward paper yellow by 0.04 in OKLab /// and lighter by half that on a dark tag (darker on a light), so it reads @@ -1791,7 +1711,6 @@ pub fn loadThemeFile(p: *Pardes, generation: u32, bytes: []const u8) bool { theme.name = view.name; p.theme_chrome = .of(&theme, &view); - p.body_chrome = .{ .theme = view, .chrome = p.theme_chrome }; const old = p.custom_theme; p.custom_theme = view; if (old) |theme_value| p.gpa.free(theme_value.name); @@ -1828,13 +1747,10 @@ fn inOldNames(source: [:0]const u8) bool { } /// The session's theme's chrome, at its start (Pardes.init, a Restore): -/// never one the window previews (`previewTheme`); the body's copy of it -/// (Core.bodyChrome's, keyed by the theme) made with it, not again at the -/// first frame. +/// never one the window previews (`previewTheme`). pub fn finishThemeInitialization(p: *Pardes) void { const theme = if (p.custom_theme) |*custom| custom else &legacy_themes[p.settings.theme]; p.theme_chrome = if (p.custom_theme != null) .fromTheme(theme) else .of(&themes[p.settings.theme], theme); - p.body_chrome = .{ .theme = theme.*, .chrome = p.theme_chrome }; } /// Themes near `name`, a line of them, for a Theme given a name there is @@ -1915,7 +1831,6 @@ pub fn previewTheme(p: *Pardes, index: ?usize) void { if (p.theme_preview) |had| if (had == i) return; p.theme_preview = @intCast(i); p.preview_chrome = .of(&themes[i], &legacy_themes[i]); - p.body_chrome = .{ .theme = legacy_themes[i], .chrome = p.preview_chrome }; } pub fn setThemeIndex(p: *Pardes, index: usize) void { @@ -1923,7 +1838,6 @@ pub fn setThemeIndex(p: *Pardes, index: usize) void { (p.custom_theme == null and p.theme_file_path.get().len == 0 and index == @as(usize, p.settings.theme))) return; p.theme_chrome = .of(&themes[index], &legacy_themes[index]); - p.body_chrome = .{ .theme = legacy_themes[index], .chrome = p.theme_chrome }; if (p.custom_theme) |theme_value| { p.custom_theme = null; p.gpa.free(theme_value.name); @@ -2131,9 +2045,8 @@ test "native themes keep text and UI roles readable on their own surfaces" { const chrome = ChromeTheme.fromTheme(&th); const minimum: f32 = if (std.mem.eql(u8, name, "ink") or std.mem.eql(u8, name, "daybreak")) 7 else 4.5; const text_colors = [_][3]u8{ - th.fg.?, th.kw, th.str, th.num, th.comment, - chrome.diagnostic_error, chrome.diagnostic_warning, chrome.diagnostic_info, chrome.diagnostic_hint, - }; + th.fg.?, th.kw, th.str, th.num, th.comment, + } ++ chrome.resolved.page.severity; for (text_colors) |fg| try std.testing.expect(contrast(fg, th.bg.?) >= minimum); // Gutters are orientation aids, not source text: stay visible without // competing with comments or pulling attention away from the body. @@ -2153,7 +2066,7 @@ test "native themes keep text and UI roles readable on their own surfaces" { try std.testing.expect(contrast(chrome.tag_active_bg, th.tag_bg) <= 1.6); try std.testing.expect(contrast(chrome.tag_active_fg, th.tag_fg) <= 1.6); try std.testing.expect(contrast(th.sel_fg, th.sel_bg) >= minimum); - try std.testing.expect(contrast(chrome.search_fg, chrome.search_bg) >= minimum); + try std.testing.expect(contrast(chrome.resolved.hit_current_text, chrome.resolved.hit_current) >= Chrome.text_floor); // ANSI black can intentionally match the page (for backgrounds). All // other ANSI foregrounds, including bright black, remain legible. for (th.palette.?[1..]) |fg| try std.testing.expect(contrast(fg, th.bg.?) >= minimum); @@ -2219,6 +2132,7 @@ test "line numbers stay quiet without a current-line tag background" { custom.lineno = .{ 70, 70, 70 }; custom.lineno_active = .{ 95, 95, 95 }; p.custom_theme = custom; + finishThemeInitialization(p); p.sync(); const x = p.view().rects[0].x + config.GUTTER; const y = p.view().rects[0].y + BOX_H; @@ -2228,10 +2142,13 @@ test "line numbers stay quiet without a current-line tag background" { try std.testing.expectEqual(Color{ .rgb = custom.bg.? }, surface.at(x, y).style.bg); try std.testing.expect(surface.at(x, y).style.bold); try std.testing.expect(!surface.at(x, y + 1).style.bold); - // Old ThemeFile palettes need no new field, and do not regain the block. + // Old ThemeFile palettes need no new field: the current number is the + // text toward the page to 4.5:1 (R12), and the block not regained. p.custom_theme.?.lineno_active = null; + finishThemeInitialization(p); const fallback = try p.render(p.scratch.allocator()); - try std.testing.expectEqual(Color{ .rgb = .{ 70, 70, 70 } }, fallback.at(x, y).style.fg); + try std.testing.expectEqual(Color{ .rgb = p.chrome().line_number_current }, fallback.at(x, y).style.fg); + try std.testing.expect(contrast(p.chrome().line_number_current, custom.bg.?) >= Chrome.text_floor - 0.05); try std.testing.expectEqual(Color{ .rgb = custom.bg.? }, fallback.at(x, y).style.bg); try std.testing.expect(fallback.at(x, y).style.bold); // Moving the caret clears the previous cue; editing the tag parks it. @@ -2374,7 +2291,6 @@ test "every theme's walk UI roles meet their floors on every ground they are dra const chrome = ChromeTheme.fromTheme(th); const r = &chrome.roles; const page = th.bg orelse null_page; - const body_ink = th.fg orelse th.tag_fg; const tags = [_][3]u8{ r.tag[0].ground, r.tag[1].ground, r.tag[2].ground, r.selected[0].ground, r.selected[1].ground, r.selected[2].ground, r.selected[3].ground }; const messages = [_][3]u8{ r.tag[0].ground, r.tag[1].ground, r.tag[2].ground, page }; for (r.tag ++ r.selected ++ [1]RoleInks{r.notice}) |inks| { @@ -2401,15 +2317,6 @@ test "every theme's walk UI roles meet their floors on every ground they are dra try checks.append(a, .{ .what = "reading", .got = oklabDistance(toOklab(chrome.tag_reading_bg), toOklab(th.tag_bg)), .floor = Roles.reading_distance }); for ([_][3]u8{ th.tag_fg, th.tag_active_fg orelse th.tag_fg }) |ink| try checks.append(a, .{ .what = "text on reading", .got = contrast(ink, chrome.tag_reading_bg), .floor = @min(7, contrast(ink, th.tag_bg)) - 0.02 }); - const ink_floor = @min(Roles.ink_floor, contrast(body_ink, page)); - // A preview's landing line 1.5:1 off the page, its matched span (the - // current hit) a step stronger, 1.9:1 (UX E7 7b: 1.29 read as faint). - for ([_][3]u8{ r.hit, r.hit_current }, [_]f32{ 1.5, 1.9 }) |ground, floor| { - const on = contrast(body_ink, ground); - try checks.append(a, .{ .what = "hit", .got = contrast(ground, page), .floor = if (on < ink_floor + 0.3) 0 else floor }); - try checks.append(a, .{ .what = "ink on hit", .got = on, .floor = ink_floor - 0.01 }); - } - try checks.append(a, .{ .what = "current over hit", .got = contrast(r.hit_current, page) - contrast(r.hit, page), .floor = 0 }); for (checks.items) |c| if (c.got < c.floor - 0.005) { failed += 1; std.debug.print("{s}: {s} {d:.2} under {d:.2}\n", .{ th.name, c.what, c.got, c.floor }); diff --git a/core/draw.zig b/core/draw.zig index 7f178bfb..e90535b5 100644 --- a/core/draw.zig +++ b/core/draw.zig @@ -842,8 +842,8 @@ fn renderHeaderLayer(p: *Pardes, layer: *pardes.Layer, kind: TagKind, id: u16, v var col = panes.File.rawDisplayCol(p.settings.tab, shown, @max(swept.lo, start) - start) -| scroll; const stop = panes.File.rawDisplayCol(p.settings.tab, shown, @min(swept.hi, end) - start) -| scroll; while (col < stop and col < columns) : (col += 1) { - surface.at(@intCast(col), 0).style.bg = .{ .rgb = body_layer.buttonTints(p.theme())[button] }; - surface.at(@intCast(col), 0).style.fg = .{ .rgb = body_layer.buttonInks(p.theme())[button] }; + surface.at(@intCast(col), 0).style.bg = .{ .rgb = p.chrome().sweeps[button].ground }; + surface.at(@intCast(col), 0).style.fg = .{ .rgb = p.chrome().sweeps[button].text }; } } } else |_| {}; @@ -1221,12 +1221,11 @@ fn paintPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, body_layer.paintPointerSelection(p, s, pane, r, sel, 0, preview_bg, null); }; } - const sel_btn = body_layer.buttonTints(th); - const sel_ink = body_layer.buttonInks(th); + const sweeps = &p.chrome().sweeps; for (pane.sel, 0..) |selection, button| { if (selection.state == .none or (selection.state == .done and button != 0)) continue; if (button == pardes.sel_slot or @min(selection.r0, selection.r1) >= rows) continue; - body_layer.paintPointerSelection(p, s, pane, r, selection, 0, sel_btn[button], sel_ink[button]); + body_layer.paintPointerSelection(p, s, pane, r, selection, 0, sweeps[button].ground, sweeps[button].text); } } diff --git a/core/look.zig b/core/look.zig index 41c59cf3..d9dfe0e1 100644 --- a/core/look.zig +++ b/core/look.zig @@ -2134,8 +2134,9 @@ test "Look hover waits without mutating the pane and input cancels it" { _ = frame.reset(.retain_capacity); const surface = try p.render(frame.allocator()); + // On the selection's faint half (R7); a tag's (below) is the tags' own. + try std.testing.expectEqual(Color{ .rgb = p.chrome().selection_secondary }, surface.at(word_x, body_y).style.bg); const expected_bg = colors.mix(p.theme().bg orelse p.theme().tag_bg, colors.mix(p.theme().bg orelse p.theme().tag_bg, p.theme().sel_bg)); - try std.testing.expectEqual(Color{ .rgb = expected_bg }, surface.at(word_x, body_y).style.bg); // Background traffic in another pane does not change the text or geometry // under this pointer and must not strand a stationary hover unarmed. diff --git a/core/root.zig b/core/root.zig index 11cb5058..e07cbed6 100644 --- a/core/root.zig +++ b/core/root.zig @@ -764,11 +764,11 @@ test "what core/ asks of the machine is where the list says, with why: a new lin /// state did not make it diverged a client: Pane.notices, then Tables' /// reading, 2026-11-19). A file, its names, the reason. const kept_out = [_]struct { []const u8, []const u8, []const u8 }{ - .{ "Core.zig", "surface facts frames own_frames theme_chrome frame_arena scratch echo undrawn", "the frame's own and the views drawn here: written by frames (and chrome by a theme's step), read by frames and the runner; no step reads them" }, + .{ "Core.zig", "surface facts frames own_frames theme_chrome frame_arena scratch echo undrawn", "the frame's own and the views drawn here: written by frames (and chrome by a theme's step), read by frames and the runner, and the chrome by a query's rows for colours only (out of their digest, locations.Row.digest); no step's outcome reads them" }, .{ "Core.zig", "needs_frame", "whether to draw: steps set it, the loop reads it; no step's outcome reads it" }, .{ "Core.zig", "effects effects_head effects_len in_q in_head in_len opts dump_out dump_export tape", "this process's queues, options and tape, drained or set by its host" }, .{ "Core.zig", "shell_rows", "a terminal's rows as read here, swept at every update; the terminal's own digest covers its active area, not its history (Term.zig `calls`)" }, - .{ "Core.zig", "diff_output locations_cache tty_filter_palette body_chrome", "caches of pure functions of their key (a text, a theme): a step finds what it would make; a query row's colours from them are out of its digest (locations.Row.digest), and what a step asks a worker to paint is never decided by them (Stream.paintRows)" }, + .{ "Core.zig", "diff_output locations_cache tty_filter_palette", "caches of pure functions of their key (a text, a theme): a step finds what it would make; a query row's colours from them are out of its digest (locations.Row.digest), and what a step asks a worker to paint is never decided by them (Stream.paintRows)" }, .{ "Core.zig", "retired_panes", "panes torn down this step, freed at its end" }, .{ "Core.zig", "theme_preview preview_chrome", "a themes picker's preview (colors.previewTheme): made from the live picker's cursor, in the digest with it, after every step (Pick.produceAll) and gone at its roll-up; a step reading a theme meanwhile reads the one its own state previews" }, .{ "Core.zig", "multi_first multi_stop multi_index multi_count exec_depth exec_column", "a step's own: set by a key's replay across the ranges (normal.replaySels) and a word's run (exec.zig), each put back before the step ends; between steps what `init` makes, so a load takes them as it makes them (a dump's said 2^30 ranges once: a yank sized its register by it)" }, diff --git a/test/output.zig b/test/output.zig index 77de7649..f2a35c01 100644 --- a/test/output.zig +++ b/test/output.zig @@ -41,7 +41,7 @@ test "search tint survives wrapping and theme changes while selections remain au const surface = try p.render(frame.allocator()); var marked: usize = 0; for (surface.cells) |cell| { - if (std.meta.eql(cell.style.bg, pardes.Color{ .rgb = p.theme().search_bg.? })) marked += 1; + if (std.meta.eql(cell.style.bg, pardes.Color{ .rgb = p.chrome().hit })) marked += 1; } try std.testing.expectEqual(@as(usize, 3), marked); _ = frame.reset(.retain_capacity); @@ -50,8 +50,8 @@ test "search tint survives wrapping and theme changes while selections remain au const light = try p.render(frame.allocator()); var light_matches: usize = 0; for (light.cells) |cell| { - if (!std.meta.eql(cell.style.bg, pardes.Color{ .rgb = p.theme().search_bg.? })) continue; - try std.testing.expectEqualDeep(pardes.Color{ .rgb = p.theme().search_fg.? }, cell.style.fg); + if (!std.meta.eql(cell.style.bg, pardes.Color{ .rgb = p.chrome().hit })) continue; + try std.testing.expectEqualDeep(pardes.Color{ .rgb = p.chrome().page.text }, cell.style.fg); light_matches += 1; } try std.testing.expectEqual(@as(usize, 3), light_matches); @@ -61,7 +61,7 @@ test "search tint survives wrapping and theme changes while selections remain au pane.body.vsel = .{ .active = true, .row = 0, .col = pane.body.cur_col - 2, .explicit = true }; const selected = try p.render(frame.allocator()); for (selected.cells) |cell| - try std.testing.expect(!std.meta.eql(cell.style.bg, pardes.Color{ .rgb = p.theme().search_bg.? })); + try std.testing.expect(!std.meta.eql(cell.style.bg, pardes.Color{ .rgb = p.chrome().hit })); try std.testing.expectEqualStrings(text, pane.file.?.content); } } @@ -128,15 +128,15 @@ test "location producers retain rendered location match and diagnostic styles" { var frame = std.heap.ArenaAllocator.init(p.gpa); defer frame.deinit(); const surface = try p.render(frame.allocator()); - const chrome = pardes.ChromeTheme.fromTheme(p.theme()); - try std.testing.expectEqual(pardes.Color{ .rgb = chrome.lineno }, outputCell(p, surface, id, 0).style.fg); + const chrome = p.chrome(); + try std.testing.expectEqual(pardes.Color{ .rgb = chrome.line_number }, outputCell(p, surface, id, 0).style.fg); const start = file.location_rows[0].code_start; const first = outputCell(p, surface, id, start); if (diagnostic) { - try std.testing.expectEqual(pardes.Color{ .rgb = chrome.diagnostic_warning }, first.style.fg); + try std.testing.expectEqual(pardes.Color{ .rgb = chrome.page.severity[1] }, first.style.fg); try std.testing.expect(first.style.bold); } else if (origin == .search or origin == .cmd) { - try std.testing.expectEqual(pardes.Color{ .rgb = chrome.search_bg }, first.style.bg); + try std.testing.expectEqual(pardes.Color{ .rgb = chrome.hit }, first.style.bg); } if (!diagnostic) { const number = start + std.mem.indexOf(u8, code, "42").?; @@ -1145,10 +1145,10 @@ test "LSP occurrence tint follows the supplied source span through context" { var frame = std.heap.ArenaAllocator.init(p.gpa); defer frame.deinit(); const surface = try p.render(frame.allocator()); - const chrome = pardes.ChromeTheme.fromTheme(p.theme()); + const chrome = p.chrome(); var marked: usize = 0; for (surface.cells) |cell| { - if (!std.meta.eql(cell.style.bg, pardes.Color{ .rgb = chrome.search_bg })) continue; + if (!std.meta.eql(cell.style.bg, pardes.Color{ .rgb = chrome.hit })) continue; try std.testing.expect(cell.text[0] == 'f' or cell.text[0] == 'o'); marked += 1; } @@ -1294,10 +1294,10 @@ test "stacked search and LSP results retain source tint navigation and dump owne var arena = std.heap.ArenaAllocator.init(p.gpa); defer arena.deinit(); const surface = try p.render(arena.allocator()); - const chrome = pardes.ChromeTheme.fromTheme(p.theme()); + const chrome = p.chrome(); var marked: usize = 0; for (surface.cells) |cell| { - if (!std.meta.eql(cell.style.bg, pardes.Color{ .rgb = chrome.search_bg })) continue; + if (!std.meta.eql(cell.style.bg, pardes.Color{ .rgb = chrome.hit })) continue; try std.testing.expect(cell.text[0] == 'f' or cell.text[0] == 'o'); marked += 1; } diff --git a/test/panes.zig b/test/panes.zig index 3acd5769..8f0a352c 100644 --- a/test/panes.zig +++ b/test/panes.zig @@ -2056,7 +2056,7 @@ const OutputTests = struct { const y = body_y + @as(u16, @intCast(index)); const cell = surface.at(x, y); try std.testing.expect(!cell.style.bold); - try std.testing.expectEqual(pardes.Color{ .rgb = pardes.ChromeTheme.fromTheme(p.theme()).lineno }, cell.style.fg); + try std.testing.expectEqual(pardes.Color{ .rgb = p.chrome().line_number }, cell.style.fg); } // Old dumps and edited outputs still identify both context prefixes. panes.File.setContent(p, file, try p.gpa.dupe(u8, "| old.zig:1 old\n new.zig:2 new\nmain.zig:42 ***\t\tmatch\n")); diff --git a/test/snapshots/callstack.golden b/test/snapshots/callstack.golden index d1140d0c..58e04798 100644 --- a/test/snapshots/callstack.golden +++ b/test/snapshots/callstack.golden @@ -51,18 +51,18 @@ |8: 0-0 d,#608269, 1-4 d,#0d1410, 5-10 #59675c,#0d1410, 11-14 #c9a7ed,#0d1410, 15-109 #e5eee5,#0d1410, |9: 0-0 d,#152019, 1-4 d,#0d1410, 5-6 #59675c,#0d1410, 7-109 #e5eee5,#0d1410, |10: 0-1 d,#add38a, 2-32 #becfc4,#314738, 33-43 #dfbce5,#314738, 44-109 #becfc4,#314738, -|11: 0-0 d,#608269, 1-1 d,#0d1410, 2-4 d,#0d1410,b 5-6 #616f64,#0d1410,b 7-11 #92d1de,#0d1410, 12-109 #59675c,#0d1410, -|12: 0-0 d,#608269, 1-4 d,#0d1410, 5-9 #59675c,#0d1410, 10-11 #92d1de,#0d1410, 12-14 #c9a7ed,#0d1410, 15-109 #e5eee5,#0d1410, -|13: 0-0 d,#608269, 1-4 d,#0d1410, 5-9 #59675c,#0d1410, 10-12 #92d1de,#0d1410, 13-109 #59675c,#0d1410, -|14: 0-0 d,#608269, 1-4 d,#0d1410, 5-9 #59675c,#0d1410, 10-12 #92d1de,#0d1410, 13-16 #c9a7ed,#0d1410, 17-109 #e5eee5,#0d1410, -|15: 0-0 d,#608269, 1-4 d,#0d1410, 5-9 #59675c,#0d1410, 10-12 #92d1de,#0d1410, 13-109 #59675c,#0d1410, -|16: 0-0 d,#608269, 1-4 d,#0d1410, 5-9 #59675c,#0d1410, 10-12 #92d1de,#0d1410, 13-16 #c9a7ed,#0d1410, 17-109 #e5eee5,#0d1410, -|17: 0-0 d,#608269, 1-4 d,#0d1410, 5-9 #59675c,#0d1410, 10-14 #92d1de,#0d1410, 15-109 #59675c,#0d1410, -|18: 0-0 d,#608269, 1-4 d,#0d1410, 5-12 #59675c,#0d1410, 13-14 #92d1de,#0d1410, 15-17 #c9a7ed,#0d1410, 18-109 #e5eee5,#0d1410, -|19: 0-0 d,#608269, 1-4 d,#0d1410, 5-12 #59675c,#0d1410, 13-15 #92d1de,#0d1410, 16-109 #59675c,#0d1410, -|20: 0-0 d,#608269, 1-3 d,#0d1410, 4-12 #59675c,#0d1410, 13-15 #92d1de,#0d1410, 16-19 #c9a7ed,#0d1410, 20-23 #e5eee5,#0d1410, 24-26 #f7e4a5,#5e4923, 27-109 #e5eee5,#0d1410, -|21: 0-0 d,#608269, 1-3 d,#0d1410, 4-12 #59675c,#0d1410, 13-15 #92d1de,#0d1410, 16-109 #59675c,#0d1410, -|22: 0-0 d,#608269, 1-3 d,#0d1410, 4-15 #59675c,#0d1410, 16-19 #c9a7ed,#0d1410, 20-23 #e5eee5,#0d1410, 24-26 #f7e4a5,#5e4923, 27-109 #e5eee5,#0d1410, +|11: 0-0 d,#608269, 1-1 d,#0d1410, 2-4 d,#0d1410,b 5-6 #616f64,#0d1410,b 7-11 #666f68,#0d1410, 12-109 #59675c,#0d1410, +|12: 0-0 d,#608269, 1-4 d,#0d1410, 5-9 #59675c,#0d1410, 10-11 #666f68,#0d1410, 12-14 #c9a7ed,#0d1410, 15-109 #e5eee5,#0d1410, +|13: 0-0 d,#608269, 1-4 d,#0d1410, 5-9 #59675c,#0d1410, 10-12 #666f68,#0d1410, 13-109 #59675c,#0d1410, +|14: 0-0 d,#608269, 1-4 d,#0d1410, 5-9 #59675c,#0d1410, 10-12 #666f68,#0d1410, 13-16 #c9a7ed,#0d1410, 17-109 #e5eee5,#0d1410, +|15: 0-0 d,#608269, 1-4 d,#0d1410, 5-9 #59675c,#0d1410, 10-12 #666f68,#0d1410, 13-109 #59675c,#0d1410, +|16: 0-0 d,#608269, 1-4 d,#0d1410, 5-9 #59675c,#0d1410, 10-12 #666f68,#0d1410, 13-16 #c9a7ed,#0d1410, 17-109 #e5eee5,#0d1410, +|17: 0-0 d,#608269, 1-4 d,#0d1410, 5-9 #59675c,#0d1410, 10-14 #666f68,#0d1410, 15-109 #59675c,#0d1410, +|18: 0-0 d,#608269, 1-4 d,#0d1410, 5-12 #59675c,#0d1410, 13-14 #666f68,#0d1410, 15-17 #c9a7ed,#0d1410, 18-109 #e5eee5,#0d1410, +|19: 0-0 d,#608269, 1-4 d,#0d1410, 5-12 #59675c,#0d1410, 13-15 #666f68,#0d1410, 16-109 #59675c,#0d1410, +|20: 0-0 d,#608269, 1-3 d,#0d1410, 4-12 #59675c,#0d1410, 13-15 #666f68,#0d1410, 16-19 #c9a7ed,#0d1410, 20-23 #e5eee5,#0d1410, 24-26 #e5eee5,#5e4923, 27-109 #e5eee5,#0d1410, +|21: 0-0 d,#608269, 1-3 d,#0d1410, 4-12 #59675c,#0d1410, 13-15 #666f68,#0d1410, 16-109 #59675c,#0d1410, +|22: 0-0 d,#608269, 1-3 d,#0d1410, 4-15 #59675c,#0d1410, 16-19 #c9a7ed,#0d1410, 20-23 #e5eee5,#0d1410, 24-26 #e5eee5,#5e4923, 27-109 #e5eee5,#0d1410, |23: 0-0 d,#608269, 1-4 d,#0d1410, 5-109 #59675c,#0d1410, |24: 0-0 d,#608269, 1-109 d,#0d1410, |25: 0-0 d,#608269, 1-109 d,#0d1410, diff --git a/test/snapshots/diffstack.golden b/test/snapshots/diffstack.golden index 68c58062..1ffa87a4 100644 --- a/test/snapshots/diffstack.golden +++ b/test/snapshots/diffstack.golden @@ -57,8 +57,8 @@ |23: 0-0 d,#608269, 1-2 d,#0d1410, 3-99 #59675c,#0d1410, |24: 0-0 d,#608269, 1-1 d,#0d1410, 2-99 #59675c,#0d1410, |25: 0-0 d,#608269, 1-6 d,#0d1410, 7-9 #c9a7ed,#0d1410, 10-99 #e5eee5,#0d1410, -|26: 0-0 d,#608269, 1-1 d,#0d1410, 2-2 #f1a39b,#0d1410,b 3-10 #f1a39b,#0d1410, 11-11 #e5eee5,#453832, 12-99 #e5eee5,#0d1410, -|27: 0-0 d,#608269, 1-1 d,#0d1410, 2-2 #b6ce94,#0d1410,b 3-10 #b6ce94,#0d1410, 11-11 #e5eee5,#364131, 12-99 #e5eee5,#0d1410, +|26: 0-0 d,#608269, 1-1 d,#0d1410, 2-2 #f1a39b,#0d1410,b 3-10 #f1a39b,#0d1410, 11-11 #e5eee5,#53251b, 12-99 #e5eee5,#0d1410, +|27: 0-0 d,#608269, 1-1 d,#0d1410, 2-2 #b6ce94,#0d1410,b 3-10 #b6ce94,#0d1410, 11-11 #e5eee5,#203900, 12-99 #e5eee5,#0d1410, |28: 0-0 d,#152019, 1-10 d,#0d1410, 11-99 #e5eee5,#0d1410, -|29: 0-0 d,#152019, 1-1 d,#0d1410, 2-2 #b6ce94,#171f18,b 3-10 #b6ce94,#171f18, 11-99 #e5eee5,#171f18, +|29: 0-0 d,#152019, 1-1 d,#0d1410, 2-2 #b6ce94,#101c0b,b 3-10 #b6ce94,#101c0b, 11-99 #e5eee5,#101c0b, |30: 0-1 d,#1d2824, 2-99 #b2c3b8,#1d2824, diff --git a/test/snapshots/diffview.golden b/test/snapshots/diffview.golden index c441e19c..c0cc6194 100644 --- a/test/snapshots/diffview.golden +++ b/test/snapshots/diffview.golden @@ -43,14 +43,14 @@ |9: 0-0 d,#608269, 1-4 d,#0d1410, 5-99 #59675c,#0d1410, |10: 0-0 d,#608269, 1-4 d,#0d1410, 5-7 #59675c,#0d1410, 8-25 #e5eee5,#0d1410, 26-30 #c9a7ed,#0d1410, 31-31 #e5eee5,#0d1410, 32-35 #c9a7ed,#0d1410, 36-99 #e5eee5,#0d1410, |11: 0-0 d,#608269, 1-4 d,#0d1410, 5-11 #59675c,#0d1410, 12-99 #e5eee5,#0d1410, -|12: 0-0 d,#608269, 1-3 d,#0d1410, 4-6 #59675c,#0d1410, 7-7 #f1a39b,#302b25,b 8-11 #f1a39b,#302b25, 12-24 #e5eee5,#302b25, 25-25 #f8c082,#302b25, 26-99 #e5eee5,#302b25, -|13: 0-0 d,#608269, 1-3 d,#0d1410, 4-6 #59675c,#0d1410, 7-7 #b6ce94,#263025,b 8-11 #b6ce94,#263025, 12-99 #e5eee5,#263025, -|14: 0-0 d,#608269, 1-3 d,#0d1410, 4-6 #59675c,#0d1410, 7-7 #b6ce94,#263025,b 8-11 #b6ce94,#263025, 12-21 #e5eee5,#263025, 22-28 #c9a7ed,#263025, 29-99 #e5eee5,#263025, +|12: 0-0 d,#608269, 1-3 d,#0d1410, 4-6 #59675c,#0d1410, 7-7 #f1a39b,#331a12,b 8-11 #f1a39b,#331a12, 12-24 #e5eee5,#331a12, 25-25 #f8c082,#331a12, 26-99 #e5eee5,#331a12, +|13: 0-0 d,#608269, 1-3 d,#0d1410, 4-6 #59675c,#0d1410, 7-7 #b6ce94,#132503,b 8-11 #b6ce94,#132503, 12-99 #e5eee5,#132503, +|14: 0-0 d,#608269, 1-3 d,#0d1410, 4-6 #59675c,#0d1410, 7-7 #b6ce94,#132503,b 8-11 #b6ce94,#132503, 12-21 #e5eee5,#132503, 22-28 #c9a7ed,#132503, 29-99 #e5eee5,#132503, |15: 0-0 d,#608269, 1-3 d,#0d1410, 4-99 #59675c,#0d1410, |16: 0-0 d,#608269, 1-3 d,#0d1410, 4-11 #59675c,#0d1410, 12-99 #e5eee5,#0d1410, -|17: 0-0 d,#608269, 1-3 d,#0d1410, 4-6 #59675c,#0d1410, 7-7 #f1a39b,#302b25,b 8-15 #f1a39b,#302b25, 16-99 #b8d88a,#302b25, -|18: 0-0 d,#608269, 1-3 d,#0d1410, 4-6 #59675c,#0d1410, 7-7 #b6ce94,#263025,b 8-15 #b6ce94,#263025, 16-99 #b8d88a,#263025, -|19: 0-0 d,#608269, 1-3 d,#0d1410, 4-6 #59675c,#0d1410, 7-7 #b6ce94,#263025,b 8-15 #b6ce94,#263025, 16-99 #b8d88a,#263025, +|17: 0-0 d,#608269, 1-3 d,#0d1410, 4-6 #59675c,#0d1410, 7-7 #f1a39b,#331a12,b 8-15 #f1a39b,#331a12, 16-99 #b8d88a,#331a12, +|18: 0-0 d,#608269, 1-3 d,#0d1410, 4-6 #59675c,#0d1410, 7-7 #b6ce94,#132503,b 8-15 #b6ce94,#132503, 16-99 #b8d88a,#132503, +|19: 0-0 d,#608269, 1-3 d,#0d1410, 4-6 #59675c,#0d1410, 7-7 #b6ce94,#132503,b 8-15 #b6ce94,#132503, 16-99 #b8d88a,#132503, |20: 0-0 d,#608269, 1-3 d,#0d1410, 4-11 #59675c,#0d1410, 12-99 #e5eee5,#0d1410, |21: 0-0 d,#608269, 1-3 d,#0d1410, 4-7 #59675c,#0d1410, 8-99 #e5eee5,#0d1410, |22: 0-0 d,#608269, 1-4 d,#0d1410, 5-99 #59675c,#0d1410, diff --git a/test/snapshots/fsearch.golden b/test/snapshots/fsearch.golden index 6a70d3c4..e9b15f4c 100644 --- a/test/snapshots/fsearch.golden +++ b/test/snapshots/fsearch.golden @@ -54,7 +54,7 @@ |15: 0-0 d,#608269, 1-89 d,#0d1410, 90-90 d,#608269, 91-179 d,#0d1410, |16: 0-1 d,#496656, 2-30 #b2c3b8,#1d2824, 31-40 #d3b0d9,#1d2824, 41-89 #b2c3b8,#1d2824, 90-91 #000000,#add38a, 92-98 #becfc4,#2c2c0f, 99-99 #bada9d,#2c2c0f,b 100-100 #bada9d,#2c2c0f, 101-106 #becfc4,#2c2c0f, 107-113 #79836f,#2c2c0f, 114-126 #becfc4,#2c2c0f, 127-179 #79836f,#2c2c0f, |17: 0-0 d,#608269, 1-1 d,#0d1410, 2-89 #e5eee5,#0d1410, 90-90 #e5eee5,#608269, 91-94 #e5eee5,#0d1410, 95-96 #59675c,#0d1410, 97-179 #e5eee5,#0d1410, -|18: 0-0 d,#608269, 1-1 d,#0d1410, 2-89 #e5eee5,#0d1410, 90-90 #e5eee5,#e5eee5, 91-91 #e5eee5,#0d1410, 92-94 #e5eee5,#0d1410,b 95-95 #616f64,#0d1410,b 96-96 #bada9d,#0d1410,b 97-100 #f5f7ee,#3c614a, 101-101 #f5f7ee,#0d1410, 102-179 #e5eee5,#0d1410, +|18: 0-0 d,#608269, 1-1 d,#0d1410, 2-89 #e5eee5,#0d1410, 90-90 #e5eee5,#e5eee5, 91-91 #e5eee5,#0d1410, 92-94 #e5eee5,#0d1410,b 95-95 #616f64,#0d1410,b 96-96 #add38a,#0d1410,b 97-100 #f5f7ee,#3c614a, 101-101 #f5f7ee,#0d1410, 102-179 #e5eee5,#0d1410, |19: 0-0 d,#608269, 1-89 d,#0d1410, 90-90 d,#608269, 91-94 d,#0d1410, 95-96 #59675c,#0d1410, 97-179 #e5eee5,#0d1410, |20: 0-0 d,#608269, 1-89 d,#0d1410, 90-90 d,#608269, 91-94 d,#0d1410, 95-96 #59675c,#0d1410, 97-179 #e5eee5,#0d1410, |21: 0-0 d,#608269, 1-89 d,#0d1410, 90-90 d,#608269, 91-94 d,#0d1410, 95-96 #59675c,#0d1410, 97-179 #e5eee5,#0d1410, diff --git a/test/snapshots/headersweep-restored.golden b/test/snapshots/headersweep-restored.golden index 26a0c80b..6e0dff27 100644 --- a/test/snapshots/headersweep-restored.golden +++ b/test/snapshots/headersweep-restored.golden @@ -1,6 +1,6 @@ == style col-sweeping grid=120x21 |0: 0-1 d,#1d2824, 2-119 #b2c3b8,#1d2824, -|1: 0-1 d,#887455, 2-35 #becfc4,#314738, 36-43 #f5f7ee,#5b7e5a, 44-59 #becfc4,#314738, 60-61 #becfc4,#887455, 62-119 #b2c3b8,#1d2824, +|1: 0-1 d,#887455, 2-35 #becfc4,#314738, 36-43 #e5eee5,#4c251b, 44-59 #becfc4,#314738, 60-61 #becfc4,#887455, 62-119 #b2c3b8,#1d2824, |2: 0-1 d,#add38a, 2-43 #becfc4,#314738, 44-53 #dfbce5,#314738, 54-59 #becfc4,#314738, 60-61 #becfc4,#496656, 62-103 #b2c3b8,#1d2824, 104-113 #d3b0d9,#1d2824, 114-119 #b2c3b8,#1d2824, |3: 0-1 d,#314738, 2-59 #becfc4,#314738, 60-61 #becfc4,#1d2824, 62-119 #b2c3b8,#1d2824, |4: 0-0 d,#608269, 1-1 d,#0d1410, 2-59 #e5eee5,#0d1410, 60-60 #e5eee5,#608269, 61-119 #e5eee5,#0d1410, @@ -43,7 +43,7 @@ | | ✓ @p1 Dump 1 message · SPC h m == style ws-sweeping grid=120x21 -|0: 0-1 d,#1d2824, 2-100 #b2c3b8,#1d2824, 101-108 #f5f7ee,#5b7e5a, 109-119 #b2c3b8,#1d2824, +|0: 0-1 d,#1d2824, 2-100 #b2c3b8,#1d2824, 101-108 #e5eee5,#4c251b, 109-119 #b2c3b8,#1d2824, |1: 0-1 d,#887455, 2-59 #becfc4,#314738, 60-61 #becfc4,#887455, 62-119 #b2c3b8,#1d2824, |13: 0-0 d,#608269, 1-59 d,#0d1410, 60-60 d,#608269, 61-119 d,#0d1410, |14: 0-0 d,#608269, 1-1 d,#0d1410, 2-59 #666f68,#0d1410, 60-60 #666f68,#608269, 61-119 #666f68,#0d1410, diff --git a/test/snapshots/headersweep.golden b/test/snapshots/headersweep.golden index 8763fbb2..49eda692 100644 --- a/test/snapshots/headersweep.golden +++ b/test/snapshots/headersweep.golden @@ -1,6 +1,6 @@ == style col-sweeping grid=120x21 |0: 0-1 d,#1d2824, 2-119 #b2c3b8,#1d2824, -|1: 0-1 d,#887455, 2-35 #becfc4,#314738, 36-43 #f5f7ee,#5b7e5a, 44-59 #becfc4,#314738, 60-61 #becfc4,#887455, 62-119 #b2c3b8,#1d2824, +|1: 0-1 d,#887455, 2-35 #becfc4,#314738, 36-43 #e5eee5,#4c251b, 44-59 #becfc4,#314738, 60-61 #becfc4,#887455, 62-119 #b2c3b8,#1d2824, |2: 0-1 d,#add38a, 2-34 #becfc4,#314738, 35-44 #dfbce5,#314738, 45-59 #becfc4,#314738, 60-61 #becfc4,#496656, 62-94 #b2c3b8,#1d2824, 95-104 #d3b0d9,#1d2824, 105-119 #b2c3b8,#1d2824, |3: 0-1 d,#314738, 2-59 #becfc4,#314738, 60-61 #becfc4,#1d2824, 62-119 #b2c3b8,#1d2824, |4: 0-0 d,#608269, 1-1 d,#0d1410, 2-59 #e5eee5,#0d1410, 60-60 #e5eee5,#608269, 61-119 #e5eee5,#0d1410, diff --git a/test/snapshots/lsprelpath.golden b/test/snapshots/lsprelpath.golden index bd2dc172..48fbfbd1 100644 --- a/test/snapshots/lsprelpath.golden +++ b/test/snapshots/lsprelpath.golden @@ -62,9 +62,9 @@ |15: 0-1 d,#496656, 2-99 #b2c3b8,#1d2824, |16: 0-0 d,#608269, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, |17: 0-0 d,#608269, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, -|18: 0-0 d,#608269, 1-1 d,#0d1410, 2-21 #59675c,#243a2d, 22-31 #e5eee5,#243a2d, 32-36 #f7e4a5,#5e4923, 37-37 #f7e4a5,#243a2d, 38-39 #e5eee5,#243a2d, 40-44 #c9a7ed,#243a2d, 45-99 #e5eee5,#243a2d, +|18: 0-0 d,#608269, 1-1 d,#0d1410, 2-21 #59675c,#24382c, 22-31 #e5eee5,#24382c, 32-36 #e5eee5,#5e4923, 37-39 #e5eee5,#24382c, 40-44 #c9a7ed,#24382c, 45-99 #e5eee5,#24382c, |19: 0-0 d,#608269, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, -|20: 0-0 d,#608269, 1-1 d,#0d1410, 2-19 #59675c,#0d1410, 20-23 #e5eee5,#0d1410, 24-26 #c9a7ed,#0d1410, 27-40 #e5eee5,#0d1410, 41-45 #f7e4a5,#5e4923, 46-99 #e5eee5,#0d1410, +|20: 0-0 d,#608269, 1-1 d,#0d1410, 2-19 #59675c,#0d1410, 20-23 #e5eee5,#0d1410, 24-26 #c9a7ed,#0d1410, 27-40 #e5eee5,#0d1410, 41-45 #0d1410,#917a53, 46-99 #e5eee5,#0d1410, |21: 0-0 d,#608269, 1-99 d,#0d1410, |22: 0-0 d,#608269, 1-99 d,#0d1410, |23: 0-0 d,#608269, 1-99 d,#0d1410, @@ -144,9 +144,9 @@ |15: 0-1 d,#496656, 2-99 #b2c3b8,#1d2824, |16: 0-0 d,#608269, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, |17: 0-0 d,#608269, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, -|18: 0-0 d,#608269, 1-1 d,#0d1410, 2-23 #59675c,#243a2d, 24-33 #e5eee5,#243a2d, 34-37 #f7e4a5,#5e4923, 38-38 #f7e4a5,#243a2d, 39-40 #e5eee5,#243a2d, 41-45 #c9a7ed,#243a2d, 46-99 #e5eee5,#243a2d, +|18: 0-0 d,#608269, 1-1 d,#0d1410, 2-23 #59675c,#24382c, 24-33 #e5eee5,#24382c, 34-37 #e5eee5,#5e4923, 38-40 #e5eee5,#24382c, 41-45 #c9a7ed,#24382c, 46-99 #e5eee5,#24382c, |19: 0-0 d,#608269, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, -|20: 0-0 d,#608269, 1-1 d,#0d1410, 2-19 #59675c,#0d1410, 20-23 #e5eee5,#0d1410, 24-26 #c9a7ed,#0d1410, 27-38 #e5eee5,#0d1410, 39-42 #f7e4a5,#5e4923, 43-99 #e5eee5,#0d1410, +|20: 0-0 d,#608269, 1-1 d,#0d1410, 2-19 #59675c,#0d1410, 20-23 #e5eee5,#0d1410, 24-26 #c9a7ed,#0d1410, 27-38 #e5eee5,#0d1410, 39-42 #0d1410,#917a53, 43-99 #e5eee5,#0d1410, |21: 0-0 d,#608269, 1-99 d,#0d1410, |22: 0-0 d,#608269, 1-99 d,#0d1410, |23: 0-0 d,#608269, 1-99 d,#0d1410, diff --git a/test/snapshots/multicursor.golden b/test/snapshots/multicursor.golden index 267fba5e..9c992e04 100644 --- a/test/snapshots/multicursor.golden +++ b/test/snapshots/multicursor.golden @@ -80,8 +80,8 @@ == snap three-selections grid=150x31 cursor=83,19 == style three-selections grid=150x31 |16: 0-1 d,#496656, 2-34 #b2c3b8,#1d2824, 35-44 #d3b0d9,#1d2824, 45-74 #b2c3b8,#1d2824, 75-75 #b2c3b8,#add38a, 76-76 #000000,#f9cb70,b 77-109 #becfc4,#314738, 110-115 #dfbce5,#314738, 116-149 #becfc4,#314738, -|17: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 #e5eee5,#608269, 76-79 #e5eee5,#0d1410, 80-81 #59675c,#0d1410, 82-82 #f5f7ee,#243a2d, 83-83 #3c614a,#f5f7ee, 84-149 #e5eee5,#0d1410, -|18: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 #e5eee5,#608269, 76-79 #e5eee5,#0d1410, 80-81 #59675c,#0d1410, 82-82 #f5f7ee,#243a2d, 83-83 #3c614a,#f5f7ee, 84-149 #e5eee5,#0d1410, +|17: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 #e5eee5,#608269, 76-79 #e5eee5,#0d1410, 80-81 #59675c,#0d1410, 82-82 #e5eee5,#24382c, 83-83 #3c614a,#f5f7ee, 84-149 #e5eee5,#0d1410, +|18: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 #e5eee5,#608269, 76-79 #e5eee5,#0d1410, 80-81 #59675c,#0d1410, 82-82 #e5eee5,#24382c, 83-83 #3c614a,#f5f7ee, 84-149 #e5eee5,#0d1410, |19: 0-0 d,#608269, 1-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-79 d,#0d1410,b 80-81 #616f64,#0d1410,b 82-83 #f5f7ee,#3c614a, 84-149 #e5eee5,#0d1410, |20: 0-0 d,#608269, 1-74 d,#0d1410, 75-75 d,#608269, 76-79 d,#0d1410, 80-81 #59675c,#0d1410, 82-149 #e5eee5,#0d1410, |26: 0-0 d,#608269, 1-74 d,#0d1410, 75-75 d,#608269, 76-78 d,#0d1410, 79-81 #59675c,#0d1410, 82-149 #e5eee5,#0d1410, diff --git a/test/snapshots/pagercolor.golden b/test/snapshots/pagercolor.golden index beaaf7f5..f665b6bf 100644 --- a/test/snapshots/pagercolor.golden +++ b/test/snapshots/pagercolor.golden @@ -121,8 +121,8 @@ |33: 0-1 d,#496656, 2-33 #b2c3b8,#1d2824, 34-47 #d3b0d9,#1d2824, 48-99 #b2c3b8,#1d2824, |34: 0-0 d,#608269, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, |35: 0-0 d,#608269, 1-1 d,#0d1410, 2-99 #59675c,#0d1410, -|36: 0-0 d,#608269, 1-1 d,#0d1410, 2-2 #f1a39b,#1a1d18,b 3-99 #f8c082,#1a1d18, -|37: 0-0 d,#608269, 1-1 d,#0d1410, 2-2 #b6ce94,#171f18,b 3-99 #b8d88a,#171f18, +|36: 0-0 d,#608269, 1-1 d,#0d1410, 2-2 #f1a39b,#211812,b 3-99 #f8c082,#211812, +|37: 0-0 d,#608269, 1-1 d,#0d1410, 2-2 #b6ce94,#101c0b,b 3-99 #b8d88a,#101c0b, |41: 0-0 d,#608269, 1-99 d,#0d1410, |42: 0-0 d,#608269, 1-99 d,#0d1410, |45: 0-1 d,#496656, 2-33 #b2c3b8,#1d2824, 34-40 #d3b0d9,#1d2824, 41-99 #b2c3b8,#1d2824, diff --git a/test/snapshots/psearch.golden b/test/snapshots/psearch.golden index 9f7eab39..fca566b4 100644 --- a/test/snapshots/psearch.golden +++ b/test/snapshots/psearch.golden @@ -66,11 +66,11 @@ |20: 0-0 d,#608269, 1-139 d,#0d1410, |21: 0-1 d,#496656, 2-30 #b2c3b8,#1d2824, 31-38 #d3b0d9,#1d2824, 39-139 #b2c3b8,#1d2824, |22: 0-0 d,#608269, 1-4 d,#0d1410, 5-139 #59675c,#0d1410, -|23: 0-0 d,#608269, 1-4 d,#0d1410, 5-6 #59675c,#0d1410, 7-8 #e5eee5,#0d1410, 9-12 #f7e4a5,#5e4923, 13-13 #f7e4a5,#0d1410, 14-139 #e5eee5,#0d1410, +|23: 0-0 d,#608269, 1-4 d,#0d1410, 5-6 #59675c,#0d1410, 7-8 #e5eee5,#0d1410, 9-12 #e5eee5,#5e4923, 13-139 #e5eee5,#0d1410, |24: 0-0 d,#608269, 1-4 d,#0d1410, 5-139 #59675c,#0d1410, -|25: 0-0 d,#608269, 1-4 d,#0d1410, 5-6 #59675c,#0d1410, 7-8 #e5eee5,#0d1410, 9-12 #f7e4a5,#5e4923, 13-13 #f7e4a5,#0d1410, 14-139 #e5eee5,#0d1410, +|25: 0-0 d,#608269, 1-4 d,#0d1410, 5-6 #59675c,#0d1410, 7-8 #e5eee5,#0d1410, 9-12 #e5eee5,#5e4923, 13-139 #e5eee5,#0d1410, |26: 0-0 d,#608269, 1-4 d,#0d1410, 5-139 #59675c,#0d1410, -|27: 0-0 d,#608269, 1-4 d,#0d1410, 5-6 #59675c,#0d1410, 7-8 #e5eee5,#0d1410, 9-12 #f7e4a5,#5e4923, 13-13 #f7e4a5,#0d1410, 14-139 #e5eee5,#0d1410, +|27: 0-0 d,#608269, 1-4 d,#0d1410, 5-6 #59675c,#0d1410, 7-8 #e5eee5,#0d1410, 9-12 #e5eee5,#5e4923, 13-139 #e5eee5,#0d1410, |28: 0-0 d,#608269, 1-4 d,#0d1410, 5-139 #59675c,#0d1410, |29: 0-0 d,#608269, 1-139 d,#0d1410, |30: 0-1 d,#1d2824, 2-139 #b2c3b8,#1d2824, diff --git a/test/snapshots/selregex.golden b/test/snapshots/selregex.golden index fa7ec980..621018b7 100644 --- a/test/snapshots/selregex.golden +++ b/test/snapshots/selregex.golden @@ -32,8 +32,8 @@ |1: 0-1 d,#887455, 2-159 #becfc4,#314738, |2: 0-1 #000000,#add38a, 2-2 #bada9d,#2c2c0f,b 3-3 #bada9d,#2c2c0f, 4-10 #becfc4,#2c2c0f, 11-17 #79836f,#2c2c0f, 18-115 #becfc4,#2c2c0f, 116-159 #79836f,#2c2c0f, |3: 0-0 d,#608269, 1-1 d,#0d1410, 2-4 d,#0d1410,b 5-5 #616f64,#0d1410,b 6-6 #add38a,#0d1410,b 7-10 #f5f7ee,#3c614a, 11-11 #3c614a,#f5f7ee, 12-12 #3c614a,#0d1410, 13-18 #e5eee5,#0d1410, 19-19 #f8c082,#0d1410, 20-159 #e5eee5,#0d1410, -|4: 0-0 d,#608269, 1-4 d,#0d1410, 5-5 #59675c,#0d1410, 6-6 #add38a,#0d1410, 7-10 #f5f7ee,#243a2d, 11-11 #3c614a,#f5f7ee, 12-12 #3c614a,#0d1410, 13-18 #e5eee5,#0d1410, 19-19 #f8c082,#0d1410, 20-159 #e5eee5,#0d1410, -|5: 0-0 d,#608269, 1-4 d,#0d1410, 5-5 #59675c,#0d1410, 6-6 #add38a,#0d1410, 7-10 #f5f7ee,#243a2d, 11-11 #3c614a,#f5f7ee, 12-12 #3c614a,#0d1410, 13-20 #e5eee5,#0d1410, 21-21 #f8c082,#0d1410, 22-159 #e5eee5,#0d1410, +|4: 0-0 d,#608269, 1-4 d,#0d1410, 5-5 #59675c,#0d1410, 6-6 #add38a,#0d1410, 7-10 #e5eee5,#24382c, 11-11 #3c614a,#f5f7ee, 12-12 #3c614a,#0d1410, 13-18 #e5eee5,#0d1410, 19-19 #f8c082,#0d1410, 20-159 #e5eee5,#0d1410, +|5: 0-0 d,#608269, 1-4 d,#0d1410, 5-5 #59675c,#0d1410, 6-6 #add38a,#0d1410, 7-10 #e5eee5,#24382c, 11-11 #3c614a,#f5f7ee, 12-12 #3c614a,#0d1410, 13-20 #e5eee5,#0d1410, 21-21 #f8c082,#0d1410, 22-159 #e5eee5,#0d1410, |6: 0-0 d,#608269, 1-4 d,#0d1410, 5-159 #59675c,#0d1410, |7: 0-0 d,#608269, 1-159 d,#0d1410, |8: 0-0 d,#608269, 1-159 d,#0d1410, @@ -61,8 +61,8 @@ == style three-selected grid=160x25 |2: 0-1 d,#add38a, 2-47 #becfc4,#2c2c0f, 48-53 #dfbce5,#2c2c0f, 54-159 #becfc4,#2c2c0f, |3: 0-0 d,#608269, 1-1 d,#0d1410, 2-4 d,#0d1410,b 5-6 #616f64,#0d1410,b 7-11 #f5f7ee,#3c614a, 12-12 #f5f7ee,#0d1410, 13-18 #e5eee5,#0d1410, 19-19 #f8c082,#0d1410, 20-159 #e5eee5,#0d1410, -|4: 0-0 d,#608269, 1-4 d,#0d1410, 5-6 #59675c,#0d1410, 7-10 #f5f7ee,#243a2d, 11-11 #3c614a,#f5f7ee, 12-12 #3c614a,#0d1410, 13-18 #e5eee5,#0d1410, 19-19 #f8c082,#0d1410, 20-159 #e5eee5,#0d1410, -|5: 0-0 d,#608269, 1-4 d,#0d1410, 5-6 #59675c,#0d1410, 7-10 #f5f7ee,#243a2d, 11-11 #3c614a,#f5f7ee, 12-12 #3c614a,#0d1410, 13-20 #e5eee5,#0d1410, 21-21 #f8c082,#0d1410, 22-159 #e5eee5,#0d1410, +|4: 0-0 d,#608269, 1-4 d,#0d1410, 5-6 #59675c,#0d1410, 7-10 #e5eee5,#24382c, 11-11 #3c614a,#f5f7ee, 12-12 #3c614a,#0d1410, 13-18 #e5eee5,#0d1410, 19-19 #f8c082,#0d1410, 20-159 #e5eee5,#0d1410, +|5: 0-0 d,#608269, 1-4 d,#0d1410, 5-6 #59675c,#0d1410, 7-10 #e5eee5,#24382c, 11-11 #3c614a,#f5f7ee, 12-12 #3c614a,#0d1410, 13-20 #e5eee5,#0d1410, 21-21 #f8c082,#0d1410, 22-159 #e5eee5,#0d1410, == snap narrowed grid=160x25 cursor=21,2 |2: ^ Edit x/const/ › s t = Exec Edit x/t/ 3 selections in 3 lines ⏎ select · M-⏎ as a list · C-r history · esc |3: 1┃const one = 1; @@ -81,8 +81,8 @@ == style esc-restores grid=160x25 |2: 0-1 d,#add38a, 2-47 #becfc4,#2c2c0f, 48-53 #dfbce5,#2c2c0f, 54-159 #becfc4,#2c2c0f, |3: 0-0 d,#608269, 1-1 d,#0d1410, 2-4 d,#0d1410,b 5-6 #616f64,#0d1410,b 7-11 #f5f7ee,#3c614a, 12-12 #f5f7ee,#0d1410, 13-18 #e5eee5,#0d1410, 19-19 #f8c082,#0d1410, 20-159 #e5eee5,#0d1410, -|4: 0-0 d,#608269, 1-4 d,#0d1410, 5-6 #59675c,#0d1410, 7-10 #f5f7ee,#243a2d, 11-11 #3c614a,#f5f7ee, 12-12 #3c614a,#0d1410, 13-18 #e5eee5,#0d1410, 19-19 #f8c082,#0d1410, 20-159 #e5eee5,#0d1410, -|5: 0-0 d,#608269, 1-4 d,#0d1410, 5-6 #59675c,#0d1410, 7-10 #f5f7ee,#243a2d, 11-11 #3c614a,#f5f7ee, 12-12 #3c614a,#0d1410, 13-20 #e5eee5,#0d1410, 21-21 #f8c082,#0d1410, 22-159 #e5eee5,#0d1410, +|4: 0-0 d,#608269, 1-4 d,#0d1410, 5-6 #59675c,#0d1410, 7-10 #e5eee5,#24382c, 11-11 #3c614a,#f5f7ee, 12-12 #3c614a,#0d1410, 13-18 #e5eee5,#0d1410, 19-19 #f8c082,#0d1410, 20-159 #e5eee5,#0d1410, +|5: 0-0 d,#608269, 1-4 d,#0d1410, 5-6 #59675c,#0d1410, 7-10 #e5eee5,#24382c, 11-11 #3c614a,#f5f7ee, 12-12 #3c614a,#0d1410, 13-20 #e5eee5,#0d1410, 21-21 #f8c082,#0d1410, 22-159 #e5eee5,#0d1410, == snap commented grid=160x25 cursor=14,3 |2: *Edit x/const/ › /tmp/pardes-snap/selregex/cwd/m.zig Save Term Collapse Follow TreeContext Def Refs Del |3: 1 // const one = 1; diff --git a/test/snapshots/stepgrain.golden b/test/snapshots/stepgrain.golden index 5f73bd1f..e24b19a8 100644 --- a/test/snapshots/stepgrain.golden +++ b/test/snapshots/stepgrain.golden @@ -47,10 +47,10 @@ |11: 0-1 #000000,#add38a, 2-149 #becfc4,#314738, |12: 0-0 d,#608269, 1-1 d,#0d1410, 2-149 #e5eee5,#0d1410, |13: 0-0 d,#608269, 1-1 d,#0d1410, 2-149 #e5eee5,#0d1410, -|14: 0-0 d,#608269, 1-1 d,#0d1410, 2-14 #59675c,#0d1410, 15-20 #e5eee5,#0d1410, 21-26 #f7e4a5,#5e4923, 27-27 #f7e4a5,#0d1410, 28-149 #e5eee5,#0d1410, -|15: 0-0 d,#608269, 1-1 d,#0d1410, 2-14 #59675c,#243a2d, 15-37 #e5eee5,#243a2d, 38-43 #f7e4a5,#5e4923, 44-44 #f7e4a5,#243a2d, 45-149 #e5eee5,#243a2d, +|14: 0-0 d,#608269, 1-1 d,#0d1410, 2-14 #59675c,#0d1410, 15-20 #e5eee5,#0d1410, 21-26 #e5eee5,#5e4923, 27-149 #e5eee5,#0d1410, +|15: 0-0 d,#608269, 1-1 d,#0d1410, 2-14 #59675c,#24382c, 15-37 #e5eee5,#24382c, 38-43 #e5eee5,#5e4923, 44-149 #e5eee5,#24382c, |16: 0-0 d,#608269, 1-1 d,#0d1410, 2-149 #e5eee5,#0d1410, -|17: 0-0 d,#608269, 1-1 d,#0d1410, 2-18 #59675c,#0d1410, 19-24 #f7e4a5,#5e4923, 25-25 #f7e4a5,#0d1410, 26-149 #e5eee5,#0d1410, +|17: 0-0 d,#608269, 1-1 d,#0d1410, 2-18 #59675c,#0d1410, 19-24 #e5eee5,#5e4923, 25-149 #e5eee5,#0d1410, |18: 0-0 d,#608269, 1-149 d,#0d1410, |19: 0-0 d,#608269, 1-149 d,#0d1410, |20: 0-0 d,#608269, 1-149 d,#0d1410, @@ -85,7 +85,7 @@ |3: 0-0 d,#608269, 1-4 d,#0d1410, 5-6 #59675c,#0d1410, 7-149 #e5eee5,#0d1410, |4: 0-0 d,#608269, 1-4 d,#0d1410, 5-6 #59675c,#0d1410, 7-149 #e5eee5,#0d1410, |7: 0-0 d,#608269, 1-149 d,#0d1410, -|13: 0-0 d,#608269, 1-1 d,#0d1410, 2-5 #e5eee5,#243a2d, 6-10 #f7e4a5,#5e4923,b 11-149 #e5eee5,#243a2d, +|13: 0-0 d,#608269, 1-1 d,#0d1410, 2-5 #e5eee5,#24382c, 6-10 #e5eee5,#5e4923,b 11-149 #e5eee5,#24382c, |14: 0-0 d,#608269, 1-149 d,#0d1410, |15: 0-0 d,#608269, 1-149 d,#0d1410, |16: 0-0 d,#608269, 1-149 d,#0d1410, diff --git a/test/snapshots/themesel.golden b/test/snapshots/themesel.golden index b975c35b..e13e0618 100644 --- a/test/snapshots/themesel.golden +++ b/test/snapshots/themesel.golden @@ -574,7 +574,7 @@ |23: 0-0 d,#99994c, 1-3 d,#ffffea, 4-6 #999980,#ffffea, 7-99 #000000,#ffffea, |24: 0-0 d,#99994c, 1-3 d,#ffffea, 4-6 #999980,#ffffea, 7-99 #000000,#ffffea, |25: 0-0 d,#99994c, 1-3 d,#ffffea, 4-6 #999980,#ffffea, 7-99 #000000,#ffffea, -|26: 0-0 d,#99994c, 1-1 d,#ffffea, 2-3 d,#ffffea,b 4-6 #999980,#ffffea,b 7-99 #000000,#ffffea, +|26: 0-0 d,#99994c, 1-1 d,#ffffea, 2-3 d,#ffffea,b 4-6 #74746a,#ffffea,b 7-99 #000000,#ffffea, |27: 0-0 d,#99994c, 1-3 d,#ffffea, 4-6 #999980,#ffffea, 7-99 #000000,#ffffea, |28: 0-0 d,#99994c, 1-3 d,#ffffea, 4-99 #999980,#ffffea, |29: 0-0 d,#99994c, 1-3 d,#ffffea, 4-6 #999980,#ffffea, 7-99 #000000,#ffffea, @@ -715,7 +715,7 @@ |23: 0-0 d,#eee8d5, 1-3 d,#002b36, 4-6 #586e75,#002b36, 7-99 #839496,#002b36, |24: 0-0 d,#eee8d5, 1-3 d,#002b36, 4-99 #586e75,#002b36, |25: 0-0 d,#eee8d5, 1-3 d,#002b36, 4-6 #586e75,#002b36, 7-99 #839496,#002b36, -|26: 0-0 d,#eee8d5, 1-1 d,#002b36, 2-3 d,#002b36,b 4-6 #586e75,#002b36,b 7-99 #839496,#002b36, +|26: 0-0 d,#eee8d5, 1-1 d,#002b36, 2-3 d,#002b36,b 4-6 #7f9193,#002b36,b 7-99 #839496,#002b36, |27: 0-0 d,#eee8d5, 1-3 d,#002b36, 4-6 #586e75,#002b36, 7-99 #839496,#002b36, |28: 0-0 d,#eee8d5, 1-3 d,#002b36, 4-99 #586e75,#002b36, |29: 0-0 d,#eee8d5, 1-3 d,#002b36, 4-6 #586e75,#002b36, 7-99 #839496,#002b36, -- cgit v1.3 From 8393c24f76675f182055149645c10af3102b739e Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 26 Nov 2026 02:49:36 -0300 Subject: lsp_client, Output, lspmock, syntax, Pick, Query, docs: the Symbols builtin (a language server's documentSymbol) gives the Symbols picker's marks and order (UX DESIGN N, binding: "The builtin `Symbols` keeps reading the server but gets the same mark, order and qualified names, from `SymbolKind`"): walkSymbols keeps each symbol's SymbolKind, mapped onto N2's kinds (5 Class, 10 Enum, 11 Interface, 23 Struct, 26 TypeParameter a type; 6 Method, 9 Constructor, 12 Function, 25 Operator a function; 7 Property, 8 Field, 22 EnumMember a field; 14 Constant a const; 13 Variable, 15 to 21 and 24 a var; 1 File to 4 Package a module; any other the other), and names each in the ones it is in (a DocumentSymbol's nesting, a SymbolInformation's `containerName`): a row is `shapes.rs:5:5-8 m Shape.side`, the rows types, functions, fields, then the rest, each in the server's order; the +Search keeps that order: a file's symbols are neither sorted by their places (Output.sortResults) nor laid out as Locations, which put a file's rows in their lines' order (Output.usesLocationsConfig): a row each, as the picker lists them; the walk's list picker (`Jumps walk`, Ask's) takes them in that order (tty `lsp` with zls: `f helper`, `f main`, `c std`, was `std`, `helper`, `main`); an index's Symbols (SCIP, dev/lsp/Scip.zig) keep their rows unmarked, one row each now too; the mock answers documentSymbol with a nested list in no kind's order (a const, a function, a struct with a field and a method, an enum with a member, a module); docs/typ guide's `Symbols name` and the reference's Symbols say the marks and the order; and three faults of the change before's rows, which its pictures showed (each TEST FIRST: the syntax.zig and Pick.zig tests failed with them first; the pattern guard came with its JavaScript case, not before it): a test whose name is longer than 200 bytes was no symbol, so its body was no scope and its local structs and functions were listed as types and functions (Pick.zig's own tests: `t typeIn = struct`): a name that long is cut, on a character, and a test's body lists nothing (370 rows of core/Pick.zig to 247); a name field is taken whole when it is one line (C++'s `namespace v8::internal::torque` named `v8`, now whole; a value binding's must still be a name, never a pattern: `const { x, y } = a`, OCaml's `let () =`); the qualifier dimmed in a row ran to the name's last `.`, a test's sentence's (`(SPEC §6.3, §7.3)` dimmed most of it): it is the candidate's `base` now, the qualifier's length from the gather, which also gives the scorer its basename bonus on the name; core/root.zig's import of syntax.zig (the change before) says what it does: without it a -Dtest-filter run compiles none of syntax.zig's tests, while a whole run has them (core-test 1135/1308 with it or without it; the change before said they ran nowhere: wrong); RUN (TEST FIRST): test/behaviour/language_servers.zig "language-servers: a server's Symbols are the Symbols picker's rows ..." opens shapes.rs with no index (the server asked) and asks the +Search's rows in that order: with walkSymbols' marks alone they came in their lines' order (`c LIMIT`, `f main`, `t Shape`, ...: the sort and the Locations layout), passes now; the index's Symbols test asks one row each (`lib.rs:1:11-15 Shape`); test/snapshots/lsp.golden re-recorded: only its symbols snap's three rows (marked and grouped) and the preview landing on their first, `helper`'s line 3; GATES on this stack (the change before under it): core-test 1135/1308 (173 skipped; base 1127/1301 with the base's one failure, a CPU-time test under load: colors' "the whole ring resolves in 150 ms"), shell-test 1356/1359 (3 skipped), pane-test 183/184 (1 skipped), behaviour-test 281/281 and --replay 281/281, process-test 1 of 147 failed (tty editing: lsp, its golden: re-recorded, the ten `tty editing: lsp` cases 0 of 10 failed), term-test 17/17, kitty-test 45/45; the dump fuzz (Names.Cand.group, Stream.Batch.symbols) at 40,000 join seeds twice and 1,779 image seeds 13/13; the soak `replicas -- --clients 5 --rtt 30,80,207`: diverged 0, unequal 0, quiet checks 421/0 415/0 590/0, unlisted stops 0, the corpus 22 of 22 scenes the same, no leak; the gui unit-test 1960/1964 (4 skipped; its one failure the perf check's BaselineHarnessMismatch, every base's); core-test, shell-test, pane-test and behaviour-test again after the three faults: the same counts; the pictures (the S kit at 26 px, neonotte84, 100x30, typed through the pty; .scratch/walkui/W6/png): today's install (install74) beside this tree's Debug gui, SPC s s on core/Pick.zig (today 127 rows of declarations, `pub fn deinit(...` first; here 247, `t Pick = @This()` first, the types, then the functions ...) and on V8's torque-parser.cc (today 132, here 273 under `v8::internal::torque.`), and `count` typed (today the cursor on `count`, then `paneCount` and every row whose signature holds c-o-u-n-t, `[]const u8` among them; here `f count` current, `f paneCount`, `c counts_zig`, then the tests whose sentences match); no frame or perf gate (the user's rule of 2026-11-26); load 3.0 to 14.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE --- core/Output.zig | 9 +++++-- core/Pick.zig | 10 ++++---- core/Query.zig | 7 ++++-- core/root.zig | 2 +- core/syntax.zig | 48 +++++++++++++++++++++++++++---------- dev/lsp/lsp_client.zig | 39 +++++++++++++++++++++++++----- docs/typ/guide.typ | 2 +- docs/typ/reference.typ | 3 ++- test/behaviour/language_servers.zig | 25 ++++++++++++++++++- test/lspmock.zig | 11 +++++++-- test/snapshots/lsp.golden | 12 +++++----- 11 files changed, 130 insertions(+), 38 deletions(-) (limited to 'core/root.zig') diff --git a/core/Output.zig b/core/Output.zig index fe1543fe..e55ff4a3 100644 --- a/core/Output.zig +++ b/core/Output.zig @@ -198,11 +198,15 @@ pub fn traits(o: Origin) Traits { }; } +/// A list laid out as Locations (each place's lines from its file, in +/// their order): not a file's symbols, a row each in their own order (UX +/// DESIGN N: types, functions, fields, the rest). pub fn usesLocationsConfig(from: Origin) bool { const tr = traits(from); return tr.steps and !tr.commands and from != .kind and !std.meta.eql(from, Origin{ .query = .completion }) and - !std.meta.eql(from, Origin{ .query = .callstack }); + !std.meta.eql(from, Origin{ .query = .callstack }) and + !std.meta.eql(from, Origin{ .query = .document_symbols }); } pub fn fileTraits(out: ?State) Traits { @@ -244,6 +248,8 @@ pub fn isResultRow(file: *const File.State, row: usize) bool { return !locations.isContextLine(modal.lineSlice(file.content, row)); } +/// A language server's places in the order of their places; a file's +/// symbols stay in theirs (lsp_client: types, functions, fields, the rest). fn sortResults(arena: std.mem.Allocator, from: Origin, content: []u8, anchor: ?usize) !?usize { switch (from) { .search => {}, @@ -258,7 +264,6 @@ fn sortResults(arena: std.mem.Allocator, from: Origin, content: []u8, anchor: ?u .outgoing_calls, .supertypes, .subtypes, - .document_symbols, .workspace_symbols, .diagnostics, .workspace_diagnostics, diff --git a/core/Pick.zig b/core/Pick.zig index 2b5714cb..dcb838f3 100644 --- a/core/Pick.zig +++ b/core/Pick.zig @@ -677,10 +677,9 @@ fn rowAt(p: *Pardes, pk: *const Pick, arena: std.mem.Allocator, i: usize) std.me for (marks_in, row.marks) |*m, at| m.* = at -| line; row.marks = marks_in; const name_at = cand.key - line; - const dot = std.mem.lastIndexOfScalar(u8, row.text[name_at .. name_at + cand.key_len], '.'); row.kind = @intCast(name_at - 1); row.pre = @intCast(name_at); - row.faint = @intCast(if (dot) |at| at + 1 else 0); + row.faint = cand.base; if (name_at + cand.key_len < row.text.len) row.quiet = .{ @intCast(name_at + cand.key_len), @intCast(row.text.len) }; const owner = p.panes[p.paneBySerial(pk.owner) orelse return row] orelse return row; const f = owner.file orelse return row; @@ -3357,7 +3356,7 @@ const counts_zig = \\pub fn count(text: []const u8) Counts { \\ return .{ .lines = text.len }; \\} - \\test "count" {} + \\test "count.add" {} \\ ; @@ -3381,9 +3380,12 @@ test "Symbols (UX DESIGN N): a Zig file's rows types, functions, fields, then th \\ 1 n std = @import("std") \\ 5 c Counts.zero : Counts = .{} \\12 v hits : u32 = 0 - \\16 · "count" + \\16 · "count.add" \\ , try rowLines(p, a)); + // The qualifier dim, `Counts.`; a name holding a `.` none of it. + try std.testing.expectEqual(@as(u16, "Counts.".len), (try rowAt(p, live(p).?, a, 4)).faint); + try std.testing.expectEqual(@as(u16, 0), (try rowAt(p, live(p).?, a, 11)).faint); // Drawn: `m Counts.lines : usize = 0` (not the cursor's row). const pane = p.panes[p.paneBySerial(live(p).?.landing).?].?; _ = try p.render(a); diff --git a/core/Query.zig b/core/Query.zig index 743e9540..a5926e23 100644 --- a/core/Query.zig +++ b/core/Query.zig @@ -785,7 +785,8 @@ pub fn gather(p: *Pardes, names: *Names, source: Source, dir: []const u8, self: // line, its mark, its name qualified by the ones it is in, then // what its first line says after the name; types, functions, // fields, then the rest, each in the text's order (UX DESIGN N). - // The name alone is matched. + // The qualified name alone is matched, its own name the + // basename. for (0..4) |group| for (symbols) |sym| { if (sym.kind.group() != group or sym.kind == .scope or sym.end > text.len) continue; var buf: [512]u8 = undefined; @@ -793,13 +794,15 @@ pub fn gather(p: *Pardes, names: *Names, source: Source, dir: []const u8, self: row.print("{d: >6} {s} ", .{ sym.line + 1, sym.kind.mark() }) catch continue; const key_at = row.end; qualify(&row, symbols, text, sym.parent, 4) catch continue; + // The name its basename: the qualifier dim (Pick.rowAt). + const base = row.end - key_at; row.writeAll(text[sym.name_start..sym.name_end]) catch continue; const key_len = row.end - key_at; const rest = text[sym.name_end..@max(sym.name_end, sym.end)]; var detail = std.mem.trim(u8, rest[0 .. std.mem.indexOfScalar(u8, rest, '\n') orelse rest.len], " \t\r"); detail = std.mem.trimEnd(u8, std.mem.trimEnd(u8, detail, "{,;"), " \t"); if (detail.len > 0) row.print(" {s}", .{detail[0..@min(detail.len, buf.len - row.end -| 2)]}) catch {}; - names.add(gpa, row.buffered(), key_at, key_len, 0, sym.line + 1) catch break; + names.add(gpa, row.buffered(), key_at, key_len, @intCast(base), sym.line + 1) catch break; names.cands.items[names.cands.items.len - 1].group = @intCast(group); }; }, diff --git a/core/root.zig b/core/root.zig index 86ca62e0..a9c95a96 100644 --- a/core/root.zig +++ b/core/root.zig @@ -461,7 +461,7 @@ test { _ = @import("FrameStats.zig"); _ = @import("Query.zig"); _ = @import("Names.zig"); - _ = @import("syntax.zig"); // its tests ran nowhere before + _ = @import("syntax.zig"); // without it a -Dtest-filter run compiles none of its tests (a whole run has them) _ = @import("Stream.zig"); _ = @import("Tables.zig"); _ = @import("Handover.zig"); diff --git a/core/syntax.zig b/core/syntax.zig index 5cdc2ff3..9fbad3cf 100644 --- a/core/syntax.zig +++ b/core/syntax.zig @@ -1135,6 +1135,9 @@ const SymbolWalk = struct { fn visit(w: *SymbolWalk, node: ts.Node) !void { while (w.depth > 0 and w.scopes[w.depth - 1].end <= node.startByte()) w.depth -= 1; const in: Scope = if (w.depth > 0) w.scopes[w.depth - 1] else .{ .end = 0, .kind = .module, .symbol = 0 }; + // A test's body (a macro's) lists nothing: its types are its + // locals' (a test's `const Find = struct`). + if (in.kind == .other) return; const kind_name = node.kind(); const rule = for (w.rules) |r| { if (std.mem.eql(u8, r.node, kind_name)) break r; @@ -1145,11 +1148,17 @@ const SymbolWalk = struct { if (local and (found.kind == .constant or found.kind == .variable)) return; var named = in.symbol; if (found.name) |name| { + // A longer name is cut (a test's sentence), on a character. + var end = name.endByte(); + if (end - name.startByte() > max_name) { + end = name.startByte() + max_name; + while (end > name.startByte() and w.source[end] & 0xc0 == 0x80) end -= 1; + } try w.out.append(w.gpa, .{ .kind = found.kind, .line = name.startPoint().row, .name_start = name.startByte(), - .name_end = name.endByte(), + .name_end = end, .end = found.end, .parent = in.symbol, }); @@ -1190,7 +1199,10 @@ fn symbolOf(rule: Rule, node: ts.Node, source: []const u8, in: SymbolKind) ?stru if (kind == .variable and constant(source, node.startByte(), name orelse return null)) kind = .constant; }, .value => { + // Named by a name, never a pattern (`const { a, b } = ...`, + // OCaml's `let () = ...`). name = nameOf(node, rule.name); + if (name) |n| if (!nameLike(n.kind())) return null; kind = valueKind(node, source) orelse kind; // JavaScript's keyword is its declaration's (`const a = 1, b`). const from = if (std.mem.eql(u8, rule.node, "variable_declarator")) (node.parent() orelse node).startByte() else node.startByte(); @@ -1228,20 +1240,24 @@ fn symbolOf(rule: Rule, node: ts.Node, source: []const u8, in: SymbolKind) ?stru if (childOfKind(node, "Block")) |block| end = block.startByte(); } if (name == null and kind != .scope) return null; - if (name) |n| if (n.endByte() <= n.startByte() or n.endByte() - n.startByte() > max_name) return null; + if (name) |n| if (n.endByte() <= n.startByte()) return null; return .{ .kind = kind, .name = name, .end = end }; } -/// The longest name a symbol has: a longer one is no name. +/// The longest name a symbol has: a longer one is cut. const max_name = 200; -/// The node naming `node`: its field `field`; without one, its declarator's -/// (C's `int *f(void)`: `f`); else the first name under it, past its -/// type, value, body and parameters (Kotlin's, Fortran's). +/// The node naming `node`: its field `field`, whole on its line (C++'s +/// `namespace v8::internal`, Rust's `impl Vec`); without one, its +/// declarator's (C's `int *f(void)`: `f`); else the first name under it, +/// past its type, value, body and parameters (Kotlin's, Fortran's). fn nameOf(node: ts.Node, field: []const u8) ?ts.Node { if (field.len == 0) return null; var n = node; - if (node.childByFieldName(field)) |f| n = f else while (n.childByFieldName("declarator")) |d| n = d; + if (node.childByFieldName(field)) |f| { + if (f.startPoint().row == f.endPoint().row) return f; + n = f; + } else while (n.childByFieldName("declarator")) |d| n = d; if (nameLike(n.kind())) return n; if (n.childByFieldName("name")) |f| if (nameLike(f.kind())) return f; return firstName(n, 3); @@ -2786,12 +2802,20 @@ test "syntax symbols: a Zig file's types, functions, fields and the rest by thei \\fn List(comptime T: type) type { \\ return struct { items: []T }; \\} - \\test "count" {} + \\test "count" { + \\ const Local = struct { + \\ fn helper() void {} + \\ }; + \\ _ = Local; + \\} \\test {} \\extern fn tick() void; \\ ; - const lines = try symbolLines(gpa, "a.zig", source); + // A test's name longer than a row's room is cut, its body still none. + const xs: [250]u8 = @splat('x'); + const long = "test \"" ++ xs ++ "\" {\n const Inner = struct {};\n _ = Inner;\n}\n"; + const lines = try symbolLines(gpa, "a.zig", source ++ long); defer gpa.free(lines); try std.testing.expectEqualStrings( \\n std @@ -2810,7 +2834,7 @@ test "syntax symbols: a Zig file's types, functions, fields and the rest by thei \\· "count" \\f tick \\ - , lines); + ++ "· \"" ++ xs[0 .. max_name - 1].* ++ "\n", lines); } test "syntax symbols: C, C++, Rust, Go, Python and JavaScript by their kind tables, members named in their types, an impl's in its type, locals none" { @@ -2820,11 +2844,11 @@ test "syntax symbols: C, C++, Rust, Go, Python and JavaScript by their kind tabl defer stop(); const cases = [_]struct { path: []const u8, source: []const u8, want: []const u8 }{ .{ .path = "a.c", .source = "#define LIMIT 4\nstruct point { int x; int *y; };\ntypedef struct { int a; } pair;\nenum color { RED };\nstatic int counter = 0;\nconst int limit = 4;\nint add(int a) { int local = a; return local; }\nint later(void);\nstruct point p;\n", .want = "· LIMIT\nt point\nm point.x\nm point.y\nt pair\nm pair.a\nt color\nm color.RED\nv counter\nc limit\nf add\nf later\nv p\n" }, - .{ .path = "a.cc", .source = "namespace torque {\nclass Parser : public Base {\n public:\n Parser();\n int Parse(int depth) const { return depth; }\n int depth_;\n};\nint Parser::Run(int n) { int local = n; return local; }\nusing Alias = int;\n}\n", .want = "n torque\nt torque.Parser\nf torque.Parser.Parser\nf torque.Parser.Parse\nm torque.Parser.depth_\nf torque.Parser::Run\nt torque.Alias\n" }, + .{ .path = "a.cc", .source = "namespace torque {\nclass Parser : public Base {\n public:\n Parser();\n int Parse(int depth) const { return depth; }\n int depth_;\n};\nint Parser::Run(int n) { int local = n; return local; }\nusing Alias = int;\n}\nnamespace v8::internal {\nint flags;\n}\n", .want = "n torque\nt torque.Parser\nf torque.Parser.Parser\nf torque.Parser.Parse\nm torque.Parser.depth_\nf torque.Parser::Run\nt torque.Alias\nn v8::internal\nv v8::internal.flags\n" }, .{ .path = "a.rs", .source = "mod m {\npub struct S { pub a: u32 }\nenum E { A, B(u32) }\ntrait T { fn f(&self); }\nimpl S { pub fn new() -> Self { let x = 1; S { a: x } } }\nconst C: u32 = 1;\nstatic G: u32 = 2;\nmacro_rules! mac { () => {} }\n}\n", .want = "n m\nt m.S\nm m.S.a\nt m.E\nm m.E.A\nm m.E.B\nt m.T\nf m.T.f\nf m.S.new\nc m.C\nv m.G\n· m.mac\n" }, .{ .path = "a.go", .source = "package main\ntype S struct { A int }\ntype I interface { M() }\nconst C = 1\nvar V = 2\nfunc F() { var x = 1; _ = x }\nfunc (s *S) M() {}\n", .want = "t S\nm S.A\nt I\nf I.M\nc C\nv V\nf F\nf M\n" }, .{ .path = "a.py", .source = "X = 1\nclass C:\n attr = 2\n def m(self):\n y = 3\n self.z = 4\ndef f():\n pass\n", .want = "v X\nt C\nm C.attr\nf C.m\nf f\n" }, - .{ .path = "a.js", .source = "const A = 1;\nlet b = 2;\nfunction f() { const local = 1; }\nclass K { field = 1; m() {} }\nconst arrow = () => 1;\nconst Klass = class {};\n", .want = "c A\nv b\nf f\nt K\nm K.field\nf K.m\nf arrow\nt Klass\n" }, + .{ .path = "a.js", .source = "const A = 1;\nlet b = 2;\nfunction f() { const local = 1; }\nclass K { field = 1; m() {} }\nconst arrow = () => 1;\nconst Klass = class {};\nconst { x, y } = A;\n", .want = "c A\nv b\nf f\nt K\nm K.field\nf K.m\nf arrow\nt Klass\n" }, }; for (cases) |case| { const lines = try symbolLines(gpa, case.path, case.source); diff --git a/dev/lsp/lsp_client.zig b/dev/lsp/lsp_client.zig index a53ff57f..b76be78c 100644 --- a/dev/lsp/lsp_client.zig +++ b/dev/lsp/lsp_client.zig @@ -50,6 +50,7 @@ const std = @import("std"); const builtin = @import("builtin"); const libc = std.c; const lsp = @import("core").lsp; +const SymbolKind = @import("core").syntax.SymbolKind; const Scip = @import("Scip.zig"); extern "c" fn execv(path: [*:0]const u8, argv: [*:null]const ?[*:0]const u8) c_int; @@ -1002,7 +1003,11 @@ fn run(c: *Conn, io: std.Io, si: usize, arena: std.mem.Allocator, req: lsp.Req, .document_symbols => { const b = try docParams(arena, uri.items); const result = (try call(c, io, arena, "textDocument/documentSymbol", b.items, deadline)) orelse return; - try walkSymbols(&cx, c.caps.enc, uri.items, result, 0); + // Types, functions, fields, then the rest, each in the + // server's order (UX DESIGN N, the Symbols picker's). + var found: std.ArrayList(Symbol) = .empty; + try walkSymbols(arena, &found, uri.items, result, "", 0); + for (0..4) |group| for (found.items) |sym| if (sym.kind.group() == group) try emitRange(&cx, c.caps.enc, sym.uri, sym.range, sym.note); }, .workspace_symbols => { var b: std.ArrayList(u8) = .empty; @@ -1106,20 +1111,42 @@ fn locations(cx: *Cx, enc: Enc, result: std.json.Value) Err!void { } } -/// DocumentSymbol[] nests (`children`), SymbolInformation[] is flat. -fn walkSymbols(cx: *Cx, enc: Enc, uri: []const u8, node: std.json.Value, depth: u8) Err!void { +/// A symbol a server listed: its row's place and words, `t Shape.area`. +const Symbol = struct { kind: SymbolKind, uri: []const u8, range: ?std.json.Value, note: []const u8 }; + +/// DocumentSymbol[] nests (`children`), SymbolInformation[] is flat: each +/// its kind's mark and its name qualified by the ones it is in (the +/// nesting, or SymbolInformation's `containerName`), into `out`. +fn walkSymbols(arena: std.mem.Allocator, out: *std.ArrayList(Symbol), uri: []const u8, node: std.json.Value, qualifier: []const u8, depth: u8) Err!void { if (depth > 8) return; for (items(node)) |sym| { const name = str(get(sym, "name")) orelse continue; + const kind = symbolKind(num(get(sym, "kind")) orelse 0); + const container = if (qualifier.len > 0) qualifier else str(get(sym, "containerName")) orelse ""; + const qualified = if (container.len > 0) try std.fmt.allocPrint(arena, "{s}.{s}", .{ container, name }) else name; + const note = try std.fmt.allocPrint(arena, "{s} {s}", .{ kind.mark(), qualified }); if (get(get(sym, "location"), "range")) |r| { - try emitRange(cx, enc, str(get(get(sym, "location"), "uri")) orelse uri, r, name); + try out.append(arena, .{ .kind = kind, .uri = str(get(get(sym, "location"), "uri")) orelse uri, .range = r, .note = note }); } else { - try emitRange(cx, enc, uri, get(sym, "selectionRange") orelse get(sym, "range"), name); + try out.append(arena, .{ .kind = kind, .uri = uri, .range = get(sym, "selectionRange") orelse get(sym, "range"), .note = note }); } - if (get(sym, "children")) |kids| try walkSymbols(cx, enc, uri, kids, depth + 1); + if (get(sym, "children")) |kids| try walkSymbols(arena, out, uri, kids, qualified, depth + 1); } } +/// LSP's SymbolKind as the Symbols picker's (UX DESIGN N2). +fn symbolKind(lsp_kind: i64) SymbolKind { + return switch (lsp_kind) { + 5, 10, 11, 23, 26 => .type, + 6, 9, 12, 25 => .function, + 7, 8, 22 => .field, + 14 => .constant, + 13, 15...21, 24 => .variable, + 1...4 => .module, + else => .other, + }; +} + /// Pull when the server does (LSP 3.17), the push store otherwise. The store /// path waits briefly for a publish that postdates the didChange we just /// sent, so `]d` right after an edit sees the new truth, not the old one. diff --git a/docs/typ/guide.typ b/docs/typ/guide.typ index 66d3bb00..d80302c5 100644 --- a/docs/typ/guide.typ +++ b/docs/typ/guide.typ @@ -207,7 +207,7 @@ Line 1's first word names what it searches, and editing the word changes it: [`Grep text`], [the lines of those files holding `text`, literally (#key("SPC f g"), #word("Grep")); past 2000 lines #word("More") goes on], [`Recent name`], [the files opened lately, in any window (#key("SPC f r"), #word("Recent"))], [`Panes name`], [the open panes, then the ones closed this session, `(closed)` and dimmer: #key("Enter") (or a #word("Look") at its `@pN`) brings one back where it was, its text with it (#key("SPC b b"), #word("Panes"))], - [`Symbols name`], [the text's declarations (#key("SPC s s"))], + [`Symbols name`], [the text's symbols, a row each: its kind's mark (`t` type, `f` function, `m` field, `c` const, `v` var, `n` module, `·` other), its name in the ones it is in (`Counts.lines`), what its line says after the name; types, functions, fields, then the rest, each in the text's order, and so while typed, the best match current (#key("SPC s s"))], [`All pat`], [every open pane's text, its rows under each pane (#key("SPC /"))], [`Refs`, `Def`, `Impl`, `Diagnostics`], [the language server's lists (#key("g r"), #key("g d"), #key("g i"), #key("SPC l d")): one answer is a jump, none a message; several open the list with the keyboard on its current row in normal mode (#keys("j", "k", "n", "N") step it, #key("Enter") lands, #key("Esc") goes back), the diagnostics' keeping it in the text for `]d`; their places in the text tinted as a `/`'s are], ) diff --git a/docs/typ/reference.typ b/docs/typ/reference.typ index 42b44fc9..035625cf 100644 --- a/docs/typ/reference.typ +++ b/docs/typ/reference.typ @@ -290,7 +290,8 @@ A line written to #file("exec") is #word("Exec"): runtime depth (1–64, default 8) for subsequent queries. #word("Callers") and #word("Callees") keep their short lists and single-result jumps. - #word("Diagnostics") and #word("Symbols") list the file's in `+Search`; + #word("Diagnostics") and #word("Symbols") list the file's in `+Search` + (its symbols marked and in the order #key("SPC s s") lists them); #word("Lspinfo") fills `+Lsp`, the pane its write answers, with the index the file asks (`scip: , , , , indexed , files newer`, or `scip: no index.scip above ; diff --git a/test/behaviour/language_servers.zig b/test/behaviour/language_servers.zig index 13e42fa6..80d1cb1e 100644 --- a/test/behaviour/language_servers.zig +++ b/test/behaviour/language_servers.zig @@ -206,7 +206,7 @@ test "language-servers: Symbols lists the file's definitions by name, a local's try s.write(s.at("/pane/{d}/look", .{main}), s.at("{s}/lib.rs\n", .{std.fs.path.dirname(std.mem.trimEnd(u8, try s.read(s.at("/pane/{d}/name", .{main})), "\n")).?})); try s.write(s.at("/pane/{d}/ctl", .{try s.focused()}), "Symbols\n"); const rows = try bodyOf(&s, "+Search"); - for ([_][]const u8{ "lib.rs:1:11-15\nShape\n", "lib.rs:2:8-11\narea\n", "lib.rs:5:8-10\nadd\n", "lib.rs:8:12-17\nSquare\n", "lib.rs:10:8-11\narea\n" }) |row| + for ([_][]const u8{ "lib.rs:1:11-15 Shape\n", "lib.rs:2:8-11 area\n", "lib.rs:5:8-10 add\n", "lib.rs:8:12-17 Square\n", "lib.rs:10:8-11 area\n" }) |row| try std.testing.expect(has(rows, row)); try std.testing.expect(!has(rows, "lib.rs:5:12")); } @@ -323,3 +323,26 @@ test "language-servers: SPC l a lists the server's code actions in the pane's ta try s.keys("u"); try s.expect(body, before); } + +test "language-servers: a server's Symbols are the Symbols picker's rows: types, functions, fields, then the rest, each its kind's mark and its name in the ones it is in (UX DESIGN N)" { + var tmp = std.testing.tmpDir(.{}); + defer tmp.cleanup(); + var s = try Session.initLanguage(std.testing.allocator); + defer s.deinit(); + try s.write("/ctl", "Jumps new-pane\n"); + // No index: the server is asked. + try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "shapes.rs", .data = "const LIMIT: u32 = 4;\n\nfn main() {}\npub struct Shape {\n side: u32,\n fn area() {}\n}\nenum Kind {\n Round,\n}\nmod lib;\n" }); + var buf: [4096]u8 = undefined; + const dir = buf[0..try tmp.dir.realPath(std.testing.io, &buf)]; + const shapes = try s.lookFile(s.at("{s}/shapes.rs:1:1", .{dir})); + try s.write(s.at("/pane/{d}/ctl", .{shapes}), "Symbols\n"); + const rows = try bodyOf(&s, "+Search"); + var at: usize = 0; + for ([_][]const u8{ "shapes.rs:4:12-16 t Shape\n", "shapes.rs:8:6-9 t Kind\n", "shapes.rs:3:4-7 f main\n", "shapes.rs:6:8-11 f Shape.area\n", "shapes.rs:5:5-8 m Shape.side\n", "shapes.rs:9:5-9 m Kind.Round\n", "shapes.rs:1:7-11 c LIMIT\n", "shapes.rs:11:5-7 n lib\n" }) |row| { + const found = std.mem.indexOfPos(u8, rows, at, row) orelse { + std.debug.print("{s} not after {d} in\n{s}\n", .{ row, at, rows }); + return error.TestUnexpectedResult; + }; + at = found + row.len; + } +} diff --git a/test/lspmock.zig b/test/lspmock.zig index 0fd34677..6f52f568 100644 --- a/test/lspmock.zig +++ b/test/lspmock.zig @@ -257,8 +257,15 @@ fn handle(a: std.mem.Allocator, raw: []const u8) void { } else if (std.mem.eql(u8, method, "textDocument/hover")) { reply(a, rid, "{{\"contents\":{{\"kind\":\"markdown\",\"value\":\"mock hover: pub fn add\"}}}}", .{}); } else if (std.mem.eql(u8, method, "textDocument/documentSymbol")) { - reply(a, rid, "[{{\"name\":\"main\",\"kind\":12,\"range\":{s},\"selectionRange\":{s}}}]", .{ - range(a, 2, 0, 11), range(a, 2, 3, 7), + // Nested and in no kind's order: a const, a function, a struct + // with a field and a method, an enum with a member, a module. + reply(a, rid, "[{{\"name\":\"LIMIT\",\"kind\":14,\"range\":{s},\"selectionRange\":{s}}},{{\"name\":\"main\",\"kind\":12,\"range\":{s},\"selectionRange\":{s}}}," ++ + "{{\"name\":\"Shape\",\"kind\":23,\"range\":{s},\"selectionRange\":{s},\"children\":[{{\"name\":\"side\",\"kind\":8,\"range\":{s},\"selectionRange\":{s}}},{{\"name\":\"area\",\"kind\":6,\"range\":{s},\"selectionRange\":{s}}}]}}," ++ + "{{\"name\":\"Kind\",\"kind\":10,\"range\":{s},\"selectionRange\":{s},\"children\":[{{\"name\":\"Round\",\"kind\":22,\"range\":{s},\"selectionRange\":{s}}}]}},{{\"name\":\"lib\",\"kind\":2,\"range\":{s},\"selectionRange\":{s}}}]", .{ + range(a, 0, 0, 21), range(a, 0, 6, 11), range(a, 2, 0, 11), range(a, 2, 3, 7), + range(a, 3, 0, 18), range(a, 3, 11, 16), range(a, 4, 4, 14), range(a, 4, 4, 8), + range(a, 5, 4, 16), range(a, 5, 7, 11), range(a, 7, 0, 11), range(a, 7, 5, 9), + range(a, 8, 4, 10), range(a, 8, 4, 9), range(a, 10, 0, 8), range(a, 10, 4, 7), }); } else if (std.mem.eql(u8, method, "workspace/symbol")) { const q = str(get(params, "query")) orelse ""; diff --git a/test/snapshots/lsp.golden b/test/snapshots/lsp.golden index c680700d..0db3b21e 100644 --- a/test/snapshots/lsp.golden +++ b/test/snapshots/lsp.golden @@ -59,13 +59,13 @@ == snap symbols grid=120x41 cursor=24,2 |2: ^ a.zig:8 › ␣ l Symbols 1/3 |3: │ │ Walk Look Split Newcol Grep Edit Copy Keep Drop | Find Grep Recent Panes Symbols All Jumplist -|4: │ │ ▶ a.zig:1:7-9 std -|5: │ │ a.zig:3:4-9 helper -|6: │ │ a.zig:7:8-11 main +|4: │ │ ▶ a.zig:3:4-9 f helper +|5: │ │ a.zig:7:8-11 f main +|6: │ │ a.zig:1:7-9 c std |7: │ │ -|8: 1▸const std = @import("std"); +|8: 1 const std = @import("std"); |9: 2 -|10: 3 fn helper(x: u32) u32 { +|10: 3▸fn helper(x: u32) u32 { |11: fn helper(x: u32) u32 |12: (fn (u32) u32) |13: 4 return x + 1; @@ -81,6 +81,6 @@ |4: │ │ nothing matches |5: │ │ |6: │ │ -|8: 1 const std = @import("std"); +|10: 3 fn helper(x: u32) u32 { == snap nothing grid=120x41 cursor=29,2 |2: ^ a.zig:8 › ␣ l Symbols jngd 0 -- cgit v1.3