diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-05 22:27:44 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-05 23:58:31 -0300 |
| commit | f930d53c58187381b2f0df6892546ac1c217c9db (patch) | |
| tree | 5ca1eea4698b3c14178d2b1ae5d0251c0b884543 /src | |
| parent | 71e5a0f4a8685b385fac762995d45575b638179f (diff) | |
| download | pardes-f930d53c58187381b2f0df6892546ac1c217c9db.tar.gz pardes-f930d53c58187381b2f0df6892546ac1c217c9db.zip | |
settings #1, Tagbottom goes, a pane's tag at its head the one value anyone used: layout.bodyTop and tagTop, mouse's seam and clampBorderRow, applyRowSplit, body_layer's copy and the tests' row arithmetic lose their other arm (reads deleted in Core.zig, layout.zig, mouse.zig, draw.zig, gui.zig, macos.zig, whose ABI slot 11 says 0 now, and ninep/events.zig, ninep/tree.zig, look.zig, Messages.zig), with the registry row, SPC t b, Help, /commands, the builtins JSON and the reference row; deleted: the snapshot scripts tagbottom, tagbottomshort and tagbottomimage with their goldens, the behaviour test "placement: under Tagbottom a look from a pane's text goes under its text too", the window scene 10-tagbottom with its gui-goldens line and the macOS parity check tags-bottom; tests that ran both ends of the tag run the head; a dump that kept the field loads without it; perf.zig's harness id moves in the two debug baselines (its reads of the field went); the window scenes after 10-tagbottom (12 to 15, 17) take new gui-goldens lines, the two Tagbottom writes gone from the scene and with them their words on the message row (the base window build running the same scenes gives the same frames); gates on tui: core-test 966/966, behaviour-test 243/243, unit-test 1484/1485, pane-test 171/172, snap all 105 scripts ok, process-test 0 of 37 failed; gui unit-test 1529/1530, gui-golden 0 of 1 failed
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src')
| -rw-r--r-- | src/CHANGELOG.md | 5 | ||||
| -rw-r--r-- | src/Core.zig | 55 | ||||
| -rw-r--r-- | src/File.zig | 2 | ||||
| -rw-r--r-- | src/Layer.zig | 4 | ||||
| -rw-r--r-- | src/Messages.zig | 2 | ||||
| -rw-r--r-- | src/body_layer.zig | 7 | ||||
| -rw-r--r-- | src/config.zig | 5 | ||||
| -rw-r--r-- | src/draw.zig | 97 | ||||
| -rw-r--r-- | src/gui/gui.zig | 10 | ||||
| -rw-r--r-- | src/layout.zig | 52 | ||||
| -rw-r--r-- | src/look.zig | 4 | ||||
| -rw-r--r-- | src/macos.zig | 8 | ||||
| -rw-r--r-- | src/mouse.zig | 34 | ||||
| -rw-r--r-- | src/ninep/events.zig | 2 | ||||
| -rw-r--r-- | src/ninep/tree.zig | 2 |
15 files changed, 129 insertions, 160 deletions
diff --git a/src/CHANGELOG.md b/src/CHANGELOG.md index 08b86064..ee968587 100644 --- a/src/CHANGELOG.md +++ b/src/CHANGELOG.md @@ -2,6 +2,11 @@ ## Unreleased +- Half the settings are gone, each one now the value it had by default, + its word refused as any unknown one is (an init file that still says it + gets a notice naming its line), and a dump that kept it loads as before: + - Tagbottom: a pane's tag is at its head (`SPC t b` with it). + - 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 the DumpDir (`$XDG_DATA_HOME/pardes`, else `~/.local/share/pardes`), diff --git a/src/Core.zig b/src/Core.zig index eb3f0562..38493b93 100644 --- a/src/Core.zig +++ b/src/Core.zig @@ -3682,7 +3682,7 @@ test "raw terminal cursor obeys visibility without hiding modal and tag cursors" defer frame.deinit(); const visible = (try p.render(frame.allocator())).cursor orelse return error.MissingCursor; const rect = p.rects[0]; - const body_y = if (p.settings.tag_bottom) rect.y else rect.y + BOX_H; + const body_y = rect.y + BOX_H; try std.testing.expectEqual(rect.x + config.GUTTER + 3, visible.x); try std.testing.expectEqual(body_y, visible.y); @@ -3697,7 +3697,7 @@ test "raw terminal cursor obeys visibility without hiding modal and tag cursors" try std.testing.expectEqual(body_y, modal_cursor.y); tagline.enterTag(p, pane); const tag_cursor = (try p.render(frame.allocator())).cursor orelse return error.MissingCursor; - try std.testing.expectEqual(if (p.settings.tag_bottom) rect.y + rect.h - BOX_H else rect.y, tag_cursor.y); + try std.testing.expectEqual(rect.y, tag_cursor.y); pane.focus = .body; pane.body.mode = .tty; try std.testing.expect((try p.render(frame.allocator())).cursor == null); @@ -3716,34 +3716,31 @@ test "raw terminal cursor obeys visibility without hiding modal and tag cursors" test "raw terminal cursor follows its active row only while that row is visible" { const gpa = std.testing.allocator; - for ([_]bool{ false, true }) |tag_bottom| { - const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 40, .rows = 12 }); - defer p.deinit(); - while (p.nextEffect()) |_| {} - p.settings.tag_bottom = tag_bottom; - const pane = p.panes[0].?; - pane.body.mode = .tty; - for (0..60) |_| p.update(.{ .output = .{ .pane = 0, .bytes = "row\r\n" } }); - p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b[3;4H" } }); - var frame = std.heap.ArenaAllocator.init(gpa); - defer frame.deinit(); - const live = (try p.render(frame.allocator())).cursor orelse return error.MissingCursor; - const rect = p.rects[0]; - const body_y = if (tag_bottom) rect.y else rect.y + BOX_H; - try std.testing.expectEqual(rect.x + config.GUTTER + 3, live.x); - try std.testing.expectEqual(body_y + 2, live.y); + const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 40, .rows = 12 }); + defer p.deinit(); + while (p.nextEffect()) |_| {} + const pane = p.panes[0].?; + pane.body.mode = .tty; + for (0..60) |_| p.update(.{ .output = .{ .pane = 0, .bytes = "row\r\n" } }); + p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b[3;4H" } }); + var frame = std.heap.ArenaAllocator.init(gpa); + defer frame.deinit(); + const live = (try p.render(frame.allocator())).cursor orelse return error.MissingCursor; + const rect = p.rects[0]; + const body_y = rect.y + BOX_H; + try std.testing.expectEqual(rect.x + config.GUTTER + 3, live.x); + try std.testing.expectEqual(body_y + 2, live.y); - pardes.panes.terminal.scrollGrid(pane, -1); - const scrolled = (try p.render(frame.allocator())).cursor orelse return error.MissingCursor; - try std.testing.expectEqual(live.x, scrolled.x); - try std.testing.expectEqual(live.y + 1, scrolled.y); - pardes.panes.terminal.scrollGrid(pane, -@as(i32, pane.rows)); - try std.testing.expect((try p.render(frame.allocator())).cursor == null); - pardes.panes.terminal.followOutput(pane); - const returned = (try p.render(frame.allocator())).cursor orelse return error.MissingCursor; - try std.testing.expectEqual(live.x, returned.x); - try std.testing.expectEqual(live.y, returned.y); - } + pardes.panes.terminal.scrollGrid(pane, -1); + const scrolled = (try p.render(frame.allocator())).cursor orelse return error.MissingCursor; + try std.testing.expectEqual(live.x, scrolled.x); + try std.testing.expectEqual(live.y + 1, scrolled.y); + pardes.panes.terminal.scrollGrid(pane, -@as(i32, pane.rows)); + try std.testing.expect((try p.render(frame.allocator())).cursor == null); + pardes.panes.terminal.followOutput(pane); + const returned = (try p.render(frame.allocator())).cursor orelse return error.MissingCursor; + try std.testing.expectEqual(live.x, returned.x); + try std.testing.expectEqual(live.y, returned.y); } test "the bare tty startup opens a text pane under the shell, unfocused" { diff --git a/src/File.zig b/src/File.zig index 05d02673..5b3c6bb7 100644 --- a/src/File.zig +++ b/src/File.zig @@ -1933,7 +1933,7 @@ pub fn drawGutter(p: *Pardes, s: *Surface, pane: *Pane, r: pardes.Rect, tx: u16, const gcrow = if (pane.body.cur_pinned) pane.body.cur_row else @as(i32, gcur.y) + goff; const typing_body = pane.focus == .body and (pane.prompt == .none or pane.prompt == .del_side or pane.prompt == .repl_choice); const cur_line: i32 = if (active and typing_body) gcrow else std.math.minInt(i32); - // the body's first row, the way renderPane derives it (Tagbottom) + // the body's first row, the way renderPane derives it const body_y = p.bodyTop(pane, r); const context_bg = p.theme().tag_bg; for (0..@min(pane.context_rows, body_h)) |context_row| { diff --git a/src/Layer.zig b/src/Layer.zig index deca3466..aa346413 100644 --- a/src/Layer.zig +++ b/src/Layer.zig @@ -276,7 +276,7 @@ pub fn taglineBandOffset(row: u16, canvas_h: f32, cell_h: u32, tagline_h: u32) u const rows: u32 = @max(1, @as(u32, @intFromFloat(@floor(canvas_h / @as(f32, @floatFromInt(cell_h)))))); // Every band centers in its cell, so text and anchors sit at the same // height in the workspace, column and pane tags alike. Only the last row - // faces the window edge (Tagbottom). + // faces the window edge. if (@as(u32, row) + 1 >= rows) return spare; return spare / 2; } @@ -286,7 +286,7 @@ pub fn topbarPaneBorderPixels(cell_h: u32, tagline_h: u32) u32 { return @min(@as(u32, config.gui_topbar_pane_border_px), spare * 2); } -test "tagline bands center in their cells and Tagbottom faces the window edge" { +test "tagline bands center in their cells and the last row faces the window edge" { const cell_h: u32 = 20; const tagline_h: u32 = 16; const canvas_h: f32 = 200; diff --git a/src/Messages.zig b/src/Messages.zig index 8eb18f1d..66beb6bc 100644 --- a/src/Messages.zig +++ b/src/Messages.zig @@ -803,7 +803,7 @@ test "a builtin announces itself on the message row, and Verbose silences it" { if (layer.rows != 0 and layer.kind == .notice) break layer; } else return error.NoNoticeBand; try std.testing.expectEqual(@as(u16, 1), band.viewport.h); - try std.testing.expectEqual(if (p.settings.tag_bottom) r.y else r.y + BOX_H, band.viewport.y); + try std.testing.expectEqual(r.y + BOX_H, band.viewport.y); // Right aligned: the text ends at the band's right edge. const line = band.cells[0..band.cols]; var last: usize = line.len; diff --git a/src/body_layer.zig b/src/body_layer.zig index 2fc1454c..b8336b7b 100644 --- a/src/body_layer.zig +++ b/src/body_layer.zig @@ -188,9 +188,8 @@ pub fn joinBody(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, var temporary: Surface = .{ .cols = r.w, .rows = @intCast(logical_rows + pane.tag_rows), .cells = temporary_cells }; const synthetic: Rect = .{ .x = 0, .y = 0, .w = r.w, .h = @intCast(logical_rows + pane.tag_rows) }; try renderBody(p, &temporary, arena, pane, synthetic, id, active, null); - const first_row: usize = if (p.settings.tag_bottom) 0 else pane.tag_rows; for (0..logical_rows) |row| { - const start = (row + first_row) * r.w + config.GUTTER; + const start = (row + pane.tag_rows) * r.w + config.GUTTER; @memcpy(layer.cells[row * width ..][0..width], temporary_cells[start..][0..width]); } layer.kind = .body; @@ -204,8 +203,8 @@ pub fn joinBody(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, layer.setContextLines(pane.wrap_line[0..pane.context_rows]); layer.cursor = null; if (temporary.cursor) |cursor| { - if (cursor.x >= config.GUTTER and cursor.y >= first_row) - layer.cursor = .{ .x = cursor.x - config.GUTTER, .y = @intCast(cursor.y - first_row), .bar = cursor.bar }; + if (cursor.x >= config.GUTTER and cursor.y >= pane.tag_rows) + layer.cursor = .{ .x = cursor.x - config.GUTTER, .y = @intCast(cursor.y - pane.tag_rows), .bar = cursor.bar }; } // The grid: the layer's first rows, as many as the body has, each a // body row high; its caret where one of them has it. (pane.rows is the diff --git a/src/config.zig b/src/config.zig index 1c4e92a1..bea5dbbf 100644 --- a/src/config.zig +++ b/src/config.zig @@ -129,7 +129,6 @@ pub const leader_path = paths: { .Verbose = null, .TreeContextTagStyle = null, .Wrap = "tw", - .Tagbottom = "tb", .NextColor = "tn", .Themes = "tt", .Theme = null, @@ -690,7 +689,6 @@ pub const Runtime = struct { theme: usize = 0, colors: bool = true, wrap: bool = true, - tag_bottom: bool = false, tree_context_tag_style: bool = true, debug: bool = false, focus_tint: bool = true, @@ -861,7 +859,7 @@ pub const Runtime = struct { pub const Capability = std.meta.FieldEnum(Capabilities); - pub const Toggle = enum { colors, wrap, tree_context_tag_style, tag_bottom, debug, focus_tint, syntax_bold, pager_color, verbose, ligatures, cursor_blink, jump_trail, program_esc }; + pub const Toggle = enum { colors, wrap, tree_context_tag_style, debug, focus_tint, syntax_bold, pager_color, verbose, ligatures, cursor_blink, jump_trail, program_esc }; pub const Action = union(enum) { toggle: Toggle, @@ -920,7 +918,6 @@ pub const Runtime = struct { .{ .word = "Colors", .action = .{ .toggle = .colors }, .doc = "Syntax colours in text panes, on or off." }, .{ .word = "Wrap", .action = .{ .toggle = .wrap }, .doc = "Long lines wrap onto the next row, on or off." }, .{ .word = "TreeContextTagStyle", .action = .{ .toggle = .tree_context_tag_style }, .doc = "A pane's TreeContext rows draw in the tag's style, on or off." }, - .{ .word = "Tagbottom", .action = .{ .toggle = .tag_bottom }, .doc = "Each pane's tag goes at its foot rather than its head, on or off." }, .{ .word = "Debug", .action = .{ .toggle = .debug }, .doc = "A small box of frame statistics at the top right, on or off." }, .{ .word = "FocusTint", .action = .{ .toggle = .focus_tint }, .doc = "The focused pane's and column's tags are tinted, on or off." }, .{ .word = "SyntaxBold", .action = .{ .toggle = .syntax_bold }, .doc = "Keywords and the like are drawn bold, on or off." }, diff --git a/src/draw.zig b/src/draw.zig index ac13fc7d..ce5f86c1 100644 --- a/src/draw.zig +++ b/src/draw.zig @@ -1040,27 +1040,24 @@ test "a tag of three rows has its grip on the first, and band under it that stil pane.tag.own = try std.testing.allocator.dupe(u8, "Second\nthird\nfourth"); var arena: std.heap.ArenaAllocator = .init(std.testing.allocator); defer arena.deinit(); - for ([_]bool{ false, true }) |bottom| { - p.settings.tag_bottom = bottom; - p.sync(); - _ = arena.reset(.retain_capacity); - const s = try p.render(arena.allocator()); - const r = p.rects[0]; - const top = p.tagTop(pane, r); - try std.testing.expect(pane.tag_rows >= 3); - const chrome = p.chromeTheme(); - const band = if (p.settings.focus_tint) chrome.tag_active_bg else chrome.tag_bg; - for (0..config.GUTTER) |dx| { - const x = r.x + @as(u16, @intCast(dx)); - try std.testing.expectEqual(Color{ .rgb = chrome.box }, s.at(x, top).style.bg); - for (1..pane.tag_rows) |line| { - const cell = s.at(x, top + @as(u16, @intCast(line))); - try std.testing.expectEqual(Color{ .rgb = band }, cell.style.bg); - try std.testing.expectEqualStrings(" ", cell.grapheme()); - } + p.sync(); + _ = arena.reset(.retain_capacity); + const s = try p.render(arena.allocator()); + const r = p.rects[0]; + const top = p.tagTop(pane, r); + try std.testing.expect(pane.tag_rows >= 3); + const chrome = p.chromeTheme(); + const band = if (p.settings.focus_tint) chrome.tag_active_bg else chrome.tag_bg; + for (0..config.GUTTER) |dx| { + const x = r.x + @as(u16, @intCast(dx)); + try std.testing.expectEqual(Color{ .rgb = chrome.box }, s.at(x, top).style.bg); + for (1..pane.tag_rows) |line| { + const cell = s.at(x, top + @as(u16, @intCast(line))); + try std.testing.expectEqual(Color{ .rgb = band }, cell.style.bg); + try std.testing.expectEqualStrings(" ", cell.grapheme()); } - try std.testing.expectEqual(pane.tag_rows, s.region(.grip, 0).?.rect.h); } + try std.testing.expectEqual(pane.tag_rows, s.region(.grip, 0).?.rect.h); } test "place puts every part where the painters and layers put it, in every layout" { @@ -1074,7 +1071,6 @@ test "place puts every part where the painters and layers put it, in every layou var arena: std.heap.ArenaAllocator = .init(std.testing.allocator); defer arena.deinit(); for (0..16) |step| { - p.settings.tag_bottom = step & 1 != 0; if (step & 4 != 0) try std.testing.expect(p.executeBuiltinLine(p.active, "Msg a placed notice")); if (step == 8) try std.testing.expect(p.executeBuiltinLine(1, "Collapse")); if (step == 12) try std.testing.expect(p.executeBuiltinLine(1, "Collapse")); @@ -1214,7 +1210,7 @@ test "a monkey over notices, prompts, tags and tiny panes at a gui's metrics nev var arena: std.heap.ArenaAllocator = .init(std.testing.allocator); defer arena.deinit(); const words = [_][]const u8{ "error:", "\u{754c}", "x", "Shader /tmp/a.glsl:", "e\u{301}", "\t", std.mem.asBytes(&@as([20][5]u8, @splat("long-".*))), " " }; - const commands = [_][]const u8{ "New", "Newcol", "Collapse", "Tagbottom", "TreeContext", "Wrap", "Find", "Del", "FocusTint", "Debug" }; + const commands = [_][]const u8{ "New", "Newcol", "Collapse", "TreeContext", "Wrap", "Find", "Del", "Debug" }; var text: std.ArrayListUnmanaged(u8) = .empty; defer text.deinit(std.testing.allocator); for (0..steps) |_| { @@ -1318,38 +1314,35 @@ test "a body with context rows is painted once, and the grid's rows are what a p pane.file.?.scroll = 8; var arena: std.heap.ArenaAllocator = .init(std.testing.allocator); defer arena.deinit(); - for ([_]bool{ false, true }) |bottom| { - p.settings.tag_bottom = bottom; - // A selection and the cursor on body rows, painted in the one pass. - pane.body.cur_row = 12; - pane.body.cur_col = 3; - pane.body.vsel = .{ .active = true, .row = 10, .col = 2 }; - pane.body.mode = .normal; - p.sync(); - _ = arena.reset(.retain_capacity); - const s = try p.render(arena.allocator()); - const layer = &s.body_layers[0]; - try std.testing.expect(layer.context_rows > 0); - const body = s.region(.body, 0).?; - // The plain paint the grid used to take, of the same frame. - const cells = try arena.allocator().alloc(Cell, s.cells.len); - @memset(cells, .{}); - var plain: Surface = .{ .cols = s.cols, .rows = s.rows, .cells = cells }; - pane.view.layered = false; - try body_layer.renderBody(p, &plain, arena.allocator(), pane, p.rects[0], 0, true, null); - pane.view.layered = true; - for (0..body.rect.h) |row| { - const y = body.rect.y + row; - for (0..body.rect.w) |col| { - const x = body.rect.x + col; - const got = s.cells[y * s.cols + x]; - const want = plain.cells[y * s.cols + x]; - try std.testing.expect(got.visuallyEqual(&want)); - } + // A selection and the cursor on body rows, painted in the one pass. + pane.body.cur_row = 12; + pane.body.cur_col = 3; + pane.body.vsel = .{ .active = true, .row = 10, .col = 2 }; + pane.body.mode = .normal; + p.sync(); + _ = arena.reset(.retain_capacity); + const s = try p.render(arena.allocator()); + const layer = &s.body_layers[0]; + try std.testing.expect(layer.context_rows > 0); + const body = s.region(.body, 0).?; + // The plain paint the grid used to take, of the same frame. + const cells = try arena.allocator().alloc(Cell, s.cells.len); + @memset(cells, .{}); + var plain: Surface = .{ .cols = s.cols, .rows = s.rows, .cells = cells }; + pane.view.layered = false; + try body_layer.renderBody(p, &plain, arena.allocator(), pane, p.rects[0], 0, true, null); + pane.view.layered = true; + for (0..body.rect.h) |row| { + const y = body.rect.y + row; + for (0..body.rect.w) |col| { + const x = body.rect.x + col; + const got = s.cells[y * s.cols + x]; + const want = plain.cells[y * s.cols + x]; + try std.testing.expect(got.visuallyEqual(&want)); } - try std.testing.expectEqual(plain.cursor, s.cursor); - // The layer's own rows run past the grid's. - try std.testing.expect(layer.rows > body.rect.h); } + try std.testing.expectEqual(plain.cursor, s.cursor); + // The layer's own rows run past the grid's. + try std.testing.expect(layer.rows > body.rect.h); } diff --git a/src/gui/gui.zig b/src/gui/gui.zig index f9b757f8..7c042703 100644 --- a/src/gui/gui.zig +++ b/src/gui/gui.zig @@ -1018,7 +1018,7 @@ const Gui = struct { scroll_pane: ?usize = null, scroll_rect: pardes.Rect = .{ .x = 0, .y = 0, .w = 0, .h = 0 }, - scroll_body_y: u16 = 0, // that rect's first BODY row (Tagbottom moves it) + scroll_body_y: u16 = 0, // that rect's first BODY row scroll_body_h: u16 = 0, // and its BODY rows, which a taller tag leaves fewer of scroll_held_px: f32 = 0, // its tree-sitter context band, which never moves scroll_col: u16 = 0, // where the wheel turned: crossed rows are delivered @@ -5801,7 +5801,6 @@ test "the layer cover is the per-cell layer scan, over a core's layouts and rand var cover: [97 * 31]Cover = undefined; var notices = false; for (0..32) |step| { - core.settings.tag_bottom = step & 1 != 0; if (step & 3 == 0) try std.testing.expect(core.executeBuiltinLine(2, "Collapse")); core.prefix = if (step & 4 != 0) .leader else .none; if (step & 8 != 0) { @@ -6141,8 +6140,7 @@ test "every pixel of a grip column is band, button or ring, and the button sits const pane = try core.setTestFile(std.mem.asBytes(&@as([60][5]u8, @splat("text\n".*)))); pane.tag.own = try gpa.dupe(u8, "second\nthird"); core.newScratchBelow(0); - for ([_]struct { w: u32, h: u32, tag: u32 }{ .{ .w = 10, .h = 20, .tag = 12 }, .{ .w = 17, .h = 35, .tag = 30 }, .{ .w = 9, .h = 19, .tag = 15 }, .{ .w = 12, .h = 24, .tag = 24 } }) |m| for ([_]bool{ false, true }) |bottom| for ([_]usize{ 0, 1 }) |focus| for ([_]bool{ false, true }) |dirty| { - core.settings.tag_bottom = bottom; + for ([_]struct { w: u32, h: u32, tag: u32 }{ .{ .w = 10, .h = 20, .tag = 12 }, .{ .w = 17, .h = 35, .tag = 30 }, .{ .w = 9, .h = 19, .tag = 15 }, .{ .w = 12, .h = 24, .tag = 24 } }) |m| for ([_]usize{ 0, 1 }) |focus| for ([_]bool{ false, true }) |dirty| { core.active = focus; pane.file.?.revision = pane.file.?.saved_revision + @intFromBool(dirty); core.sync(); @@ -6208,11 +6206,11 @@ test "every pixel of a grip column is band, button or ring, and the button sits // Under the first row there is no button: band and rules only. if (n / w_px >= m.h and n / w_px < h_px - 1 and !std.meta.eql(got, rgb(band)) and !std.meta.eql(got, rgb(chrome.border))) return error.TestButtonUnderFirstRow; - if (!known) std.debug.print("sliver {any} at {d},{d} of {d}x{d} (metrics {d}x{d}/{d}, bottom {}, focus {d}, dirty {}) page {any}\n", .{ got, n % w_px, n / w_px, w_px, h_px, m.w, m.h, m.tag, bottom, focus, dirty, s.chrome.page }); + if (!known) std.debug.print("sliver {any} at {d},{d} of {d}x{d} (metrics {d}x{d}/{d}, focus {d}, dirty {}) page {any}\n", .{ got, n % w_px, n / w_px, w_px, h_px, m.w, m.h, m.tag, focus, dirty, s.chrome.page }); try std.testing.expect(known); } // The rule under the tag runs unbroken across the grip column. - if (!bottom) for (pixels[(h_px - 1) * w_px ..][0..w_px]) |pixel| + for (pixels[(h_px - 1) * w_px ..][0..w_px]) |pixel| try std.testing.expectEqual(rgb(chrome.tag_rule orelse mixRgb(chrome.tag_bg, chrome.page orelse bg_default)), pixel.?); // The button's edges are the scrollbar's. const button = gripButton(&g, chrome, grip.rect.x, grip.rect.y, layout); diff --git a/src/layout.zig b/src/layout.zig index 10bed438..38841f59 100644 --- a/src/layout.zig +++ b/src/layout.zig @@ -407,7 +407,7 @@ pub fn applyRowSplit(p: *Pardes, cc: usize, k: usize, cur_y: u16) void { const ra = p.rects[p.cols[cc].panes[k]]; const rb = p.rects[p.cols[cc].panes[k + 1]]; const combined: f32 = @floatFromInt(ra.h + rb.h); - var nt: f32 = @floatFromInt(if (p.settings.tag_bottom) cur_y -| ra.y else (cur_y + 1) -| ra.y); + var nt: f32 = @floatFromInt((cur_y + 1) -| ra.y); // A terminal keeps its tag and two body rows (floorRows); a text pane // gives up all but its tag, as acme's do. const lo: f32 = @floatFromInt(@max(BOX_H, floorRows(p, p.cols[cc].panes[k]))); @@ -828,9 +828,7 @@ fn splitAt(p: *Pardes, c: usize, id: usize, y: u16) void { } /// A pane's top plus its tag's rows, as heights go: a split this far down -/// leaves the pane its tag and that much of its body, whichever end the tag -/// is on (Tagbottom's is at its foot, the height the same; behaviour test -/// "placement: under Tagbottom..."). +/// leaves the pane its tag and that much of its body. fn bodyFrom(p: *const Pardes, id: usize) u16 { return p.rects[id].y + p.panes[id].?.tag_rows; } @@ -1429,7 +1427,6 @@ test "collapse local transfers remain bounded through repeated tiny window resiz } for (0..180) |step| { p.screen_h = @intCast((step * 17) % 81); - p.settings.tag_bottom = step % 3 == 0; compute(p); toggleCollapse(p, step % 5); var used: u16 = 0; @@ -1484,7 +1481,7 @@ test "collapse single and all panes leave unused column space" { try std.testing.expectEqual(p.screen_h - 1, p.rects[1].y); } -test "collapse survives tiny resizes and TagBottom" { +test "collapse survives tiny resizes" { const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 32 }); defer p.deinit(); _ = try p.newShell(1, ""); @@ -1492,22 +1489,17 @@ test "collapse survives tiny resizes and TagBottom" { insert(p, 0, 1, 1); insert(p, 0, 2, 2); p.panes[1].?.collapsed = true; - for ([_]bool{ false, true }) |bottom| { - p.settings.tag_bottom = bottom; - { - for (0..50) |height| { - p.screen_h = @intCast(height); - compute(p); - var used: u16 = 0; - for (p.cols[0].panes[0..p.cols[0].n]) |id| { - const rect = p.rects[id]; - try std.testing.expect(rect.h <= p.screen_h -| rect.y); - used += rect.h; - } - try std.testing.expect(used <= p.screen_h); - if (height >= 5) try std.testing.expectEqual(@as(u16, 1), p.rects[1].h); - } + for (0..50) |height| { + p.screen_h = @intCast(height); + compute(p); + var used: u16 = 0; + for (p.cols[0].panes[0..p.cols[0].n]) |id| { + const rect = p.rects[id]; + try std.testing.expect(rect.h <= p.screen_h -| rect.y); + used += rect.h; } + try std.testing.expect(used <= p.screen_h); + if (height >= 5) try std.testing.expectEqual(@as(u16, 1), p.rects[1].h); } p.screen_h = 32; compute(p); @@ -1525,8 +1517,7 @@ test "collapse can be expanded by dragging its boundary" { try std.testing.expect(!p.panes[0].?.collapsed); try std.testing.expectEqual(@as(u16, 6), p.rects[0].h); toggleCollapse(p, 1); - p.settings.tag_bottom = true; - applyRowSplit(p, 0, 0, p.rects[1].y - 5); + applyRowSplit(p, 0, 0, p.rects[1].y - 6); compute(p); try std.testing.expect(!p.panes[1].?.collapsed); try std.testing.expectEqual(@as(u16, 6), p.rects[1].h); @@ -1849,16 +1840,15 @@ pub fn wantedTagRows(p: *Pardes, id: usize) u16 { return @intCast(@max(BOX_H, @min(shown.rows(), MAX_TAG_ROWS))); } -/// The pane's first body row: under the tag when it is on top, over it -/// when it is at the bottom. Notice bands do NOT move it -- they are an -/// overlay, drawn over the top rows rather than taking them. -pub fn bodyTop(p: *const Pardes, pane: *const Pane, r: Rect) u16 { - return if (p.settings.tag_bottom) r.y else r.y + pane.tag_rows; +/// The pane's first body row, under its tag. Notice bands do NOT move it +/// -- they are an overlay, drawn over the top rows rather than taking them. +pub fn bodyTop(_: *const Pardes, pane: *const Pane, r: Rect) u16 { + return r.y + pane.tag_rows; } -/// The tag's first row: the pane's top, or its last rows with Tagbottom. -pub fn tagTop(p: *const Pardes, pane: *const Pane, r: Rect) u16 { - return if (p.settings.tag_bottom) r.y + r.h -| pane.tag_rows else r.y; +/// The tag's first row: the pane's top. +pub fn tagTop(_: *const Pardes, _: *const Pane, r: Rect) u16 { + return r.y; } pub fn tagCapacity(p: *const Pardes, physical_width: u16) u16 { diff --git a/src/look.zig b/src/look.zig index 7df48c5a..ab1407ee 100644 --- a/src/look.zig +++ b/src/look.zig @@ -1924,7 +1924,7 @@ test "Look hover waits without mutating the pane and input cancels it" { _ = try p.render(frame.allocator()); const rect = p.rects[p.active]; const word_x = rect.x + config.GUTTER + config.PREFIX_W + 7; - const body_y = if (p.settings.tag_bottom) rect.y else rect.y + BOX_H; + const body_y = rect.y + BOX_H; const motion = Event{ .mouse = .{ .button = .none, .kind = .motion, .col = word_x, .row = body_y } }; const selections_before = pane.sel; @@ -1987,7 +1987,7 @@ test "Look hover waits without mutating the pane and input cancels it" { // first character must be paintable all the way at tag column zero — which // is TAG_TEXT_INSET, not GUTTER: the grip keeps the gutter and the gap // beside it separates the grip's hit area from the text. - const tag_y = if (p.settings.tag_bottom) rect.y + rect.h - BOX_H else rect.y; + const tag_y = rect.y; p.look_hover_preview = .{ .col = rect.x + TAG_TEXT_INSET, .row = tag_y, diff --git a/src/macos.zig b/src/macos.zig index 0d79f96b..13b8b332 100644 --- a/src/macos.zig +++ b/src/macos.zig @@ -1923,7 +1923,8 @@ export fn pardes_tag_layer_value(index: u32, field: u32) u32 { 8 => if (layer.cursor) |c| c.x else 65535, 9 => if (layer.cursor) |c| @intFromBool(c.bar) else 0, 10 => @as(u32, layer.bg[0]) << 16 | @as(u32, layer.bg[1]) << 8 | layer.bg[2], - 11 => @intFromBool(layer.kind == .pane and st.core.settings.tag_bottom), + // A tag at its pane's foot: there is no Tagbottom now. + 11 => 0, 12 => rgb: { const border = st.core.chromeTheme().border; break :rgb @as(u32, border[0]) << 16 | @as(u32, border[1]) << 8 | border[2]; @@ -2849,11 +2850,6 @@ test "mac tag layer ABI preserves logical capacity and physical grip" { try std.testing.expectEqual(@as(u32, 12), pardes_tag_layer_value(0, 0)); try std.testing.expectEqual(@as(u32, 0x123456), pardes_tag_layer_value(0, 10)); try std.testing.expectEqual(@as(u32, 0), pardes_tag_layer_value(0, 11)); - core.settings.tag_bottom = true; - try std.testing.expectEqual(@as(u32, 1), pardes_tag_layer_value(0, 11)); - core.surface.tag_layers[0].kind = .column; - try std.testing.expectEqual(@as(u32, 0), pardes_tag_layer_value(0, 11)); - core.surface.tag_layers[0].kind = .pane; const border = core.chromeTheme().border; const border_rgb = @as(u32, border[0]) << 16 | @as(u32, border[1]) << 8 | border[2]; try std.testing.expectEqual(border_rgb, pardes_tag_layer_value(0, 12)); diff --git a/src/mouse.zig b/src/mouse.zig index 02f966bd..7905735c 100644 --- a/src/mouse.zig +++ b/src/mouse.zig @@ -154,16 +154,15 @@ fn clampBorderCol(lx: u16, lw: u16, rw: u16, mcol: u16) u16 { return if (lo <= hi) std.math.clamp(mcol, lo, hi) else mcol; } -fn clampBorderRow(ay: u16, ah: u16, bh: u16, mrow: u16, tag_bottom: bool) u16 { - const d: u16 = if (tag_bottom) 1 else 0; - const lo = ay + BOX_H - 1 + d; - const hi = (ay +| ah +| bh -| (BOX_H + 1)) +| d; +fn clampBorderRow(ay: u16, ah: u16, bh: u16, mrow: u16) u16 { + const lo = ay + BOX_H - 1; + const hi = ay +| ah +| bh -| (BOX_H + 1); return if (lo <= hi) std.math.clamp(mrow, lo, hi) else mrow; } fn seamRowOf(p: *const Pardes, c: usize, k: usize) u16 { const r = p.rects[p.cols[c].panes[k]]; - return if (p.settings.tag_bottom) r.y +| r.h else r.y + r.h -| 1; + return r.y + r.h -| 1; } fn cornerFixture(gpa: std.mem.Allocator) !*Pardes { @@ -747,7 +746,7 @@ pub fn handleMouse(p: *Pardes, event: Mouse) void { // window by its button. if (m.rule_above and mrow > 0) for (0..p.ncol) |cc| { if (mcol < p.col_x[cc] or mcol >= p.col_x[cc] + p.col_w[cc]) continue; - const seam = if (p.settings.tag_bottom) mrow else mrow - 1; + const seam = mrow - 1; if (seamIdxAt(p, cc, seam)) |k| { p.drag = .{ .border_h = .{ .col = cc, .top_idx = k, .cur_y = seam } }; return; @@ -903,7 +902,7 @@ pub fn dragUpdate(p: *Pardes, mcol: u16, mrow: u16, body_hit: ?Mouse.BodyHit) vo if (d.corner) |k| if (k.idx + 1 < p.cols[k.col].n) { const a = p.rects[p.cols[k.col].panes[k.idx]]; const b = p.rects[p.cols[k.col].panes[k.idx + 1]]; - d.cur_y = clampBorderRow(a.y, a.h, b.h, mrow, p.settings.tag_bottom); + d.cur_y = clampBorderRow(a.y, a.h, b.h, mrow); } else { d.cur_y = mrow; }; @@ -915,8 +914,7 @@ pub fn dragUpdate(p: *Pardes, mcol: u16, mrow: u16, body_hit: ?Mouse.BodyHit) vo const a = p.rects[p.cols[cc].panes[k]]; const b = p.rects[p.cols[cc].panes[k + 1]]; // Held by the rule over the lower pane: the seam is the row above. - const seam = if (p.settings.tag_bottom) mrow else mrow -| 1; - d.cur_y = clampBorderRow(a.y, a.h, b.h, seam, p.settings.tag_bottom); + d.cur_y = clampBorderRow(a.y, a.h, b.h, mrow -| 1); } else d.cur_y = mrow; }, .column_move => |*d| d.cur_x = mcol, @@ -1545,29 +1543,25 @@ test "a corner drag's two axes clamp independently" { // each axis alone, at both walls try std.testing.expectEqual(@as(u16, config.MINW), clampBorderCol(lx, lw, rw, 0)); try std.testing.expectEqual(@as(u16, 100 - config.MINW), clampBorderCol(lx, lw, rw, 999)); - try std.testing.expectEqual(row_lo, clampBorderRow(ay, ah, bh, 0, false)); - try std.testing.expectEqual(row_hi, clampBorderRow(ay, ah, bh, 999, false)); + try std.testing.expectEqual(row_lo, clampBorderRow(ay, ah, bh, 0)); + try std.testing.expectEqual(row_hi, clampBorderRow(ay, ah, bh, 999)); // THE corner property: drag off the right edge while staying mid-height — // x sits at its wall, y still tracks the mouse row exactly try std.testing.expectEqual(@as(u16, 100 - config.MINW), clampBorderCol(lx, lw, rw, 999)); - try std.testing.expectEqual(@as(u16, 12), clampBorderRow(ay, ah, bh, 12, false)); + try std.testing.expectEqual(@as(u16, 12), clampBorderRow(ay, ah, bh, 12)); // and the mirror: pinned at the bottom, x still free - try std.testing.expectEqual(row_hi, clampBorderRow(ay, ah, bh, 999, false)); + try std.testing.expectEqual(row_hi, clampBorderRow(ay, ah, bh, 999)); try std.testing.expectEqual(@as(u16, 40), clampBorderCol(lx, lw, rw, 40)); // both pinned at once is just both walls, not a stuck gesture try std.testing.expectEqual(@as(u16, config.MINW), clampBorderCol(lx, lw, rw, 0)); - try std.testing.expectEqual(row_hi, clampBorderRow(ay, ah, bh, 999, false)); - - try std.testing.expectEqual(row_lo + 1, clampBorderRow(ay, ah, bh, 0, true)); - try std.testing.expectEqual(row_hi + 1, clampBorderRow(ay, ah, bh, 999, true)); - try std.testing.expectEqual(@as(u16, 12), clampBorderRow(ay, ah, bh, 12, true)); + try std.testing.expectEqual(row_hi, clampBorderRow(ay, ah, bh, 999)); // degenerate pairs pass through untouched, each on its own terms: a pane // pair with no room stays draggable even when the column pair has room try std.testing.expectEqual(@as(u16, 7), clampBorderCol(0, 5, 5, 7)); try std.testing.expectEqual(@as(u16, 40), clampBorderCol(lx, lw, rw, 40)); - try std.testing.expectEqual(@as(u16, 9), clampBorderRow(TOPBAR_H, 1, 0, 9, false)); + try std.testing.expectEqual(@as(u16, 9), clampBorderRow(TOPBAR_H, 1, 0, 9)); } test "a v-handle press at the RIGHT column's seam drags both boundaries" { @@ -1668,7 +1662,7 @@ test "a RIGHT-column corner's two axes clamp independently" { try std.testing.expectEqual(handle, p.drag.border_v.cur_x); const a = p.rects[p.cols[1].panes[0]]; const b = p.rects[p.cols[1].panes[1]]; - try std.testing.expectEqual(clampBorderRow(a.y, a.h, b.h, 999, p.settings.tag_bottom), p.drag.border_v.cur_y); + try std.testing.expectEqual(clampBorderRow(a.y, a.h, b.h, 999), p.drag.border_v.cur_y); p.update(.{ .mouse = .{ .button = .left, .kind = .release, .col = handle, .row = 999 } }); } diff --git a/src/ninep/events.zig b/src/ninep/events.zig index e0a67ad4..a4094e57 100644 --- a/src/ninep/events.zig +++ b/src/ninep/events.zig @@ -1374,7 +1374,7 @@ test "a click in the body reports the offsets of the word it takes, so the recor _ = try p.render(frame.allocator()); const rect = p.rects[id]; const x0 = rect.x + config.GUTTER + config.PREFIX_W; - const y0 = if (p.settings.tag_bottom) rect.y else rect.y + p.panes[id].?.tag_rows; + const y0 = rect.y + p.panes[id].?.tag_rows; const tab: u16 = config.tab_now; const Click = struct { x: u16, y: u16, look: []const u8, exec: []const u8, scroll: i32 = 0 }; // Where the wrapped line's `qty` landed, as drawn. diff --git a/src/ninep/tree.zig b/src/ninep/tree.zig index a00a8947..1b6c242e 100644 --- a/src/ninep/tree.zig +++ b/src/ninep/tree.zig @@ -1434,7 +1434,7 @@ test "filesystem inspection preserves pending and displayed Look hover" { .button = .none, .kind = .motion, .col = rect.x + config.GUTTER + config.PREFIX_W + 7, - .row = if (p.settings.tag_bottom) rect.y else rect.y + pardes.BOX_H, + .row = rect.y + pardes.BOX_H, } }); try testing.expect(p.look_hover_wait != null); const body = Node.of(serialOf(p), .body); |
