From 9299281492d63e549ab274034efb59ab4e9d96f6 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Sat, 24 Oct 2026 13:11:11 -0300 Subject: Search converge 6/6: SearchPlace column, the finder column at the right edge holding the query panes; n/N in a frozen query pane; the design doc --- src/layout.zig | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) (limited to 'src/layout.zig') diff --git a/src/layout.zig b/src/layout.zig index dac0aa7e..8739122c 100644 --- a/src/layout.zig +++ b/src/layout.zig @@ -166,6 +166,11 @@ pub fn columnDrop(p: *const Pardes, source: usize, x: u16, grab: u16) ColumnDrop pub fn setColumnPairWidth(p: *Pardes, left: usize, left_width: u64) void { if (left + 1 >= p.ncol) return; const combined: u64 = p.col_w[left] + p.col_w[left + 1]; + // The finder's edge sets its share (Finder.dragWidth). + if (p.finder.column(p)) |fc| { + if (fc == left + 1) return p.finder.dragWidth(p, left, combined -| left_width); + if (fc == left) return p.finder.dragWidth(p, left + 1, left_width); + } // Too narrow for both to keep MINW: any split would squeeze one away. if (combined < 2 * @as(u64, config.MINW)) return; const width = std.math.clamp(left_width, config.MINW, @max(@as(u64, config.MINW), combined -| config.MINW)); @@ -467,7 +472,12 @@ pub fn dropColumn(p: *Pardes, c: usize) void { pub fn dropColumnUnannounced(p: *Pardes, c: usize) void { std.debug.assert(p.col_n[c] == 0); tagline.exitHeader(p); - if (p.ncol > 1) p.col_weight[if (c > 0) c - 1 else c + 1] +|= p.col_weight[c]; + // The finder's width was its share, no weight: nobody gets one, so the + // others are as wide as before it came. A column whose weight would go + // to the finder gives it to the column on the finder's other side. + const finder = p.finder.column(p); + const heir: ?usize = if (p.ncol <= 1 or finder == c) null else if (c > 0 and finder != c - 1) c - 1 else if (c + 1 < p.ncol and finder != c + 1) c + 1 else if (c > 1) c - 2 else if (c + 2 < p.ncol) c + 2 else null; + if (heir) |h| p.col_weight[h] +|= p.col_weight[c]; p.col_tags[c].deinit(p.gpa); var j = c; while (j + 1 < p.ncol) : (j += 1) { @@ -1187,20 +1197,32 @@ pub fn compute(p: *Pardes) void { if (p.ncol == 0) return; keepGroups(p); for (0..p.ncol) |column| _ = columnSerial(p, column); + // The finder column is as wide as its share says (Finder.width), not + // by weight: the others share what it leaves by theirs, so it comes + // and goes and each of them keeps its proportion, none rounded off. + const finder = p.finder.column(p); + const finder_w: u16 = if (finder != null) p.finder.width(p) else 0; + const rest = p.screen_w -| finder_w; var wsum: u128 = 0; - for (0..p.ncol) |c| wsum += p.col_weight[c]; + var last_plain: usize = p.ncol; + for (0..p.ncol) |c| if (finder != c) { + wsum += p.col_weight[c]; + last_plain = c; + }; if (wsum == 0) wsum = 1; // Round cumulative boundaries so widths still sum to the available screen. var prefix: u128 = 0; + var offset: u16 = 0; for (0..p.ncol) |c| { - const last = c + 1 == p.ncol; - const x = columnBoundary(p.screen_w, prefix, wsum); - prefix += p.col_weight[c]; - const end: u16 = if (last) - p.screen_w - else - columnBoundary(p.screen_w, prefix, wsum); + const x = offset + columnBoundary(rest, prefix, wsum); + const end: u16 = if (finder == c) end: { + offset = finder_w; + break :end x + finder_w; + } else end: { + prefix += p.col_weight[c]; + break :end if (c == last_plain) offset + rest else offset + columnBoundary(rest, prefix, wsum); + }; const cw = end -| x; p.col_x[c] = x; p.col_w[c] = cw; -- cgit v1.3