summaryrefslogtreecommitdiff
path: root/core/layout.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/layout.zig')
-rw-r--r--core/layout.zig14
1 files changed, 12 insertions, 2 deletions
diff --git a/core/layout.zig b/core/layout.zig
index 3f6bea51..be2d213c 100644
--- a/core/layout.zig
+++ b/core/layout.zig
@@ -592,12 +592,18 @@ pub const min_body_rows = 2;
/// wants a row more.
pub fn wantedTagRows(p: *Pardes, id: usize) u16 {
const pane = p.panes[id] orelse return BOX_H;
+ return tagRows(p, id, tagline.computedWords(pane));
+}
+
+/// The rows pane `id`'s tag at rest takes with computed words `words`.
+fn tagRows(p: *Pardes, id: usize, words: []const u8) u16 {
+ const pane = p.panes[id] orelse return BOX_H;
if (pane.collapsed or !pane.tag_expanded) return BOX_H;
if (p.view().rects[id].w == 0) return pane.tag_rows; // never laid out
var wrap_room: [32 * 1024]u8 = undefined;
var wrap_fba = std.heap.FixedBufferAllocator.init(&wrap_room);
const wa = wrap_fba.allocator();
- const prefix = tagline.restPrefix(p, wa, pane) catch return pane.tag_rows;
+ const prefix = tagline.prefixWith(p, wa, pane, words) catch return pane.tag_rows;
const whole = std.mem.concat(wa, u8, &.{ prefix, tagline.curTail(pane) }) catch return pane.tag_rows;
const shown = tagline.wrapTag(p.settings.tab, wa, whole, tagline.tagWidth(p, id)) catch return pane.tag_rows;
return @intCast(@max(BOX_H, @min(shown.rows(), MAX_TAG_ROWS)));
@@ -622,7 +628,11 @@ pub fn headRows(p: *Pardes, id: usize) u16 {
/// The rows a placement, and a `size`, leave a pane: its tag at its width
/// and `min_body_rows`. The one minimum both ask.
pub fn minRows(p: *Pardes, id: usize) u16 {
- return wantedTagRows(p, id) + min_body_rows;
+ const pane = p.panes[id] orelse return BOX_H + min_body_rows;
+ // Its tag with the widest computed words it can come to show (UX
+ // K'3): an edit that brings Save and Undo never takes a row its
+ // column did not give.
+ return tagRows(p, id, tagline.widestWords(p, pane)) + min_body_rows;
}
/// Whether every column has the rows for each of its unfolded panes'