diff options
Diffstat (limited to 'core/root.zig')
| -rw-r--r-- | core/root.zig | 42 |
1 files changed, 31 insertions, 11 deletions
diff --git a/core/root.zig b/core/root.zig index 8d5f8c40..1b107d59 100644 --- a/core/root.zig +++ b/core/root.zig @@ -166,7 +166,13 @@ pub const TAG_TEXT_INSET: u16 = config.GUTTER; pub fn taglineOriginCol(p: *const Pardes, col: u16, row: u16) f32 { const v = p.view(); - if (row < p.topBarHeight()) return 0; + // The window row's two tags (UX K'2): a lone column's from the inset, + // the window's from its words. + if (row < p.topBarHeight()) { + const sides = tagline.windowRow(p); + if (col >= sides.words) return @floatFromInt(sides.words); + return if (sides.column > 0 and col >= TAG_TEXT_INSET) @floatFromInt(TAG_TEXT_INSET) else 0; + } if (row < p.topBarHeight() + layout.columnBarHeight(p)) { for (v.col_x[0..p.view().ncol], v.col_w[0..p.view().ncol]) |x, w| if (col >= x and col - x < w) return @floatFromInt(x); @@ -183,7 +189,17 @@ pub fn taglineOriginCol(p: *const Pardes, col: u16, row: u16) f32 { pub fn gridColAt(p: ?*const Pardes, x: f32, row: u16, body_w: f32, tagline_w: f32) u16 { const body = @max(body_w, 1); const tag = @max(tagline_w, 1); - if (row < (if (p) |core| core.topBarHeight() else TOPBAR_H)) return colFromSpan(x, tag); + if (row < (if (p) |core| core.topBarHeight() else TOPBAR_H)) { + // Its inset and the blank between its two tags on the body's grid, + // each tag's glyphs from its origin (taglineOriginCol). + const core = p orelse return colFromSpan(x, tag); + const cell = colFromSpan(x, body); + const origin: u16 = @intFromFloat(taglineOriginCol(core, cell, row)); + if (origin == 0) return cell; + const sides = tagline.windowRow(core); + const end = if (origin < sides.words) TAG_TEXT_INSET + sides.column else core.view().screen_w; + return @min(origin + colFromSpan(x - @as(f32, @floatFromInt(origin)) * body, tag), end -| 1); + } if (p) |core| if (row < core.topBarHeight() + layout.columnBarHeight(core)) { for (core.view().col_x[0..core.view().ncol], core.view().col_w[0..core.view().ncol]) |origin, width| { if (width == 0) continue; @@ -279,7 +295,7 @@ fn shortcuts(comptime b: Builtin) []const u8 { for (config.exec_key) |k| s = s ++ ", " ++ chordName(k); s = s ++ ", " ++ @tagName(config.exec_button) ++ "-click"; } - var it = std.mem.tokenizeScalar(u8, config.topbar_str, ' '); + var it = std.mem.tokenizeScalar(u8, config.window_words_str, ' '); while (it.next()) |w| if (std.mem.eql(u8, w, @tagName(b))) { s = s ++ ", topbar"; }; @@ -333,7 +349,7 @@ pub const builtin_rows: [std.enums.values(Builtin).len]Row = blk: { comptime { @setEvalBranchQuota(20000); // one branch per string byte, behind the decl walk that folds Builtin - var it = std.mem.tokenizeScalar(u8, config.topbar_str, ' '); + var it = std.mem.tokenizeScalar(u8, config.topbar_str ++ " " ++ config.window_words_str ++ " " ++ config.columns_words_str, ' '); words: while (it.next()) |w| { for (@typeInfo(Builtin).@"enum".field_names) |name| if (std.mem.eql(u8, name, w)) continue :words; @@ -368,9 +384,11 @@ test "a compact tagline anchors at its own pane, and both shells step from the s try std.testing.expectEqual(@as(f32, @floatFromInt(left.x)), taglineOriginCol(p, left.x + 3, left.y)); try std.testing.expectEqual(@as(f32, @floatFromInt(right.x)), taglineOriginCol(p, right.x + 3, right.y)); - // The topbar's origin is column zero always — it is not a pane rect, which - // is why row zero is right even in a window with no core to ask. + // The window row (UX K'2): its blank's origin is column zero, as a window + // with no core to ask has it; the window's words start at their own. + const words = tagline.windowRow(p).words; try std.testing.expectEqual(@as(f32, 0), taglineOriginCol(p, 40, 0)); + try std.testing.expectEqual(@as(f32, @floatFromInt(words)), taglineOriginCol(p, words + 3, 0)); const body_row = left.y + 2; try std.testing.expectEqual(@as(f32, 7), taglineOriginCol(p, 7, body_row)); @@ -399,9 +417,10 @@ test "a compact tagline anchors at its own pane, and both shells step from the s try std.testing.expectEqual(col, gridColAt(p, glyph_x + tag_w / 2, left.y, body_w, tag_w)); } - // The topbar's pointer grid is compact from column zero, with no pane to - // anchor to — the one tag row that is right with or without a core. - try std.testing.expectEqual(@as(u16, 3), gridColAt(p, 3.5 * tag_w, 0, body_w, tag_w)); + // The window row's blank is on the body's grid, its words compact from + // where they start; with no core to ask, compact from column zero. + try std.testing.expectEqual(@as(u16, 3), gridColAt(p, 3.5 * body_w, 0, body_w, tag_w)); + try std.testing.expectEqual(words + 3, gridColAt(p, @as(f32, @floatFromInt(words)) * body_w + 3.5 * tag_w, 0, body_w, tag_w)); try std.testing.expectEqual(@as(u16, 3), gridColAt(null, 3.5 * tag_w, 0, body_w, tag_w)); // A body row is untouched: still the body grid, still divided by the body @@ -461,6 +480,7 @@ test { _ = @import("FrameStats.zig"); _ = @import("Query.zig"); _ = @import("Names.zig"); + _ = @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"); @@ -764,11 +784,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)" }, |
