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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
//! Inline-image payloads carried through the authority.
//!
//! ## The seam: the authority owns TRANSMISSION, the renderer owns PIXELS
//!
//! A terminal image arrives as an escape sequence carrying encoded bytes —
//! a sixel stream, or a PNG / raw RGBA under the kitty protocol. Two
//! separate facts come out of that, and conflating them is what makes this
//! hard:
//!
//! 1. **What was transmitted, and where the cursor was.** That is terminal
//! state. It belongs to the authority, exactly like a cell.
//! 2. **What those bytes look like as pixels.** That is rendering. It needs
//! a PNG decoder, a sixel decoder, a GPU texture.
//!
//! tear owns (1) and deliberately **not** (2). The payload is stored
//! undecoded, so `tear-core` needs no `image` crate, no `icy_sixel`, and no
//! GPU dependency — a daemon on a headless box carries images perfectly
//! well without being able to draw one.
//!
//! This is what closes the last flip blocker in
//! [`SHUKEN`](https://github.com/pleme-io/tear/blob/main/docs/SHUKEN.md).
//! Before it, `GridState` implemented no `hook`/`put`/`unhook` and vte
//! silently swallows APC in its `SosPmApcString` state, so **every sixel
//! and every kitty image vanished with no error and no flag** — a renderer
//! could not even know content had been dropped. Carrying them undecoded
//! keeps mado's decoders exactly where they are while making the authority
//! lossless.
use ;
/// Largest payload accepted for one image.
///
/// Matches mado's `SIXEL_DCS_MAX` / `APC_MAX`. A terminal image is bounded
/// by what a program can reasonably paint; anything past this is a runaway
/// or hostile stream, and accepting it would let a child process drive the
/// daemon out of memory.
pub const GRAPHIC_PAYLOAD_MAX: usize = 8 * 1024 * 1024;
/// Which protocol delivered a payload. The renderer needs this to pick a
/// decoder; the authority only needs to record it faithfully.
/// One transmitted image, undecoded, with the cursor position it arrived
/// at.