diff options
| author | Gabriel Schneider <[email protected]> | 2026-09-28 19:17:12 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 00:12:15 -0300 |
| commit | 8429e7bd8aff1ae0c71d3b1a7a6b9f01ed52e691 (patch) | |
| tree | 9ae9dbe35e371a7b64b7e64bd690c4871e0b705c /src/pardes.zig | |
| parent | 4cea4751960b359561997cb040f05179923cb80e (diff) | |
| download | pardes-8429e7bd8aff1ae0c71d3b1a7a6b9f01ed52e691.tar.gz pardes-8429e7bd8aff1ae0c71d3b1a7a6b9f01ed52e691.zip | |
Column and workspace tags are one line again, as acme's
acme gives a column tag one font height (cols.c:244) and its row tag one line; pardes let them grow a row per line. A newline typed, pasted, written or restored into a column or workspace tag now becomes a space, the caret and selection kept on the same characters, and the bars are one row each. A dump holding a multi-line header tag comes back with its lines joined by spaces.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/pardes.zig')
| -rw-r--r-- | src/pardes.zig | 45 |
1 files changed, 13 insertions, 32 deletions
diff --git a/src/pardes.zig b/src/pardes.zig index 00843b78..cebd851b 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -3148,7 +3148,7 @@ test "header clicks beyond text append and long UTF-8 tags reveal their caret" { try std.testing.expectEqual(@as(usize, 0), p.header_scroll); } -test "a column tag with a newline in it takes a row per line and pushes its panes down" { +test "a newline typed into a column tag is a space: the tag stays one row" { const p = try Pardes.init(std.testing.allocator, .{ .cols = 50, .rows = 12, .tty_only = true }); defer p.deinit(); _ = try p.setTestFile("body\n"); @@ -3158,26 +3158,9 @@ test "a column tag with a newline in it takes a row per line and pushes its pane p.update(.{ .mouse = .{ .button = .left, .kind = .release, .col = 40, .row = TOPBAR_H } }); p.update(.{ .key = .{ .cp = Key.enter } }); p.update(.{ .key = .{ .cp = 'S', .text = "Snarf" } }); - try std.testing.expectEqualStrings("New\nSnarf", tagline.columnTag(p, 0)); - try std.testing.expectEqual(@as(u16, 2), p.columnBarHeight()); - const frame = try p.render(p.scratch.allocator()); - try std.testing.expectEqual(TOPBAR_H + 2, p.rects[0].y); - try std.testing.expectEqual(TOPBAR_H + 1, frame.cursor.?.y); - try std.testing.expectEqual(@as(u8, 'S'), frame.at(TAG_TEXT_INSET, TOPBAR_H + 1).text[0]); - - // A click on the second row lands on the second line. - p.update(.{ .key = .{ .cp = Key.escape } }); - p.acknowledgePanelPresentation(&.{}); - p.update(.{ .mouse = .{ .button = .left, .kind = .press, .col = TAG_TEXT_INSET + 1, .row = TOPBAR_H + 1 } }); - p.update(.{ .mouse = .{ .button = .left, .kind = .release, .col = TAG_TEXT_INSET + 1, .row = TOPBAR_H + 1 } }); - try std.testing.expectEqual(@as(i32, 1), p.col_tags[0].cur_row); - try std.testing.expectEqual(@as(i32, 1), p.col_tags[0].cur_col); - - // Taking the newline back out gives the panes their row again. - p.update(.{ .key = .{ .cp = Key.home } }); - p.update(.{ .key = .{ .cp = Key.backspace } }); - try std.testing.expectEqualStrings("NewSnarf", tagline.columnTag(p, 0)); _ = try p.render(p.scratch.allocator()); + try std.testing.expectEqualStrings("New Snarf", tagline.columnTag(p, 0)); + try std.testing.expectEqual(COLBAR_H, p.columnBarHeight()); try std.testing.expectEqual(TOPBAR_H + COLBAR_H, p.rects[0].y); } @@ -4457,24 +4440,21 @@ pub const Pardes = struct { return a; } - /// The workspace tag's height: a row per line of it while the setting - /// keeps it, zero once a native shell takes its commands over. Layout and - /// hit testing read this rather than the constant, the way they read - /// `columnBarHeight`. + /// The workspace tag's height: one row while the setting keeps it, as + /// acme's row tag is, zero once a native shell takes its commands over. + /// Layout and hit testing read this rather than the constant, the way + /// they read `columnBarHeight`. pub fn topBarHeight(p: *const Pardes) u16 { if (!p.settings.workspace_tag) return 0; - const lines = if (p.global_tag.own) |own| std.mem.count(u8, own, "\n") + 1 else TOPBAR_H; - return @intCast(@min(lines, MAX_TAG_ROWS, @max(TOPBAR_H, p.screen_h / 3))); + return TOPBAR_H; } - /// The column tags' height: a row per line of the tallest one. + /// The column tags' height: one row, as acme's (cols.c:244, colresize, + /// gives a column tag one font height); a newline in one is a space + /// (tagline.flattenHeaders). pub fn columnBarHeight(p: *const Pardes) u16 { if (!p.settings.column_tags or p.screen_h < 3) return 0; - var lines: usize = COLBAR_H; - for (p.col_tags[0..p.ncol]) |t| if (t.own) |own| { - lines = @max(lines, std.mem.count(u8, own, "\n") + 1); - }; - return @intCast(@min(lines, MAX_TAG_ROWS, @max(COLBAR_H, p.screen_h / 3))); + return COLBAR_H; } fn detachCwds(p: *Pardes, parents: []const *Pane) !void { @@ -6119,6 +6099,7 @@ pub const Pardes = struct { /// Recompute geometry, push grid-size changes to each emulator + pty, fire /// deferred greetings. The mirror of the prototype's loop epilogue. pub fn sync(p: *Pardes) void { + tagline.flattenHeaders(p); if (p.header_column != null and p.columnBarHeight() == 0) { tagline.exitHeader(p); } |
