summaryrefslogtreecommitdiff
path: root/src/mouse.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/mouse.zig')
-rw-r--r--src/mouse.zig22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/mouse.zig b/src/mouse.zig
index 21961cf8..8020fda8 100644
--- a/src/mouse.zig
+++ b/src/mouse.zig
@@ -965,6 +965,21 @@ fn reportGesture(
operand: exec.PointerOperand,
chord_arg: ?[]const u8,
) bool {
+ if ((p.panes[id] orelse return false).fs.readers == 0) return false;
+ return reportRange(p, id, cmd, text, on_tag, gestureRange(p, id, text, on_tag, operand), chord_arg);
+}
+
+/// An event reader told of a look or an exec of `text` at `range` of the
+/// tag or body, by a click or a key alike: false when the pane has none.
+pub fn reportRange(
+ p: *Pardes,
+ id: usize,
+ cmd: Builtin,
+ text: []const u8,
+ on_tag: bool,
+ range: ctlfs.pane.State.Range,
+ chord_arg: ?[]const u8,
+) bool {
const scripted = p.panes[id] orelse return false;
if (scripted.fs.readers == 0) return false;
const is_look = cmd == config.look_cmd;
@@ -973,7 +988,6 @@ fn reportGesture(
else
(if (on_tag) .tag_exec else .body_exec);
const named = exec.namesBuiltin(text);
- const range = gestureRange(p, id, text, on_tag, operand);
// No flag 2: the record already carries the word a click took, its
// range and text, and in acme flag 2 promises a second record with them
// (editors/acme/exec.c:154-183, look.c:42-68), which none follows here.
@@ -1044,7 +1058,9 @@ fn gestureRange(p: *Pardes, id: usize, text: []const u8, on_tag: bool, operand:
return .{ .q0 = q0, .q1 = @intCast(@min(q0 + text.len, f.content.len)) };
}
-fn dispatchPointerBuiltin(
+/// A look or exec of what an operand took (exec.operandAt), from a
+/// click or a key: an event reader is told, else it runs.
+pub fn dispatchPointerBuiltin(
p: *Pardes,
id: usize,
cmd: Builtin,
@@ -1291,7 +1307,7 @@ fn dragRelease(p: *Pardes, button: Mouse.Button) void {
return;
}
};
- var operand = exec.pointerOperand(p, pane, clk);
+ var operand = exec.operandAt(p, pane, clk, true, s.button == config.look_button);
if (operand.expanded) |expanded|
pane.sel[b] = expanded
else if (operand.text == null)