summaryrefslogtreecommitdiff
path: root/core/term/terminal.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/term/terminal.zig')
-rw-r--r--core/term/terminal.zig35
1 files changed, 8 insertions, 27 deletions
diff --git a/core/term/terminal.zig b/core/term/terminal.zig
index a4120f5a..4de389bd 100644
--- a/core/term/terminal.zig
+++ b/core/term/terminal.zig
@@ -181,9 +181,6 @@ pub const State = struct {
reply: [4096]u8 = undefined,
reply_len: u16 = 0,
reply_dropped: u32 = 0,
- /// The grid cell the program last heard the mouse at, so motion is
- /// reported once per cell.
- mouse_cell: ?ghostty_vt.Coordinate = null,
/// The kitty graphics its program placed, as drawn (TerminalImages.zig).
images: TerminalImages = if (images_enabled) .{} else {},
/// Counts the emulator's writes (output, a resize, its view scrolled):
@@ -257,8 +254,6 @@ pub fn parts(s: *const State) Term.Parts {
return .{
.reply = s.reply[0..s.reply_len],
.reply_dropped = s.reply_dropped,
- .mouse_cell = if (s.mouse_cell) |c| .{ .x = c.x, .y = c.y } else null,
- .petscii = if (comptime images_enabled) s.images.petscii else false,
.view = s.vt.screens.active.pages.scrollbar().offset,
.phase = h.phase,
.started = h.started,
@@ -370,8 +365,6 @@ fn install(out: *State, continuation: ghostty_vt.snapshot.Continuation, saved: *
@memcpy(out.reply[0..reply.len], reply);
out.reply_len = @intCast(reply.len);
out.reply_dropped = saved.reply_dropped;
- out.mouse_cell = coordinate(saved.mouse_cell);
- out.images = if (images_enabled) .{ .petscii = saved.petscii } else {};
const h = &out.stream.handler;
h.phase = saved.phase;
h.started = saved.started;
@@ -674,10 +667,13 @@ pub fn paste(state: ?*const State, text: []u8) [3][]const u8 {
/// 1015 urxvt, 1005 UTF-8, else X10) how, modifiers as shift+4, meta+8,
/// ctrl+16. `col`,`row` are the 0-based grid cell; a drag that left the
/// grid is reported clamped to its edge, motion only when the cell
-/// changed. Empty when the program does not hear of it.
-pub fn mouse(state: *State, buf: *[64]u8, action: Term.MouseAction, button: ?Term.MouseButton, mods: Term.MouseMods, col: i32, row: i32, any_pressed: bool) []const u8 {
+/// changed from `last`, the cell it last heard of (its pane's, which a
+/// rollback puts back). Empty when the program does not hear of it.
+pub fn mouse(state: *State, last: *?Term.Parts.Coordinate, buf: *[64]u8, action: Term.MouseAction, button: ?Term.MouseButton, mods: Term.MouseMods, col: i32, row: i32, any_pressed: bool) []const u8 {
const input = ghostty_vt.input;
var writer = std.Io.Writer.fixed(buf);
+ var cell = coordinate(last.*);
+ defer last.* = if (cell) |c| .{ .x = c.x, .y = c.y } else null;
var opts: input.MouseEncodeOptions = .{
.event = state.vt.flags.mouse_event,
.format = state.vt.flags.mouse_format,
@@ -687,7 +683,7 @@ pub fn mouse(state: *State, buf: *[64]u8, action: Term.MouseAction, button: ?Ter
.padding = .{},
},
.any_button_pressed = any_pressed,
- .last_cell = &state.mouse_cell,
+ .last_cell = &cell,
};
// A release is always reported; the rest only over the grid, or held.
if (action == .release) opts.any_button_pressed = true;
@@ -716,7 +712,7 @@ pub fn mouse(state: *State, buf: *[64]u8, action: Term.MouseAction, button: ?Ter
/// program: its mouse report while it tracks the mouse, else, on the
/// alternate screen, an arrow key in the cursor keys' mode (none for a
/// sideways turn). Null when the wheel is not the program's (`Modes.wheel`).
-pub fn wheel(state: *State, buf: *[64]u8, turn: Term.MouseButton, col: u16, row: u16, mods: Term.MouseMods) ?[]const u8 {
+pub fn wheel(state: *State, last: *?Term.Parts.Coordinate, buf: *[64]u8, turn: Term.MouseButton, col: u16, row: u16, mods: Term.MouseMods) ?[]const u8 {
const now = modes(state);
if (!now.wheel) return null;
const m = &state.vt.modes;
@@ -725,7 +721,7 @@ pub fn wheel(state: *State, buf: *[64]u8, turn: Term.MouseButton, col: u16, row:
.wheel_down => if (m.get(.cursor_keys)) "\x1bOB" else "\x1b[B",
else => null,
};
- return mouse(state, buf, .press, turn, mods, col, row, false);
+ return mouse(state, last, buf, .press, turn, mods, col, row, false);
}
/// The whole scrollback as plain text, `gpa`-owned: what a terminal's body
@@ -1536,21 +1532,6 @@ pub fn due(state: *const State) ?u64 {
return state.images.animation_due_ms;
}
-/// The Petscii builtin on a terminal: its kitty graphics as glyph art,
-/// or back to pixels where the shell draws pixels.
-pub fn togglePetscii(state: *State) void {
- if (comptime !images_enabled) return;
- state.images.petscii = !state.images.petscii;
-}
-
-/// Whether the pane draws its kitty graphics as glyph art by choice; null
-/// for a pane with no emulator.
-pub fn petscii(maybe: ?*const State) ?bool {
- if (comptime !images_enabled) return null;
- const state = maybe orelse return null;
- return state.images.petscii;
-}
-
/// Whether the screen showing holds any kitty graphics image.
pub fn hasImages(maybe: ?*const State) bool {
if (comptime !images_enabled) return false;