diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-06 02:56:53 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-06 04:13:33 -0300 |
| commit | d1d5d3cfb18841604bba2057eeb3598f729b4475 (patch) | |
| tree | 298c29ab8767852bf74eb86ad4d15acc4348f109 /src/tagline.zig | |
| parent | 33037ece5af9ae1c7048819bbbae3fc5e6fc4ade (diff) | |
| download | pardes-d1d5d3cfb18841604bba2057eeb3598f729b4475.tar.gz pardes-d1d5d3cfb18841604bba2057eeb3598f729b4475.zip | |
client #1, the views indexed: a view's share of the session is Pardes.View (the ~42 fields views.fields named: size, cell metrics, columns, rects, focus, jumps, pointer, gestures, prefixes, frontend), one of Pardes.views[4] (null when closed), the live one views[live] through Pardes.view() (index field `view` renamed `live`); going into another view is the index plus the panes' shares, which stay swapped (park and unpark now move only Pane.pv); views.zig loses fields, Part over Pardes, Parked, kept, emptied and the session half of every copy, and a pane closing leaves every view's layout at once (views.gone, at the two places a slot is freed) instead of the serials each parked view kept; drawOne and within put the drawn view's own share back whole; the views are in the digest now (tape's per-field parts name views[k].field), so a fresh view's col_x/col_w default to zeros, not undefined; the dump keeps every open view in the core and the panes' shares of the others under `shares`; an image from before (live view as the core's own fields, the rest under `views`) loads them into views[] once; the ~2,400 references rewritten mechanically from the compiler's errors (p.active is p.view().active, `const v = p.view()` hoisted in 823 places), Kind.zig (4 lines) and addon_test.zig (3) among them, macos.zig by pattern (not compiled here); tape's watched host writes read the live view's frontend and active; perf.zig's accessor lines change its harness hash, the debug baselines re-keyed to it (their numbers the base's); no golden changes; gates: core-test 956/956 both, unit-test 1487/1488 tui and 1530/1531 gui, behaviour-test 248/248 both, pane-test 171/172, snap all 105 ok, process-test 0 of 37 failed tui, replicas ok
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/tagline.zig')
| -rw-r--r-- | src/tagline.zig | 66 |
1 files changed, 35 insertions, 31 deletions
diff --git a/src/tagline.zig b/src/tagline.zig index 5cfb9f50..469d97d1 100644 --- a/src/tagline.zig +++ b/src/tagline.zig @@ -65,37 +65,39 @@ pub fn topbar(p: *Pardes) []const u8 { } pub fn columnTag(p: *const Pardes, c: usize) []const u8 { - return p.col_tags[c].own orelse column_tag_default; + return p.view().col_tags[c].own orelse column_tag_default; } /// The header with the keyboard, when one has it. pub fn focusedHeader(p: *Pardes) ?*Text { - if (p.header == null) return null; - if (p.headerColumn()) |c| return if (c < p.ncol) &p.col_tags[c] else null; + const v = p.view(); + if (v.header == null) return null; + if (p.headerColumn()) |c| return if (c < v.ncol) &v.col_tags[c] else null; return &p.global_tag; } pub fn revealHeader(p: *Pardes) void { + const v = p.view(); const t = focusedHeader(p) orelse { - p.header_scroll = 0; - p.header_top = 0; + v.header_scroll = 0; + v.header_top = 0; return; }; const text = edit.flatSurface(p, t) catch return; const cur: usize = @intCast(@max(0, t.cur_row)); const rows: usize = if (p.headerColumn() != null) layout.columnBarHeight(p) else p.topBarHeight(); - if (cur < p.header_top) p.header_top = cur; - if (rows > 0 and cur >= p.header_top + rows) p.header_top = cur + 1 - rows; + if (cur < v.header_top) v.header_top = cur; + if (rows > 0 and cur >= v.header_top + rows) v.header_top = cur + 1 - rows; const line = modal.lineSlice(text, cur); - const width = layout.tagCapacity(p, if (p.headerColumn()) |c| p.col_w[c] -| TAG_TEXT_INSET else p.screen_w -| TAG_TEXT_INSET); + const width = layout.tagCapacity(p, if (p.headerColumn()) |c| v.col_w[c] -| TAG_TEXT_INSET else v.screen_w -| TAG_TEXT_INSET); const col = panes.File.rawDisplayCol(line, @min(@as(usize, @intCast(@max(0, t.cur_col))), line.len)); - if (col < p.header_scroll) p.header_scroll = col; - if (col >= p.header_scroll + width) p.header_scroll = col -| (width -| 1); - var raw = panes.File.rawAtDisplay(line, p.header_scroll); - p.header_scroll = panes.File.rawDisplayCol(line, raw); - if (width > 0 and col >= p.header_scroll + width) { + if (col < v.header_scroll) v.header_scroll = col; + if (col >= v.header_scroll + width) v.header_scroll = col -| (width -| 1); + var raw = panes.File.rawAtDisplay(line, v.header_scroll); + v.header_scroll = panes.File.rawDisplayCol(line, raw); + if (width > 0 and col >= v.header_scroll + width) { raw = modal.nextGrapheme(line, raw); - p.header_scroll = panes.File.rawDisplayCol(line, raw); + v.header_scroll = panes.File.rawDisplayCol(line, raw); } } @@ -151,7 +153,7 @@ pub fn pathPrefix(p: *const Pardes, arena: std.mem.Allocator, pane: *Pane) ![]co // A terminal showing kitty graphics says how it draws them, as an image // pane does, and so does one drawing them as glyph art by choice. if (panes.terminal.petscii(pane)) |chosen| { - const on = chosen or !p.frontend.native_images; + const on = chosen or !p.view().frontend.native_images; if (chosen or panes.terminal.hasImages(pane)) return std.fmt.allocPrint(arena, "{s} petscii:{s}", .{ (try shownDir(arena, pane)), if (on) "on" else "off" }); } @@ -309,7 +311,7 @@ pub fn wrapTag(arena: std.mem.Allocator, whole: []const u8, width: usize) !Shown /// than what is left (libframe frutil.c _frcklinewrap), and the caret past /// its end sits at the edge (frptofchar.c clamps it to r.max.x). pub fn tagWidth(p: *const Pardes, id: usize) usize { - return @max(1, @as(usize, layout.tagCapacity(p, p.rects[id].w -| TAG_TEXT_INSET))); + return @max(1, @as(usize, layout.tagCapacity(p, p.view().rects[id].w -| TAG_TEXT_INSET))); } pub fn shownTag(p: *Pardes, arena: std.mem.Allocator, pane: *Pane) !Shown { @@ -366,7 +368,7 @@ pub fn draftName(p: *Pardes, pane: *Pane, col: usize) void { const name = p.gpa.dupe(u8, f.path) catch return; pane.closePrompt(); pane.prompt = .name; - pane.prompt_view = p.view; + pane.prompt_view = p.live; pane.input = .{ .what = .input, .own = name, .mode = .insert, .cur_pinned = true, .cur_col = @intCast(@min(name.len, panes.File.rawAtDisplay(name, col))) }; } @@ -398,18 +400,19 @@ pub fn commitTagName(p: *Pardes, pane: *Pane) bool { } pub fn exitHeader(p: *Pardes) void { - p.header = null; - p.header_drag = false; - p.header_scroll = 0; - p.header_top = 0; + const v = p.view(); + v.header = null; + v.header_drag = false; + v.header_scroll = 0; + v.header_top = 0; } /// Give the keyboard to a column's tag, or the workspace's for null, in /// normal mode, its cursor where that header last had it. pub fn enterHeader(p: *Pardes, column: ?usize) void { exitHeader(p); - if (p.panes[p.active]) |pane| pane.focus = .body; - p.header = if (column) |c| .{ .column = c } else .workspace; + if (p.panes[p.view().active]) |pane| pane.focus = .body; + p.view().header = if (column) |c| .{ .column = c } else .workspace; if (column) |c| p.setActiveColumn(c); const t = focusedHeader(p) orelse return exitHeader(p); takeKeyboard(t, edit.flatSurface(p, t) catch ""); @@ -437,10 +440,11 @@ pub fn headerSelection(t: *const Text, text: []const u8, row: usize) ?struct { l /// tabs: blank is no text, so no button of acme's is taken from any. A /// column's tag and a pane's are not: their blank is where B1 types. pub fn workspaceBlank(p: *Pardes, col: u16, row: u16, tag_hit: ?pardes.TagHit) bool { - if (row >= p.topBarHeight() or col >= p.screen_w) return false; + const v = p.view(); + if (row >= p.topBarHeight() or col >= v.screen_w) return false; if (col < TAG_TEXT_INSET) return true; const text = edit.flatSurface(p, &p.global_tag) catch return false; - const scroll: usize = if (p.header != null and p.headerColumn() == null) p.header_scroll else 0; + const scroll: usize = if (v.header != null and p.headerColumn() == null) v.header_scroll else 0; const at = @as(usize, Layer.columnAt(p, .workspace, 0, tag_hit, false, 0) orelse (col - TAG_TEXT_INSET)) + scroll; return at >= panes.File.displayWidth(modal.lineSlice(text, 0)) + 2; } @@ -474,7 +478,7 @@ test "the workspace tag is blank left of its text and past its end, and nowhere /// pasted or restored from a dump into one becomes a space, the caret and /// the selection kept on the same characters. pub fn flattenHeaders(p: *Pardes) void { - for (p.col_tags[0..p.ncol]) |*t| flatten(t); + for (p.view().col_tags[0..p.view().ncol]) |*t| flatten(t); flatten(&p.global_tag); } @@ -494,15 +498,15 @@ fn flatten(t: *Text) void { test "a column or workspace tag is one line: a newline in it is a space" { const p = try Pardes.init(std.testing.allocator, .{ .cols = 50, .rows = 12, .tty_only = true }); defer p.deinit(); - p.col_tags[0].own = try p.gpa.dupe(u8, "New\nSnarf"); - p.col_tags[0].cur_row = 1; - p.col_tags[0].cur_col = 2; + p.view().col_tags[0].own = try p.gpa.dupe(u8, "New\nSnarf"); + p.view().col_tags[0].cur_row = 1; + p.view().col_tags[0].cur_col = 2; p.global_tag.own = try p.gpa.dupe(u8, "Newcol\nExit"); p.sync(); try std.testing.expectEqualStrings("New Snarf", columnTag(p, 0)); try std.testing.expectEqualStrings("Newcol Exit", p.global_tag.own.?); - try std.testing.expectEqual(@as(i32, 0), p.col_tags[0].cur_row); - try std.testing.expectEqual(@as(i32, 6), p.col_tags[0].cur_col); + try std.testing.expectEqual(@as(i32, 0), p.view().col_tags[0].cur_row); + try std.testing.expectEqual(@as(i32, 6), p.view().col_tags[0].cur_col); try std.testing.expectEqual(pardes.COLBAR_H, layout.columnBarHeight(p)); try std.testing.expectEqual(pardes.TOPBAR_H, p.topBarHeight()); } |
