From 342650183a54dcfcdce6ca4d45d6fdf48b2d1c1c Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 5 Nov 2026 23:16:22 -0300 Subject: settings #4, the three ways to place a search go, a query pane attached under the pane that asked, eight rows under its line 1 (Query.born_rows), the next search from that pane reusing it: SearchPlace, SearchPane and SearchRows, and with SearchPlace's column the finder column itself, src/Finder.zig and its reads (Core.zig's finder field, pardes.zig's export, views.zig's per-view and laid-out field names, panes.zig's emptied column, exec.placeNew's away column, and layout.zig's compute share, setColumnPairWidth, dropColumnUnannounced's heir and newColumn), with ctl's SearchRows check and the requiresArg and applySettingBuiltin arms; deleted tests: "SearchPlace column: query panes stack in a finder column at the right edge, nothing else moves after it opens, and it goes with its last pane" (Finder.zig) and the SearchPane new half of Query's "* seeds line 1" test; root_ctl's number refusal is Tab's range now; the guide says eight rows; a dump that kept the finder or the three fields loads without them; no golden changes; gates on tui: core-test 963/963, behaviour-test 241/241, unit-test 1479/1480, pane-test 171/172, snap all 105 scripts ok, process-test 0 of 37 failed; gui unit-test 1523/1524 Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- src/CHANGELOG.md | 3 + src/Core.zig | 4 - src/Finder.zig | 235 ------------------------------------------------------ src/Query.zig | 53 ++++-------- src/builtins.zig | 2 +- src/config.zig | 28 +------ src/exec.zig | 17 +--- src/layout.zig | 46 ++--------- src/ninep/ctl.zig | 1 - src/panes.zig | 4 +- src/pardes.zig | 2 - src/views.zig | 4 +- 12 files changed, 40 insertions(+), 359 deletions(-) delete mode 100644 src/Finder.zig (limited to 'src') diff --git a/src/CHANGELOG.md b/src/CHANGELOG.md index 3869aa07..ba9bc911 100644 --- a/src/CHANGELOG.md +++ b/src/CHANGELOG.md @@ -16,6 +16,9 @@ - PagerColor: a +Pager keeps its program's colours. - TermImages: a new terminal draws its program's images as pixels where the shell can; Petscii still flips one terminal to glyph art. + - SearchPlace, SearchPane and SearchRows: a query pane is attached under + the pane that asked, eight rows under its line 1, and the next search + from that pane reuses it; the finder column is gone with them. - What pardes keeps on disk is in xitdb databases now (a pinned commit of github.com/xit-vcs/xitdb, pure Zig). The state file, `pardes.xitdb` in diff --git a/src/Core.zig b/src/Core.zig index 0f90f4cb..76f59247 100644 --- a/src/Core.zig +++ b/src/Core.zig @@ -16,7 +16,6 @@ const ChromeTheme = pardes.ChromeTheme; const Color = pardes.Color; const Effect = pardes.Effect; const Event = pardes.Event; -const Finder = pardes.Finder; const FontRole = pardes.FontRole; const FrameStats = pardes.FrameStats; const Handover = pardes.Handover; @@ -114,9 +113,6 @@ cols: [MAX_COLS]Column = @splat(.{}), /// tags of its own. col_tags: [MAX_COLS]Text = @splat(.{ .what = .column }), next_column_serial: u32 = 1, -/// The finder column, where query panes stack with SearchPlace column -/// (Finder.zig). -finder: Finder = .{}, /// A pane or column on its way to another window (Handover.zig). handover: Handover = .{}, global_tag: Text = .{ .what = .workspace }, diff --git a/src/Finder.zig b/src/Finder.zig deleted file mode 100644 index 1e8fa022..00000000 --- a/src/Finder.zig +++ /dev/null @@ -1,235 +0,0 @@ -//! The finder column: where query panes go with `SearchPlace column`, the -//! alternative to attaching them under the pane that asked (lifted from -//! the column prototype, cut to its placement). A column with a role at -//! the right edge: the first search opens it and the other columns give it -//! its share once, each in proportion to its weight; after that no pane -//! outside it moves for a search. Its width is a share of the window, not a -//! column weight (layout.compute), so it opens and closes without rounding -//! anyone's width off. Its panes are a recency stack: the newest query pane -//! on top and open, the older ones folded to their tags. A pane opened -//! from a row goes to the column of the pane the query searches, never in -//! here. Its last pane gone, the column goes and every other is as wide as -//! before it came. The role is the column's serial. -const Finder = @This(); - -const std = @import("std"); -const pardes = @import("pardes.zig"); -const layout = @import("layout.zig"); -const config = @import("config.zig"); -const Pardes = pardes.Pardes; - -/// The finder column's serial (layout.columnSerial); 0 while there is none. -serial: u32 = 0, -/// Its width, in thousandths of the window's: kept while it is closed, so -/// it comes back as wide as it went. -share: u16 = 300, - -/// More query panes than this and the oldest closes: each folded one keeps -/// a tag row. ponytail: a fixed count; size it from the column's rows. -pub const max_results = 8; - -const tag_text = "Finder Delcol"; - -/// The finder column's index, while it is there. -pub fn column(f: *const Finder, p: *const Pardes) ?usize { - if (f.serial == 0) return null; - return layout.columnBySerial(p, f.serial); -} - -/// Its width in cells: its share, leaving every other column MINW; the -/// whole window when it is the only column. -pub fn width(f: *const Finder, p: *const Pardes) u16 { - if (p.ncol <= 1) return p.screen_w; - const others: u32 = @as(u32, config.MINW) * @as(u32, @intCast(p.ncol - 1)); - const most: u32 = @as(u32, p.screen_w) -| others; - const wanted: u32 = @as(u32, p.screen_w) * f.share / 1000; - return @intCast(@min(@max(wanted, config.MINW), @max(most, @min(config.MINW, p.screen_w)))); -} - -/// Query pane `id` goes on top of the finder column, opened at the right -/// edge if there is none; the older ones fold. False when the window has -/// no room for the column (the caller attaches it instead). -pub fn place(f: *Finder, p: *Pardes, id: usize) bool { - const pane = p.panes[id] orelse return false; - const c = f.column(p) orelse f.open(p) orelse return false; - layout.insert(p, c, 0, id); - pane.vweight = 1; - pane.collapsed = false; - fold(p, c, id); - // The oldest goes once there are too many: the bottom one, as the top - // is always the newest. - while (p.cols[c].n > max_results) { - const oldest = p.cols[c].panes[p.cols[c].n - 1]; - p.removePane(oldest, null) catch break; - } - return true; -} - -/// A finder column at the right edge, empty, its tag its own: the other -/// columns give it its share, each in proportion to its weight. Null when -/// the window has no room for one more column, or narrower columns would -/// leave a pane under its tag and 2 rows. -fn open(f: *Finder, p: *Pardes) ?usize { - if (p.ncol >= pardes.MAX_COLS or p.ncol == 0) return null; - if (p.screen_w < @as(u32, config.MINW) * @as(u32, @intCast(p.ncol + 1))) return null; - const before_min = layout.minima(p); - const before = p.rects; - const c = p.ncol; - // Its weight, the default, is not used for its width (layout.compute), - // only kept positive for the code that halves and joins weights. - p.cols[c] = .{}; - p.col_tags[c] = .{ .what = .column, .gpa = p.gpa }; - p.col_tags[c].own = p.gpa.dupe(u8, tag_text) catch null; - p.ncol += 1; - f.serial = layout.columnSerial(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; -} - -/// Fold every pane of finder column `c` but `top` (and what is attached -/// to it, its +Preview) to its tag. -fn fold(p: *Pardes, c: usize, top: usize) void { - layout.compute(p); - for (p.cols[c].panes[0..p.cols[c].n]) |k| { - const pane = p.panes[k] orelse continue; - if (k == top or layout.groupRoot(p, k) == top) { - pane.collapsed = false; - pane.vweight = 1; - } else if (!pane.collapsed) { - // As Collapse folds it: its weight keeps its height for later. - pane.vweight = @floatFromInt(@max(1, p.rects[k].h)); - pane.collapsed = true; - } - } - layout.compute(p); -} - -/// Query pane `id`, asked again: back on top of the stack, open, the rest -/// folded. Nothing outside the finder column moves. -pub fn raise(f: *Finder, p: *Pardes, id: usize) void { - const c = f.column(p) orelse return; - const at = layout.findPane(p, id) orelse return; - if (at.col != c) return; - if (at.idx != 0) { - // the pane and what is attached to it (its +Preview) move together - const end = layout.groupEnd(p, c, at.idx); - var moved: [pardes.MAX_PANES]usize = undefined; - const n = end - at.idx; - @memcpy(moved[0..n], p.cols[c].panes[at.idx..end]); - for (moved[0..n]) |k| layout.removePane(p, k); - for (moved[0..n], 0..) |k, i| layout.insert(p, c, i, k); - } - fold(p, c, id); -} - -/// The column a pane asked for from the finder goes in (a row looked at, a -/// command run there): the column of the pane its query searches, else -/// the nearest other. Null when nothing points at the finder. -pub fn away(f: *Finder, p: *Pardes, from: usize, kind: pardes.exec.NewPane) ?usize { - const fc = f.column(p) orelse return null; - const in_finder = if (layout.findPane(p, from)) |at| at.col == fc else false; - const to_last = (kind == .command or kind == .errors) and fc == p.ncol - 1; - if (!in_finder and p.exec_column != fc and !to_last) return null; - if (in_finder) { - const root = layout.groupRoot(p, from); - if (p.panes[root]) |qp| if (qp.query) |q| if (p.paneBySerial(q.owner)) |oid| if (layout.findPane(p, oid)) |at| - if (at.col != fc) return at.col; - } - if (fc > 0) return fc - 1; - if (fc + 1 < p.ncol) return fc + 1; - // The finder is the only column: a document asked from it gets one of - // its own, left of it. - return layout.insertColumn(p, fc, true); -} - -/// The finder column has lost its last pane: it goes, and every other -/// column is as wide as before it came. -pub fn emptied(f: *Finder, p: *Pardes, c: usize) bool { - if (f.column(p) != c or p.cols[c].n != 0) return false; - layout.dropColumn(p, c); - f.serial = 0; - return true; -} - -/// A drag of the border between the finder column and column `other` -/// beside it: the finder's share follows the edge, and `other` takes the -/// difference, every other column keeping its width. -pub fn dragWidth(f: *Finder, p: *Pardes, other: usize, finder_w: u64) void { - const fc = f.column(p) orelse return; - if (p.screen_w == 0) return; - const combined: u64 = p.col_w[fc] + p.col_w[other]; - if (combined < 2 * @as(u64, config.MINW)) return; - const fw = std.math.clamp(finder_w, config.MINW, combined - config.MINW); - f.share = @intCast(@max(1, @min(999, fw * 1000 / p.screen_w))); - var rest_weight: u128 = 0; - var rest_cells: u64 = 0; - for (0..p.ncol) |k| if (k != fc and k != other) { - rest_weight += p.cols[k].weight; - rest_cells += p.col_w[k]; - }; - if (rest_cells > 0) { - const other_cells = combined - fw; - const w = @as(u128, other_cells) * rest_weight / rest_cells; - p.cols[other].weight = @intCast(std.math.clamp(w, 1, layout.max_column_weight)); - } - layout.compute(p); -} - -fn typeKeys(p: *Pardes, text: []const u8) void { - for (text) |c| p.update(.{ .key = .{ .cp = c, .text = &[_]u8{c} } }); -} - -test "SearchPlace column: query panes stack in a finder column at the right edge, nothing else moves after it opens, and it goes with its last pane" { - const Key = pardes.Key; - const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 160, .rows = 40 }); - defer p.deinit(); - p.settings.search_place = .column; - const pane = try p.setTestFile("alpha one\nbeta\nalphabet\n"); - p.newScratchBelow(0); - const other = p.active; - p.active = 0; - layout.compute(p); - const before = p.rects; - const width_before = p.col_w[0]; - typeKeys(p, "/"); - const fc = p.finder.column(p).?; - try std.testing.expectEqual(@as(usize, 1), fc); - const first = p.cols[fc].panes[0]; - try std.testing.expect(p.panes[first].?.query != null); - // the first search narrows the column once; its panes keep their rows - try std.testing.expect(p.col_w[0] < width_before); - try std.testing.expectEqual(before[0].h, p.rects[0].h); - try std.testing.expectEqual(before[other].h, p.rects[other].h); - typeKeys(p, "alpha"); - p.update(.{ .key = .{ .cp = Key.enter } }); - try std.testing.expectEqual(@as(usize, 0), p.active); - try std.testing.expect(pane.places.started); - layout.compute(p); - const opened = p.rects; - // a second search, from the other pane: on top, the first folded - p.active = other; - typeKeys(p, "/"); - const second = p.cols[fc].panes[0]; - try std.testing.expect(second != first); - try std.testing.expect(p.panes[first].?.collapsed); - layout.compute(p); - try std.testing.expectEqualDeep(opened[0], p.rects[0]); - try std.testing.expectEqualDeep(opened[other], p.rects[other]); - // Esc: the second closes, the first stays - p.update(.{ .key = .{ .cp = Key.escape } }); - try std.testing.expect(p.panes[second] == null); - try std.testing.expectEqual(fc, p.finder.column(p).?); - // the first's Del: the column goes, every other as wide as before it - pardes.exec.runBuiltin(p, .Del, first, "", null); - try std.testing.expect(p.finder.column(p) == null); - layout.compute(p); - try std.testing.expectEqual(width_before, p.col_w[0]); - try std.testing.expectEqualDeep(before[0], p.rects[0]); -} diff --git a/src/Query.zig b/src/Query.zig index 9865001b..749a5245 100644 --- a/src/Query.zig +++ b/src/Query.zig @@ -25,8 +25,7 @@ //! rewrites line 1 on its own; zero hits is a state (`0` in the tag). //! Enter lands on the current hit and freezes the rows into ordinary text; //! Esc while typing puts every view back and closes the pane (or brings a -//! reused pane's frozen rows back); Del closes it. One per owner, reused -//! (SearchPane reuse|new). +//! reused pane's frozen rows back); Del closes it. One per owner, reused. const Query = @This(); const std = @import("std"); @@ -202,7 +201,7 @@ fn freeSaved(gpa: std.mem.Allocator, s: Saved) void { } /// The owner's query pane (attached to it, or left where it was by -/// SearchPane new): the one a later search from it reuses. +/// Unattach): the one a later search from it reuses. pub fn ofOwner(p: *Pardes, owner_serial: u32) ?usize { var found: ?usize = null; for (p.panes, 0..) |slot, i| { @@ -243,8 +242,8 @@ pub fn open(p: *Pardes, from: usize, source: Source, arg: []const u8, focus: boo const line = std.mem.concat(p.scratch.allocator(), u8, &.{ wordOf(source), if (source == .text) "" else " ", arg }) catch return; var id: usize = undefined; const existing = ofOwner(p, owner.serial); - if (existing != null and (p.settings.search_pane == .reuse or existing.? == from)) { - id = existing.?; + if (existing) |reused| { + id = reused; const rp = p.panes[id].?; const q = rp.query.?; // Its frozen rows, kept for an Esc to bring back. @@ -254,20 +253,12 @@ pub fn open(p: *Pardes, from: usize, source: Source, arg: []const u8, focus: boo const new = std.mem.concat(p.gpa, u8, &.{ line, "\n" }) catch return; File.setContent(p, f, new); q.reset(p); - if (p.finder.column(p)) |fc| if (layout.findPane(p, id)) |at| if (at.col == fc) p.finder.raise(p, id); if (rp.collapsed) layout.toggleCollapse(p, id); // A source that previews gets its +Preview now, at the key that // asked, not under the typing later. if (previews(source) and previewOf(p, id) == null) - _ = makePreview(p, id, @max(pardes.BOX_H, rp.tag_rows) + p.settings.search_rows, layout.groupRoot(p, id)); - } else { - if (existing) |old| { - // SearchPane new: the last one stays where it is, a result of - // its own; its places are the new one's to feed. - p.panes[old].?.attached_to = null; - } - id = create(p, owner_id, line, source) orelse return; - } + _ = makePreview(p, id, @max(pardes.BOX_H, rp.tag_rows) + born_rows, layout.groupRoot(p, id)); + } else id = create(p, owner_id, line, source) orelse return; // Every view as the search found it, for Esc to put back. owner.places.remember(p, owner); // Before the first key: a names source lists every candidate at once. @@ -277,8 +268,12 @@ pub fn open(p: *Pardes, from: usize, source: Source, arg: []const u8, focus: boo if (focus) toLineOne(p, id) else p.active = from; } -/// A new query pane under pane `owner_id`, `rows` of the owner's rows (the -/// SearchRows setting), its +Preview under it when `source` can need one. +/// The body rows a query pane is born with under its line 1 (and its +/// +Preview with): it never resizes itself after. +pub const born_rows: u16 = 8; + +/// A new query pane under pane `owner_id`, `born_rows` of the owner's rows, +/// its +Preview under it when `source` can need one. fn create(p: *Pardes, owner_id: usize, line: []const u8, source: Source) ?usize { const owner = p.panes[owner_id] orelse return null; const free = p.freeSlot() orelse { @@ -298,14 +293,14 @@ fn create(p: *Pardes, owner_id: usize, line: []const u8, source: Source) ?usize }; q.* = .{ .owner = owner.serial }; np.query = q; - const body: u16 = 1 + p.settings.search_rows; + const body: u16 = 1 + born_rows; const tag = @max(pardes.BOX_H, np.tag_rows); const with_preview = previews(source); // The preview, made right after, takes its own rows from the owner: // when the owner has not the rows for both, they share what it has, so // the group is whole from the first key and nothing moves later. var want: u16 = tag + body; - var preview_rows: u16 = tag + p.settings.search_rows; + var preview_rows: u16 = tag + born_rows; if (with_preview) { layout.compute(p); const spare = p.rects[owner_id].h -| layout.minRows(p, owner_id); @@ -315,13 +310,7 @@ fn create(p: *Pardes, owner_id: usize, line: []const u8, source: Source) ?usize preview_rows = spare -| want; } } - if (p.settings.search_place == .column) { - // On top of the finder column at the right edge (Finder.zig), the - // older query panes folded under it; its preview under it there. - if (!p.finder.place(p, free) and !layout.attachFrom(p, owner_id, free, want, owner_id)) exec.placeNew(p, owner_id, owner_id, free, .doc); - if (with_preview) _ = makePreview(p, free, p.rects[free].h / 2, free); - return free; - } else if (!layout.attachFrom(p, owner_id, free, want, owner_id)) { + if (!layout.attachFrom(p, owner_id, free, want, owner_id)) { // An owner too short to give a query pane its rows: placed as any // new pane is, the one place a search moves another pane. exec.placeNew(p, owner_id, owner_id, free, .doc); @@ -1937,8 +1926,7 @@ pub fn cancel(p: *Pardes, id: usize) void { if (owner_id) |oid| p.active = oid; return; } - // Attached, its rows go back to its owner; in the finder column, to its - // own column's. + // Attached, its rows go back to its owner; else to its own column's. const attached = layout.ownerOf(p, id) != null; if (owner_id) |oid| { p.removePane(id, if (attached) oid else null) catch {}; @@ -2427,7 +2415,7 @@ test "Grep: lines of the files under the owner's directory, under their file; Al try std.testing.expectEqual(@as(usize, 1), std.mem.count(u8, all, "twice")); } -test "* seeds line 1 and keeps the keyboard; SPC b b picks a pane, SPC s s a declaration; SearchPane new leaves the last where it is" { +test "* seeds line 1 and keeps the keyboard; SPC b b picks a pane, SPC s s a declaration" { const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 120, .rows = 48 }); defer p.deinit(); const pane = try p.setTestFile("const alpha = 1;\nfn beta() void {\n _ = alpha;\n}\nfn gamma() void {}\n"); @@ -2463,13 +2451,6 @@ test "* seeds line 1 and keeps the keyboard; SPC b b picks a pane, SPC s s a dec try std.testing.expectEqual(@as(usize, 0), p.active); try std.testing.expectEqual(@as(i32, 1), pane.body.cur_row); _ = other; - // SearchPane new: the frozen one stays, unattached; a new one under the owner - p.settings.search_pane = .new; - typeKeys(p, "/"); - const nid = queryPane2(p, sid).?; - try std.testing.expect(nid != sid); - try std.testing.expect(p.panes[sid].?.attached_to == null); - try std.testing.expectEqual(@as(?usize, 0), layout.ownerOf(p, nid)); } fn queryPane2(p: *Pardes, not: usize) ?usize { diff --git a/src/builtins.zig b/src/builtins.zig index 26d6c770..5b15a968 100644 --- a/src/builtins.zig +++ b/src/builtins.zig @@ -245,7 +245,7 @@ pub const registry = struct { .toggle, .dump_dir, .choice, .shell => false, .theme, .font, .tagline_size, .window_opacity, .window_blur, .message_linger, .inactive_dim, .grip_width => true, // bare, it says the current value (exec.applySettingBuiltin) - .tab, .callstack_depth, .search_rows => false, + .tab, .callstack_depth => false, }; return declOr(b, "requires_arg", false, false); } diff --git a/src/config.zig b/src/config.zig index 3d5de631..6f45adba 100644 --- a/src/config.zig +++ b/src/config.zig @@ -111,9 +111,6 @@ pub const leader_path = paths: { .Newcol = "cn", .Delcol = "cd", .Joincol = "cj", - .SearchPlace = null, - .SearchPane = null, - .SearchRows = null, .Search = null, .Panes = null, .More = null, @@ -745,21 +742,10 @@ pub const Runtime = struct { /// is what the drawing and the column arithmetic read). tab: u16 = tab_width, callstack_depth: u8 = @import("lsp/lsp.zig").callstack_default_depth, - /// Where a query pane goes (Query.zig): `attached`, under the pane that - /// asked, out of its rows alone; `column`, in the finder column. - search_place: SearchPlace = .attached, - /// A search from a pane that has a query pane: `reuse` it (its frozen - /// rows back on Esc), or open a `new` one, the last left where it is. - search_pane: SearchPane = .reuse, - /// The body rows a query pane is born with under its line 1 (and its - /// +Preview with): it never resizes itself after. - search_rows: u16 = 8, pub const JumpScope = enum { file, all }; - pub const SearchPlace = enum { attached, column }; - pub const SearchPane = enum { reuse, new }; /// A setting that is one of a few words, each an enum field of Runtime. - pub const Choice = enum { jump_scope, search_place, search_pane, pet }; + pub const Choice = enum { jump_scope, pet }; pub const Pet = enum { off, cat, frog }; pub const tagline_percent_min: u8 = 1; @@ -846,7 +832,6 @@ pub const Runtime = struct { grip_width, tab, callstack_depth, - search_rows, choice: Choice, }; @@ -904,9 +889,6 @@ pub const Runtime = struct { .{ .word = "JumpScope", .action = .{ .choice = .jump_scope }, .doc = "What Back and Forward keep to: file, the focused pane's file until it runs out that way, or all, every place in order." }, .{ .word = "CallstackDepth", .action = .callstack_depth, .doc = "Caller levels collected by Callstack, 1 through 64; default 8. Bare, it says the current limit." }, .{ .word = "Tab", .action = .tab, .doc = "A tab's width in cells, 1 through 16, in every pane; bare, it says the width." }, - .{ .word = "SearchPlace", .action = .{ .choice = .search_place }, .doc = "Where a query pane goes: attached, under the pane that asked, out of its rows alone, or column, in the finder column." }, - .{ .word = "SearchPane", .action = .{ .choice = .search_pane }, .doc = "A search from a pane that has a query pane: reuse it, or open a new one and leave the last where it is." }, - .{ .word = "SearchRows", .action = .search_rows, .doc = "The rows a query pane is born with under its line 1, 1 through 100; default 8. It never resizes itself." }, }; pub fn find(name: []const u8) ?Setting { @@ -988,7 +970,6 @@ pub const Runtime = struct { .grip_width => state.grip_width = number(u16, argument, " \t\r\n%", 50, 300) orelse return false, .callstack_depth => state.callstack_depth = number(u8, argument, " \t\r\n", 1, @import("lsp/lsp.zig").callstack_max_depth) orelse return false, .tab => state.tab = number(u16, argument, " \t\r\n", 1, 16) orelse return false, - .search_rows => state.search_rows = number(u16, argument, " \t\r\n", 1, 100) orelse return false, .theme, .font => return false, } return true; @@ -1022,7 +1003,6 @@ pub const Runtime = struct { .grip_width => "50-300 (a percentage)", .tab => "1-16 (cells)", .callstack_depth => "1-64 (levels)", - .search_rows => "1-100 (rows)", .tagline_size => std.fmt.comptimePrint("{d}-{d} (a percentage)", .{ tagline_percent_min, tagline_percent_max }), .message_linger => std.fmt.comptimePrint("0-{d} (milliseconds)", .{message_ms_max}), .shell => "a path of at most 255 bytes; bare, $SHELL, else /bin/sh", @@ -1112,7 +1092,7 @@ pub const Runtime = struct { else try out.print("{s} {s}\n", .{ setting.word, context.theme_name }), // A number in a field named as its action. - inline .window_opacity, .window_blur, .inactive_dim, .callstack_depth, .tab, .search_rows, .grip_width => |_, tag| try out.print("{s} {d}\n", .{ setting.word, @field(state, @tagName(tag)) }), + inline .window_opacity, .window_blur, .inactive_dim, .callstack_depth, .tab, .grip_width => |_, tag| try out.print("{s} {d}\n", .{ setting.word, @field(state, @tagName(tag)) }), .dump_dir => { const dir = if (state.dump_dir.len > 0) state.dump_dir.get() else context.default_dump_dir; if (dir.len > 0) try out.print("{s} {s}\n", .{ setting.word, dir }) else try out.print("# {s} (none)\n", .{setting.word}); @@ -1314,9 +1294,9 @@ pub const Runtime = struct { const values = [_][2][]const u8{ .{ "TaglineSize", "73" }, .{ "WindowOpacity", "85" }, .{ "WindowBlur", "40" }, .{ "MessageLinger", "1500" }, .{ "DumpDir", "~/dumps" }, - .{ "JumpScope", "all" }, .{ "SearchPlace", "column" }, .{ "SearchPane", "new" }, + .{ "JumpScope", "all" }, .{ "GripWidth", "200" }, .{ "InactiveDim", "35" }, .{ "CallstackDepth", "16" }, - .{ "Tab", "8" }, .{ "SearchRows", "12" }, + .{ "Tab", "8" }, }; for (values) |v| try std.testing.expect(apply(&state, find(v[0]).?, v[1])); try std.testing.expect(state.font.requested_name.set("Wanted Mono")); diff --git a/src/exec.zig b/src/exec.zig index aaca3e0e..ca79a481 100644 --- a/src/exec.zig +++ b/src/exec.zig @@ -1054,7 +1054,7 @@ pub fn applySettingBuiltin(p: *Pardes, setting: config.Runtime.Setting, arg: ?[] if (!p.settings.apply(setting, want)) p.reportFailure(p.active, "Shell: takes " ++ comptime config.Runtime.takes(.shell).?); }, // Bare, each says its value, as acme's Tab says the width. - inline .tab, .callstack_depth, .search_rows => |_, tag| if (arg == null) { + inline .tab, .callstack_depth => |_, tag| if (arg == null) { var said: [40]u8 = undefined; return p.setMessage(p.active, std.fmt.bufPrint(&said, "{s} {d}", .{ setting.word, @field(p.settings, @tagName(tag)) }) catch setting.word); } else if (!p.settings.apply(setting, arg)) { @@ -1095,14 +1095,6 @@ pub fn placeNew(p: *Pardes, from: usize, origin: ?usize, id: usize, kind: NewPan // No column left (the last one Delcol'd): a pane made from the workspace // tag opens one to go in. _ = layout.firstColumn(p); - // Anything asked from the finder column (a row looked at, a command - // there) goes where its query came from, never into the finder; and - // the rules that take the last column take the last that is not it. - const exec_column = p.exec_column; - defer p.exec_column = exec_column; - const away = p.finder.away(p, from, kind); - if (away) |c| p.exec_column = c; - const finder_column = p.finder.column(p); const asked = if (p.exec_column != null) null else origin; layout.compute(p); const before = p.rects; @@ -1112,10 +1104,9 @@ pub fn placeNew(p: *Pardes, from: usize, origin: ?usize, id: usize, kind: NewPan // (look.c:921-923, et->col). .scratch => layout.acmePlace(p, p.exec_column orelse columnOf(p, from), null, id), // +Errors, a command's output: the last column (util.c:94-98); a - // command run from a column's tag, that column. The finder's is - // never the last column for them. + // command run from a column's tag, that column. .command => layout.acmePlace(p, p.exec_column orelse p.ncol - 1, null, id), - .errors => layout.acmePlace(p, away orelse p.ncol - 1, null, id), + .errors => layout.acmePlace(p, p.ncol - 1, null, id), // makenewwindow(nil) for 9P's new (acme.c:877), else (t). .fs => layout.acmePlace(p, acmeColumn(p, from), null, id), .shell, .doc => layout.acmePlace(p, acmeColumn(p, from), asked, id), @@ -1148,7 +1139,7 @@ pub fn placeNew(p: *Pardes, from: usize, origin: ?usize, id: usize, kind: NewPan var c = p.ncol; while (c > 0) { c -= 1; - if (c == f.col or c == finder_column) continue; + if (c == f.col) continue; for (p.cols[c].panes[0..p.cols[c].n]) |k| p.rects[k] = before[k]; layout.snapColWeights(p, c); if (p.cols[c].n == 0) { diff --git a/src/layout.zig b/src/layout.zig index 38841f59..1515b525 100644 --- a/src/layout.zig +++ b/src/layout.zig @@ -182,11 +182,6 @@ 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)); @@ -468,11 +463,7 @@ pub fn dropColumn(p: *Pardes, c: usize) void { pub fn dropColumnUnannounced(p: *Pardes, c: usize) void { std.debug.assert(p.cols[c].n == 0); tagline.exitHeader(p); - // 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; + const heir: ?usize = if (p.ncol <= 1) null else if (c > 0) c - 1 else c + 1; if (heir) |h| p.cols[h].weight +|= p.cols[c].weight; p.col_tags[c].deinit(p.gpa); var j = c; @@ -703,7 +694,7 @@ pub fn restoreMinimaFrom(p: *Pardes, before: *const [MAX_PANES]Rect, before_min: compute(p); } -/// Whether new column `c` (Newcol's, the finder's) may stay. A narrower +/// Whether new column `c` (Newcol'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 @@ -1237,32 +1228,16 @@ 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; - var last_plain: usize = p.ncol; - for (0..p.ncol) |c| if (finder != c) { - wsum += p.cols[c].weight; - last_plain = c; - }; + for (0..p.ncol) |c| wsum += p.cols[c].weight; 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 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.cols[c].weight; - break :end if (c == last_plain) offset + rest else offset + columnBoundary(rest, prefix, wsum); - }; + const x = columnBoundary(p.screen_w, prefix, wsum); + prefix += p.cols[c].weight; + const end: u16 = if (c == p.ncol - 1) p.screen_w else columnBoundary(p.screen_w, prefix, wsum); const cw = end -| x; p.col_x[c] = x; p.col_w[c] = cw; @@ -1722,12 +1697,7 @@ pub fn columnBarHeight(p: *const Pardes) u16 { pub fn newColumn(p: *Pardes, from_id: usize) void { // An empty window (Delcol took the last column): its first column. if (firstColumn(p)) |c| return tagline.enterHeader(p, c); - const keyboard_col = keyboardColumn(p, from_id) orelse return; - // Asked from the finder: the new column goes left of it, so the - // finder stays at the edge as wide. - const in_finder = p.finder.column(p) == keyboard_col; - const before_finder = in_finder and keyboard_col == 0; - const col = if (in_finder and keyboard_col > 0) keyboard_col - 1 else keyboard_col; + const col = keyboardColumn(p, from_id) orelse return; // A trial: laying it out gives it a serial (layout.compute), which a // refusal takes back. Every other column has its own already, so // the counter as it is now is the trial's to return to. @@ -1736,7 +1706,7 @@ pub fn newColumn(p: *Pardes, from_id: usize) void { const before_min = minima(p); const before = p.rects; // Said, not silently nothing: "no space" is 9ns's word for ENOSPC. - const c = insertColumnUnannounced(p, col, before_finder) orelse { + const c = insertColumnUnannounced(p, col, false) orelse { var said: [96]u8 = undefined; return p.reportFailure(from_id, if (p.ncol >= MAX_COLS) std.fmt.bufPrint(&said, "Newcol: no space for a column: {d} max", .{MAX_COLS}) catch "Newcol: no space for a column" diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig index 3784cf41..81ccd6ea 100644 --- a/src/ninep/ctl.zig +++ b/src/ninep/ctl.zig @@ -558,7 +558,6 @@ fn checkBuiltin(p: *Pardes, req: Req, line: []const u8, scope: builtins.Scope) ? // Bare, it says the width, as from a pane's exec. .tab => arg.len == 0 or (std.fmt.parseInt(u16, arg, 10) catch 0) -% 1 < 16, .callstack_depth => arg.len == 0 or (std.fmt.parseInt(u8, arg, 10) catch 0) -% 1 < pardes.lsp.callstack_max_depth, - .search_rows => arg.len == 0 or (std.fmt.parseInt(u16, arg, 10) catch 0) -% 1 < 100, else => probe: { var probe = p.settings; break :probe probe.apply(setting, if (arg.len > 0) arg else null); diff --git a/src/panes.zig b/src/panes.zig index 2e1e9262..c4a32413 100644 --- a/src/panes.zig +++ b/src/panes.zig @@ -1035,15 +1035,13 @@ pub fn removePane(p: *Pardes, id: usize, to: ?usize) error{OutOfMemory}!void { layout.removePane(p, id); p.panes[id] = null; if (kept) |k| p.store.close(p, k, gainer); - // The finder's last pane takes the column with it. - const finder_gone = if (emptied) |c| p.finder.emptied(p, c) else false; if (p.active != id) return; // No pane left: the session is over. p.active = gainer orelse beside orelse anyPane(p) orelse { p.quit = true; return p.emit(.quit); }; - if (emptied) |c| if (!finder_gone and p.header == null) tagline.enterHeader(p, c); + if (emptied) |c| if (p.header == null) tagline.enterHeader(p, c); } /// The pane Last should fall back to when the jumplist has nothing: the diff --git a/src/pardes.zig b/src/pardes.zig index 22f4b7de..05dc42ef 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -29,7 +29,6 @@ pub const Registers = @import("Registers.zig"); pub const Macro = @import("Macro.zig"); pub const Pipe = @import("Pipe.zig"); pub const Stream = @import("Stream.zig"); -pub const Finder = @import("Finder.zig"); pub const Handover = @import("Handover.zig"); pub const colors = @import("colors.zig"); pub const Theme = colors.Theme; @@ -307,7 +306,6 @@ test { _ = @import("Query.zig"); _ = @import("Names.zig"); _ = @import("Stream.zig"); - _ = @import("Finder.zig"); _ = @import("Tables.zig"); _ = @import("Handover.zig"); _ = @import("walk.zig"); diff --git a/src/views.zig b/src/views.zig index d598e2fc..169bef63 100644 --- a/src/views.zig +++ b/src/views.zig @@ -33,7 +33,7 @@ pub const max = 4; /// what drawing it keeps (its frame and its timings). pub const fields = [_][:0]const u8{ "screen_w", "screen_h", "cell_pixels", "row_metrics", - "ncol", "cols", "col_tags", "finder", "rects", + "ncol", "cols", "col_tags", "rects", "col_x", "col_w", "active", "jumps", "active_column", @@ -451,7 +451,7 @@ pub fn open(p: *Pardes) ?u8 { /// How a view is laid out and focused: what a new one takes of the live /// one (`open`), and what one going leaves the view that stays (`closeKeeping`). -const laid_out = .{ "ncol", "cols", "finder", "active", "active_column", "jumps" }; +const laid_out = .{ "ncol", "cols", "active", "active_column", "jumps" }; const sized = .{ "screen_w", "screen_h", "cell_pixels", "row_metrics" }; /// View `k` gone, and the view that stays live laid out as `k` was: its -- cgit v1.3