From 80d47cd246f37356fd2e705495936f6546613e29 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 5 Nov 2026 20:47:45 -0300 Subject: 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 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- src/layout.zig | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/layout.zig') diff --git a/src/layout.zig b/src/layout.zig index aec8587c..10bed438 100644 --- a/src/layout.zig +++ b/src/layout.zig @@ -126,7 +126,7 @@ pub fn windowKey(p: *Pardes, key: pardes.Key) void { // outlined pane is the active one while it runs. p.active = at; pardes.exec.runBuiltin(p, .Del, at, "", null); - if (p.panes[at] == null) p.window_pick = if (p.header_focus) null else p.active; + if (p.panes[at] == null) p.window_pick = if (p.header != null) null else p.active; return; } const chosen = if (key.cp == pardes.Key.enter or key.cp == pardes.Key.escape or key.cp == ':') at else for (0..p.panes.len) |id| { @@ -211,11 +211,12 @@ pub fn reorderColumn(p: *Pardes, from: usize, to: usize) void { } p.cols[to] = moved; p.col_tags[to] = tag; - if (p.header_column) |column| { - if (column == from) p.header_column = to else if (from < to and column > from and column <= to) { - p.header_column = column - 1; - } else if (from > to and column >= to and column < from) p.header_column = column + 1; - } + if (p.header) |*h| if (h.* == .column) { + const column = h.column; + if (column == from) h.column = to else if (from < to and column > from and column <= to) { + h.column = column - 1; + } else if (from > to and column >= to and column < from) h.column = column + 1; + }; p.pointer_tag_hit = null; p.look_hover_wait = null; p.look_hover_preview = null; @@ -1563,14 +1564,13 @@ test "column reorder moves only crossed state and preserves weights" { const original_weights = weightsOf(p); const outer_x = p.col_x[0]; const outer_w = p.col_w[0]; - p.header_focus = true; - p.header_column = 1; + p.header = .{ .column = 1 }; p.header_scroll = 9; reorderColumn(p, 1, 3); try std.testing.expectEqual(original_weights[1], p.cols[3].weight); try std.testing.expectEqual(original_weights[2], p.cols[1].weight); try std.testing.expectEqual(@as(u32, 11), p.cols[3].serial); - try std.testing.expectEqual(@as(?usize, 3), p.header_column); + try std.testing.expectEqual(@as(?usize, 3), p.headerColumn()); try std.testing.expectEqual(@as(i32, 21), tagline.focusedHeader(p).?.cur_col); try std.testing.expectEqual(@as(usize, 9), p.header_scroll); try std.testing.expectEqual(outer_x, p.col_x[0]); @@ -1772,8 +1772,8 @@ pub fn activeColumn(p: *const Pardes) ?usize { } pub fn noteTyped(p: *Pardes) void { - if (p.header_focus) { - if (p.header_column) |c| p.setActiveColumn(c); + if (p.header != null) { + if (p.headerColumn()) |c| p.setActiveColumn(c); } else if (findPane(p, p.active)) |f| p.setActiveColumn(f.col); } @@ -1788,7 +1788,7 @@ pub fn newScratchIn(p: *Pardes, from_id: usize, c: usize) void { /// the one whose tag has the keyboard, else `id`'s. pub fn keyboardColumn(p: *Pardes, id: usize) ?usize { if (p.exec_column) |c| return c; - if (p.header_focus) if (p.header_column) |c| return c; + if (p.headerColumn()) |c| return c; return if (findPane(p, id)) |f| f.col else null; } @@ -1796,7 +1796,7 @@ pub fn keyboardColumn(p: *Pardes, id: usize) ?usize { pub fn removeColumn(p: *Pardes, col: usize) !void { if (col >= p.ncol) return; const had_focus = keyboardColumn(p, p.active) == col; - const beside = if (had_focus) besideColumn(p, col, if (p.header_focus) null else p.rects[p.active]) else null; + const beside = if (had_focus) besideColumn(p, col, if (p.header != null) null else p.rects[p.active]) else null; var ids: [MAX_PANES]usize = undefined; var parents: [MAX_PANES]*Pane = undefined; const count = p.cols[col].n; -- cgit v1.3