summaryrefslogtreecommitdiff
path: root/src/mouse.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/mouse.zig')
-rw-r--r--src/mouse.zig34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/mouse.zig b/src/mouse.zig
index 8867982c..4eb18141 100644
--- a/src/mouse.zig
+++ b/src/mouse.zig
@@ -91,7 +91,7 @@ fn headerSweepRun(p: *Pardes, sweep: HeaderSweep) void {
const v = p.view();
const column = sweep.column(p) catch return; // error.Gone: its column closed under the sweep
const t = if (column) |c| &v.col_tags[c] else &p.global_tag;
- const text = edit.flatSurface(p, t) catch |err| return p.reportError(v.active, "edit", err);
+ const text = edit.flatSurface(p.editor(), t) catch |err| return p.reportError(v.active, "edit", err);
const swept = sweep.span(text.len);
const selected = if (swept.lo < swept.hi) text[swept.lo..swept.hi] else click: {
const line = std.mem.count(u8, text[0..swept.lo], "\n");
@@ -364,7 +364,7 @@ fn headerPoint(p: *Pardes, column: ?usize, mcol: u16, mrow: u16, clamp: bool) ?s
const t = if (column) |c| &v.col_tags[c] else &p.global_tag;
const x = if (column) |c| v.col_x[c] + TAG_TEXT_INSET else TAG_TEXT_INSET;
const focused = v.header != null and p.headerColumn() == column;
- const text = edit.flatSurface(p, t) catch return null;
+ const text = edit.flatSurface(p.editor(), t) catch return null;
const base = if (column != null) p.topBarHeight() else 0;
const rows = if (column != null) layout.columnBarHeight(p) else p.topBarHeight();
const row: u16 = if (clamp) @min(mrow -| base, rows -| 1) else mrow -| base;
@@ -412,10 +412,10 @@ fn chordCutPaste(p: *Pardes, cut: bool) edit.Error!void {
t.nsel = 0;
}
if (cut) {
- if (t.vsel.active) try edit.normalDelete(p, t, true);
+ if (t.vsel.active) try edit.normalDelete(p.editor(), t, true);
} else if (t.vsel.active) {
- try edit.chordReplace(p, t);
- } else try edit.pasteText(p, t, p.registers.text(p.gpa, pardes.Registers.default) orelse return, true, 1);
+ try edit.chordReplace(p.editor(), t);
+ } else try edit.pasteText(p.editor(), t, p.registers.text(p.gpa, pardes.Registers.default) orelse return, true, 1);
return;
}
if (pane.body.mode == .tty) {
@@ -444,7 +444,7 @@ fn chordCutPaste(p: *Pardes, cut: bool) edit.Error!void {
// Everything done while B1 stays down is one undo step, as acme
// marks the file once per B1 hold (text.c:881 textselect, `state`
// and its one filemark): B1-B2 then B1-B3 is a copy.
- try edit.pushUndo(p, &pane.body);
+ try edit.pushUndo(p.editor(), &pane.body);
p.view().chord_hold = true;
const sl = pane.sel[sel_slot];
pane.sel[sel_slot].state = .none;
@@ -455,8 +455,8 @@ fn chordCutPaste(p: *Pardes, cut: bool) edit.Error!void {
const w1 = pane.wrapAt(@max(0, sl.r1 - @as(i32, pane.tag_rows)));
const row0 = w0.line;
const row1 = w1.line;
- const col0 = edit.paneByteAtDisplay(p, &pane.body, w0.line, w0.at, sl.c0 - pfx - w0.pad);
- const col1 = edit.paneByteAtDisplay(p, &pane.body, w1.line, w1.at, sl.c1 - pfx - w1.pad);
+ const col0 = edit.paneByteAtDisplay(p.editor(), &pane.body, w0.line, w0.at, sl.c0 - pfx - w0.pad);
+ const col1 = edit.paneByteAtDisplay(p.editor(), &pane.body, w1.line, w1.at, sl.c1 - pfx - w1.pad);
pane.body.cur_row = row1;
pane.body.cur_col = col1;
pane.body.cur_pinned = true;
@@ -466,16 +466,16 @@ fn chordCutPaste(p: *Pardes, cut: bool) edit.Error!void {
pane.body.nsel = 0;
}
if (cut) {
- if (pane.body.vsel.active) try edit.normalDelete(p, &pane.body, true);
+ if (pane.body.vsel.active) try edit.normalDelete(p.editor(), &pane.body, true);
} else if (pane.body.vsel.active) {
- try edit.chordReplace(p, &pane.body);
+ try edit.chordReplace(p.editor(), &pane.body);
} else if (pane.file) |*f| {
// bare cursor: splice the register in literally (no linewise
// magic) so a paste right after a cut restores the text exactly
const y = p.registers.text(p.gpa, pardes.Registers.default) orelse return;
if (y.len == 0) return;
const at = modal.Cursor{ .row = @intCast(@max(0, pane.body.cur_row)), .col = @intCast(@max(0, pane.body.cur_col)) };
- try edit.pushUndo(p, &pane.body);
+ try edit.pushUndo(p.editor(), &pane.body);
const new = try modal.insertAt(p.gpa, f.content, at, y);
panes.File.setContent(p, f, new);
pane.body.vsel = .{ .active = modal.nextGrapheme(y, 0) < y.len, .row = @intCast(at.row), .col = @intCast(at.col), .explicit = false };
@@ -491,7 +491,7 @@ fn chordCutPaste(p: *Pardes, cut: bool) edit.Error!void {
pane.body.cur_pinned = true;
pane.body.sticky_col = -1;
pane.ensureCursorVisible();
- } else try edit.pasteText(p, &pane.body, p.registers.text(p.gpa, pardes.Registers.default) orelse return, true, 1);
+ } else try edit.pasteText(p.editor(), &pane.body, p.registers.text(p.gpa, pardes.Registers.default) orelse return, true, 1);
}
pub fn handleMouse(p: *Pardes, event: Mouse) void {
@@ -1042,7 +1042,7 @@ fn gestureRange(p: *Pardes, id: usize, text: []const u8, on_tag: bool, operand:
const top = lead[0] - @as(i32, pane.tag_rows);
if (top < 0) break :lead null;
const w = pane.wrapAt(top);
- const col = edit.paneByteAtDisplay(p, &pane.body, w.line, w.at, lead[1] - panes.File.gutterWidth(pane) - w.pad);
+ const col = edit.paneByteAtDisplay(p.editor(), &pane.body, w.line, w.at, lead[1] - panes.File.gutterWidth(pane) - w.pad);
break :lead .{
.row = @intCast(@max(0, w.line)),
.col = @intCast(@max(0, col)),
@@ -1107,7 +1107,7 @@ fn mirrorTtySelection(p: *Pardes, pane: *Pane) void {
pane.body.restore_cursor = false;
pane.body.sticky_col = -1;
pane.body.normal.clear();
- edit.setYank(p, text) catch |err| p.reportError(p.view().active, "yank", err);
+ edit.setYank(p.editor(), text) catch |err| p.reportError(p.view().active, "yank", err);
}
/// acme's double-click (text.c:881 textselect, plan9port text.c:1407
@@ -1124,7 +1124,7 @@ fn doubleClick(p: *Pardes, id: usize, t: *panes.Text, on_tag: bool, row: i32, co
const c = prev orelse return;
if (c.id != id or c.on_tag != on_tag or c.row != row or c.col != col or now - c.ms > 500) return;
v.last_click = null;
- const text = edit.flatSurface(p, t) catch |err| return p.reportError(v.active, "edit", err);
+ const text = edit.flatSurface(p.editor(), t) catch |err| return p.reportError(v.active, "edit", err);
const q = modal.offsetAt(text, .{ .row = @intCast(@max(0, t.cur_row)), .col = @intCast(@max(0, t.cur_col)) });
const r = edit.doubleClickRange(text, q);
if (r[1] <= r[0]) return;
@@ -1160,7 +1160,7 @@ fn sweepPoint(p: *Pardes, pane: *panes.Pane, r: i32, c: i32) ?modal.Cursor {
if (visible < 0) return null;
const w = pane.wrapAt(visible);
if (w.line < 0) return null;
- const col = edit.paneByteAtDisplay(p, &pane.body, w.line, w.at, c - w.pad - (if (pane.file != null) @as(i32, panes.File.gutterWidth(pane)) else 0));
+ const col = edit.paneByteAtDisplay(p.editor(), &pane.body, w.line, w.at, c - w.pad - (if (pane.file != null) @as(i32, panes.File.gutterWidth(pane)) else 0));
return .{ .row = @intCast(w.line), .col = @intCast(@max(0, col)) };
}
@@ -1220,7 +1220,7 @@ fn dragRelease(p: *Pardes, button: Mouse.Button) void {
const w = pane.wrapAt(body_vis);
pane.body.cur_row = w.line;
pane.body.cur_col = edit.paneByteAtDisplay(
- p,
+ p.editor(),
&pane.body,
w.line,
w.at,