diff options
Diffstat (limited to 'src/terminal.zig')
| -rw-r--r-- | src/terminal.zig | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/src/terminal.zig b/src/terminal.zig index d8f279dc..b4f0d353 100644 --- a/src/terminal.zig +++ b/src/terminal.zig @@ -142,6 +142,31 @@ pub const MarkedHandler = struct { } }; +fn ptyReport(handler: *ghostty_vt.TerminalStream.Handler, data: []const u8) void { + const state: *State = @alignCast(@fieldParentPtr("vt", handler.terminal)); + const room = state.reply.len - state.reply_len; + // A cut answer is worse than none: the program would read the start of + // a sequence and wait, or misparse what follows. + if (data.len > room) { + state.reply_dropped +|= 1; + return; + } + @memcpy(state.reply[state.reply_len..][0..data.len], data); + state.reply_len += @intCast(data.len); +} + +fn ptyDeviceAttrs(_: *ghostty_vt.TerminalStream.Handler) ghostty_vt.device_attributes.Attributes { + return .{}; +} + +/// CSI 14/16/18 t: the pane's size, and its cells' in pixels, which a +/// program sizes its kitty graphics by (yazi asks 16 t). Unknown, not asked. +fn ptySize(handler: *ghostty_vt.TerminalStream.Handler) ?ghostty_vt.size_report.Size { + const t = handler.terminal; + if (t.width_px == 0 or t.height_px == 0 or t.cols == 0 or t.rows == 0) return null; + return .{ .rows = t.rows, .columns = t.cols, .cell_width = t.width_px / t.cols, .cell_height = t.height_px / t.rows }; +} + pub const State = struct { /// What the emulator and this struct are allocated with: the core's, /// but on a screen-state replica the C heap (`emulator_gpa`), outside @@ -391,10 +416,6 @@ fn asGhostRgb(rgb: [3]u8) GColor.RGB { return .{ .r = rgb[0], .g = rgb[1], .b = rgb[2] }; } -fn asPardesColor(rgb: GColor.RGB) pardes.Color { - return .{ .rgb = .{ rgb.r, rgb.g, rgb.b } }; -} - /// The owned text standing in for `rows` live terminal rows, beginning at /// absolute surface row `row`. The emulator grid remains untouched underneath. pub const EditBuffer = struct { @@ -2198,6 +2219,10 @@ fn cellStyle(p: *Pardes, ci: ghostty_vt.PageList.Cell, filtered: ?*FilteredColor return cs; } +fn asPardesColor(rgb: GColor.RGB) pardes.Color { + return .{ .rgb = .{ rgb.r, rgb.g, rgb.b } }; +} + /// A program's colours mapped to the theme (Filter): a terminal's cells, or /// a +Pager's spans (`vt` null, the program's palette xterm's own). pub const FilteredColors = struct { @@ -2422,31 +2447,6 @@ pub fn undoStep(p: *Pardes, pane: *Pane, back: bool) void { pane.ensureCursorVisible(); } -fn ptyReport(handler: *ghostty_vt.TerminalStream.Handler, data: []const u8) void { - const state: *State = @alignCast(@fieldParentPtr("vt", handler.terminal)); - const room = state.reply.len - state.reply_len; - // A cut answer is worse than none: the program would read the start of - // a sequence and wait, or misparse what follows. - if (data.len > room) { - state.reply_dropped +|= 1; - return; - } - @memcpy(state.reply[state.reply_len..][0..data.len], data); - state.reply_len += @intCast(data.len); -} - -fn ptyDeviceAttrs(_: *ghostty_vt.TerminalStream.Handler) ghostty_vt.device_attributes.Attributes { - return .{}; -} - -/// CSI 14/16/18 t: the pane's size, and its cells' in pixels, which a -/// program sizes its kitty graphics by (yazi asks 16 t). Unknown, not asked. -fn ptySize(handler: *ghostty_vt.TerminalStream.Handler) ?ghostty_vt.size_report.Size { - const t = handler.terminal; - if (t.width_px == 0 or t.height_px == 0 or t.cols == 0 or t.rows == 0) return null; - return .{ .rows = t.rows, .columns = t.cols, .cell_width = t.width_px / t.cols, .cell_height = t.height_px / t.rows }; -} - /// The emulator's size in pixels follows the shell's cells: kitty graphics /// placements are sized by it, and CSI 14/16 t report it. fn syncPixels(p: *const Pardes, pane: *Pane) void { |
