summaryrefslogtreecommitdiff
path: root/src/mouse.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/mouse.zig')
-rw-r--r--src/mouse.zig30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/mouse.zig b/src/mouse.zig
index 49e9927e..06f3a755 100644
--- a/src/mouse.zig
+++ b/src/mouse.zig
@@ -199,7 +199,7 @@ pub fn sameBodyCell(a: ?Mouse.BodyHit, b: ?Mouse.BodyHit) bool {
return first.serial == second.serial and first.row == second.row and first.col == second.col;
}
-/// A wheel over a terminal whose program owns it (`terminal.ownsWheel`:
+/// A wheel over a terminal whose program owns it (`Term.Modes.wheel`:
/// codex, htop, less) goes to the program as the program asked, one turn
/// per line, instead of scrolling a scrollback the alternate screen does
/// not have. Shift keeps it pardes's, as xterm's Shift does. False when
@@ -207,19 +207,19 @@ pub fn sameBodyCell(a: ?Mouse.BodyHit, b: ?Mouse.BodyHit) bool {
fn programWheel(p: *Pardes, id: usize, m: Mouse, col: u16, row: u16) bool {
if (m.shift) return false;
const pane = p.panes[id] orelse return false;
- if (!pane.isTerminal() or !panes.terminal.ownsWheel(pane)) return false;
+ if (!pane.isTerminal() or !panes.Term.modes(pane.terminal).wheel) return false;
const r = p.view().rects[id];
const body_y = p.bodyTop(pane, r);
const gcol = std.math.clamp(col -| (r.x + config.GUTTER), 0, pane.cols -| 1);
const grow = std.math.clamp(row -| body_y, 0, pane.rows -| 1);
var buf: [64]u8 = undefined;
- const wheel: panes.terminal.MouseButton = switch (m.button) {
+ const wheel: panes.Term.MouseButton = switch (m.button) {
.wheel_up => .wheel_up,
.wheel_down => .wheel_down,
.wheel_left => .wheel_left,
else => .wheel_right,
};
- const bytes = panes.terminal.wheelBytes(pane, &buf, wheel, gcol, grow, .{ .alt = m.alt, .ctrl = m.ctrl }) orelse return true;
+ const bytes = panes.Term.wheel(pane.terminal.?, &buf, wheel, gcol, grow, .{ .alt = m.alt, .ctrl = m.ctrl }) orelse return true;
for (0..@intCast(config.wheel_rows)) |_| p.emitWrite(id, bytes);
return true;
}
@@ -249,7 +249,7 @@ fn programCell(p: *const Pardes, id: usize, col: u16, row: u16) ?struct { col: i
/// A pane whose program tracks the mouse (1000, 1002, 1003, or X10's 9)
/// and has the keyboard's raw input: its clicks are the program's.
fn tracksMouse(pane: *const Pane) bool {
- return pane.isTerminal() and pane.body.mode == .tty and panes.terminal.reportsMouse(pane);
+ return pane.isTerminal() and pane.body.mode == .tty and panes.Term.modes(pane.terminal).mouse;
}
/// A program that tracks the mouse gets it over its grid, as xterm gives
@@ -300,7 +300,7 @@ pub fn kindLeave(p: *Pardes) void {
fn programMouse(p: *Pardes, m: Mouse) bool {
const v = p.view();
- const button: ?panes.terminal.MouseButton = switch (m.button) {
+ const button: ?panes.Term.MouseButton = switch (m.button) {
.left => .left,
.middle => .middle,
.right => .right,
@@ -309,7 +309,7 @@ fn programMouse(p: *Pardes, m: Mouse) bool {
};
const bit: u3 = if (button) |b| @as(u3, 1) << @intCast(@backingInt(b)) else 0;
const at: struct { col: u16, row: u16 } = .{ .col = @min(m.col, v.screen_w -| 1), .row = @min(m.row, v.screen_h -| 1) };
- var mods: panes.terminal.MouseMods = .{ .shift = m.shift, .alt = m.alt, .ctrl = m.ctrl };
+ var mods: panes.Term.MouseMods = .{ .shift = m.shift, .alt = m.alt, .ctrl = m.ctrl };
var buf: [64]u8 = undefined;
if (v.mouse_grab) |*grab| {
if (grab.unshift) mods.shift = false;
@@ -326,14 +326,14 @@ fn programMouse(p: *Pardes, m: Mouse) bool {
const r = v.rects[grab.id];
const col: i32 = @as(i32, at.col) - @as(i32, r.x + config.GUTTER);
const row: i32 = @as(i32, at.row) - @as(i32, p.bodyTop(pane, r));
- const action: panes.terminal.MouseAction = switch (m.kind) {
+ const action: panes.Term.MouseAction = switch (m.kind) {
.press => .press,
.release => .release,
.drag, .motion => .motion,
};
if (m.kind == .press) grab.held |= bit;
if (m.kind == .release) grab.held &= ~bit;
- const bytes = panes.terminal.mouseBytes(pane, &buf, action, button, mods, col, row, grab.held != 0);
+ const bytes = panes.Term.mouse(pane.terminal.?, &buf, action, button, mods, col, row, grab.held != 0);
if (bytes.len > 0) p.emitWrite(grab.id, bytes);
if (grab.held == 0) v.mouse_grab = null;
return true;
@@ -357,7 +357,7 @@ fn programMouse(p: *Pardes, m: Mouse) bool {
pane.focus = .body;
pane.closePrompt();
v.mouse_grab = .{ .id = id, .serial = pane.serial, .held = bit, .unshift = shifted_to_program };
- const bytes = panes.terminal.mouseBytes(pane, &buf, .press, button, mods, cell.col, cell.row, true);
+ const bytes = panes.Term.mouse(pane.terminal.?, &buf, .press, button, mods, cell.col, cell.row, true);
if (bytes.len > 0) p.emitWrite(id, bytes);
return true;
},
@@ -365,11 +365,11 @@ fn programMouse(p: *Pardes, m: Mouse) bool {
// pardes's.
.release, .drag => return false,
.motion => {
- const bytes = panes.terminal.mouseBytes(pane, &buf, .motion, null, mods, cell.col, cell.row, false);
+ const bytes = panes.Term.mouse(pane.terminal.?, &buf, .motion, null, mods, cell.col, cell.row, false);
if (bytes.len > 0) p.emitWrite(id, bytes);
// Under 1003 the move is the program's; below that pardes
// hovers as ever.
- return panes.terminal.tracksAllMotion(pane);
+ return panes.Term.modes(pane.terminal).all_motion;
},
}
}
@@ -461,13 +461,13 @@ fn chordCutPaste(p: *Pardes, cut: bool) edit.Error!void {
if (cut) return;
const y = p.registers.text(p.gpa, pardes.Registers.default) orelse return;
if (y.len == 0) return;
- if (panes.terminal.reportsMouse(pane)) {
+ if (panes.Term.modes(pane.terminal).mouse) {
// A click where the text goes, so the program's cursor is there.
const col = @max(0, pane.sel[sel_slot].c1);
const row = @max(0, pane.sel[sel_slot].r1 - @as(i32, pane.tag_rows));
var mb: [64]u8 = undefined;
- for ([_]panes.terminal.MouseAction{ .press, .release }) |action| {
- const bytes = panes.terminal.mouseBytes(pane, &mb, action, .left, .{}, col, row, action == .press);
+ for ([_]panes.Term.MouseAction{ .press, .release }) |action| {
+ const bytes = panes.Term.mouse(pane.terminal.?, &mb, action, .left, .{}, col, row, action == .press);
if (bytes.len > 0) p.emitWrite(s.id, bytes);
}
}