diff options
Diffstat (limited to 'src/tagline.zig')
| -rw-r--r-- | src/tagline.zig | 16 |
1 files changed, 7 insertions, 9 deletions
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; } |
