summaryrefslogtreecommitdiff
path: root/core/Band.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/Band.zig')
-rw-r--r--core/Band.zig17
1 files changed, 16 insertions, 1 deletions
diff --git a/core/Band.zig b/core/Band.zig
index a8d97bb4..e562da1d 100644
--- a/core/Band.zig
+++ b/core/Band.zig
@@ -56,6 +56,9 @@ pub const Row = struct {
/// tint; the `faint` bytes after them dimmed (a path's directory).
pre: u16 = 0,
faint: u16 = 0,
+ /// Said at the row's right end in the dim ink, two cells off its text
+ /// at least, and the first to give way (UX D5): `in use`.
+ meta: []const u8 = "",
};
/// A column of rows. A level of more than 9 rows flows into two columns
@@ -375,7 +378,7 @@ fn place(band: *Band, p: *Pardes, arena: std.mem.Allocator, pane: *Pane, id: usi
for (band.steps[0..band.nsteps]) |*step| {
if (step.doc) continue;
var widest: usize = 0;
- for (step.rows) |row| widest = @max(widest, File.displayWidth(tab, row.text));
+ for (step.rows) |row| widest = @max(widest, File.displayWidth(tab, row.text) + if (row.meta.len > 0) 2 + File.displayWidth(tab, row.meta) else 0);
const column: u16 = @intCast(@min(widest + 2, std.math.maxInt(u16) / 4, @max(min_width, band.columns -| x)));
step.width = if (step.two) 2 * column + 1 else column;
need += step.width + 2;
@@ -493,14 +496,26 @@ pub fn line(band: *const Band, arena: std.mem.Allocator, tab: u16, y: u16) !Line
col += @intCast(File.displayWidth(tab, lead));
try parts.append(arena, .{ .col = col, .width = per -| @as(u16, @intCast(File.displayWidth(tab, lead))), .row = row });
const room = per -| @as(u16, @intCast(File.displayWidth(tab, lead)));
+ const at = col;
const cut = File.byteAtDisplay(tab, row.text, room);
try text.appendSlice(arena, row.text[0..cut]);
col += @intCast(File.displayWidth(tab, row.text[0..cut]));
+ if (metaShown(tab, row, room)) {
+ const meta: u16 = @intCast(File.displayWidth(tab, row.meta));
+ while (col < at + room - meta) : (col += 1) try text.append(arena, ' ');
+ try text.appendSlice(arena, row.meta);
+ col += meta;
+ }
}
}
return .{ .text = text.items, .parts = parts.items };
}
+/// Whether row `row`'s meta fits `room` cells after its text.
+pub fn metaShown(tab: u16, row: Row, room: u16) bool {
+ return row.meta.len > 0 and File.displayWidth(tab, row.text) + 2 + File.displayWidth(tab, row.meta) <= room;
+}
+
/// The word under column `col` of band row `y` of pane `id`, at the
/// tagline's pitch: what B2 executes and B3 looks at.
pub fn wordAt(p: *Pardes, arena: std.mem.Allocator, id: usize, y: u16, col: u16) !?[]const u8 {