summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Core.zig24
-rw-r--r--src/Pipe.zig2
-rw-r--r--src/builtins.zig18
-rw-r--r--src/draw.zig12
-rw-r--r--src/echo.zig2
-rw-r--r--src/keys.zig8
-rw-r--r--src/layout.zig26
-rw-r--r--src/look.zig2
-rw-r--r--src/mouse.zig8
-rw-r--r--src/ninep/cols.zig2
-rw-r--r--src/ninep/ctl.zig4
-rw-r--r--src/ninep/tree.zig2
-rw-r--r--src/panes.zig2
-rw-r--r--src/tagline.zig16
-rw-r--r--src/views.zig2
15 files changed, 67 insertions, 63 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));
diff --git a/src/Pipe.zig b/src/Pipe.zig
index 05085b9a..b7310e5c 100644
--- a/src/Pipe.zig
+++ b/src/Pipe.zig
@@ -144,7 +144,7 @@ pub fn submitPipe(p: *Pardes, id: usize) void {
.pane = id,
.serial = pane.serial,
.what = t.what,
- .column = p.header_column orelse 0,
+ .column = p.headerColumn() orelse 0,
.revision = if (pane.file) |f| f.revision else 0,
.sum = std.hash.Wyhash.hash(0, content),
.arena = arena_state,
diff --git a/src/builtins.zig b/src/builtins.zig
index a924396d..7a9c2df1 100644
--- a/src/builtins.zig
+++ b/src/builtins.zig
@@ -1744,8 +1744,8 @@ pub const Panes = struct {
/// Move the keyboard to the pane, or column tag, to the left.
pub const Left = struct {
pub fn run(c: Ctx) void {
- if (c.p.header_focus) {
- if (c.p.header_column) |column| if (column > 0) tagline.enterHeader(c.p, column - 1);
+ if (c.p.header != null) {
+ if (c.p.headerColumn()) |column| if (column > 0) tagline.enterHeader(c.p, column - 1);
return;
}
_ = layout.focusDir(c.p, c.id, .left);
@@ -1755,12 +1755,12 @@ pub const Left = struct {
/// Move the keyboard to the pane below, off a tag onto the pane under it.
pub const Down = struct {
pub fn run(c: Ctx) void {
- if (c.p.header_focus) {
+ if (c.p.header != null) {
const column = layout.findPane(c.p, c.id);
- if (c.p.header_column == null and layout.columnBarHeight(c.p) > 0)
+ if (c.p.headerColumn() == null and layout.columnBarHeight(c.p) > 0)
return tagline.enterHeader(c.p, if (column) |at| at.col else 0);
// Onto the top pane of the column the header stands over.
- const col = c.p.header_column orelse if (column) |at| at.col else return;
+ const col = c.p.headerColumn() orelse if (column) |at| at.col else return;
// An empty column's tag has nothing below it.
if (col < c.p.ncol and c.p.cols[col].n == 0) return;
tagline.exitHeader(c.p);
@@ -1774,8 +1774,8 @@ pub const Down = struct {
/// Move the keyboard to the pane above, and from a column's top pane to its tag.
pub const Up = struct {
pub fn run(c: Ctx) void {
- if (c.p.header_focus) {
- if (c.p.header_column != null and c.p.topBarHeight() > 0) tagline.enterHeader(c.p, null);
+ if (c.p.header != null) {
+ if (c.p.headerColumn() != null and c.p.topBarHeight() > 0) tagline.enterHeader(c.p, null);
return;
}
if (layout.focusDir(c.p, c.id, .up)) return;
@@ -1788,8 +1788,8 @@ pub const Up = struct {
/// Move the keyboard to the pane, or column tag, to the right.
pub const Right = struct {
pub fn run(c: Ctx) void {
- if (c.p.header_focus) {
- if (c.p.header_column) |column| if (column + 1 < c.p.ncol) tagline.enterHeader(c.p, column + 1);
+ if (c.p.header != null) {
+ if (c.p.headerColumn()) |column| if (column + 1 < c.p.ncol) tagline.enterHeader(c.p, column + 1);
return;
}
_ = layout.focusDir(c.p, c.id, .right);
diff --git a/src/draw.zig b/src/draw.zig
index e8276904..830f10df 100644
--- a/src/draw.zig
+++ b/src/draw.zig
@@ -471,7 +471,7 @@ fn paintHeaders(p: *Pardes, s: *Surface) !void {
// global tagbar: full width, top rows — unless a native shell has
// taken its commands over, in which case the rows are not ours to draw
if (s.region(.workspace_tag, Region.none)) |region| {
- const top = if (p.header_focus and p.header_column == null) p.header_top else 0;
+ const top = if (p.header != null and p.headerColumn() == null) p.header_top else 0;
const layer = &s.tag_layers[MAX_PANES + MAX_COLS];
var viewport = region.rect;
const inset = @min(TAG_TEXT_INSET, viewport.w);
@@ -500,7 +500,7 @@ fn paintHeaders(p: *Pardes, s: *Surface) !void {
s.fill(p.col_x[c], region.rect.y + 1, grip, column_rows -| 1, .{ .bg = .{ .rgb = bg }, .font_role = .tagline });
s.fill(p.col_x[c] + grip, region.rect.y, inset - grip, column_rows, .{ .bg = .{ .rgb = bg }, .font_role = .tagline });
}
- const top = if (p.header_focus and p.header_column == c) p.header_top else 0;
+ const top = if (p.header != null and p.headerColumn() == c) p.header_top else 0;
const layer = &s.tag_layers[MAX_PANES + c];
try renderHeaderLayer(p, layer, .column, @intCast(c), region.rect, tagline.columnTag(p, c), top, bg, fg);
if (p.col_x[c] < s.cols) joinHeaderRows(s, layer, fg);
@@ -597,9 +597,9 @@ fn renderHeaderLayer(p: *Pardes, layer: *pardes.Layer, kind: TagKind, id: u16, v
// A notice band carries a PANE id, not a column index, so it must not
// answer to the column being edited -- that would scroll and select
// its text with the column tag's offsets and give it a second caret.
- const editing: ?*Text = if (p.header_focus and switch (kind) {
- .workspace => p.header_column == null,
- .column => p.header_column == id,
+ const editing: ?*Text = if (p.header != null and switch (kind) {
+ .workspace => p.headerColumn() == null,
+ .column => p.headerColumn() == id,
.pane, .notice, .body => false,
}) tagline.focusedHeader(p) else null;
const scroll = if (editing != null) p.header_scroll else 0;
@@ -710,7 +710,7 @@ fn joinPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r
layer.rows = rows;
layer.context_rows = 0;
layer.bg = if (p.window_pick == id) p.theme().sel_bg else if (active and p.settings.focus_tint) chrome.tag_active_bg else chrome.tag_bg;
- layer.cursor = if (p.header_focus) null else if (temporary.cursor) |cursor|
+ layer.cursor = if (p.header != null) null else if (temporary.cursor) |cursor|
.{ .x = cursor.x - TAG_TEXT_INSET, .y = cursor.y, .bar = cursor.bar }
else
null;
diff --git a/src/echo.zig b/src/echo.zig
index e98aff49..89d02154 100644
--- a/src/echo.zig
+++ b/src/echo.zig
@@ -541,7 +541,7 @@ fn keyboardPane(c: *const Pardes, view: u8) ?usize {
const live = c.view == view;
const part = if (live) null else &(c.parked[view] orelse return null).view;
const id = if (part) |v| v.active else c.active;
- if (if (part) |v| v.window_pick != null or v.header_focus else c.window_pick != null or c.header_focus) return null;
+ if (if (part) |v| v.window_pick != null or v.header != null else c.window_pick != null or c.header != null) return null;
const pane = c.panes[id] orelse return null;
if (!pane.isTerminal() or pane.terminal == null or pane.prompt != .none) return null;
const mode = if (live) pane.body.mode else pane.pv[view].body.mode;
diff --git a/src/keys.zig b/src/keys.zig
index 264eb95e..2906e870 100644
--- a/src/keys.zig
+++ b/src/keys.zig
@@ -143,7 +143,7 @@ pub fn answerQuestion(p: *Pardes, id: usize, choice: ?u8) bool {
if (choice == 'k') exec.runBuiltin(p, .Del, id, "", "k");
if (choice == 'j') exec.runBuiltin(p, .Del, id, "", "j");
// Asked from window mode (`d`): the outline goes with the rows.
- if (p.window_pick == id and p.panes[id] == null) p.window_pick = if (p.header_focus) null else p.active;
+ if (p.window_pick == id and p.panes[id] == null) p.window_pick = if (p.header != null) null else p.active;
},
else => return false,
}
@@ -260,7 +260,7 @@ pub fn handleKey(p: *Pardes, key: Key) void {
const nt = p.newShell(free, "") catch return;
nt.greet = true;
// From a tag, as a 9P new is: acme's t->w == nil.
- exec.placeNew(p, p.active, if (p.header_focus) null else p.active, free, .shell);
+ exec.placeNew(p, p.active, if (p.header != null) null else p.active, free, .shell);
return;
}
for (config.jump_keys) |jk| {
@@ -351,7 +351,7 @@ pub fn handleKey(p: *Pardes, key: Key) void {
};
const txt = shown[span[0]..span[1]];
// A column tag's command acts on that column, empty or not.
- p.exec_column = if (header != null) p.header_column else null;
+ p.exec_column = if (header != null) p.headerColumn() else null;
defer p.exec_column = null;
p.exec_header = header != null;
defer p.exec_header = false;
@@ -796,7 +796,7 @@ test "s in a header selects in the header's own text" {
// the prompt takes the keys while the header keeps the keyboard
p.update(.{ .key = .{ .cp = 'c', .text = "col" } });
p.update(.{ .key = .{ .cp = Key.enter } });
- try std.testing.expect(p.header_focus and pane.prompt == .none);
+ try std.testing.expect(p.header != null and pane.prompt == .none);
var ranges: [Text.max_selections]modal.Selection = undefined;
const text = try edit.flatSurface(p, &p.global_tag);
const got = p.global_tag.ranges(text, 0, &ranges);
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;
diff --git a/src/look.zig b/src/look.zig
index 31b80948..7df48c5a 100644
--- a/src/look.zig
+++ b/src/look.zig
@@ -851,7 +851,7 @@ fn lookSpanIn(p: *Pardes, pane: *Pane, from: LookFrom, delta: i32, budget: *usiz
/// A command pane has the keyboard: `n` there walks its own output.
fn commandPaneActive(p: *Pardes) bool {
const pane = p.panes[p.active] orelse return false;
- return pane.command != null and pane.file == null and !p.header_focus;
+ return pane.command != null and pane.file == null and p.header == null;
}
pub fn lookWalk(p: *Pardes, delta: i32) void {
diff --git a/src/mouse.zig b/src/mouse.zig
index 56a1b378..02f966bd 100644
--- a/src/mouse.zig
+++ b/src/mouse.zig
@@ -100,7 +100,7 @@ pub const HeaderSweep = struct {
fn headerPoint(p: *Pardes, column: ?usize, mcol: u16, mrow: u16, clamp: bool) ?struct { t: *panes.Text, text: []const u8, line: u16, at: usize } {
const t = if (column) |c| &p.col_tags[c] else &p.global_tag;
const x = if (column) |c| p.col_x[c] + TAG_TEXT_INSET else TAG_TEXT_INSET;
- const focused = p.header_focus and p.header_column == column;
+ const focused = p.header != null and p.headerColumn() == column;
const text = edit.flatSurface(p, t) catch return null;
const base = if (column != null) p.topBarHeight() else 0;
const rows = if (column != null) layout.columnBarHeight(p) else p.topBarHeight();
@@ -128,7 +128,7 @@ fn headerSweepRun(p: *Pardes, sweep: HeaderSweep) void {
const start = modal.lineStartOffset(text, line);
const bar = modal.lineSlice(text, line);
const at = swept.lo - start;
- const focused = p.header_focus and p.header_column == column;
+ const focused = p.header != null and p.headerColumn() == column;
const on = if (focused) tagline.headerSelection(t, text, line) else null;
const under = if (tagline.wordBoundsAtCol(bar, at)) |b| bar[b.lo..b.hi] else "";
break :click if (on) |sp| (if (at >= sp.lo and at < sp.hi) bar[sp.lo..sp.hi] else under) else under;
@@ -609,7 +609,7 @@ pub fn handleMouse(p: *Pardes, event: Mouse) void {
}
// Held to the focused header's rows and text; the anchor stays
// where the press put it.
- const point = headerPoint(p, p.header_column, mcol, mrow, true) orelse return;
+ const point = headerPoint(p, p.headerColumn(), mcol, mrow, true) orelse return;
const t = point.t;
t.cur_row = point.line;
t.cur_col = @intCast(point.at - modal.lineStartOffset(point.text, point.line));
@@ -643,7 +643,7 @@ pub fn handleMouse(p: *Pardes, event: Mouse) void {
const t = point.t;
const at = point.at - modal.lineStartOffset(point.text, point.line);
// A clicked header starts in normal mode, as a clicked tag does.
- if (!(p.header_focus and p.header_column == column)) tagline.enterHeader(p, column);
+ if (!(p.header != null and p.headerColumn() == column)) tagline.enterHeader(p, column);
t.mode = .normal;
t.cur_row = point.line;
t.cur_col = @intCast(at);
diff --git a/src/ninep/cols.zig b/src/ninep/cols.zig
index 3a7f0dbb..20ee2e3e 100644
--- a/src/ninep/cols.zig
+++ b/src/ninep/cols.zig
@@ -20,7 +20,7 @@ const E = tree.E;
/// else the active pane's. Null when the workspace tag has it and no pane
/// is active.
pub fn activeColumn(p: *const Pardes) ?usize {
- if (p.header_focus) if (p.header_column) |c| return if (c < p.ncol) c else null;
+ if (p.headerColumn()) |c| return if (c < p.ncol) c else null;
const at = layout.findPane(p, p.active) orelse return null;
return at.col;
}
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig
index 04ac1cbf..9c5b82bf 100644
--- a/src/ninep/ctl.zig
+++ b/src/ninep/ctl.zig
@@ -431,7 +431,7 @@ pub fn paneText(p: *Pardes, pane: *Pane, buf: []u8) []const u8 {
const font = p.settings.font.effective_name.get();
writeQuoted(&w, if (font.len == 0) "default" else font) catch return w.buffered();
// While a column's or the workspace's tag has the keyboard, no pane does.
- const current = p.panes[p.active] == pane and !p.header_focus;
+ const current = p.panes[p.active] == pane and p.header == null;
const f = pane_files.fileOf(pane);
const undo = if (f) |file| file.history.journal.done > 0 else false;
const redo = if (f) |file| file.history.journal.done < file.history.journal.steps.items.len else false;
@@ -909,7 +909,7 @@ pub fn commandsText(p: *Pardes) ![]const u8 {
/// rio keeps `current` apart from `unhide`.
pub fn readFocus(p: *Pardes, req: Req) Reply {
const out = p.fs.stage(p.gpa);
- if (p.header_focus) return tree.stagedReply(p, req);
+ if (p.header != null) return tree.stagedReply(p, req);
const pane = p.panes[p.active] orelse return tree.stagedReply(p, req);
out.print(p.gpa, "{d}\n", .{pane.serial}) catch return Reply.fail(req.tag, E.NOMEM);
return tree.stagedReply(p, req);
diff --git a/src/ninep/tree.zig b/src/ninep/tree.zig
index 08db0d75..a00a8947 100644
--- a/src/ninep/tree.zig
+++ b/src/ninep/tree.zig
@@ -686,7 +686,7 @@ fn topSize(p: *Pardes, f: TopFile) u64 {
.ctl => if (ctl.settingsText(p)) |text| text.len else |_| 0,
.commands => if (ctl.commandsText(p)) |text| text.len else |_| 0,
.focus => focus: {
- if (p.header_focus) break :focus 0;
+ if (p.header != null) break :focus 0;
const pn = p.panes[p.active] orelse break :focus 0;
var digits: [16]u8 = undefined;
// unreachable: a u32 serial and a newline fit 16
diff --git a/src/panes.zig b/src/panes.zig
index 4f7ca0e7..c0783ac7 100644
--- a/src/panes.zig
+++ b/src/panes.zig
@@ -1044,7 +1044,7 @@ pub fn removePane(p: *Pardes, id: usize, to: ?usize) error{OutOfMemory}!void {
p.quit = true;
return p.emit(.quit);
};
- if (emptied) |c| if (!finder_gone and !p.header_focus) tagline.enterHeader(p, c);
+ if (emptied) |c| if (!finder_gone and p.header == null) tagline.enterHeader(p, c);
}
/// The pane Last should fall back to when the jumplist has nothing: the
diff --git a/src/tagline.zig b/src/tagline.zig
index 3e7ebe52..9655f537 100644
--- a/src/tagline.zig
+++ b/src/tagline.zig
@@ -70,8 +70,8 @@ pub fn columnTag(p: *const Pardes, c: usize) []const u8 {
/// The header with the keyboard, when one has it.
pub fn focusedHeader(p: *Pardes) ?*Text {
- if (!p.header_focus) return null;
- if (p.header_column) |c| return if (c < p.ncol) &p.col_tags[c] else null;
+ if (p.header == null) return null;
+ if (p.headerColumn()) |c| return if (c < p.ncol) &p.col_tags[c] else null;
return &p.global_tag;
}
@@ -83,11 +83,11 @@ pub fn revealHeader(p: *Pardes) void {
};
const text = edit.flatSurface(p, t) catch return;
const cur: usize = @intCast(@max(0, t.cur_row));
- const rows: usize = if (p.header_column != null) layout.columnBarHeight(p) else p.topBarHeight();
+ 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;
const line = modal.lineSlice(text, cur);
- const width = layout.tagCapacity(p, if (p.header_column) |c| p.col_w[c] -| TAG_TEXT_INSET else p.screen_w -| TAG_TEXT_INSET);
+ const width = layout.tagCapacity(p, if (p.headerColumn()) |c| p.col_w[c] -| TAG_TEXT_INSET else p.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);
@@ -398,8 +398,7 @@ pub fn commitTagName(p: *Pardes, pane: *Pane) bool {
}
pub fn exitHeader(p: *Pardes) void {
- p.header_focus = false;
- p.header_column = null;
+ p.header = null;
p.header_drag = false;
p.header_scroll = 0;
p.header_top = 0;
@@ -410,8 +409,7 @@ pub fn exitHeader(p: *Pardes) void {
pub fn enterHeader(p: *Pardes, column: ?usize) void {
exitHeader(p);
if (p.panes[p.active]) |pane| pane.focus = .body;
- p.header_focus = true;
- p.header_column = column;
+ p.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 "");
@@ -442,7 +440,7 @@ pub fn workspaceBlank(p: *Pardes, col: u16, row: u16, tag_hit: ?pardes.TagHit) b
if (row >= p.topBarHeight() or col >= p.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_focus and p.header_column == null) p.header_scroll else 0;
+ const scroll: usize = if (p.header != null and p.headerColumn() == null) p.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;
}
diff --git a/src/views.zig b/src/views.zig
index dcd11b2c..f28cabe1 100644
--- a/src/views.zig
+++ b/src/views.zig
@@ -43,7 +43,7 @@ pub const fields = [_][:0]const u8{
"pointer_body_hit", "pointer_tag_hit", "raw_hover_intent", "pointer_inside",
"last_click", "click_as", "chord_hold", "wheel_guard",
"ctrl_w_pending", "register", "leader_on", "window_pick",
- "leader_keys", "leader_n", "header_focus", "header_column",
+ "leader_keys", "leader_n", "header",
"header_drag", "header_sweep", "header_scroll", "header_top",
"chord_arg", "clip_pending",
};