summaryrefslogtreecommitdiff
path: root/core/Band.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/Band.zig')
-rw-r--r--core/Band.zig16
1 files changed, 14 insertions, 2 deletions
diff --git a/core/Band.zig b/core/Band.zig
index 079a1bcc..b5e90125 100644
--- a/core/Band.zig
+++ b/core/Band.zig
@@ -46,6 +46,12 @@ pub const Row = struct {
/// Its place in the list its step shows (a level's child, a hit): what
/// a click on it moves the cursor to.
index: u16 = 0,
+ /// Marked in a picker's list: `•` before it.
+ mark: bool = false,
+ /// Its first `pre` bytes are a place (`file:line`, `@p3`): the name's
+ /// tint; the `faint` bytes after them dimmed (a path's directory).
+ pre: u16 = 0,
+ faint: u16 = 0,
};
/// A column of rows. A level of more than 9 rows flows into two columns
@@ -89,6 +95,7 @@ pub fn takes(p: *Pardes, id: usize) u16 {
.rest => {},
.help => return @max(doc_rows, @max(1, @min(Cursor.shown, s.nhits))),
.describe => return 0,
+ .pick => return @import("Pick.zig").bandRows(p),
}
if (!s.unrolled) return 0;
const cur = TagState.current(p, v) orelse return 0;
@@ -117,6 +124,11 @@ pub fn of(p: *Pardes, arena: std.mem.Allocator, pane: *Pane, id: usize) !?Band {
return band;
},
.describe => return null,
+ .pick => {
+ for (try @import("Pick.zig").steps(p, arena)) |step| band.add(step);
+ try band.place(p, arena, pane, id);
+ return band;
+ },
}
const cur = TagState.current(p, v).?;
// The level, its cursor on the child it names, else the leaf its group
@@ -263,7 +275,7 @@ fn place(band: *Band, p: *Pardes, arena: std.mem.Allocator, pane: *Pane, id: usi
if (step.doc) continue;
var widest: usize = 0;
for (step.rows) |row| widest = @max(widest, File.displayWidth(tab, row.text));
- const column: u16 = @intCast(@min(widest + 2, std.math.maxInt(u16) / 4));
+ 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;
}
@@ -368,7 +380,7 @@ pub fn line(band: *const Band, arena: std.mem.Allocator, tab: u16, y: u16) !Line
while (col < start) : (col += 1) try text.append(arena, ' ');
if (y >= shown or k >= step.rows.len) continue;
const row = step.rows[k];
- const lead: []const u8 = if (step.doc) "" else if (row.on) "▶ " else " ";
+ const lead: []const u8 = if (step.doc) "" else if (row.on) "▶ " else if (row.mark) "• " else " ";
try text.appendSlice(arena, lead);
col += @intCast(File.displayWidth(tab, lead));
try parts.append(arena, .{ .col = col, .width = per -| @as(u16, @intCast(File.displayWidth(tab, lead))), .row = row });