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/Query.zig | 49 +++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 39 insertions(+), 10 deletions(-) (limited to 'core/Query.zig') diff --git a/core/Query.zig b/core/Query.zig index 2b2abebb..743e9540 100644 --- a/core/Query.zig +++ b/core/Query.zig @@ -530,8 +530,9 @@ fn makeNameRows(p: *Pardes, id: usize) !void { f.pager_spans = spans.toOwnedSlice(p.gpa) catch &.{}; q.total = q.names.hits.items.len; q.more = q.names.busy() or p.stream.busyFor(rp.serial); - // The best is current until a step or a click moves it. - q.current = if (shown > 0) 0 else null; + // The best is current until a step or a click moves it: in a grouped + // list (Symbols) wherever its group puts it. + q.current = if (shown > 0) @min(q.names.bestRow(), shown - 1) else null; countCurrent(q); showCurrent(p.settings.tab, rp); if (q.current == null) blankPreview(p, id) else showTarget(p, id); @@ -771,23 +772,51 @@ pub fn gather(p: *Pardes, names: *Names, source: Source, dir: []const u8, self: const oid = owner_id orelse return; const owner = p.panes[oid].?; const f = if (owner.file) |*file| file else return; - const decls = ownerDecls(f) orelse { + if (f.context.revision != f.revision) { // Parsed on the worker; listed when it is done (declsArrived). Stream.parseFor(p, oid); return; - }; - for (decls) |d| { - const header = f.content[d.start_byte..@min(d.header_end_byte, f.content.len)]; - const first = std.mem.trim(u8, header[0 .. std.mem.indexOfScalar(u8, header, '\n') orelse header.len], " \t\r"); - var buf: [256 + 16]u8 = undefined; - const row = std.fmt.bufPrint(&buf, "{d: >6} {s}", .{ d.start_line + 1, first[0..@min(first.len, 240)] }) catch continue; - names.add(gpa, row, 8, row.len - 8, 0, @intCast(d.start_line + 1)) catch break; } + // The file's text, which was parsed (the `Changes` layer's lines + // are none of it). + const text = File.fileText(f, p.scratch.allocator()) catch return; + const symbols = f.context.symbols; + // A row a symbol, ` 12 m Counts.lines : usize = 0`: its + // 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. + 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; + var row: std.Io.Writer = .fixed(&buf); + 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; + 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.cands.items[names.cands.items.len - 1].group = @intCast(group); + }; }, else => {}, } } +/// The names of the symbols `parent` (an index + 1) is in, outermost +/// first, each with its `.`: `Outer.Inner.` (the `depth` innermost). +fn qualify(w: *std.Io.Writer, symbols: []const syntax.Symbol, text: []const u8, parent: u32, depth: u8) std.Io.Writer.Error!void { + if (parent == 0 or parent > symbols.len or depth == 0) return; + const up = symbols[parent - 1]; + if (up.name_end > text.len) return; + try qualify(w, symbols, text, up.parent, depth - 1); + try w.print("{s}.", .{text[up.name_start..up.name_end]}); +} + /// What a Panes row of a closed pane ends with. const closed_word = " (closed)"; -- 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/Query.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 89f51118eb241fdb5673e91eb09e5abe5c6a0bcb Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 26 Nov 2026 03:03:28 -0300 Subject: Pick, Query, Stream: Find and Grep search the work tree, the nearest directory at or above the asking pane's that holds a `.jj` or a `.git`, or the pane's directory outside one, and a leading directory narrows a Grep (the comparison video's finding, VIDEO2/STORY.md §3.1 and §9: from src/torque in V8 `SPC f f` listed its 67 files where Helix, LazyVim and Doom list 18,441, and `SPC f g` found 11 hits in src/torque alone; SPEC §5.1's "scoped to a directory if the query starts with one" found nothing; the coordinator's W8, the user asked, the default yes); THE CAUSE: Pick.open set every source's directory to the asking pane's (Pardes.paneDir), and Pick.filter sent a Grep's whole query to the disk engine as its pattern; THE FIX: Pick.workTree (Find and Grep only: Recent, Panes and Symbols as they were), a stat of `.jj` and `.git` per directory up from the pane's through the tape's kind site, once per picker opened; the rows' paths are from the root (Find's `src/torque/torque-parser.cc`), so Names' subsequence match over the whole path makes `torque/pars` narrow Find with no more code; Pick.grepScope: a query whose first word, then a blank, is a directory under the root (or absolute) searches that directory for the rest (`src/torque "UpperCamelCase"`); its rows' paths stay from the root (Query.take's `under`, the narrowed directory before each path; the query pane passes none), and the preview lights the pattern alone; no directory added to the head (the coordinator's rule: none was shown); RUN (TEST FIRST): Pick.zig "Find and Grep search the work tree (W8) ..." makes a tree with `.git` at its root and opens Find from src/deep/x.txt: its directory the root (on W7's tree src/deep), three rows, `sub/name` one, `sub/name.txt`; Grep `needle` two hits, `sub needle` one, `sub/name.txt:1 needle one`, its place the root's sub/name.txt; from `/held.txt` (no repository above /) the directory `/`; the tests whose Find or Grep pickers list a temporary directory make it a work tree of its own (Pick.testFile, and four tests in behaviour/addons.zig, addons_pdf.zig and other_files.zig): under the repository's .zig-cache it is in the pardes tree; MEASURED on a reflink copy of VIDEO2's V8 (18,441 files) with this change's Debug gui at 26 px, from src/torque/torque.cc, after the last key (V4's probe in brackets, the installed build): SPC f f 18,414 rows, the first at 0.10-0.11 s and all at 0.14-0.16 s [0.02 s, 67 files: src/torque alone]; `torque/pars` 7 rows at 0.09 s, torque-parser.cc among them [0 rows]; Grep `"UpperCamelCase"` 11 hits from the root at 0.26 s, its typing pause included [0.11 s, 11 hits, src/torque alone]; `src/torque "UpperCamelCase"` the same 11 at 0.15 s [nothing]; this harness on the installed build: 67 files at 0.05 s, the grep 0.11-0.13 s; keys typed through the frontend (the S kit's pty): a key written to 9P's kbdin runs the listing and the search on the loop for its write's answer (Pick.start and filter's `p.fs.serving` step), so a script's `SPC f g` over V8 holds the session for seconds (seen: the 9P client timed out), as before this change over a smaller directory; the find golden (test/snapshots/find.golden) re-recorded: from sub/ZQMARK-beta.txt `SPC f f` lists the root's five files, a band row more; replica.zig's may_wait lists `Find *` and `Grep *` stopping at `kind` (the root asked of the session's disk, as their listing and search are); gates: core-test 1129/1302 (173 skipped: +1), shell-test 1350/1353 (3 skipped: +1), pane-test 183/184, behaviour-test 285/285 and --replay 285/285, process-test 0 of 147 failed (3 skipped; find re-recorded), term-test 17/17, kitty-test 45/45, the gui unit-test 1958/1962 (4 skipped; its perf check's BaselineHarnessMismatch, every base's) on this change, W7 under it; no dump change; shots .scratch/walkui/W78/png v1-v3; no frame or perf gate (the user's rule of 2026-11-26); load 3.7 to 15.9 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/Jump.zig | 2 + core/Pick.zig | 117 ++++++++++++++++++++++++++++++++++++++--- core/Query.zig | 9 ++-- core/Stream.zig | 2 +- core/replica.zig | 2 + test/behaviour/addons.zig | 8 +++ test/behaviour/addons_pdf.zig | 2 + test/behaviour/other_files.zig | 2 + test/snapshots/find.golden | 3 ++ 9 files changed, 136 insertions(+), 11 deletions(-) (limited to 'core/Query.zig') diff --git a/core/Jump.zig b/core/Jump.zig index 3632a039..143aa9b5 100644 --- a/core/Jump.zig +++ b/core/Jump.zig @@ -472,6 +472,8 @@ test "Ctrl-o pops the walk one word at a time (UX L'1): after SPC f f words, Ent defer p.deinit(); var tmp = std.testing.tmpDir(.{}); defer tmp.cleanup(); + // A work tree of its own: Find searches it, not the one the test runs in. + try tmp.dir.createDir(std.testing.io, ".git", .default_dir); var text: [60 * 16]u8 = undefined; var w: std.Io.Writer = .fixed(&text); for (1..61) |n| try w.print("{s} {d}\n", .{ if (n % 12 == 4) "in_word" else "line", n }); diff --git a/core/Pick.zig b/core/Pick.zig index f13278af..cfef2baf 100644 --- a/core/Pick.zig +++ b/core/Pick.zig @@ -226,7 +226,8 @@ pub fn open(p: *Pardes, from: usize, source: Source, word: []const u8, query: [] const pk = make(p, source) catch |err| return p.reportError(.at(from), "pick", err); pk.word.set(if (word.len > 0) word else words.get(source).word); pk.keys.set(words.get(source).keys); - pk.dir.set(Pardes.paneDir(asker)); + // Find and Grep from the work tree's root (W8), as other finders search. + pk.dir.set(if (source == .find or source == .grep) workTree(p, Pardes.paneDir(asker)) else Pardes.paneDir(asker)); pk.rows = p.gpa.dupe(u8, rows) catch |err| return p.reportError(.at(from), "pick", err); hostIn(p, pk, from) catch |err| return p.reportError(.at(from), "pick", err); if (p.paneBySerial(pk.landing)) |host| pk.cap = p.view().rects[host].h * 2 / 5; @@ -237,6 +238,35 @@ pub fn open(p: *Pardes, from: usize, source: Source, word: []const u8, query: [] if (source == .themes and query.len == 0 and p.custom_theme == null) p.view().tag_state.rows.at = @intCast(p.settings.theme); } +/// The work tree `dir` is in: the nearest directory at or above it that +/// holds a `.jj` or a `.git` (a git worktree's is a file); `dir` itself +/// when none does. Find and Grep search from it, their rows' paths +/// relative to it, wherever in the tree the asking pane is. +fn workTree(p: *Pardes, dir: []const u8) []const u8 { + var d = dir; + while (true) { + var buf: [4096]u8 = undefined; + for ([_][]const u8{ ".jj", ".git" }) |name| { + const marker = std.fmt.bufPrint(&buf, "{s}/{s}", .{ std.mem.trimEnd(u8, d, "/"), name }) catch return dir; + if (exec.kindOf(p.tape, marker) != null) return d; + } + d = std.Io.Dir.path.dirname(d) orelse return dir; + } +} + +/// Where a Grep's query `q` searches and for what (SPEC §5.1): a leading +/// directory, the root's or absolute, then a blank, narrows it to that +/// directory (`src/torque Macro`), the rest the pattern; else all of it +/// from the root. The directory joined in `buf`. +fn grepScope(p: *Pardes, pk: *const Pick, q: []const u8, buf: *[4096]u8) struct { dir: []const u8, pat: []const u8 } { + const root = pk.dir.slice(); + const sp = std.mem.indexOfScalar(u8, q, ' ') orelse return .{ .dir = root, .pat = q }; + const lead = q[0..sp]; + const dir = if (lead[0] == '/') lead else std.fmt.bufPrint(buf, "{s}/{s}", .{ std.mem.trimEnd(u8, root, "/"), lead }) catch return .{ .dir = root, .pat = q }; + if (exec.kindOf(p.tape, dir) != .directory) return .{ .dir = root, .pat = q }; + return .{ .dir = dir, .pat = std.mem.trimStart(u8, q[sp + 1 ..], " ") }; +} + /// A new picker in the ring, the oldest kept one dropped for it. fn make(p: *Pardes, source: Source) !*Pick { var slot: ?usize = null; @@ -456,8 +486,10 @@ pub fn filter(p: *Pardes, pk: *Pick) void { if (pk.source == .grep) { pk.found.clearRetainingCapacity(); pk.found_bytes.clearRetainingCapacity(); - if (q.len > 0) { - Stream.query(p, pk.id, .grep, q, pk.dir.slice(), if (p.fs.serving) .now else .typed) catch |err| return p.reportError(.at(p.view().active), "pick", err); + var buf: [4096]u8 = undefined; + const at = grepScope(p, pk, q, &buf); + if (at.pat.len > 0) { + Stream.query(p, pk.id, .grep, at.pat, at.dir, if (p.fs.serving) .now else .typed) catch |err| return p.reportError(.at(p.view().active), "pick", err); if (p.fs.serving) Stream.step(p); } else if (p.stream.target == pk.id) _ = p.stream.stop(); return; @@ -501,7 +533,12 @@ fn allPanes(p: *const Pardes, pk: *const Pick, out: *[pardes.MAX_PANES]usize) [] /// The disk engine's rows for picker `target` (Stream.receive). pub fn take(p: *Pardes, target: u32, kind: Stream.Kind, rows: []const u8) bool { const pk = byId(p, target) orelse return false; - Query.take(p, pk, kind, rows); + // A Grep narrowed to a directory (grepScope): its rows' paths from the + // root, as an unnarrowed one's are. + var buf: [4096]u8 = undefined; + const searched = p.stream.dir.items; + const under = if (kind == .grep and !std.mem.eql(u8, searched, pk.dir.slice())) std.fmt.bufPrint(&buf, "{s}/", .{relative(searched, pk.dir.slice())}) catch "" else ""; + Query.take(p, pk, kind, rows, under); // A listing's names, scored as they come. if (kind == .files) pk.names.rescore(p.gpa); return true; @@ -626,7 +663,8 @@ fn rowAt(p: *Pardes, pk: *const Pick, arena: std.mem.Allocator, i: usize) std.me var marks: std.ArrayList(u16) = .empty; var c = fd.col; while (c < fd.end and c >= lead and pre.len + 1 + c - lead < text.len) : (c += 1) try marks.append(arena, @intCast(pre.len + 1 + c - lead)); - const path = try std.Io.Dir.path.join(arena, &.{ dir, name }); + // (Under an absolute leading directory, grepScope's, an absolute path.) + const path = if (name.len > 0 and name[0] == '/') name else try std.Io.Dir.path.join(arena, &.{ dir, name }); return .{ .text = text, .pre = @intCast(pre.len), .marks = marks.items, .target = .{ .place = .{ .path = path, .at = .{ .line = fd.line, .col = fd.col + 1 } } } }; } var marks: [Names.max_query * 4]u16 = undefined; @@ -987,7 +1025,10 @@ fn preview(p: *Pardes, pk: *Pick) void { } look.focusPaneLine(p, id, at, .third); // A Grep's matches in the file lit, as its own pane would have them. - if (pk.source == .grep) pane.places.search(p, pane, .list, pk.id, std.mem.trim(u8, s.field.text(), " "), true, null, false); + if (pk.source == .grep) { + var buf: [4096]u8 = undefined; + pane.places.search(p, pane, .list, pk.id, grepScope(p, pk, std.mem.trim(u8, s.field.text(), " "), &buf).pat, true, null, false); + } } /// Landing pane `id`'s text `bytes` (taken) as `path`: its own text set @@ -2067,6 +2108,9 @@ pub fn execWord(p: *Pardes, txt: []const u8) bool { } fn testFile(p: *Pardes, tmp: *std.testing.TmpDir, name: []const u8, text: []const u8) ![]u8 { + // The directory a work tree of its own, as a project is: Find and Grep + // search it, not the tree the test runs in. + tmp.dir.createDir(std.testing.io, ".git", .default_dir) catch |err| if (err != error.PathAlreadyExists) return err; try tmp.dir.writeFile(std.testing.io, .{ .sub_path = name, .data = text }); var base_buf: [std.Io.Dir.max_path_bytes]u8 = undefined; const dir = base_buf[0..try tmp.dir.realPath(std.testing.io, &base_buf)]; @@ -3351,3 +3395,64 @@ test "Ctrl-r in a picker unrolls its source's earlier queries (UX L2's last line p.update(.{ .key = .{ .cp = Key.escape } }); p.update(.{ .key = .{ .cp = Key.escape } }); } + +test "Find and Grep search the work tree (W8): from a pane deep in a repo Find lists the files from its root and `sub/name` narrows it, a leading directory narrows Grep, and outside a repo they search the pane's directory" { + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 30 }); + defer p.deinit(); + p.settings.jumps = .walk; + p.stream.engine = .walk; + var tmp = std.testing.tmpDir(.{}); + defer tmp.cleanup(); + for ([_][]const u8{ "src/deep", "sub", "other" }) |d| try tmp.dir.createDirPath(std.testing.io, d); + const deep = try testFile(p, &tmp, "src/deep/x.txt", "deep\n"); + defer p.gpa.free(deep); + for ([_][2][]const u8{ .{ "sub/name.txt", "needle one\n" }, .{ "other/name.txt", "needle two\n" } }) |f| p.gpa.free(try testFile(p, &tmp, f[0], f[1])); + const root = std.Io.Dir.path.dirname(std.Io.Dir.path.dirname(std.Io.Dir.path.dirname(deep).?).?).?; + _ = try p.setTestFile("held\n"); + const asker = p.view().active; + Trail.keep(p.panes[asker].?); + p.gpa.free(p.panes[asker].?.file.?.path); + p.panes[asker].?.file.?.path = try p.gpa.dupe(u8, deep); + var frame = std.heap.ArenaAllocator.init(std.testing.allocator); + defer frame.deinit(); + const a = frame.allocator(); + // Find from src/deep: the root's files, by their paths from it. + open(p, asker, .find, "", "", ""); + var pk = live(p).?; + try std.testing.expectEqualStrings(root, pk.dir.slice()); + settle(p); + try std.testing.expectEqual(@as(usize, 3), count(p, pk)); + for ("sub/name") |c| p.update(.{ .key = .{ .cp = c, .text = &[_]u8{c} } }); + settle(p); + try std.testing.expectEqual(@as(usize, 1), count(p, pk)); + try std.testing.expectEqualStrings("sub/name.txt", (try rowAt(p, pk, a, 0)).text); + p.update(.{ .key = .{ .cp = Key.escape } }); + // Grep: the whole tree, then `sub needle` in sub/ alone, its row's + // path from the root, landing on the file there. + open(p, asker, .grep, "", "", ""); + pk = live(p).?; + for ("needle") |c| p.update(.{ .key = .{ .cp = c, .text = &[_]u8{c} } }); + // (Its typing paused: the search starts.) + p.clock.now_ns = p.stream.due_ns.?; + settle(p); + try std.testing.expectEqual(@as(usize, 2), count(p, pk)); + p.update(.{ .key = .{ .cp = Key.escape } }); + open(p, asker, .grep, "", "", ""); + pk = live(p).?; + for ("sub needle") |c| p.update(.{ .key = .{ .cp = c, .text = &[_]u8{c} } }); + // (Its typing paused: the search starts.) + p.clock.now_ns = p.stream.due_ns.?; + settle(p); + try std.testing.expectEqual(@as(usize, 1), count(p, pk)); + const row = try rowAt(p, pk, a, 0); + try std.testing.expect(std.mem.startsWith(u8, row.text, "sub/name.txt:1 needle one")); + try std.testing.expectEqualStrings(try std.Io.Dir.path.join(a, &.{ root, "sub/name.txt" }), row.target.place.path); + p.update(.{ .key = .{ .cp = Key.escape } }); + // Outside a repo (`/`, the test text's directory, holds no .jj nor + // .git): the pane's directory, as before. + p.gpa.free(p.panes[asker].?.file.?.path); + p.panes[asker].?.file.?.path = try p.gpa.dupe(u8, "/held.txt"); + open(p, asker, .find, "", "", ""); + try std.testing.expectEqualStrings("/", live(p).?.dir.slice()); + p.update(.{ .key = .{ .cp = Key.escape } }); +} diff --git a/core/Query.zig b/core/Query.zig index 2b2abebb..fff6065c 100644 --- a/core/Query.zig +++ b/core/Query.zig @@ -1269,7 +1269,7 @@ fn countGrepCurrent(q: *Query) void { /// picker (Pick.zig: the same fields): a Grep's lines (`path:line:col-end /// code`, relative to the pane's directory) kept as found, a listing's /// names added to what Find scores. -pub fn take(p: *Pardes, q: anytype, kind: Stream.Kind, rows: []const u8) void { +pub fn take(p: *Pardes, q: anytype, kind: Stream.Kind, rows: []const u8, under: []const u8) void { var lines = std.mem.splitScalar(u8, rows, '\n'); while (lines.next()) |ln| { if (ln.len == 0) continue; @@ -1286,13 +1286,14 @@ pub fn take(p: *Pardes, q: anytype, kind: Stream.Kind, rows: []const u8) void { const name = if (ln[0] == '"') look.unquoted(&namebuf, t.path) else t.path; const found: Found = .{ .path = std.math.cast(u32, q.found_bytes.items.len) orelse return, - .path_len = std.math.cast(u16, name.len) orelse continue, + .path_len = std.math.cast(u16, under.len + name.len) orelse continue, .line = std.math.cast(u32, t.at.line) orelse continue, .col = std.math.cast(u32, t.at.col -| 1) orelse continue, .end = std.math.cast(u32, if (t.at.end_col > 0) t.at.end_col else t.at.col) orelse continue, - .code = std.math.cast(u32, q.found_bytes.items.len + name.len) orelse return, + .code = std.math.cast(u32, q.found_bytes.items.len + under.len + name.len) orelse return, .code_len = std.math.cast(u32, code.len) orelse continue, }; + q.found_bytes.appendSlice(p.gpa, under) catch return; q.found_bytes.appendSlice(p.gpa, name) catch return; q.found_bytes.appendSlice(p.gpa, code) catch return; q.found.append(p.gpa, found) catch return; @@ -2811,7 +2812,7 @@ test "Grep: a row whose numbers a Found cannot hold (a column past u32) is passe defer p.deinit(); var q: Query = .{ .owner = 0 }; defer q.deinit(p.gpa); - take(p, &q, .grep, "a:5000000000:b:3:1-4 hit\nok.txt:2:3-5 hit\nb:7:4294967297 hit\n"); + take(p, &q, .grep, "a:5000000000:b:3:1-4 hit\nok.txt:2:3-5 hit\nb:7:4294967297 hit\n", ""); // Taken or passed over, each: never cast (main: Query.zig:1267). try std.testing.expect(q.found.items.len <= 3); } diff --git a/core/Stream.zig b/core/Stream.zig index e9e7793b..93be5c1f 100644 --- a/core/Stream.zig +++ b/core/Stream.zig @@ -717,7 +717,7 @@ pub fn receive(p: *Pardes, b: *const Batch) void { const id = p.paneBySerial(s.target) orelse return; const q = p.panes[id].?.query orelse return; q.capped = s.state == .capped; - panes.Query.take(p, q, s.kind, b.rows); + panes.Query.take(p, q, s.kind, b.rows, ""); } /// A parse's answer: its task joined; the declarations kept as the pane's diff --git a/core/replica.zig b/core/replica.zig index 97cbaeee..d07ce9d3 100644 --- a/core/replica.zig +++ b/core/replica.zig @@ -7351,6 +7351,8 @@ const may_wait = [_]Wait{ .{ .what = "Save", .on = .any, .stop = "write_file", .why = "a save" }, // A program run, a shell opened or closed: the session's processes. .{ .what = "Exec *", .on = .any, .stop = "kind", .why = "a program run: its name asked of the disk first" }, + .{ .what = "Find *", .on = .any, .stop = "kind", .why = "the work tree it lists from, a `.jj` or `.git` above the pane's directory asked of the session's disk (Pick.workTree), as the listing itself is the session's" }, + .{ .what = "Grep *", .on = .any, .stop = "kind", .why = "the work tree it searches, a `.jj` or `.git` above the pane's directory asked of the session's disk (Pick.workTree), as the search itself is the session's" }, .{ .what = "Exec *", .on = .any, .stop = "tty_taken", .why = "a program run in a shell: whether one has it, the session's" }, .{ .what = "Term", .on = .any, .stop = "kind", .why = "a shell opened: its name asked of the disk first" }, .{ .what = "A-n", .on = .any, .stop = "open a terminal", .why = "a shell opened" }, diff --git a/test/behaviour/addons.zig b/test/behaviour/addons.zig index 25b1e523..90f4e383 100644 --- a/test/behaviour/addons.zig +++ b/test/behaviour/addons.zig @@ -381,6 +381,8 @@ fn dirOf(s: *Session, tmp: *std.testing.TmpDir) ![]const u8 { 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(); + // A work tree of its own: Find searches it, not the one the test runs in. + try tmp.dir.createDir(std.testing.io, ".git", .default_dir); 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"); @@ -421,6 +423,8 @@ test "addons: a picker shows a file of an addon's kind through its kind in the p 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(); + // A work tree of its own: Find searches it, not the one the test runs in. + try tmp.dir.createDir(std.testing.io, ".git", .default_dir); 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" }); @@ -462,6 +466,8 @@ test "addons: a picker's row of a file no kind takes and not text shows one line 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(); + // A work tree of its own: Find searches it, not the one the test runs in. + try tmp.dir.createDir(std.testing.io, ".git", .default_dir); 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 }); @@ -499,6 +505,8 @@ test "addons: moving the cursor over pictures in a picker draws only the one it 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(); + // A work tree of its own: Find searches it, not the one the test runs in. + try tmp.dir.createDir(std.testing.io, ".git", .default_dir); 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"); diff --git a/test/behaviour/addons_pdf.zig b/test/behaviour/addons_pdf.zig index d773f4e2..eca39012 100644 --- a/test/behaviour/addons_pdf.zig +++ b/test/behaviour/addons_pdf.zig @@ -307,6 +307,8 @@ test "addons: a PDF under a picker's cursor shows through the pdf addon in the p try s.loadPdf(); var tmp = std.testing.tmpDir(.{}); defer tmp.cleanup(); + // A work tree of its own: Find searches it, not the one the test runs in. + try tmp.dir.createDir(std.testing.io, ".git", .default_dir); 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" }); diff --git a/test/behaviour/other_files.zig b/test/behaviour/other_files.zig index e6c104c3..8a9016bc 100644 --- a/test/behaviour/other_files.zig +++ b/test/behaviour/other_files.zig @@ -25,6 +25,8 @@ test "other-files: kbdin types at the pane with the keyboard and mousein clicks, test "other-files: kbdin's keys are the user's: SPC f f opens Find's picker in the pane's tag where jumps walk, not the +Search a script's Find opens" { var tmp = std.testing.tmpDir(.{}); defer tmp.cleanup(); + // A work tree of its own: Find searches it, not the one the test runs in. + try tmp.dir.createDir(std.testing.io, ".git", .default_dir); try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "a.txt", .data = "a\n" }); try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "b.txt", .data = "b\n" }); var s = try Session.initFile(std.testing.allocator, "x\n"); diff --git a/test/snapshots/find.golden b/test/snapshots/find.golden index 34333048..905c35e8 100644 --- a/test/snapshots/find.golden +++ b/test/snapshots/find.golden @@ -80,6 +80,7 @@ |5: │ │ |6: │ │ |7: │ │ +|8: │ │ |40: ⏎ lands here · its text is the preview · S-⏎ a new pane 1 message · SPC h m == snap cancel grid=120x41 cursor=7,3 |2: here.txt:1 › Find zqm 2/3 › /tmp/pardes-snap/find/cwd/sub/ZQMARK-beta.txt Keep Save Term Collapse Follow Del @@ -88,6 +89,7 @@ |5: |6: |7: +|8: |40: ✓ /tmp/pardes-snap/find/cwd/sub/ZQMARK-beta.txt Find 1 message · SPC h m == snap topbar grid=120x41 cursor=29,2 |2: ^ Find zqm 2/3 › ␣ f Find bod 0 @@ -96,4 +98,5 @@ |5: │ │ |6: │ │ |7: │ │ +|8: │ │ |40: ⏎ lands here · its text is the preview · S-⏎ a new pane 1 message · SPC h m -- 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/Query.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 From 5dab435d7262b87d2cf40d6a27cea9c2d981c2e8 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 26 Nov 2026 04:01:58 -0300 Subject: Core, Term: a terminal's emulator and pty are resized once a step and its burst of inputs, at the size the layout settles on, never once a key: a level that borrows a shell's rows and gives them back in one burst resizes neither, and the shell keeps its prompt line (agent M1's find, ymkwwwnn 94f00e966c90: ttyhelp's row 3, the shell's `$`, blank after `SPC ? tutor`); THE CAUSE: Pardes.sync, at the end of every `update` (a key), resized each terminal whose rect changed (Pane.resizeGrid, Term.resize) and queued its pty's resize; `?`'s level takes 3 of the shell's rows (layout.floorRows), `tutor` in the same read gives them back, so the emulator was reflowed twice, and each reflow cleared the prompt line under its cursor for the shell to draw again (ghostty's Screen.resize, clearPromptForRedraw under Terminal.flags.shell_redraws_prompt); bash, told twice with no gap, reads its size once, finds the one it had and draws nothing (the pty probe, .scratch/walkui/T123/bashprobe.py, bash 5.3.20 with pardes's mark: resized 17 -> 14 -> 17 with no gap it writes no byte; 0.3 s apart it writes `\r\e[K\r` and its prompt twice); THE FIX: `sync` is `layOut` (the geometry, every pane's cols and rows, the bands, the greetings) and `sizeTerminals`, which gives each terminal its pane's size when its emulator has another (Term.grid's cols and len: no new state, nothing in the dump), resizes the grid and queues the pty's resize; `update` lays out only, and `settle` (a pump's, a replica's step) sizes the terminals after its queued inputs and before the effects; a 9P request's step (serveFs, a kbdin write of many keys among them), a view's open and close and a watched file's reload keep the whole `sync`; `toView` sizes them before the live view parks (a terminal is sized by one view, `sizes`); a step's own layouts in its middle (a picker's first preview, Pick's showText, showKind and putBack, Query.displayPreview, Store.reopen, jj.open, layout.givePaneRows) call `layOut`; RUN (TEST FIRST): Core.zig "a level that borrows a shell's rows and gives them back in one burst of keys resizes neither its emulator nor its pty ..." boots ttyhelp's layout in the core (100x31, a shell over the +New), gives the shell pardes's bash prompt, focuses the +New and types SPC ? t u t o r with one settle after: fails on the base (two resize_pty effects queued, the shell's first row blank after the settle), passes now; three tests that fed a new shell before any step's end sized it get a `sync` (two in Core.zig) or a `settle` (ninep/pty.zig, pty/ctl's winsize read back after a resize), Term.zig's S1 table counts Core.zig's third Term.grid; the ttyhelp golden re-recorded: row 3 is the shell's `$` again (its leaderworks snap lists 6 rows, not 7); THE MARK (the ruling's second part): ghostty's own bash integration (the genizah's, and the pinned 1.4.0's) marks bash's prompt `133;A;redraw=last;cl=line`: `last` clears only the cursor's line on a resize (bash redraws only a prompt's last line), so it would not have kept M1's one-line `$` either, and ghostty never says `redraw=0` for bash (a narrower reflow would leave the old wrapped rows under bash's redraw): the mark is unchanged (`redraw=last` would keep a multi-line PS1's first lines through a real resize: a separate change, not made); a user hit it whenever a pane beside a shell at its prompt borrowed its rows and gave them back faster than the shell read its size; NEW HOT PATHS: settle and toView walk the panes once (a terminal: Term.grid, its two sizes compared), where sync did per step before; GATES: core-test 1129/1303 (174 skipped: +1, the new test needs a terminal), shell-test 1351/1354 (3 skipped: +1), pane-test 183/184, behaviour-test 285/285 and --replay 20 seeds of 70 steps, 0 failures, process-test 1 of 147 failed (3 skipped): ttyhelp, the golden re-recorded, then 5 of 5 runs alone pass, term-test 17/17, kitty-test 45/45, the gui unit-test 1959/1963 (4 skipped: +1; its perf check's BaselineHarnessMismatch, every base's); no dump change (no new state; effects are local); no frame or perf gate (the user's rule of 2026-11-26); the shots (S kit, 26 px, .scratch/walkui/T123/png): after-0..3, this change's Debug gui: ttyhelp's bare boot, the +New clicked, `SPC ? tutor` in one pty write: the prompt stays on row 3 and the level ends on the +New's tag row as in the golden; before-0..3, the installed stage's (install74): that build's level keeps 7 of the shell's rows after `tutor` (it predates W1's floor), one shrink that bash redraws, so it does not show the fault; load 4.5 to 9.0 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE --- core/Core.zig | 82 +++++++++++++++++++++++++++++++++++++------ core/Pick.zig | 8 ++--- core/Query.zig | 2 +- core/Store.zig | 2 +- core/Term.zig | 2 +- core/jj.zig | 2 +- core/layout.zig | 2 +- core/ninep/pty.zig | 1 + test/snapshots/ttyhelp.golden | 1 - 9 files changed, 82 insertions(+), 20 deletions(-) (limited to 'core/Query.zig') diff --git a/core/Core.zig b/core/Core.zig index cbcf4324..4c98977a 100644 --- a/core/Core.zig +++ b/core/Core.zig @@ -1349,6 +1349,8 @@ pub fn toView(p: *Pardes, k: View.Id) void { if (k.index() == p.live) return; const taped = pardes.tape.enter(p, .{ .to_view = k }); defer pardes.tape.leave(p, taped); + // A terminal the going view sizes takes the size its inputs left it. + p.sizeTerminals(); Views.to(p, k.index()); } @@ -1667,6 +1669,7 @@ pub fn settle(p: *Pardes) void { // ...and the last line of an open closed with no newline after it. ctlfs.runClosedLines(p); while (p.nextQueued()) |ev| p.update(ev); + p.sizeTerminals(); while (p.nextEffect()) |e| p.perform(e); turn.bump(&turn.epoch); } @@ -1847,7 +1850,9 @@ fn updateInner(p: *Pardes, ev: Event) void { pardes.panes.Query.produceAll(p, ev == .tick, ev == .key); pardes.Pick.produceAll(p, ev == .tick); _ = p.scratch.reset(.{ .retain_with_limit = memory.limits.scratch_kept }); - p.sync(); + // Laid out; its terminals are sized when the burst it came in is + // (`settle`, `sizeTerminals`). + p.layOut(); p.fsReport(); ctlfs.events.announce(p); } @@ -1969,8 +1974,41 @@ pub fn saveRecent(p: *Pardes) void { } /// Recompute geometry, push grid-size changes to each emulator and pty, -/// fire deferred greetings. +/// fire deferred greetings: a step of its own (a 9P request's, a view's). pub fn sync(p: *Pardes) void { + p.layOut(); + p.sizeTerminals(); +} + +/// Each terminal's emulator and pty at the size its pane is laid out to, +/// once a step and its burst of inputs (`settle`), never once a key: a +/// size the keys of one burst give and take back (a level borrowing a +/// shell's rows, the next key giving them back) reaches neither. Every +/// reflow clears the prompt line under the cursor for the shell to draw +/// again (ghostty's Screen.resize, `shell_redraws_prompt`), and the shell, +/// told twice, reads its size once, finds the one it had and draws +/// nothing: the prompt was gone until it next printed one. The emulator's +/// own size says what it was given; the view that sizes a terminal +/// (`sizes`) has its size. +pub fn sizeTerminals(p: *Pardes) void { + for (p.panes, 0..) |slot, id| { + const pane = slot orelse continue; + const state = pane.terminal orelse continue; + if (!p.sizes(pane)) continue; + const grid = pardes.Term.grid(state); + if (grid.cols == pane.cols and grid.len == pane.rows) continue; + pane.resizeGrid(p, pane.cols, pane.rows); + p.shell_rows.markStale(pane); // reflow moved every row + p.emit(.{ .resize_pty = .{ .pane = .at(id), .cols = pane.cols, .rows = pane.rows } }); + pane.fs.winsize = null; + } +} + +/// The step's geometry: each pane's rect, tag rows and size (a terminal's +/// emulator and pty follow once a burst: `sizeTerminals`), its bands, and +/// the deferred greetings. What a step lays out in its middle, to read the +/// geometry after (a picker's first preview), is laid out with this. +pub fn layOut(p: *Pardes) void { const v = p.view(); while (p.unplaced.findFirstSet()) |id| { p.unplaced.unset(id); @@ -2085,14 +2123,6 @@ pub fn sync(p: *Pardes) void { if ((cols != pane.cols or rows != pane.rows) and (r.h > pane.tag_rows or (pane.isTerminal() and !pane.collapsed and r.h > 0)) and (!pane.isTerminal() or p.sizes(pane))) { - // doc panes have no pty/emulator grid to reflow; just record - // the size so bodyText renders the right number of rows - if (pane.isTerminal()) { - pane.resizeGrid(p, cols, rows); - p.shell_rows.markStale(pane); // reflow moved every row - p.emit(.{ .resize_pty = .{ .pane = .at(id), .cols = cols, .rows = rows } }); - pane.fs.winsize = null; - } pane.cols = cols; pane.rows = rows; if (pane.file) |*file| file.syntax_dirty = true; @@ -4197,6 +4227,7 @@ test "leaving tty hides the prompt and keeps the command typed at it" { defer p.deinit(); p.update(.{ .resize = .{ .cols = 80, .rows = 24 } }); p.update(.{ .key = .{ .cp = 'n', .alt = true } }); // a shell under the doc + p.sync(); // its emulator sized as its step's end sizes it, before its shell speaks const shell = p.view().active; const sp = p.panes[shell].?; try std.testing.expect(sp.isTerminal()); @@ -4263,6 +4294,7 @@ test "entering tty walks the shell cursor to the column clicked past the prompt" defer p.deinit(); p.update(.{ .resize = .{ .cols = 80, .rows = 24 } }); p.update(.{ .key = .{ .cp = 'n', .alt = true } }); + p.sync(); // its emulator sized as its step's end sizes it, before its shell speaks const shell = p.view().active; const sp = p.panes[shell].?; p.update(.{ .output = .{ @@ -4308,3 +4340,33 @@ test "entering tty walks the shell cursor to the column clicked past the prompt" test "every allocation failure during boot is a clean OutOfMemory" { try std.testing.checkAllAllocationFailures(std.testing.allocator, bootAndTearDown, .{}); } + +test "a level that borrows a shell's rows and gives them back in one burst of keys resizes neither its emulator nor its pty: its prompt line stays (M1's ttyhelp row 3)" { + if (pardes.Term.ops == null) return error.SkipZigTest; // a shell's emulator + const p = try Pardes.init(std.testing.allocator, .{ .cols = 100, .rows = 31, .boot = .tty }); + defer p.deinit(); + const shell = p.panes[0].?; + // bash's prompt as pardes's marks draw it (dev/Shell.zig bash_rc), + // the cursor at its input. + p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b]133;A;cl=line;aid=pardes\x07$ \x1b]133;B;aid=pardes\x07" } }); + const below = p.view().cols[0].panes[1]; + p.view().active = below; + p.settle(); + const rows = shell.rows; + var arena = std.heap.ArenaAllocator.init(std.testing.allocator); + defer arena.deinit(); + const body_layer = @import("body_layer.zig"); + try std.testing.expect(std.mem.startsWith(u8, try body_layer.bodyText(p.settings.tab, arena.allocator(), shell), "$ ")); + // `?`'s level takes rows of the shell's (layout.floorRows), `tutor` + // narrows it to one leaf and gives them back: keys of one burst, one + // settle after them, as a frontend takes a read of them. + p.update(.{ .key = .{ .cp = ' ', .text = " " } }); + p.update(.{ .key = .{ .cp = '?', .text = "?" } }); + try std.testing.expect(shell.rows < rows); + for ("tutor") |c| p.update(.{ .key = .{ .cp = c, .text = &.{c} } }); + try std.testing.expectEqual(rows, shell.rows); + // Its pty told nothing: no SIGWINCH for a size it had. + while (p.nextEffect()) |e| try std.testing.expect(e != .resize_pty); + p.settle(); + try std.testing.expect(std.mem.startsWith(u8, try body_layer.bodyText(p.settings.tab, arena.allocator(), shell), "$ ")); +} diff --git a/core/Pick.zig b/core/Pick.zig index cfef2baf..9a9d0cde 100644 --- a/core/Pick.zig +++ b/core/Pick.zig @@ -1009,7 +1009,7 @@ fn preview(p: *Pardes, pk: *Pick) void { // laid out again before the place is put in its rows. if (!pk.previewed) { pk.previewed = true; - p.sync(); + p.layOut(); } const keyboard = p.view().active; defer p.view().active = keyboard; @@ -1060,7 +1060,7 @@ fn showText(p: *Pardes, pk: *Pick, id: usize, path_: []const u8, bytes: []u8) vo } pane.hscroll = 0; pk.previewed = true; - p.sync(); + p.layOut(); } /// Landing pane `id` showing the file at `path` through kind `k`, as a @@ -1083,7 +1083,7 @@ fn showKind(p: *Pardes, pk: *Pick, id: usize, k: u8, path: []const u8, bytes: [] Kind.close(p, pane); return showText(p, pk, id, path, line); } - p.sync(); + p.layOut(); } /// The one line a file shows while a picker previews it and none of its @@ -1154,7 +1154,7 @@ fn putBack(p: *Pardes, pk: *Pick) void { pane.body.cur_row = pk.aside_row; pane.body.cur_col = pk.aside_col; pane.body.vsel.active = false; - p.sync(); + p.layOut(); } /// The live picker rolled up (Esc, or the tag put to rest by anything): diff --git a/core/Query.zig b/core/Query.zig index fff6065c..1a420a68 100644 --- a/core/Query.zig +++ b/core/Query.zig @@ -1704,7 +1704,7 @@ fn displayPreview(p: *Pardes, qid: usize, path: []const u8, at: look.Spot) void pane.hscroll = 0; // another file: its own places, found below pane.places.clear(p.gpa); - p.sync(); + p.layOut(); } look.clearNavigationSelection(p, pane); if (at.line == 0 or at.line > File.nlines(p.gpa, f)) { diff --git a/core/Store.zig b/core/Store.zig index 1328af38..8a1c3987 100644 --- a/core/Store.zig +++ b/core/Store.zig @@ -223,7 +223,7 @@ pub fn reopen(s: *Store, p: *Pardes, serial: u32, from: usize) bool { }; p.view().active = free; if (layout.findPane(p, free)) |f| p.setActiveColumn(f.col); - p.sync(); + p.layOut(); return true; } diff --git a/core/Term.zig b/core/Term.zig index d4baf4e8..509da6d9 100644 --- a/core/Term.zig +++ b/core/Term.zig @@ -422,7 +422,7 @@ pub const calls = [_]struct { []const u8, []const u8, []const u8 }{ .{ "endOutputHere", "ninep/pty.zig:1", "WRITE: a 9P pty/run's step ends a command's output at the cursor: the session's step, replayed as such" }, .{ "replies", "Core.zig:1", "WRITE: a step drains the reply buffer (in the digest), counted when it held any (the feed's own unit, which filled it); only the session writes it to the pty (pty_write is off the tape)" }, // ---- reads by a step: in the digest ---- - .{ "grid", "Core.zig:2 ansi.zig:3 body_layer.zig:3 draw.zig:2 dump.zig:4 echo.zig:8 exec.zig:2 layout.zig:2 panes.zig:6 replica.zig:2", "READ: the size, the history's length, the cursor: in the digest (a view's place is its pane's; ansi.zig, body_layer.zig, draw.zig, echo.zig: a draw's)" }, + .{ "grid", "Core.zig:3 ansi.zig:3 body_layer.zig:3 draw.zig:2 dump.zig:4 echo.zig:8 exec.zig:2 layout.zig:2 panes.zig:6 replica.zig:2", "READ: the size, the history's length, the cursor: in the digest (a view's place is its pane's; ansi.zig, body_layer.zig, draw.zig, echo.zig: a draw's)" }, .{ "modes", "Core.zig:5 draw.zig:1 dump.zig:2 echo.zig:3 exec.zig:3 mouse.zig:4 ninep/pty.zig:3 panes.zig:2 replica.zig:1", "READ: the program's modes (mouse, focus, bracketed paste, the alternate screen): in the digest (draw.zig, echo.zig: a draw's; panes.zig: a view scrolls no history on the alternate screen)" }, .{ "prompt", "Core.zig:1 builtins.zig:1 echo.zig:1 exec.zig:3 ninep/pty.zig:1 panes.zig:1", "READ: the OSC 133 cycle: in the digest (`marksOf`); Core.zig's and ninep/pty.zig's also taped (`.prompt`, each side's compared)" }, .{ "promptPrefix", "body_layer.zig:1 edit.zig:1 exec.zig:1", "READ: a row's prompt cells (`promptCut`): the active area's in the digest; a history row's text is not (below)" }, diff --git a/core/jj.zig b/core/jj.zig index 63488b8c..bc2cea32 100644 --- a/core/jj.zig +++ b/core/jj.zig @@ -157,7 +157,7 @@ pub fn open(p: *Pardes, near: usize, path: []const u8, rev: []const u8, at: look if (replace) p.removePane(near, free) catch |err| p.reportError(.at(free), "At", err); layout.compute(p); // Sized for its place before it is centred there. - p.sync(); + p.layOut(); look.focusPaneLine(p, free, at, .center); return free; } diff --git a/core/layout.zig b/core/layout.zig index 3f6bea51..a6e6419b 100644 --- a/core/layout.zig +++ b/core/layout.zig @@ -402,7 +402,7 @@ pub fn givePaneRows(p: *Pardes, id: usize, wanted: u16, context: usize) void { if (missing == 0) break; } setColumnWeights(p, at.col, &heights); - p.sync(); + p.layOut(); } pub fn applyRowSplit(p: *Pardes, cc: usize, k: usize, cur_y: u16) void { diff --git a/core/ninep/pty.zig b/core/ninep/pty.zig index 2dd7f7f3..2671467f 100644 --- a/core/ninep/pty.zig +++ b/core/ninep/pty.zig @@ -597,6 +597,7 @@ test "every pty/ctl verb, and every refusal" { try testing.expectEqual(@as(u64, "winsize 132 44\n".len), call(p, .{ .tag = 1, .op = .getattr, .node = ctl }).reply.attr.size); try testing.expect(std.mem.startsWith(u8, rd(p, Node.of(serialOf(p), .pty_status), 0, 64).bytes, " 132 44 ")); p.update(.{ .resize = .{ .cols = 76, .rows = 24 } }); + p.settle(); // the step's end: the pty takes its pane's size (Pardes.sizeTerminals) try testing.expect(pane.cols != 132); try testing.expectEqualStrings(try std.fmt.bufPrint(&said, "winsize {d} {d}\n", .{ pane.cols, pane.rows }), rd(p, ctl, 0, 64).bytes); diff --git a/test/snapshots/ttyhelp.golden b/test/snapshots/ttyhelp.golden index 92bb4675..5ab2e6f6 100644 --- a/test/snapshots/ttyhelp.golden +++ b/test/snapshots/ttyhelp.golden @@ -42,7 +42,6 @@ |29: 5 In the tag of the pane its Enter lands in from this one: this pane if it reads, else its rea |30: ✓ @p1 Help 1 message · SPC h m == snap leaderworks grid=100x31 cursor=12,21 -|3: |21: ^ Help tutor 1/1 |22: ▶ SPC h t Tutor help │ t Tutor |23: │ Open the tutor, a document to work through. -- cgit v1.3