summaryrefslogtreecommitdiff
path: root/src/mouse.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/mouse.zig')
-rw-r--r--src/mouse.zig25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/mouse.zig b/src/mouse.zig
index 27d5dd9c..2a00bded 100644
--- a/src/mouse.zig
+++ b/src/mouse.zig
@@ -2,6 +2,7 @@
//! releases (acme's chords, border and seam drags, gestures), and the
//! chrome targets a shell asks about.
const pardes = @import("pardes.zig");
+const exec = @import("exec.zig");
const look = @import("look.zig");
const std = @import("std");
const layout = @import("layout.zig");
@@ -341,9 +342,9 @@ pub fn handleMouse(p: *Pardes, m: Mouse) void {
if (word.len > 0) {
if (m.button == config.exec_button) {
const named = std.meta.stringToEnum(Builtin, word);
- const held = if (named) |b| (if (builtins.registry.takesArg(b)) p.heldSelection(p.active) else null) else p.heldSelection(p.active);
- _ = p.execute(p.active, p.withArg(word, held));
- } else p.runBuiltin(config.look_cmd, p.active, "", word);
+ const held = if (named) |b| (if (builtins.registry.takesArg(b)) exec.heldSelection(p, p.active) else null) else exec.heldSelection(p, p.active);
+ _ = exec.execute(p, p.active, exec.withArg(p, word, held));
+ } else exec.runBuiltin(p, config.look_cmd, p.active, "", word);
}
}
return;
@@ -389,7 +390,7 @@ pub fn handleMouse(p: *Pardes, m: Mouse) void {
config.select_button => switch (m.kind) {
.press => {
if (p.drag == .select and p.drag.select.button == config.exec_button) {
- if (p.heldSelection(p.drag.select.id)) |tx| {
+ if (exec.heldSelection(p, p.drag.select.id)) |tx| {
if (p.chord_arg) |old| p.gpa.free(old);
p.chord_arg = p.gpa.dupe(u8, tx) catch null;
}
@@ -629,7 +630,7 @@ fn reportGesture(
cmd: Builtin,
text: []const u8,
on_tag: bool,
- operand: Pardes.PointerOperand,
+ operand: exec.PointerOperand,
chorded: bool,
) bool {
const scripted = p.panes[id] orelse return false;
@@ -639,7 +640,7 @@ fn reportGesture(
(if (on_tag) .tag_look else .body_look)
else
(if (on_tag) .tag_exec else .body_exec);
- const named = std.meta.stringToEnum(Builtin, Pardes.commandText(text)) != null;
+ const named = std.meta.stringToEnum(Builtin, exec.commandText(text)) != null;
const range = gestureRange(p, id, text, on_tag, operand);
var flag: u32 = if (named) ctlfs.events.flag_builtin else 0;
if (range.q0 == range.q1 and text.len > 0) flag |= ctlfs.events.flag_expansion;
@@ -649,7 +650,7 @@ fn reportGesture(
return ctlfs.events.noteAction(p, id, action, range.q0, range.q1, flag, text);
}
-fn gestureRange(p: *Pardes, id: usize, text: []const u8, on_tag: bool, operand: Pardes.PointerOperand) ctlfs.pane.State.Range {
+fn gestureRange(p: *Pardes, id: usize, text: []const u8, on_tag: bool, operand: exec.PointerOperand) ctlfs.pane.State.Range {
const pane = p.panes[id] orelse return .{};
if (on_tag) {
const tag = p.tagText(p.scratch.allocator(), pane) catch return .{};
@@ -697,7 +698,7 @@ fn dispatchPointerBuiltin(
id: usize,
cmd: Builtin,
text: ?[]const u8,
- gesture: ?struct { on_tag: bool, operand: Pardes.PointerOperand },
+ gesture: ?struct { on_tag: bool, operand: exec.PointerOperand },
) void {
const arg = p.chord_arg;
p.chord_arg = null;
@@ -707,7 +708,7 @@ fn dispatchPointerBuiltin(
return;
};
if (gesture) |g| if (reportGesture(p, id, cmd, operand, g.on_tag, g.operand, arg != null)) return;
- p.runBuiltin(cmd, id, "", p.withArg(operand, arg));
+ exec.runBuiltin(p, cmd, id, "", exec.withArg(p, operand, arg));
}
fn mirrorTtySelection(p: *Pardes, pane: *Pane) void {
@@ -769,7 +770,7 @@ fn dragRelease(p: *Pardes, button: Mouse.Button) void {
// a file moved into the left column evicts a lone unused shell
if (p.panes[d.id]) |mt| if (mt.file != null) {
if (layout.findPane(p, d.id)) |f| if (f.col == 0)
- p.evictLonePristineTty(0, d.id);
+ exec.evictLonePristineTty(p, 0, d.id);
};
},
.select => |s| {
@@ -848,11 +849,11 @@ fn dragRelease(p: *Pardes, button: Mouse.Button) void {
pane.sel[b].state = .none;
var buf: [48]u8 = undefined;
const target = std.fmt.bufPrint(&buf, "@p{d}:{d}", .{ s.id, @as(usize, @intCast(line)) + 1 }) catch return;
- p.runBuiltin(config.look_cmd, s.id, "", target);
+ exec.runBuiltin(p, config.look_cmd, s.id, "", target);
return;
}
};
- var operand = p.pointerOperand(pane, clk);
+ var operand = exec.pointerOperand(p, pane, clk);
if (operand.expanded) |expanded|
pane.sel[b] = expanded
else if (operand.text == null)