summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-25 05:49:06 -0300
committerGabriel Schneider <[email protected]>2026-11-25 05:58:01 -0300
commit0659e42ac6f99b31a7994ddb224eb954fdc554b3 (patch)
tree51edf052c294849f4c39e725d33fdbd5ac299729 /core
parente563ef0d896fc66c3e88c274b25f09bb75f80fea (diff)
downloadpardes-0659e42ac6f99b31a7994ddb224eb954fdc554b3.tar.gz
pardes-0659e42ac6f99b31a7994ddb224eb954fdc554b3.zip
Prompt, Places: prompts in the tag as UX DESIGN.md D14 rules them: the body's places on the hit ground and the current one on the current hit's (colors.Roles: Places.paint, every search's places; they were the search ground for the current one and half of it to the page for the rest, the selection's colour on neonotte84), a pattern that is no regex dimming them as before from those grounds; `▸` in the key ink in the gutter on the current place's line alone, the other lines with places shown by the rail's ticks (Places.addTicks) where a `▪` marked each (new gutter glyphs, which D14 rules out); an invalid regex's reason in the err ink in place of the hints, `the N from before shown, dimmed` after it in the dim ink (the hints are gone while it is invalid); the plain word as before (`= Look` dim, the word in the text's ink); TEST FIRST: Prompt.zig's `/` test holds `▸` alone on the current place's line in the key ink and line 1's place on the hit ground (fails on the parent at line 1's `▪`), its `s` test the reason ending the head; core-test 1069/1239 (170 skipped)
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE
Diffstat (limited to 'core')
-rw-r--r--core/Places.zig9
-rw-r--r--core/Prompt.zig39
2 files changed, 33 insertions, 15 deletions
diff --git a/core/Places.zig b/core/Places.zig
index 7f847f6a..8563d7c8 100644
--- a/core/Places.zig
+++ b/core/Places.zig
@@ -658,14 +658,15 @@ pub fn origin(set: *const Places, pane: *Pane) usize {
return @min(r.anchor, r.head);
}
-/// Every place on the rows shown, tinted over the text; the current one in
-/// the search colour itself, the rest halfway to the page.
+/// Every place on the rows shown, tinted over the text: the hit ground,
+/// the current one the current hit's (colors.Roles, UX D4, D14).
pub fn paint(set: *Places, p: *Pardes, s: *Surface, pane: *Pane, r: pardes.Rect, body_h: u16) void {
if (!set.shows(pane)) return;
const f = &pane.file.?;
const th = p.theme();
- var strong = p.chromeTheme().search_bg;
- var quiet = colors.mix(th.bg orelse th.tag_bg, strong);
+ const roles = &p.chromeTheme().roles;
+ var strong = roles.hit_current;
+ var quiet = roles.hit;
// A search prompt's pattern that is no regex: its last places, dimmed.
if (pardes.Prompt.dims(p, pane)) {
strong = quiet;
diff --git a/core/Prompt.zig b/core/Prompt.zig
index 64e030e0..4db7e424 100644
--- a/core/Prompt.zig
+++ b/core/Prompt.zig
@@ -819,7 +819,7 @@ pub fn unlit(p: *const Pardes, pane: *Pane) ?[2]usize {
}
/// The gutter's marks while a prompt is typed (SPEC §7.1): `▸` on the
-/// current place's line and `▪` on every other line holding a place (`/
+/// current place's line alone (`/
/// ?`); `┃` on each line the selections a sam prompt began with cover (`s
/// S K A-K`), its scope. In the blank after a row's line number, on a
/// line's first row.
@@ -836,8 +836,12 @@ pub fn paintGutter(p: *Pardes, s: *Surface, pane: *Pane, r: pardes.Rect, body_h:
const tab = p.settings.tab;
const x = gutterX(pane, r);
const y = p.bodyTop(pane, r);
- const ink = p.chromeTheme().box;
+ const ink = p.chromeTheme().roles.key;
const nlines = File.nlines(p.gpa, f);
+ // `▸` on the current place's line alone: the lines with places are the
+ // rail's ticks (Places.addTicks), never glyphs of their own (UX D14).
+ const c = set.current orelse return;
+ if (c >= hits.len) return;
var last: i32 = -1;
var vr: u16 = 0;
while (vr < body_h) : (vr += 1) {
@@ -847,12 +851,11 @@ pub fn paintGutter(p: *Pardes, s: *Surface, pane: *Pane, r: pardes.Rect, body_h:
last = line;
const ls = File.lineStart(p.gpa, f, @intCast(line));
const next = File.lineStart(p.gpa, f, @intCast(line + 1));
- const i = Places.firstFrom(hits, ls);
- if (i == hits.len or hits[i].start >= @max(next, ls + 1)) continue;
- const current = if (set.current) |c| c < hits.len and hits[c].start >= ls and hits[c].start < @max(next, ls + 1) else false;
+ if (hits[c].start < ls or hits[c].start >= @max(next, ls + 1)) continue;
var style = s.at(x, y + vr).style;
style.fg = .{ .rgb = ink };
- s.set(x, y + vr, if (current) "▸" else "▪", style);
+ s.set(x, y + vr, "▸", style);
+ return;
}
}
@@ -1077,10 +1080,13 @@ pub fn head(p: *Pardes, arena: std.mem.Allocator, pane: *Pane) !TagState.Head {
try styled(arena, &text, &spans, try std.fmt.allocPrint(arena, " = {s}", .{verb}), .dim);
try text.print(arena, " {s}", .{w.buffered()});
}
+ // A pattern that is no regex: why, in the err ink, in place of the
+ // hints (UX D14), what is shown meanwhile dim.
if (pr.bad) {
try text.appendSlice(arena, " ");
try styled(arena, &text, &spans, regexMessage(line), .err);
- try text.print(arena, " · the {d} from before shown, dimmed", .{@as(usize, pane.body.nsel) + 1});
+ try styled(arena, &text, &spans, try std.fmt.allocPrint(arena, " · the {d} from before shown, dimmed", .{@as(usize, pane.body.nsel) + 1}), .dim);
+ return .{ .text = text.items, .spans = spans.items, .cells = 1, .caret = caret };
} else if (behavior(pr.op) != null) {
try pipeCount(p, arena, &text, &spans, pane, pr, line);
} else try count(arena, &text, pane, pr);
@@ -1282,7 +1288,8 @@ test "s asks in the tag's head: its key cell, the field, the plain word and the
try std.testing.expectEqual(@as(u16, 1), pane.body.nsel);
// No regex: the two from before, dimmed, and why.
typeKeys(p, "(");
- try std.testing.expect(has(try tagOf(p), " bad regular expression · the 2 from before shown, dimmed "));
+ // Its reason in place of the hints (UX D14), what follows it dim.
+ try std.testing.expect(std.mem.endsWith(u8, try tagOf(p), " bad regular expression · the 2 from before shown, dimmed"));
try std.testing.expectEqual(@as(u16, 1), pane.body.nsel);
try std.testing.expect(selecting(p, pane).?.dim);
// Esc: rest, the tag and the selection as they were.
@@ -1353,7 +1360,7 @@ fn gutterAt(p: *Pardes, arena: std.mem.Allocator, row: u16) ![]const u8 {
return s.at(x, p.bodyTop(pane, r) + row).grapheme();
}
-test "/ searches the body as it is typed: the current place selected, the gutter marked, counted 3/7 · 5 lines; Enter folds /dirty/ 3/7 into the trail; n says where it went, round the end too; the first Esc clears the tints and dims the word, Look on it lights them again" {
+test "/ searches the body as it is typed: the current place selected, `▸` in the key ink on its line alone (the others are the rail's ticks), the places on the hit ground, counted 3/7 · 5 lines; Enter folds /dirty/ 3/7 into the trail; n says where it went, round the end too; the first Esc clears the tints and dims the word, Look on it lights them again (UX D14)" {
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 200, .rows = 30 });
defer p.deinit();
var frame = std.heap.ArenaAllocator.init(std.testing.allocator);
@@ -1364,10 +1371,20 @@ test "/ searches the body as it is typed: the current place selected, the gutter
typeKeys(p, "/dirty");
try std.testing.expect(has(try tagOf(p), " / dirty = Look /dirty/ 3/7 · 5 lines ⏎ land · M-⏎ as a list"));
try std.testing.expectEqual(@as(?usize, 2), pane.places.current);
- try std.testing.expectEqualStrings("▪", try gutterAt(p, frame.allocator(), 0));
+ try std.testing.expectEqualStrings(" ", try gutterAt(p, frame.allocator(), 0));
try std.testing.expectEqualStrings(" ", try gutterAt(p, frame.allocator(), 1));
try std.testing.expectEqualStrings("▸", try gutterAt(p, frame.allocator(), 2));
- try std.testing.expectEqualStrings("▪", try gutterAt(p, frame.allocator(), 7));
+ try std.testing.expectEqualStrings(" ", try gutterAt(p, frame.allocator(), 7));
+ {
+ const s = try p.render(frame.allocator());
+ const r = p.view().rects[0];
+ const roles = &p.chromeTheme().roles;
+ const x = r.x + config.GUTTER + File.gutterWidth(pane);
+ const y = p.bodyTop(pane, r);
+ try std.testing.expectEqual(pardes.Color{ .rgb = roles.key }, s.at(x - 1 - File.laneCells(pane) - pane.layers.heat, y + 2).style.fg);
+ // Line 1's place (`dirty` at its start) on the hit ground.
+ try std.testing.expectEqual(pardes.Color{ .rgb = roles.hit }, s.at(x, y).style.bg);
+ }
p.update(.{ .key = .{ .cp = Key.enter } });
try std.testing.expectEqual(TagState.Kind.rest, p.view().tag_state.kind);
try std.testing.expect(std.mem.startsWith(u8, try tagOf(p), "/dirty/ 3/7 › /test.txt "));