summaryrefslogtreecommitdiff
path: root/core/draw.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-24 19:31:05 -0300
committerGabriel Schneider <[email protected]>2026-11-24 19:31:05 -0300
commitf44d1b7d040acf674814be3cde336527833450e9 (patch)
tree9c22c45541f16e4281a0a504084e3cf6e389d1c8 /core/draw.zig
parent326a2bac9558da0ff78987e697546a363b2b8e59 (diff)
downloadpardes-f44d1b7d040acf674814be3cde336527833450e9.tar.gz
pardes-f44d1b7d040acf674814be3cde336527833450e9.zip
TagState, Field, Band: the typing state, and Help over the binding tree (walk UI, pick-ui SPEC.md §3.2's typing row and §4.5, item 4 of line A): a tag's typing state is the view's (TagState.kind help, its host pane by serial, the hostOf every tag's text asks), its box `^` whatever the body's mode, its caret a bar at the field's (the body's caret and its layer's put by while the head is typed in), and it takes every key before anything but a question (keys.zig tagStateKey: Esc back to rest, Enter runs the row typed as its keys, Backspace on an empty field back to the level `?` was struck from, unrolled); SPC ? is Help over every leaf of every root (SPC's, g m z Z [ ]'s, window mode's, the addons' words) and `?` down a level or under a helix prefix Help for that level's (SPC l ?, g ?); its head ` Help ␣ l <field> n/N`; its rows `chord · word · group` scored by the query pane's scorer (Names.match, now pub) on each key into the view's fixed hits (max_hits: the tree's 160 leaves and the registry's 64 words; best first, the tree's order while the field is empty), the band shows eleven around the cursor, the query's bytes in the match tint, the cursor's leaf's doc beside them; `Help <name>` stays the word's +Help; FOR THE PICKERS AND PROMPTS, as they are: Field (core/Field.zig: a one-line field in a fixed 256-byte buffer with its caret, each view's in TagState.field; Field.key takes a line editor's keys: characters, Backspace/C-h, Delete/C-d, Left/C-b, Right/C-f, Home/C-a, End/C-e, C-u, C-k, C-w/M-Backspace, M-b, M-f; false for a key it has no use for, Enter, Esc, the arrows, which its owner takes; set, insert, clear) and Band.Cursor (a list's cursor, TagState.rows: Cursor.key steps it on Down/C-j/C-n, Up/C-k/C-p, PageDown/PageUp; Cursor.window(n) is the eleven rows [lo, hi) a band shows around it); a state's head is a TagState.Head {text, spans, caret}, its band Band.of's switch on TagState.kind; TagState.follow takes no argument now (a root a state puts back is current already: Help's Backspace keeps its level unrolled); TESTS: Field.zig's (a line editor's keys, and the keys it leaves), TagState.zig's two (SPC ? over every root, filtered, the box and the caret, Enter runs Wrap; SPC l ? and g ? scoped, Backspace back to the level unrolled, Esc to rest); core-test 1003 pass, 166 skip, 0 fail
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'core/draw.zig')
-rw-r--r--core/draw.zig20
1 files changed, 19 insertions, 1 deletions
diff --git a/core/draw.zig b/core/draw.zig
index 37fdee1e..772cbece 100644
--- a/core/draw.zig
+++ b/core/draw.zig
@@ -488,13 +488,18 @@ fn renderPane(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r:
});
// In window mode the box holds the pane's letter instead of its mode.
const label: ?u8 = if (p.view().window_pick != null) layout.windowLabel(p, id) else null;
- s.set(r.x, tag_y, if (label) |*letter| @as(*const [1]u8, letter) else switch (pane.body.mode) {
+ // A tag in a typing state is typed in: its box says so (walk UI SPEC
+ // §3.2), whatever the body's mode.
+ const typing = p.view().tag_state.kind != .rest and TagState.hostOf(p) == id;
+ s.set(r.x, tag_y, if (label) |*letter| @as(*const [1]u8, letter) else if (typing) config.tag_insert else switch (pane.body.mode) {
.normal => config.tag_normal,
.insert => config.tag_insert,
.tty => config.tag_tty,
}, box_style);
try joinPaneTag(p, s, arena, pane, r, id, active);
+ // The keyboard is in the head's field: its caret, not the body's.
+ const head_caret = if (typing) s.cursor else null;
if (pane.band_rows > 0) try joinBand(p, s, arena, pane, r, id, active);
// Folded panes retain their body state, but neither body pixels nor
@@ -530,6 +535,10 @@ fn renderPane(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r:
}
try body_layer.joinBody(p, s, arena, pane, r, id, active, rail.*);
+ if (typing) {
+ s.body_layers[id].cursor = null;
+ s.cursor = head_caret;
+ }
if (pane.layers.heat > 0) @import("jj.zig").railHeat(p, s, pane, id, rail.rect);
// A terminal panned to its cursor in a view shorter than it: an arrow
// in the gutter's first body row says rows are above (views.zig).
@@ -1003,6 +1012,15 @@ fn paintPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane,
}
}
}
+ // A head typed in: its caret a bar at the field's.
+ if (head) |h| if (h.caret) |c| if (active) {
+ const at = modal.positionAt(shown.text, shown.fromReal(prefix_len + c));
+ if (at.row >= top and at.row < top + rows) {
+ const line = lines[at.row - top];
+ const col = panes.File.rawDisplayCol(p.settings.tab, line, @min(at.col, line.len));
+ if (col < tw) s.cursor = .{ .x = tx + @as(u16, @intCast(col)), .y = tag_y + @as(u16, @intCast(at.row - top)), .bar = true };
+ }
+ };
// the caret: bar while typing, block in normal mode (same rule as a body)
if (caret) |at| {
const col = panes.File.rawDisplayCol(p.settings.tab, lines[at.row], at.at) -| pane.tag_scroll;