diff options
Diffstat (limited to 'core/root.zig')
| -rw-r--r-- | core/root.zig | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/core/root.zig b/core/root.zig index e07cbed6..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"); @@ -791,6 +811,7 @@ const kept_out = [_]struct { []const u8, []const u8, []const u8 }{ .{ "Text.zig", "room", "a buffer's capacity" }, .{ "Kind.zig", "ops st gpa arena plain file opened reloads jobs record", "the kind's code and memory here: a plain kind's block is in the copy, and its state hash is checked at every call (Kind.Call.end)" }, .{ "Kind.zig", "thumb_at thumb_span pointer painted over used", "a frame's: written by a paint; `painted` is read by a tick of a kind that is not plain, whose calls are the authority's alone" }, + .{ "Kind.zig", "drawn_from size", "a picker's preview through a kind (Pick.showKind): this process's draw count when the slot was made, which drops the answers of draws made before it, and the file's size for the line naming it until its kind draws; both read by a frame alone" }, .{ "Places.zig", "ticks ticks_gen re", "the rail's ticks, made again when the places move (`gen`), and the compiled pattern, of the pattern" }, .{ "Plumb.zig", "parsed parsed_arena", "the rules parsed, of their text" }, .{ "Stream.zig", "parse_ns paint paint_retired paint_count ahead ahead_for painted_ahead painted_on_loop ahead_seen ahead_ask", "the workers' paints and timings: how a text looks, and numbers" }, |
