diff options
Diffstat (limited to 'src/ninep/events.zig')
| -rw-r--r-- | src/ninep/events.zig | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/ninep/events.zig b/src/ninep/events.zig index 10e91138..3910ac05 100644 --- a/src/ninep/events.zig +++ b/src/ninep/events.zig @@ -728,11 +728,13 @@ fn scanNumber(data: []const u8, i: *usize, overflow: *bool) ?u32 { /// An empty range written back: what a click at `at` takes, as the mouse's /// does (exec.pointerOperand). In a diff pane's body that is look.diffClick's /// answer, the line's address or its code's words. -pub fn expandAt(p: *Pardes, pane: *Pane, whole: []const u8, at: usize, in_body: bool) []const u8 { +/// `for_look`: only a look in a body takes a diff line's address +/// (exec.operandAt); an exec takes the word there, as anywhere. +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) diff: { + if (in_body and for_look) diff: { 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; @@ -794,7 +796,7 @@ pub fn writeEvent(p: *Pardes, asked: Req, id: usize) Reply { // An empty range with no text is a click at that point: expanded as // the click would be, to the word or file name under it (acme's // expand, look.c). - const said = if (r.q0 == r.q1) r.text orelse expandAt(p, pane, whole, lo, !r.action.onTag()) else whole[lo..hi]; + const said = if (r.q0 == r.q1) r.text orelse expandAt(p, pane, whole, lo, !r.action.onTag(), r.action == .body_look or r.action == .tag_look) else whole[lo..hi]; const text = p.scratch.allocator().dupe(u8, said) catch continue; switch (r.action) { // A body's click written back is done as the click would have @@ -1403,7 +1405,7 @@ test "a click in the body reports the offsets of the word it takes, so the recor const rect = p.rects[id]; const x0 = rect.x + config.GUTTER + config.PREFIX_W; const y0 = if (p.settings.tag_bottom) rect.y else rect.y + p.panes[id].?.tag_rows; - const tab: u16 = config.tab_width; + const tab: u16 = config.tab_now; const Click = struct { x: u16, y: u16, look: []const u8, exec: []const u8, scroll: i32 = 0 }; // Where the wrapped line's `qty` landed, as drawn. const surface = try p.render(frame.allocator()); |
