summaryrefslogtreecommitdiff
path: root/core/root.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/root.zig')
-rw-r--r--core/root.zig37
1 files changed, 28 insertions, 9 deletions
diff --git a/core/root.zig b/core/root.zig
index 11cb5058..525e796a 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