summaryrefslogtreecommitdiff
path: root/src/ninep/events.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-17 00:39:47 -0300
committerGabriel Schneider <[email protected]>2026-11-17 12:15:01 -0300
commitdd5aa28c89e2ca31a4cd806d6087ce4ac52398fc (patch)
tree2c79f9311d7dc2b7ef833257cfe260a631496146 /src/ninep/events.zig
parentd7b3d57ed0ba649f01559356fbf2bf89561990ca (diff)
downloadpardes-dd5aa28c89e2ca31a4cd806d6087ce4ac52398fc.tar.gz
pardes-dd5aa28c89e2ca31a4cd806d6087ce4ac52398fc.zip
look: one row address, look.rowAddressAt(pane, row, col): the address a row's producer gave it (a query pane's row on its address, Query.rowAddress) else the one the pane's language reads in the line (a diff's: diffClickIn), with where the row's words start and the address's text; the mouse (exec.operandAt), an empty look written back to `event` (events.expandAt) and a whole line written to `look` (look.lineAddress, was diffLineAddress) each ask it once, where the mouse asked Query.rowAddress and diffClick in turn and the other two asked the diff alone; so a query pane's gutter look reaches events and 9P too (the behaviour change, in the changelog); test: a query row's address from an event written back and from its whole line written to look, its code still words; the diff's look tests and goldens unchanged
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'src/ninep/events.zig')
-rw-r--r--src/ninep/events.zig19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/ninep/events.zig b/src/ninep/events.zig
index 77a4e35f..dd9b488c 100644
--- a/src/ninep/events.zig
+++ b/src/ninep/events.zig
@@ -677,22 +677,21 @@ fn scanNumber(data: []const u8, i: *usize, overflow: *bool) ?u32 {
/// What a click at `at` takes, as the mouse's does (exec.operandAt),
/// for an empty range written back: the file name or word under it on its
-/// line (look.expandedWord), else nothing; in a diff pane's body, for a
-/// look alone (`for_look`, exec.operandAt), look.diffClick's answer, the
-/// line's address or its code's words.
+/// line (look.expandedWord), else nothing; in a body whose rows name
+/// addresses, for a look alone (`for_look`, exec.operandAt),
+/// look.rowAddressAt's answer, the row's address or its code's words.
pub fn expandAt(p: *Pardes, pane: *Pane, whole: []const u8, at: usize, in_body: bool, for_look: bool) []const u8 {
const start = if (std.mem.lastIndexOfScalar(u8, whole[0..at], '\n')) |nl| nl + 1 else 0;
const end = std.mem.indexOfScalarPos(u8, whole, at, '\n') orelse whole.len;
var word_from: usize = 0;
- if (in_body and for_look) diff: {
+ if (in_body and for_look) row_address: {
const row = std.mem.count(u8, whole[0..start], "\n");
- // Only when the served line is the one the diff reads there.
- const lines = look.diffLines(p, pane) orelse break :diff;
- if (row >= lines.len or !std.mem.eql(u8, std.mem.trimEnd(u8, lines[row], "\r"), std.mem.trimEnd(u8, whole[start..end], "\r"))) break :diff;
var buf: [4096 + 32]u8 = undefined;
- const click = look.diffClick(p, pane, row, at - start, &buf) orelse break :diff;
- if (click.address) |address| return p.scratch.allocator().dupe(u8, address) catch "";
- word_from = click.word_from;
+ const got = look.rowAddressAt(p, pane, row, at - start, &buf) orelse break :row_address;
+ // Only when the served line is the one the address was read from.
+ if (!std.mem.eql(u8, std.mem.trimEnd(u8, got.line, "\r"), std.mem.trimEnd(u8, whole[start..end], "\r"))) break :row_address;
+ if (got.address) |address| return p.scratch.allocator().dupe(u8, address) catch "";
+ word_from = got.word_from;
}
const line = whole[start..end];
if (at - start < word_from or word_from > line.len) return "";