diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-05 20:47:45 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-05 22:07:55 -0300 |
| commit | 80d47cd246f37356fd2e705495936f6546613e29 (patch) | |
| tree | c9b8025faa82717c9cc51d98dd4ce774dc0fad13 /src/Core.zig | |
| parent | 4c3dbce20f11204f6d4bfb715239beae74259e7f (diff) | |
| download | pardes-80d47cd246f37356fd2e705495936f6546613e29.tar.gz pardes-80d47cd246f37356fd2e705495936f6546613e29.zip | |
fields #39, a header's focus is one optional union: header_focus and header_column, of which (false, some column) never happened, are the session's header: ?Header, workspace or column, and p.headerColumn() the column whose tag has the keyboard (null for none or the workspace's); tagline.enterHeader and exitHeader set it in one write each, layout.reorderColumn moves the focused column's index in place, and the reads in 17 files say p.header != null where they said header_focus; views.zig's per-view fields name header; a dump written before this change loads it as the default once: an Upgrade or Restore from it comes back with the keyboard on a pane, not a header, and the wire's semantics change; gates on tui: core-test 960/960, behaviour-test 238/238, pane-test 171/172 (1 skipped), snap all 108 scripts ok; gui unit-test 1518/1519 (1 skipped)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/Core.zig')
| -rw-r--r-- | src/Core.zig | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/Core.zig b/src/Core.zig index b24eb6cc..9219cc0e 100644 --- a/src/Core.zig +++ b/src/Core.zig @@ -263,10 +263,8 @@ leader_on: bool = false, window_pick: ?usize = null, leader_keys: [4]u8 = undefined, leader_n: u8 = 0, -/// The keyboard is on a header: the column tag `header_column` names, or -/// the workspace's when that is null. -header_focus: bool = false, -header_column: ?usize = null, +/// 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. header_drag: bool = false, /// A middle or right sweep held over a column's or the workspace's tag. @@ -830,7 +828,7 @@ pub fn takeRestore(p: *Pardes) ?[]const u8 { /// or another window. fn reportFocus(p: *Pardes) void { const want: @FieldType(Pardes, "focus_told") = blk: { - if (!p.window_focused or p.header_focus) break :blk null; + if (!p.window_focused or p.header != null) break :blk null; const pane = p.panes[p.active] orelse break :blk null; if (pane.focus != .body) break :blk null; break :blk .{ .id = p.active, .serial = pane.serial }; @@ -1752,7 +1750,7 @@ pub fn sync(p: *Pardes) void { // A file opened or closed this step: the kept list follows. p.saveRecent(); tagline.flattenHeaders(p); - if (p.header_column != null and layout.columnBarHeight(p) == 0) { + if (p.headerColumn() != null and layout.columnBarHeight(p) == 0) { tagline.exitHeader(p); } pardes.panes.reapPanes(p); @@ -1763,7 +1761,7 @@ pub fn sync(p: *Pardes) void { const pane = slot.* orelse continue; // The keyboard is on one pane, or on a header: a tag it has left // hands it back to its body, and a name drafted there is dropped. - if (id != p.active or p.header_focus) { + if (id != p.active or p.header != null) { pane.focus = .body; if (pane.prompt == .name and pane.prompt_view == p.view) pane.closePrompt(); } @@ -2083,6 +2081,14 @@ pub const Column = struct { /// last given it; `stepped_ns` is how far its timings have been stepped /// along it, in whole frames of `frame_ns`. Idle, the two are the same /// instant. +pub const Header = union(enum) { workspace, column: usize }; + +/// The column whose tag has the keyboard, null for none or the workspace's. +pub fn headerColumn(p: *const Pardes) ?usize { + const h = p.header orelse return null; + return if (h == .column) h.column else null; +} + pub const Clock = struct { now_ns: u64 = 0, stepped_ns: u64 = 0, @@ -3586,12 +3592,12 @@ test "a screen too short for the column row releases a column tag's focus withou try std.testing.expectEqual(TOPBAR_H + COLBAR_H, shown.y); p.update(.{ .mouse = .{ .button = .left, .kind = .press, .col = TAG_TEXT_INSET, .row = TOPBAR_H } }); p.update(.{ .mouse = .{ .button = .left, .kind = .release, .col = TAG_TEXT_INSET, .row = TOPBAR_H } }); - try std.testing.expect(p.header_focus and p.header_column != null); + try std.testing.expect(p.header != null and p.headerColumn() != null); p.update(.{ .resize = .{ .cols = 60, .rows = 2 } }); try std.testing.expectEqual(@as(u16, 0), layout.columnBarHeight(p)); try std.testing.expectEqual(TOPBAR_H, p.rects[0].y); - try std.testing.expect(!p.header_focus and p.header_column == null); + try std.testing.expect(p.header == null and p.headerColumn() == null); p.update(.{ .resize = .{ .cols = 60, .rows = 12 } }); try std.testing.expectEqual(shown, p.rects[0]); try std.testing.expectEqualStrings("New Help", tagline.columnTag(p, 0)); |
