summaryrefslogtreecommitdiff
path: root/core/Core.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/Core.zig')
-rw-r--r--core/Core.zig45
1 files changed, 39 insertions, 6 deletions
diff --git a/core/Core.zig b/core/Core.zig
index 92c81ba6..296f4159 100644
--- a/core/Core.zig
+++ b/core/Core.zig
@@ -188,6 +188,9 @@ pub const View = struct {
window_pick: ?usize = null,
leader_keys: [4]u8 = undefined,
leader_n: u8 = 0,
+ /// Its tag out of rest: the which-key level, the typing states
+ /// (TagState.zig).
+ tag_state: pardes.TagState = .{},
/// The keyboard is on a header: a column's tag, or the workspace's.
header: ?Header = null,
/// A mouse sweep is extending the focused header's selection.
@@ -397,6 +400,9 @@ lsp_ask: Ask = .{},
pipe: Pipe = .{},
/// A query pane's Grep, and its Find's listing, on a worker (Stream.zig).
stream: Stream = .{},
+/// The pickers: the one live in a view's tag, and the last ones rolled
+/// up, which their list words and Resume reopen (Pick.zig).
+picks: [pardes.Pick.max_lists]?*pardes.Pick = @splat(null),
/// The panes' `Changes` (jj.zig): what was asked of jj, and what it
/// answered for each pane, by its serial: the session's, not a field of
/// every pane (a digest and a rollback copy walk every pane's fields at
@@ -927,6 +933,7 @@ pub fn deinit(p: *Pardes) void {
look.cancelLookHover(p);
if (p.repl_ask) |ask| p.gpa.free(ask.text);
for (0..MAX_PANES) |id| p.dropPendingWrite(id);
+ pardes.Pick.deinitAll(p);
// The panes, then those retired these last two frames.
inline for (.{ &p.panes, &p.retired_panes.previous, &p.retired_panes.current }) |slots| for (slots) |*slot| if (slot.*) |pane| {
pardes.panes.teardownPane(p, pane);
@@ -1809,6 +1816,7 @@ fn updateInner(p: *Pardes, ev: Event) void {
for (p.panes) |slot| if (slot) |pane| pane.places.settle(p, pane, ev == .tick);
// Each live query pane's rows, made from what changed this step.
pardes.panes.Query.produceAll(p, ev == .tick, ev == .key);
+ pardes.Pick.produceAll(p, ev == .tick);
_ = p.scratch.reset(.{ .retain_with_limit = memory.limits.scratch_kept });
p.sync();
p.fsReport();
@@ -1998,11 +2006,12 @@ pub fn sync(p: *Pardes) void {
pane.tag_lead = lead;
}
// A row per shown row: the tag's lines wrapped at its width.
- var lines = std.mem.count(u8, tagline.curTail(pane), "\n") + 1;
+ const tail = tagline.shownTail(p, wa, pane) catch tagline.curTail(pane);
+ var lines = std.mem.count(u8, tail, "\n") + 1;
var wanted = lines;
var caret_row: usize = @intCast(@max(0, pane.tag.cur_row));
if (prefix) |made| wrap: {
- const whole = std.mem.concat(wa, u8, &.{ made, tagline.curTail(pane) }) catch break :wrap;
+ const whole = std.mem.concat(wa, u8, &.{ made, tail }) catch break :wrap;
const shown = tagline.wrapTag(p.settings.tab, wa, whole, tagline.tagWidth(p, id)) catch break :wrap;
lines = shown.rows();
// Collapsed, one row, as acme's Tagup sets taglines to 1
@@ -2012,6 +2021,15 @@ pub fn sync(p: *Pardes) void {
caret_row = std.mem.count(u8, shown.text[0..@min(shown.fromReal(cur), shown.text.len)], "\n");
}
if (!pane.tag_expanded) wanted = 1;
+ // Out of rest the head is the tag's text (TagState), and the tag
+ // keeps the rows its own text takes at least: a head shorter than
+ // it (a root's key cell, before its level shows) moved the body up
+ // and back down a moment later; a terminal's exactly those, its pty
+ // its body (a resize the program under it saw at every C-w and SPC).
+ if (pardes.TagState.hostOf(p) == id) {
+ const rest = layout.wantedTagRows(p, id);
+ wanted = if (pane.isTerminal()) rest else @max(wanted, rest);
+ }
pane.tag_rows = @intCast(@min(wanted, MAX_TAG_ROWS, @max(BOX_H, r.h -| 1)));
if (pane.collapsed) pane.tag_rows = BOX_H;
if (pane.focus == .tag and pane.prompt != .name) {
@@ -2019,8 +2037,12 @@ pub fn sync(p: *Pardes) void {
var top: usize = pane.tag_top;
if (cur < top) top = cur;
if (cur >= top + pane.tag_rows) top = cur + 1 - pane.tag_rows;
- pane.tag_top = @intCast(@min(top, lines - pane.tag_rows));
+ pane.tag_top = @intCast(@min(top, lines -| pane.tag_rows));
} else pane.tag_top = 0;
+ // The band unrolled under the tag's text pushes the body down:
+ // the tag's rows, as everything under them counts them.
+ pane.band_rows = if (pane.collapsed) 0 else @min(pardes.Band.takes(p, id), r.h -| pane.tag_rows);
+ pane.tag_rows += pane.band_rows;
const cols = @max(1, r.w -| config.GUTTER);
// The tag steals the top rows. The pty is what the pane shows
// (layout keeps a terminal two body rows where the window has
@@ -2142,7 +2164,7 @@ pub fn nextWake(p: *const Pardes) ?u64 {
for (p.panes) |slot| if (slot) |pane| if (pane.places.busy(pane)) return next;
const kinds = pardes.Kind.wake(p);
if (kinds) |due| if (due <= next) return next;
- if (pardes.panes.Query.busy(p)) return next;
+ if (pardes.panes.Query.busy(p) or pardes.Pick.busy(p)) return next;
// A typed Grep waiting out its pause.
const streaming = p.stream.wake(next);
if (streaming) |due| if (due <= next) return next;
@@ -2163,6 +2185,11 @@ pub fn nextWake(p: *const Pardes) ?u64 {
const wait = @max(1, (pane.question_due_ns - p.clock.stepped_ns + frame_ns - 1) / frame_ns);
frames = if (frames) |soonest| @min(soonest, wait) else wait;
};
+ // A which-key level shows at the end of its root's delay (TagState).
+ if (pardes.TagState.wake(p)) |due| {
+ const wait = @max(1, (due - p.clock.stepped_ns + frame_ns - 1) / frame_ns);
+ frames = if (frames) |soonest| @min(soonest, wait) else wait;
+ }
// A paste's Enter waiting on its REPL goes at the end of its wait,
// a time on the clock: the frames from `stepped_ns` that reach it.
for (p.panes) |slot| if (slot) |pane| if (pane.repl_enter > 0) {
@@ -2204,6 +2231,8 @@ fn advanceInner(p: *Pardes, now_ns: u64) void {
for (p.panes) |slot| if (slot) |pane| if (pane.question_due_ns == Pane.question_asked) {
pane.question_due_ns = now_ns + config.del_question_delay_ns;
};
+ // A which-key root struck since: its level's delay from now.
+ pardes.TagState.dated(p, now_ns);
const frame = frame_ns;
var moving: u32 = 0;
// The session's ticks are the recording session's: a picture still
@@ -2621,12 +2650,16 @@ test "TreeContext rows in the tag style keep the message rows" {
p.sync();
_ = try p.render(p.scratch.allocator());
try std.testing.expectEqual(full_height, p.surface.body_layers[0].viewport.h);
- // ...and the leader's chip is an overlay that takes nothing either.
+ // ...and the leader's chip (a shown level's last leaf) is an overlay
+ // at the body's top (the level itself wraps the tag: TagState).
const r = p.view().rects[0];
p.view().prefix = .leader;
+ p.view().leader_n = 0;
+ p.view().tag_state.used[0] = 'q';
+ p.view().tag_state.due_ns = 1;
+ p.clock.now_ns = 1;
p.sync();
_ = try p.render(p.scratch.allocator());
- try std.testing.expectEqual(full_height, p.surface.body_layers[0].viewport.h);
const band = for (p.surface.tagLayers()) |*layer| {
if (layer.rows != 0 and layer.kind == .notice) break layer;
} else return error.NoNoticeBand;