summaryrefslogtreecommitdiff
path: root/core/layout.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/layout.zig')
-rw-r--r--core/layout.zig43
1 files changed, 21 insertions, 22 deletions
diff --git a/core/layout.zig b/core/layout.zig
index c8fb91f9..ae15c6e9 100644
--- a/core/layout.zig
+++ b/core/layout.zig
@@ -592,7 +592,7 @@ 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));
+ return tagRows(p, id, tagline.tagWords(p, pane));
}
/// The rows pane `id`'s tag at rest takes with computed words `words`.
@@ -609,20 +609,19 @@ fn tagRows(p: *Pardes, id: usize, words: []const u8) u16 {
return @intCast(@max(BOX_H, @min(shown.rows(), MAX_TAG_ROWS)));
}
-/// The rows pane `id`'s tag's text takes now: out of rest its head
-/// (TagState) after what of its prefix stays (UX D1), wrapped at its width
-/// as Pardes.sync wraps it; at rest what wantedTagRows says.
+/// The rows pane `id`'s head takes under its tag out of rest (TagState,
+/// UX DESIGN M2), wrapped at the tag's width as the band draws it; none at
+/// rest.
pub fn headRows(p: *Pardes, id: usize) u16 {
- const pane = p.panes[id] orelse return BOX_H;
- if (pane.collapsed or !pane.tag_expanded) return BOX_H;
+ const pane = p.panes[id] orelse return 0;
+ if (pane.collapsed) return 0;
var wrap_room: [Pane.prefix_room]u8 = undefined;
var wrap_fba = std.heap.FixedBufferAllocator.init(&wrap_room);
const wa = wrap_fba.allocator();
- const prefix = tagline.prefixIn(p, wa, pane) catch return pane.tag_rows;
- const tail = tagline.shownTail(p, wa, pane) catch return pane.tag_rows;
- const whole = std.mem.concat(wa, u8, &.{ prefix, tail }) 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)));
+ // A head with no room to be made in is a row still.
+ const head = (pardes.TagState.head(p, wa, pane) catch return 1) orelse return 0;
+ const shown = tagline.wrapTag(p.settings.tab, wa, head.text, tagline.tagWidth(p, id)) catch return 1;
+ return @intCast(@min(shown.rows(), MAX_TAG_ROWS));
}
/// The rows a placement, and a `size`, leave a pane: its tag at its width
@@ -1608,22 +1607,22 @@ pub fn compute(p: *Pardes) void {
/// The fewest rows a pane is laid out with: a terminal keeps its tag and
/// `min_body_rows` (a shorter one loses its prompt and reads busy for
/// ever), a text pane may shrink to its tag, as acme's windows do. A tag
-/// out of rest has the rows for its head and its band, drawn over its body
-/// (UX DESIGN I1); a picker's (code actions' too: its body is the preview)
-/// a body of 60 % of the pane and 6 rows at least under them (UX D6). Those
-/// are borrowed from the column's other panes, which shrink to their tags
-/// until it rolls up (walk UI SPEC §3.6). A terminal's and a kind's size
-/// is their user's: a transient state never resizes the pty under a
-/// program or a kind's view (a PDF's), it is drawn over as much of them as
-/// it has (R3).
+/// out of rest has the rows for its head and its band under it, drawn over
+/// its body (UX DESIGN I1, M4); a picker's (code actions' too: its body is
+/// the preview) a body of 60 % of the pane and 6 rows at least under them
+/// (UX D6). Those are borrowed from the column's other panes, which shrink
+/// to their tags until it rolls up (walk UI SPEC §3.6). A terminal's and a
+/// kind's size is their user's: a transient state never resizes the pty
+/// under a program or a kind's view (a PDF's), it is drawn over as much of
+/// them as it has (R3).
fn floorRows(p: *Pardes, id: usize) u16 {
const pane = p.panes[id] orelse return 0;
- const band = if (pane.isTerminal() or pane.addon != null) 0 else pardes.Band.takes(p, id);
- if (band > 0) {
+ const under = if (pane.isTerminal() or pane.addon != null) 0 else headRows(p, id) + pardes.Band.takes(p, id);
+ if (under > 0) {
// Worked out from the state, never the last sync's rows (the first
// layout after a head changed read the rows of the one before, and
// the next moved the body).
- const above = @max(wantedTagRows(p, id), headRows(p, id) + band);
+ const above = wantedTagRows(p, id) + under;
if (p.view().tag_state.kind != .pick) return above;
// A body of 60 % is one and a half times what is above it.
return above + @max(pardes.Band.body_rows, (3 * above + 1) / 2);