summaryrefslogtreecommitdiff
path: root/src/layout.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/layout.zig')
-rw-r--r--src/layout.zig26
1 files changed, 13 insertions, 13 deletions
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;