summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Finder.zig12
-rw-r--r--src/layout.zig31
-rw-r--r--src/pardes.zig12
3 files changed, 27 insertions, 28 deletions
diff --git a/src/Finder.zig b/src/Finder.zig
index 0be40c24..3744e5d1 100644
--- a/src/Finder.zig
+++ b/src/Finder.zig
@@ -84,17 +84,13 @@ fn open(f: *Finder, p: *Pardes) ?usize {
p.col_serial[c] = 0;
p.ncol += 1;
f.serial = layout.columnSerial(p, c);
- // A narrower column wraps long tags onto more rows: those rows back
- // from the panes with rows to spare, shared out again only where that
- // is not enough, and where nothing holds every minimum there is no
- // finder, as Newcol is refused.
- layout.restoreMinimaFrom(p, &before, &before_min);
- for (0..p.ncol) |k| if (k != c and layout.squeezed(p, k, &before, &before_min) and !layout.shareColumn(p, k)) {
- layout.dropColumnUnannounced(p, c);
+ // Where nothing holds every minimum there is no finder, as Newcol is
+ // refused.
+ if (!layout.keepColumn(p, c, &before, &before_min)) {
f.serial = 0;
layout.compute(p);
return null;
- };
+ }
layout.noteColumn(p, "newcol", f.serial);
return c;
}
diff --git a/src/layout.zig b/src/layout.zig
index a3fb9b8e..91947997 100644
--- a/src/layout.zig
+++ b/src/layout.zig
@@ -725,17 +725,28 @@ pub fn restoreMinimaFrom(p: *Pardes, before: *const [MAX_PANES]Rect, before_min:
compute(p);
}
-/// Whether a pane of column `c` is under its minimum now that had its
-/// minimum then (`before`, `before_min`): one a step squeezed, not one
-/// dragged short.
-pub fn squeezed(p: *Pardes, c: usize, before: *const [MAX_PANES]Rect, before_min: *const [MAX_PANES]u16) bool {
- compute(p);
- if (p.col_n[c] < 2) return false;
- for (p.col_panes[c][0..p.col_n[c]]) |k| {
- const pane = p.panes[k] orelse continue;
- if (!pane.collapsed and p.rects[k].h < minRows(p, k) and before[k].h >= before_min[k]) return true;
+/// Whether new column `c` (Newcol's, the finder's) may stay. A narrower
+/// column wraps long tags onto more rows, which can leave a pane under its
+/// tag and two rows: each pane a column squeezed so (one that had its
+/// minimum `before`, `before_min`, not one dragged short) takes rows back
+/// from the panes with rows to spare, its column shared out again only
+/// where that is not enough. False, `c` dropped unannounced, where nothing
+/// holds every minimum, as a size too small is refused.
+pub fn keepColumn(p: *Pardes, c: usize, before: *const [MAX_PANES]Rect, before_min: *const [MAX_PANES]u16) bool {
+ restoreMinimaFrom(p, before, before_min);
+ for (0..p.ncol) |k| {
+ compute(p);
+ if (p.col_n[k] < 2) continue;
+ const squeezed = for (p.col_panes[k][0..p.col_n[k]]) |id| {
+ const pane = p.panes[id] orelse continue;
+ if (!pane.collapsed and p.rects[id].h < minRows(p, id) and before[id].h >= before_min[id]) break true;
+ } else false;
+ if (squeezed and !shareColumn(p, k)) {
+ dropColumnUnannounced(p, c);
+ return false;
+ }
}
- return false;
+ return true;
}
/// Column `c`'s rows for `id`, last in it, at its minimum: a row at a
diff --git a/src/pardes.zig b/src/pardes.zig
index cd247272..e08c2f37 100644
--- a/src/pardes.zig
+++ b/src/pardes.zig
@@ -4745,19 +4745,11 @@ pub const Pardes = struct {
else
"Newcol: no space for a column: this one is too narrow to split");
};
- // A narrower column wraps long tags onto more rows, which can leave
- // a pane under its tag and two rows: it takes them back from the
- // panes with rows to spare (a pane dragged short keeps its own),
- // its column shared out again only where that is not enough, and
- // where nothing holds every minimum there is no new column, as a
- // size too small is refused.
- layout.restoreMinimaFrom(p, &before, &before_min);
- for (0..p.ncol) |k| if (layout.squeezed(p, k, &before, &before_min) and !layout.shareColumn(p, k)) {
- layout.dropColumnUnannounced(p, c);
+ if (!layout.keepColumn(p, c, &before, &before_min)) {
p.next_column_serial = unspent;
layout.compute(p);
return p.reportFailure(from_id, "Newcol: no space for a column: the panes' tags would not fit");
- };
+ }
// Kept: now it has a serial, and the log hears of it.
layout.noteColumn(p, "newcol", layout.columnSerial(p, c));
tagline.enterHeader(p, c);