1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
//! The terminal as the core sees it (docs/next-terminal.md, Phase 0): the
//! entries the core calls and the plain records they take and give. A
//! terminal pane holds a `*State` the core never looks into: what it knows
//! of one it is told here, as numbers, bytes and text. The emulator
//! (ghostty-vt) and what it brings stay behind this file, in src/term/;
//! this is the one file outside it that names a file inside it (and so
//! the one place Phase 1 turns into the module's registration).
const std = @import("std");
const terminal = @import("term/terminal.zig");
/// A terminal pane's emulator, its parse and what pardes keeps beside it.
pub const State = terminal.State;
// ---- lifecycle ----
/// A new emulator, `cols` by `rows`, allocated with `gpa` (its own from
/// then on).
pub const open = terminal.open;
/// Its emulator and what it holds, freed; the kitty images' caches were
/// `gpa`'s.
pub const close = terminal.close;
/// When its next kitty animation frame is due (ms on the core's clock), as
/// its last drawn frame left it; null when nothing plays.
pub const due = terminal.due;
/// Loaded from a dump without its shell: its program's modes reset, its
/// history marked off from what the next shell prints.
pub const revive = terminal.revive;
/// The PNG resize workers kitty images are decoded with, started and
/// stopped with the host.
pub const start = terminal.TerminalImages.start;
pub const stop = terminal.TerminalImages.stop;
// ---- output and view ----
/// One read of its program's output (`Told` says where the tracked rows
/// went).
pub const feed = terminal.feed;
/// Where the view and the cursor are (`Grid`).
pub const grid = terminal.grid;
/// Its view to a row of its history, or onto its output (null).
pub const viewTo = terminal.viewTo;
/// Its view moved by a number of rows (negative scrolls back).
pub const scroll = terminal.scroll;
/// Its view back onto its output.
pub const follow = terminal.follow;
/// Its grid reflowed, now or when `resizeDeferred` makes it.
pub const resize = terminal.resize;
pub const resizeDeferred = terminal.resizeDeferred;
/// Its cells' size in pixels (kitty graphics, CSI 14/16 t).
pub const cellPixels = terminal.cellPixels;
/// What it answered its program since the last call, to be written to its
/// pty.
pub const replies = terminal.replies;
/// Where the view and the cursor are, in rows counted from the top of the
/// history: `total` rows, the view's top at `offset`, `len` of them shown.
/// All zero without a terminal.
pub const Grid = struct {
total: usize = 0,
offset: usize = 0,
len: usize = 0,
/// The cursor, in cells of the active area (the history's last `len`
/// rows).
cursor_x: u16 = 0,
cursor_y: u16 = 0,
/// The program shows the cursor (DECTCEM).
cursor_visible: bool = false,
/// The view's top row while it is scrolled to one, null while it
/// follows the output.
view: ?usize = null,
};
/// What a `feed` told the rows the core keeps positions on: each tracked
/// row where it is after the read, whether the program erased it, whether
/// it cleared the screen, whether the pages the rows were on lived through
/// it (a reset can take them) and whether a row could not be followed (no
/// memory for its pin). Taped: a screen-state replica, which feeds
/// nothing, is told its authority's.
pub const Told = struct { rows: []const i32, erased: []const bool, cleared: bool, alive: bool, failed: bool };
|