summaryrefslogtreecommitdiff
path: root/src/tagline.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-09 00:52:52 -0300
committerGabriel Schneider <[email protected]>2026-11-09 01:28:28 -0300
commit5157579ff7f9ae0cfc3c7629e953da05bce340fc (patch)
tree02147789efdcea998981efcfe05d4bcb3e9bb7b0 /src/tagline.zig
parent4c4b9bf54d77dbc0f9f4e2619746908e501c6001 (diff)
downloadpardes-5157579ff7f9ae0cfc3c7629e953da05bce340fc.tar.gz
pardes-5157579ff7f9ae0cfc3c7629e953da05bce340fc.zip
tests: at the end of their files: every top-level test block of the 46 files that had one mid-file (the locality analysis's 45 and test/hxdiff.zig; gui.zig, macos.zig, look, host_io, 9p_io, terminal, tui, mouse, fs, replica, layout among them, 11,429 test lines), with the functions only tests call, moved after the file's code in their order, a mechanical move (.scratch/suites/tests_to_end.py), zig fmt'd; the unit suites pass as before (tui 1486/1487, gui 1536/1537, core 956/956 on both), macos.zig only parse-checked here
Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/tagline.zig')
-rw-r--r--src/tagline.zig68
1 files changed, 34 insertions, 34 deletions
diff --git a/src/tagline.zig b/src/tagline.zig
index b9abf5f0..a7438be3 100644
--- a/src/tagline.zig
+++ b/src/tagline.zig
@@ -449,6 +449,40 @@ pub fn workspaceBlank(p: *Pardes, col: u16, row: u16, tag_hit: ?pardes.TagHit) b
return at >= panes.File.displayWidth(modal.lineSlice(text, 0)) + 2;
}
+/// Column and workspace tags are one line, as acme's: a newline typed,
+/// pasted or restored from a dump into one becomes a space, the caret and
+/// the selection kept on the same characters.
+pub fn flattenHeaders(p: *Pardes) void {
+ for (p.view().col_tags[0..p.view().ncol]) |*t| flatten(t);
+ flatten(&p.global_tag);
+}
+
+fn flatten(t: *Text) void {
+ const own = t.own orelse return;
+ if (std.mem.indexOfScalar(u8, own, '\n') == null) return;
+ const cur = modal.offsetAt(own, .{ .row = @intCast(@max(0, t.cur_row)), .col = @intCast(@max(0, t.cur_col)) });
+ const anchor = modal.offsetAt(own, .{ .row = @intCast(@max(0, t.vsel.row)), .col = @intCast(@max(0, t.vsel.col)) });
+ std.mem.replaceScalar(u8, own, '\n', ' ');
+ t.cur_row = 0;
+ t.cur_col = @intCast(cur);
+ t.vsel.row = 0;
+ t.vsel.col = @intCast(anchor);
+ t.nsel = 0;
+}
+
+const WordBounds = struct { lo: usize, hi: usize };
+
+/// The space-delimited word covering `col` in `str` (a header's click and
+/// hover), null on a space or past the end.
+pub fn wordBoundsAtCol(str: []const u8, col: usize) ?WordBounds {
+ if (col >= str.len or str[col] == ' ') return null;
+ var lo: usize = col;
+ while (lo > 0 and str[lo - 1] != ' ') lo -= 1;
+ var hi: usize = col;
+ while (hi < str.len and str[hi] != ' ') hi += 1;
+ return .{ .lo = lo, .hi = hi };
+}
+
test "the workspace tag is blank left of its text and past its end, and nowhere else" {
const p = try Pardes.init(std.testing.allocator, .{ .cols = 80, .rows = 12, .tty_only = true });
defer p.deinit();
@@ -474,27 +508,6 @@ test "the workspace tag is blank left of its text and past its end, and nowhere
try std.testing.expect(!workspaceBlank(p, 79, 0, null));
}
-/// Column and workspace tags are one line, as acme's: a newline typed,
-/// pasted or restored from a dump into one becomes a space, the caret and
-/// the selection kept on the same characters.
-pub fn flattenHeaders(p: *Pardes) void {
- for (p.view().col_tags[0..p.view().ncol]) |*t| flatten(t);
- flatten(&p.global_tag);
-}
-
-fn flatten(t: *Text) void {
- const own = t.own orelse return;
- if (std.mem.indexOfScalar(u8, own, '\n') == null) return;
- const cur = modal.offsetAt(own, .{ .row = @intCast(@max(0, t.cur_row)), .col = @intCast(@max(0, t.cur_col)) });
- const anchor = modal.offsetAt(own, .{ .row = @intCast(@max(0, t.vsel.row)), .col = @intCast(@max(0, t.vsel.col)) });
- std.mem.replaceScalar(u8, own, '\n', ' ');
- t.cur_row = 0;
- t.cur_col = @intCast(cur);
- t.vsel.row = 0;
- t.vsel.col = @intCast(anchor);
- t.nsel = 0;
-}
-
test "a column or workspace tag is one line: a newline in it is a space" {
const p = try Pardes.init(std.testing.allocator, .{ .cols = 50, .rows = 12, .tty_only = true });
defer p.deinit();
@@ -520,16 +533,3 @@ test "a pane tag wraps a long line onto rows, and offsets map both ways" {
try std.testing.expectEqual(@as(usize, 10), shown.toReal(11)); // the 'e' of Del
try std.testing.expectEqual(@as(usize, 11), shown.fromReal(10));
}
-
-const WordBounds = struct { lo: usize, hi: usize };
-
-/// The space-delimited word covering `col` in `str` (a header's click and
-/// hover), null on a space or past the end.
-pub fn wordBoundsAtCol(str: []const u8, col: usize) ?WordBounds {
- if (col >= str.len or str[col] == ' ') return null;
- var lo: usize = col;
- while (lo > 0 and str[lo - 1] != ' ') lo -= 1;
- var hi: usize = col;
- while (hi < str.len and str[hi] != ' ') hi += 1;
- return .{ .lo = lo, .hi = hi };
-}