summaryrefslogtreecommitdiff
path: root/core/Pick.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/Pick.zig')
-rw-r--r--core/Pick.zig58
1 files changed, 57 insertions, 1 deletions
diff --git a/core/Pick.zig b/core/Pick.zig
index 10f78208..7bceab39 100644
--- a/core/Pick.zig
+++ b/core/Pick.zig
@@ -1942,13 +1942,69 @@ pub fn keyAtRest(p: *Pardes, k: Key) void {
p.resume_at = 0;
}
-/// B3 on a picker's row (mouse.zig bandPress): Enter on it.
+/// Enter on the live picker's current row: B3 on its text where it
+/// previews (mouse.zig, UX DESIGN O3).
pub fn landHere(p: *Pardes) void {
const pk = live(p) orelse return;
if (pk.source == .lists) return reopenListed(p, pk);
if (pk.spine == .rows) land(p, .walk);
}
+/// A press on row `row` of the live picker's band (mouse.zig bandPress, UX
+/// DESIGN O2): B1 (`enter` false) puts the cursor on it, the list's or the
+/// act step's; B3 does what Enter does there (`below`: Shift-B3, as
+/// S-Enter): the row landed, the act applied, the source switched to, the
+/// theme worn, the action applied. A row of the act step or the source
+/// spine is its key's, its first byte (actStep, steps).
+pub fn press(p: *Pardes, row: Band.Row, enter: bool, below: bool) void {
+ const pk = live(p) orelse return;
+ const s = &p.view().tag_state;
+ if ((pk.spine == .acts or pk.spine == .sources) and row.key > 0) {
+ if (enter) return key(p, .{ .cp = row.text[0] });
+ if (pk.spine == .acts) pk.act_at = @intCast(row.index);
+ return;
+ }
+ if (pk.spine != .rows or row.index >= count(p, pk)) return;
+ s.rows.at = row.index;
+ if (!enter) return;
+ if (pk.source == .lists) return reopenListed(p, pk);
+ if (pk.source == .themes or pk.source == .actions) return key(p, .{ .cp = Key.enter });
+ land(p, if (below) .below else .walk);
+}
+
+/// The wheel over the live picker's head or band (UX DESIGN O2): its
+/// cursor `delta` rows on, the band's eleven following it and the preview
+/// with them, as the keys move it.
+pub fn wheel(p: *Pardes, delta: i32) void {
+ const pk = live(p) orelse return;
+ const s = &p.view().tag_state;
+ const n = @min(count(p, pk), std.math.maxInt(u16));
+ if (n == 0 or pk.spine != .rows) return;
+ s.rows.at = @intCast(std.math.clamp(@as(i64, s.rows.at) + delta, 0, @as(i64, @intCast(n)) - 1));
+ if (fuzzy(pk)) pk.names.reachTo(@as(usize, s.rows.at) + Band.Cursor.shown);
+}
+
+/// Whether screen row `row` of pane `id` is text the live picker previews:
+/// its landing pane's body, a place shown in it (UX DESIGN O3). B2 and B3
+/// there land it first: acting on the file is taking it.
+pub fn previewsAt(p: *const Pardes, id: usize, row: u16) bool {
+ const pk = live(p) orelse return false;
+ const pane = p.panes[id] orelse return false;
+ if (pane.serial != pk.landing or !pk.previewed or pk.source == .themes or pk.source == .actions) return false;
+ return row >= p.bodyTop(pane, p.view().rects[id]);
+}
+
+/// The live picker, waiting or not, ended as Esc ends it when what is about
+/// to run changes or closes pane `id`, the pane it asks from or previews in
+/// (UX DESIGN O3: Del, Get, Undo, Put, Keep, a walk step there, a Look that
+/// lands there, the pane closed): the preview's own text back, a pane made
+/// for it gone with it. Anything else leaves it up.
+pub fn yieldFor(p: *Pardes, id: usize) void {
+ const pk = live(p) orelse return;
+ const pane = p.panes[id] orelse return;
+ if (pane.serial == pk.owner or pane.serial == pk.landing) TagState.toRest(p);
+}
+
/// Enter in Lists (UX L'3): the kept picker under its cursor unrolled again
/// as it was left, where Lists was asked from, and the newest now.
fn reopenListed(p: *Pardes, pk: *Pick) void {