diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-25 10:24:47 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-25 10:25:08 -0300 |
| commit | d7eec005d9f56384f439a09a92c2d05a571e96e8 (patch) | |
| tree | 2e06531381849d93ffffa930380bf63920949b4c /core/Messages.zig | |
| parent | 0e3b4aa74a5969a3b8b298e9ffa3205399c9afdd (diff) | |
| download | pardes-d7eec005d9f56384f439a09a92c2d05a571e96e8.tar.gz pardes-d7eec005d9f56384f439a09a92c2d05a571e96e8.zip | |
Messages: the notice row's left text is cut with `…`, two blanks at least before its right block, the pane's path from the left so its name and line stay (`…/core/Store.zig:1`), a message or a sentence from the right (UX D2, DESIGN.md E5.4: "the notice row cutting a path mid-word into its right block", P1-L 06/07, P3 actions-L: one blank before `5 messages`); TEST FIRST: Messages.zig "the notice row's left is cut with `…` two blanks before its right block at least: the pane's path from the left, its name and line kept; a message from the right" (40 cells, a path of 53 bytes and `1 message · SPC h m`: on the base the row began `/home/someone/pro` with no `…` and one blank before the count); THE CHANGE: noticeRow leaves `width - (right block + 2)` cells to the left text (all of the row when there is no right block), and where the text is wider it keeps `room - 1` cells and a `…`: from the left when the text is the live pane's path:line (no message leads, no picker's sentence), from the right otherwise; the row is still exactly `width` cells (the gap after the cut is 2 or more); a rolled level's last leaf (the whole row, no right block) is as it was; the mouse reads the same row (mouse.zig noticeRow); GOLDENS: 20 regenerated (badutf chordcut edit hscroll layout-open look-file-1col lookloaded lookpanes lsp-rename-files modal msg savepane shellset shrinktag tagalign tagpath ttyedit ttylook wheeldrift wrap), every changed row the notice row and only it: a message cut from the right that ran into its count with one blank (`what the program draw 1 message · SPC h m`) now ends `…` two blanks before it (`what the program dr… 1 message · SPC h m`); no other row moved; core-test 1087/1258 (171 skipped), process-test 20 of 147 failed before the goldens (those 20, all GoldenMismatch), 0 of 103 tty cases after `-- --update`
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE
Diffstat (limited to 'core/Messages.zig')
| -rw-r--r-- | core/Messages.zig | 62 |
1 files changed, 56 insertions, 6 deletions
diff --git a/core/Messages.zig b/core/Messages.zig index 2cb196f6..725f5a99 100644 --- a/core/Messages.zig +++ b/core/Messages.zig @@ -737,15 +737,35 @@ pub fn noticeRow(p: *const Pardes, width: usize, out: *[notice_row_cap]u8) Row { var keys: [64]u8 = undefined; if (pardes.TagState.pending(p, p.view(), &keys)) |typed| r.print("{s}{s}", .{ if (r.end > 0) " " else "", typed }) catch {}; const tail = r.buffered(); - // The left cut to make room for the right, a blank between them. + // The left cut with `…` to make room for the right, two blanks between + // them at least (UX D2): the pane's path from the left, so its name + // and line stay (`…core/Store.zig:12`), anything else from the right. const tail_w = panes.File.displayWidth(tab, tail); - const room = width -| (tail_w + 1); + const room = width -| (if (tail_w > 0) tail_w + 2 else 0); var cut = left_end; if (panes.File.displayWidth(tab, out[0..cut]) > room) { - cut = panes.File.rawAtDisplay(tab, out[0..left_end], room); - while (cut > 0 and panes.File.displayWidth(tab, out[0..cut]) > room) { - cut -= 1; - while (cut > 0 and out[cut] & 0xC0 == 0x80) cut -= 1; + if (said == null and lead == null) { + var from: usize = 0; + while (from < left_end and panes.File.displayWidth(tab, out[from..left_end]) > room -| 1) { + from += 1; + while (from < left_end and out[from] & 0xC0 == 0x80) from += 1; + } + var kept: [notice_row_cap]u8 = undefined; + const name = kept[0 .. left_end - from]; + @memcpy(name, out[from..left_end]); + w.end = 0; + w.writeAll(if (room > 0) "…" else "") catch {}; + w.writeAll(name) catch {}; + cut = w.end; + } else { + cut = panes.File.rawAtDisplay(tab, out[0..left_end], room -| 1); + while (cut > 0 and panes.File.displayWidth(tab, out[0..cut]) > room -| 1) { + cut -= 1; + while (cut > 0 and out[cut] & 0xC0 == 0x80) cut -= 1; + } + w.end = cut; + w.writeAll(if (room > 0) "…" else "") catch {}; + cut = w.end; } } w.end = cut; @@ -1560,3 +1580,33 @@ test "Esc at rest takes a search's tints first, then the warnings and errors, an try std.testing.expectEqual(@as(u8, 0), p.messages.live_len); try std.testing.expectEqual(id, p.view().active); } + +test "the notice row's left is cut with `…` two blanks before its right block at least: the pane's path from the left, its name and line kept; a message from the right" { + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 24 }); + defer p.deinit(); + const pane = try p.setTestFile("one\ntwo\n"); + const id = p.view().active; + p.gpa.free(pane.file.?.path); + pane.file.?.path = try p.gpa.dupe(u8, "/home/someone/projects/a/long/way/down/core/Store.zig"); + p.messages.live_len = 0; + p.messages.len = 0; + _ = say(p, .notice, id, "saved"); + p.messages.live_len = 0; + var buf: [notice_row_cap]u8 = undefined; + const tab = p.settings.tab; + // The path and `1 message · SPC h m`: 40 cells. + var row = noticeRow(p, 40, &buf); + try std.testing.expect(std.mem.startsWith(u8, row.text, "…") and std.mem.endsWith(u8, row.text[0..row.left], "/Store.zig:1")); + try std.testing.expect(std.mem.endsWith(u8, row.text, "1 message \u{b7} SPC h m")); + try std.testing.expect(row.right - row.left >= 2); + try std.testing.expectEqual(@as(usize, 40), panes.File.displayWidth(tab, row.text)); + // A live message: cut from the right, `…` at its end. + _ = say(p, .@"error", id, "the build failed because something somewhere went badly wrong"); + row = noticeRow(p, 40, &buf); + try std.testing.expect(std.mem.startsWith(u8, row.text, "\u{2717} ") and std.mem.endsWith(u8, row.text[0..row.left], "…")); + try std.testing.expect(row.right - row.left >= 2); + try std.testing.expect(panes.File.displayWidth(tab, row.text) <= 40); + // Room for it all: nothing cut, no `…`. + row = noticeRow(p, 200, &buf); + try std.testing.expect(std.mem.indexOf(u8, row.text, "…") == null); +} |
