summaryrefslogtreecommitdiff
path: root/core/mouse.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/mouse.zig')
-rw-r--r--core/mouse.zig42
1 files changed, 21 insertions, 21 deletions
diff --git a/core/mouse.zig b/core/mouse.zig
index 073f09c3..8e761453 100644
--- a/core/mouse.zig
+++ b/core/mouse.zig
@@ -375,7 +375,7 @@ fn headerPoint(p: *Pardes, column: ?usize, mcol: u16, mrow: u16, clamp: bool) ?s
const bar = modal.lineSlice(text, line);
const scroll = if (focused) v.header_scroll else 0;
const kind: Layer.Kind = if (column != null) .column else .workspace;
- const at = @min(bar.len, panes.File.rawAtDisplay(bar, (Layer.columnAt(p, kind, column orelse 0, v.pointer_tag_hit, clamp, row) orelse (mcol -| x)) + scroll));
+ const at = @min(bar.len, panes.File.rawAtDisplay(p.settings.tab, bar, (Layer.columnAt(p, kind, column orelse 0, v.pointer_tag_hit, clamp, row) orelse (mcol -| x)) + scroll));
return .{ .t = t, .text = text, .line = line, .at = modal.lineStartOffset(text, line) + at };
}
@@ -451,8 +451,8 @@ fn chordCutPaste(p: *Pardes, cut: bool) edit.Error!void {
const pfx: i32 = if (pane.file != null) panes.File.gutterWidth(pane) else 0;
// both ends of the sweep through the same last-frame map, so a
// chord over wrapped rows cuts the text that was under it
- const w0 = pane.wrapAt(@max(0, sl.r0 - @as(i32, pane.tag_rows)));
- const w1 = pane.wrapAt(@max(0, sl.r1 - @as(i32, pane.tag_rows)));
+ const w0 = pane.wrapAt(p.settings.tab, @max(0, sl.r0 - @as(i32, pane.tag_rows)));
+ const w1 = pane.wrapAt(p.settings.tab, @max(0, sl.r1 - @as(i32, pane.tag_rows)));
const row0 = w0.line;
const row1 = w1.line;
const col0 = edit.paneByteAtDisplay(p.editor(), &pane.body, w0.line, w0.at, sl.c0 - pfx - w0.pad);
@@ -490,7 +490,7 @@ fn chordCutPaste(p: *Pardes, cut: bool) edit.Error!void {
}
pane.body.cur_pinned = true;
pane.body.sticky_col = -1;
- pane.ensureCursorVisible();
+ pane.ensureCursorVisible(p.settings.tab);
} else try edit.pasteText(p.editor(), &pane.body, p.registers.text(p.gpa, pardes.Registers.default) orelse return, true, 1);
}
@@ -711,12 +711,12 @@ pub fn handleMouse(p: *Pardes, event: Mouse) void {
} else if (pane.file != null and !p.settings.wrap) {
// wrapped there is nothing off to the right to reach
const line = panes.File.sourceLine(pane, pane.body.cur_row);
- const visual = panes.File.rawDisplayCol(line, @intCast(@max(0, pane.hscroll)));
+ const visual = panes.File.rawDisplayCol(p.settings.tab, line, @intCast(@max(0, pane.hscroll)));
const next: usize = if (m.button == .wheel_right)
visual +| @as(usize, @intCast(config.wheel_cols))
else
visual -| @as(usize, @intCast(config.wheel_cols));
- pane.hscroll = @intCast(panes.File.rawAtDisplay(line, next));
+ pane.hscroll = @intCast(panes.File.rawAtDisplay(p.settings.tab, line, next));
}
},
config.select_button => switch (m.kind) {
@@ -773,7 +773,7 @@ pub fn handleMouse(p: *Pardes, event: Mouse) void {
const rail_h = r.h -| pane.tag_rows;
if (mrow >= body_y and mrow < body_y + rail_h) if (pane.places.tickHit(p, pane, mrow - body_y, rail_h)) |i| {
pane.focus = .body;
- return pane.places.goTo(pane, i, false);
+ return pane.places.goTo(p.settings.tab, pane, i, false);
};
// gutter scrollbar: a left click scrolls UP to that row
pane.scrollBy(-(@as(i32, mrow) - @as(i32, body_y)));
@@ -905,7 +905,7 @@ pub fn dragUpdate(p: *Pardes, mcol: u16, mrow: u16, body_hit: ?Mouse.BodyHit) vo
const r = v.rects[s.id];
const b = @backingInt(s.button);
const tag_rows: i32 = pane.tag_rows;
- panes.File.geometry(pane);
+ panes.File.geometry(p.settings.tab, pane);
if (pane.body_rows > 0 and pane.sel[b].r0 >= tag_rows) if (body_hit) |supplied| {
if (supplied.serial == pane.serial) s.body = supplied.place;
const mapped_hit = bodyHitForPane(p, s.id, supplied, true) orelse return;
@@ -1015,7 +1015,7 @@ fn gestureRange(p: *Pardes, id: usize, text: []const u8, on_tag: bool, operand:
const lead = if (sel.r0 < sel.r1 or (sel.r0 == sel.r1 and sel.c0 <= sel.c1)) sel else Pane.Sel{ .r0 = sel.r1, .c0 = sel.c1 };
const row: usize = @as(usize, @intCast(@max(0, lead.r0))) + pane.tag_top;
const start = modal.lineStartOffset(shown.text, row);
- const at = shown.toReal(start + panes.File.rawAtDisplay(modal.lineSlice(shown.text, row), @intCast(@max(0, lead.c0))));
+ const at = shown.toReal(start + panes.File.rawAtDisplay(p.settings.tab, modal.lineSlice(shown.text, row), @intCast(@max(0, lead.c0))));
const q0: u32 = @intCast(@min(at, tag.len));
return .{ .q0 = q0, .q1 = @intCast(@min(q0 + text.len, tag.len)) };
}
@@ -1041,7 +1041,7 @@ fn gestureRange(p: *Pardes, id: usize, text: []const u8, on_tag: bool, operand:
const lead = edit.sweepEnds(sel)[0];
const top = lead[0] - @as(i32, pane.tag_rows);
if (top < 0) break :lead null;
- const w = pane.wrapAt(top);
+ const w = pane.wrapAt(p.settings.tab, top);
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)),
@@ -1089,7 +1089,7 @@ fn mirrorTtySelection(p: *Pardes, pane: *Pane) void {
if (rows.len == 0) return;
const forward = gesture.r1 > gesture.r0 or (gesture.r1 == gesture.r0 and gesture.c1 >= gesture.c0);
const endpoint = rows[if (forward) rows.len - 1 else 0];
- const body = body_layer.bodyText(p.scratch.allocator(), pane) catch |err| return p.reportError(p.view().active, "select", err);
+ const body = body_layer.bodyText(p.settings.tab, p.scratch.allocator(), pane) catch |err| return p.reportError(p.view().active, "select", err);
const line = modal.lineSlice(body, @intCast(@max(0, endpoint.row - @as(i32, @intCast(panes.Term.grid(pane.terminal).offset)))));
const byte = if (forward) modal.prevGrapheme(line, @min(endpoint.hi, line.len)) else endpoint.lo;
pane.body.cur_row = pane.surfRow(endpoint.row);
@@ -1158,7 +1158,7 @@ pub fn edgeScroll(p: *Pardes) void {
fn sweepPoint(p: *Pardes, pane: *panes.Pane, r: i32, c: i32) ?modal.Cursor {
const visible = r - @as(i32, pane.tag_rows);
if (visible < 0) return null;
- const w = pane.wrapAt(visible);
+ const w = pane.wrapAt(p.settings.tab, visible);
if (w.line < 0) return null;
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)) };
@@ -1204,7 +1204,7 @@ fn dragRelease(p: *Pardes, button: Mouse.Button) void {
// click on the path, if it can be renamed, drafts a name.
const row: usize = @intCast(@max(0, sl.r1));
const col: usize = @intCast(@max(0, sl.c1));
- if (!dragged and tagline.onName(pane, row, col)) {
+ if (!dragged and tagline.onName(p.settings.tab, pane, row, col)) {
tagline.draftName(p, pane, col);
} else if (tagline.tagOffsetAt(p, pane, row, col)) |cursor| {
pane.tag.cur_row = @intCast(cursor.row);
@@ -1217,7 +1217,7 @@ fn dragRelease(p: *Pardes, button: Mouse.Button) void {
if (dragged and pane.body.mode == .tty) mirrorTtySelection(p, pane);
const body_vis = sl.r1 - @as(i32, pane.tag_rows);
if (body_vis >= 0 and pane.body.mode != .tty) {
- const w = pane.wrapAt(body_vis);
+ const w = pane.wrapAt(p.settings.tab, body_vis);
pane.body.cur_row = w.line;
pane.body.cur_col = edit.paneByteAtDisplay(
p.editor(),
@@ -1227,7 +1227,7 @@ fn dragRelease(p: *Pardes, button: Mouse.Button) void {
sl.c1 - w.pad - (if (pane.file != null) @as(i32, panes.File.gutterWidth(pane)) else 0),
);
pane.body.cur_pinned = true;
- if (edit.clampFileCursor(&pane.body)) pane.ensureCursorVisible();
+ if (edit.clampFileCursor(&pane.body)) pane.ensureCursorVisible(p.settings.tab);
pane.body.normal.clear();
pane.body.vsel.active = false;
pane.body.nsel = 0; // a click says WHERE the one cursor is
@@ -1253,7 +1253,7 @@ fn dragRelease(p: *Pardes, button: Mouse.Button) void {
if (s.button == config.look_button and clk.r0 >= pane.tag_rows and clk.r0 == clk.r1 and
clk.c0 == clk.c1 and clk.c0 >= 0 and pane.body.mode != .tty)
if (pane.file) |f| if (f.output == null and clk.c0 < panes.File.gutterWidth(pane)) {
- const line = pane.wrapAt(clk.r0 - pane.tag_rows).line;
+ const line = pane.wrapAt(p.settings.tab, clk.r0 - pane.tag_rows).line;
if (line >= 0) {
pane.sel[b].state = .none;
var buf: [48]u8 = undefined;
@@ -1276,18 +1276,18 @@ fn dragRelease(p: *Pardes, button: Mouse.Button) void {
pane.body.select = false;
pane.body.cur_row = operand.row;
pane.body.cur_col = operand.col;
- if (edit.clampFileCursor(&pane.body)) pane.ensureCursorVisible();
+ if (edit.clampFileCursor(&pane.body)) pane.ensureCursorVisible(p.settings.tab);
}
const txt = operand.text;
const cmd = if (s.button == config.look_button) config.look_cmd else config.exec_cmd;
if (clk.r0 == 0 and s.button == config.exec_button and pane.prompt == .name) {
- const prefix_width = panes.File.displayWidth(tagline.tagPrefix(p, pane) catch return);
+ const prefix_width = panes.File.displayWidth(p.settings.tab, tagline.tagPrefix(p, pane) catch return);
const on_name = @as(usize, @intCast(@max(0, clk.c0))) < prefix_width;
if (!tagline.commitTagName(p, pane)) return;
// Executing a staged filename commits it; executing its
// command tail uses the new identity (especially Save).
if (on_name) return;
- const new_width = panes.File.displayWidth(tagline.tagPrefix(p, pane) catch return);
+ const new_width = panes.File.displayWidth(p.settings.tab, tagline.tagPrefix(p, pane) catch return);
const shift = @as(i32, @intCast(new_width)) - @as(i32, @intCast(prefix_width));
if (operand.expanded) |*sel| {
sel.c0 += shift;
@@ -1479,7 +1479,7 @@ test "mouse thumb buttons navigate once and clear selection gestures" {
const p = try Pardes.init(std.testing.allocator, .{ .cols = 60, .rows = 12 });
defer p.deinit();
const pane = try p.setTestFile("alpha beta\ngamma delta\nepsilon zeta\n");
- pane.body.setRange(pane.file.?.content, 0, .{ .anchor = 1, .head = 5 }, true);
+ pane.body.setRange(config.tab_width, pane.file.?.content, 0, .{ .anchor = 1, .head = 5 }, true);
p.view().jumps.n = 3;
p.view().jumps.cur = 2;
for (0..3) |i| p.view().jumps.list[i] = .{ .pane = 0, .serial = pane.serial, .line = @intCast(i + 1), .col = 1 };
@@ -1504,7 +1504,7 @@ test "a chorded exec an event reader holds is told with its argument, and writte
const event = ctlfs.Node.of(serial, .event);
const h = th.call(p, .{ .tag = 1, .op = .open, .node = event, .omode = 2 }).reply.handle;
// The argument: a selection held in the pane (its second line).
- ctlfs.pane.setDot(p.panes[0].?, .{ .q0 = 9, .q1 = 17 });
+ ctlfs.pane.setDot(p.settings.tab, p.panes[0].?, .{ .q0 = 9, .q1 = 17 });
p.view().chord_arg = try p.gpa.dupe(u8, "arg-text");
dispatchPointerBuiltin(p, 0, config.exec_cmd, "Msg", .{ .on_tag = false, .operand = .{ .row = 0, .col = 1, .text = "Msg" } });
var records: [3][]const u8 = undefined;