summaryrefslogtreecommitdiff
path: root/src/Core.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/Core.zig')
-rw-r--r--src/Core.zig24
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));