@clarkarch/opentui-fork-linux-arm64 0.8.1-fork.2 → 0.8.4-fork.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/libopentui.so +0 -0
- package/opentui.h +3918 -0
- package/package.json +1 -1
package/opentui.h
ADDED
|
@@ -0,0 +1,3918 @@
|
|
|
1
|
+
#ifndef OPENTUI_H
|
|
2
|
+
#define OPENTUI_H
|
|
3
|
+
|
|
4
|
+
#include <stdint.h>
|
|
5
|
+
|
|
6
|
+
#ifdef __cplusplus
|
|
7
|
+
extern "C" {
|
|
8
|
+
#endif
|
|
9
|
+
|
|
10
|
+
/* Experimental context and session ABI, version 2. This header does not stabilize the
|
|
11
|
+
* library's legacy renderer, Yoga, or other FFI exports. Use matching headers
|
|
12
|
+
* and artifacts. The restricted scene surface supports roots, boxes, plain text,
|
|
13
|
+
* sliders, standard arrows, editor views, and images. */
|
|
14
|
+
#define OT_CONTEXT_ABI_VERSION UINT32_C(2)
|
|
15
|
+
|
|
16
|
+
typedef int32_t ot_status;
|
|
17
|
+
#define OT_OK INT32_C(0)
|
|
18
|
+
#define OT_INVALID_ARGUMENT (-INT32_C(1))
|
|
19
|
+
#define OT_UNSUPPORTED_VERSION (-INT32_C(2))
|
|
20
|
+
#define OT_OUT_OF_MEMORY (-INT32_C(3))
|
|
21
|
+
#define OT_WRONG_THREAD (-INT32_C(4))
|
|
22
|
+
#define OT_INTERNAL_ERROR (-INT32_C(5))
|
|
23
|
+
#define OT_CONTEXT_BUSY (-INT32_C(6))
|
|
24
|
+
#define OT_WRONG_CONTEXT (-INT32_C(7))
|
|
25
|
+
#define OT_WRONG_KIND (-INT32_C(8))
|
|
26
|
+
#define OT_STALE_HANDLE (-INT32_C(9))
|
|
27
|
+
#define OT_WRONG_SESSION (-INT32_C(10))
|
|
28
|
+
#define OT_OUTPUT_BACKPRESSURE (-INT32_C(11))
|
|
29
|
+
#define OT_SESSION_CLOSED (-INT32_C(12))
|
|
30
|
+
#define OT_OUTPUT_BUSY (-INT32_C(13))
|
|
31
|
+
#define OT_STALE_OUTPUT (-INT32_C(14))
|
|
32
|
+
#define OT_OUTPUT_FAILED (-INT32_C(15))
|
|
33
|
+
#define OT_OBJECT_LIMIT (-INT32_C(16))
|
|
34
|
+
#define OT_RENDERER_ATTACHED (-INT32_C(17))
|
|
35
|
+
#define OT_RENDERER_NOT_ATTACHED (-INT32_C(18))
|
|
36
|
+
#define OT_INVALID_PHASE (-INT32_C(19))
|
|
37
|
+
#define OT_CONTROL_PACKET_LIMIT (-INT32_C(20))
|
|
38
|
+
#define OT_LEASE_LIMIT (-INT32_C(21))
|
|
39
|
+
#define OT_LEASE_BYTES_LIMIT (-INT32_C(22))
|
|
40
|
+
#define OT_STALE_LEASE (-INT32_C(23))
|
|
41
|
+
#define OT_UNSUPPORTED_RESOURCE (-INT32_C(24))
|
|
42
|
+
#define OT_STALE_FRAME (-INT32_C(25))
|
|
43
|
+
#define OT_LAYOUT_LIMIT (-INT32_C(26))
|
|
44
|
+
#define OT_FRAME_BUSY (-INT32_C(27))
|
|
45
|
+
#define OT_FRAME_REQUEST_LIMIT (-INT32_C(28))
|
|
46
|
+
#define OT_IMAGE_UNSUPPORTED_FORMAT (-INT32_C(40))
|
|
47
|
+
#define OT_IMAGE_UNSUPPORTED_COLOR_SPACE (-INT32_C(41))
|
|
48
|
+
#define OT_IMAGE_MALFORMED_DATA (-INT32_C(42))
|
|
49
|
+
#define OT_IMAGE_DIMENSION_LIMIT (-INT32_C(43))
|
|
50
|
+
#define OT_IMAGE_MEMORY_LIMIT (-INT32_C(44))
|
|
51
|
+
#define OT_IMAGE_OUTPUT_TOO_SMALL (-INT32_C(45))
|
|
52
|
+
#define OT_IMAGE_UNSUPPORTED_FEATURE (-INT32_C(46))
|
|
53
|
+
#define OT_IMAGE_BUSY (-INT32_C(47))
|
|
54
|
+
#define OT_VIDEO_FAILED (-INT32_C(60))
|
|
55
|
+
#define OT_AUDIO_DECODE_FAILED (-INT32_C(61))
|
|
56
|
+
#define OT_AUDIO_DEVICE_FAILED (-INT32_C(62))
|
|
57
|
+
|
|
58
|
+
/* A context owns its native resources and I/O storage. Only its creating OS
|
|
59
|
+
* thread may call its functions, including error queries and destruction.
|
|
60
|
+
* Separate contexts may run on separate threads. Do not race a call with
|
|
61
|
+
* destruction. A successful destroy invalidates every copy of the pointer;
|
|
62
|
+
* stale, forged, and already-destroyed pointers are caller errors.
|
|
63
|
+
* Callbacks run synchronously on the owner thread and must return normally.
|
|
64
|
+
* A C++ exception, longjmp, or thread exit through native frames skips native
|
|
65
|
+
* cleanup and is undefined behavior. */
|
|
66
|
+
typedef struct ot_context ot_context;
|
|
67
|
+
|
|
68
|
+
/* Context-qualified identity. A destroyed slot cannot identify its replacement.
|
|
69
|
+
* Numeric IDs belong to one native image and its load lifetime; independent
|
|
70
|
+
* images can issue equal IDs. Do not reuse handles or tickets across images
|
|
71
|
+
* or after unloading.
|
|
72
|
+
* Copying this value does not retain the object. An all-zero handle is invalid. */
|
|
73
|
+
typedef struct ot_handle {
|
|
74
|
+
uint64_t context_id;
|
|
75
|
+
uint32_t slot;
|
|
76
|
+
uint32_t generation;
|
|
77
|
+
} ot_handle;
|
|
78
|
+
|
|
79
|
+
#define OT_SCENE_ROOT UINT32_C(0)
|
|
80
|
+
#define OT_SCENE_BOX UINT32_C(1)
|
|
81
|
+
#define OT_SCENE_TEXT UINT32_C(2)
|
|
82
|
+
#define OT_SCENE_SLIDER UINT32_C(3)
|
|
83
|
+
#define OT_SCENE_ARROW UINT32_C(4)
|
|
84
|
+
#define OT_SCENE_EDITOR UINT32_C(5)
|
|
85
|
+
#define OT_SCENE_CUSTOM UINT32_C(6)
|
|
86
|
+
#define OT_SCENE_TEXT_VIEW UINT32_C(7)
|
|
87
|
+
#define OT_SCENE_IMAGE UINT32_C(8)
|
|
88
|
+
#define OT_SCENE_VIDEO UINT32_C(9)
|
|
89
|
+
#define OT_SCENE_WRAP_NONE UINT32_C(0)
|
|
90
|
+
#define OT_SCENE_WRAP_CHAR UINT32_C(1)
|
|
91
|
+
#define OT_SCENE_WRAP_WORD UINT32_C(2)
|
|
92
|
+
#define OT_SCENE_ALIGN_LEFT UINT32_C(0)
|
|
93
|
+
#define OT_SCENE_ALIGN_CENTER UINT32_C(1)
|
|
94
|
+
#define OT_SCENE_ALIGN_RIGHT UINT32_C(2)
|
|
95
|
+
|
|
96
|
+
/* Layout property groups and kinds. ENUM/FLOAT require edge=OT_EDGE_NONE and
|
|
97
|
+
* unit=OT_UNIT_UNDEFINED. VALUE uses an edge for MARGIN/PADDING/POSITION and a
|
|
98
|
+
* gutter for GAP; other kinds ignore edge. DIMENSION requires OT_EDGE_NONE.
|
|
99
|
+
* BORDER is read-only, uses OT_STYLE_BORDER_WIDTH, and reads an OT_EDGE_* border width.
|
|
100
|
+
* Read dimensions through VALUE WIDTH/HEIGHT or DIMENSION WIDTH/HEIGHT.
|
|
101
|
+
* Numeric lengths use terminal display cells; percent uses 0..100 for 0..100%.
|
|
102
|
+
* UNDEFINED ignores value. AUTO ignores value and is supported only by width,
|
|
103
|
+
* height, flex basis, margin, and position. NaN clears a numeric value; infinity
|
|
104
|
+
* rejects. ENUM values must be nonnegative integers from the named family.
|
|
105
|
+
* Scene layout requires box geometry; Yoga's display:contents is unsupported. */
|
|
106
|
+
#define OT_STYLE_ENUM UINT32_C(0)
|
|
107
|
+
#define OT_STYLE_FLOAT UINT32_C(1)
|
|
108
|
+
#define OT_STYLE_VALUE UINT32_C(2)
|
|
109
|
+
#define OT_STYLE_BORDER UINT32_C(3)
|
|
110
|
+
#define OT_STYLE_DIMENSION UINT32_C(4)
|
|
111
|
+
#define OT_STYLE_BORDER_WIDTH UINT32_C(0)
|
|
112
|
+
#define OT_STYLE_FLAGS_NONE UINT32_C(0)
|
|
113
|
+
#define OT_STYLE_DISABLE_FLEX_SHRINK UINT32_C(1)
|
|
114
|
+
#define OT_STYLE_CONTENT UINT32_C(2)
|
|
115
|
+
#define OT_STYLE_ENUM_DIRECTION UINT32_C(0)
|
|
116
|
+
#define OT_STYLE_ENUM_FLEX_DIRECTION UINT32_C(1)
|
|
117
|
+
#define OT_STYLE_ENUM_JUSTIFY_CONTENT UINT32_C(2)
|
|
118
|
+
#define OT_STYLE_ENUM_ALIGN_CONTENT UINT32_C(3)
|
|
119
|
+
#define OT_STYLE_ENUM_ALIGN_ITEMS UINT32_C(4)
|
|
120
|
+
#define OT_STYLE_ENUM_ALIGN_SELF UINT32_C(5)
|
|
121
|
+
#define OT_STYLE_ENUM_POSITION_TYPE UINT32_C(6)
|
|
122
|
+
#define OT_STYLE_ENUM_FLEX_WRAP UINT32_C(7)
|
|
123
|
+
#define OT_STYLE_ENUM_OVERFLOW UINT32_C(8)
|
|
124
|
+
#define OT_STYLE_ENUM_DISPLAY UINT32_C(9)
|
|
125
|
+
#define OT_STYLE_ENUM_BOX_SIZING UINT32_C(10)
|
|
126
|
+
/* Scene layout only: LIST stacks in-flow children top to bottom without flex. */
|
|
127
|
+
#define OT_STYLE_ENUM_LAYOUT_MODE UINT32_C(11)
|
|
128
|
+
#define OT_STYLE_FLOAT_FLEX UINT32_C(0)
|
|
129
|
+
#define OT_STYLE_FLOAT_FLEX_GROW UINT32_C(1)
|
|
130
|
+
#define OT_STYLE_FLOAT_FLEX_SHRINK UINT32_C(2)
|
|
131
|
+
#define OT_STYLE_FLOAT_ASPECT_RATIO UINT32_C(3)
|
|
132
|
+
#define OT_STYLE_VALUE_WIDTH UINT32_C(0)
|
|
133
|
+
#define OT_STYLE_VALUE_HEIGHT UINT32_C(1)
|
|
134
|
+
#define OT_STYLE_VALUE_MIN_WIDTH UINT32_C(2)
|
|
135
|
+
#define OT_STYLE_VALUE_MIN_HEIGHT UINT32_C(3)
|
|
136
|
+
#define OT_STYLE_VALUE_MAX_WIDTH UINT32_C(4)
|
|
137
|
+
#define OT_STYLE_VALUE_MAX_HEIGHT UINT32_C(5)
|
|
138
|
+
#define OT_STYLE_VALUE_FLEX_BASIS UINT32_C(6)
|
|
139
|
+
#define OT_STYLE_VALUE_MARGIN UINT32_C(7)
|
|
140
|
+
#define OT_STYLE_VALUE_PADDING UINT32_C(8)
|
|
141
|
+
#define OT_STYLE_VALUE_POSITION UINT32_C(9)
|
|
142
|
+
#define OT_STYLE_VALUE_GAP UINT32_C(10)
|
|
143
|
+
#define OT_DIMENSION_WIDTH UINT32_C(0)
|
|
144
|
+
#define OT_DIMENSION_HEIGHT UINT32_C(1)
|
|
145
|
+
#define OT_UNIT_UNDEFINED UINT32_C(0)
|
|
146
|
+
#define OT_UNIT_POINT UINT32_C(1)
|
|
147
|
+
#define OT_UNIT_PERCENT UINT32_C(2)
|
|
148
|
+
#define OT_UNIT_AUTO UINT32_C(3)
|
|
149
|
+
#define OT_EDGE_NONE UINT32_C(0)
|
|
150
|
+
#define OT_EDGE_LEFT UINT32_C(0)
|
|
151
|
+
#define OT_EDGE_TOP UINT32_C(1)
|
|
152
|
+
#define OT_EDGE_RIGHT UINT32_C(2)
|
|
153
|
+
#define OT_EDGE_BOTTOM UINT32_C(3)
|
|
154
|
+
#define OT_EDGE_START UINT32_C(4)
|
|
155
|
+
#define OT_EDGE_END UINT32_C(5)
|
|
156
|
+
#define OT_EDGE_HORIZONTAL UINT32_C(6)
|
|
157
|
+
#define OT_EDGE_VERTICAL UINT32_C(7)
|
|
158
|
+
#define OT_EDGE_ALL UINT32_C(8)
|
|
159
|
+
#define OT_GUTTER_COLUMN UINT32_C(0)
|
|
160
|
+
#define OT_GUTTER_ROW UINT32_C(1)
|
|
161
|
+
#define OT_GUTTER_ALL UINT32_C(2)
|
|
162
|
+
#define OT_DIRECTION_INHERIT UINT32_C(0)
|
|
163
|
+
#define OT_DIRECTION_LTR UINT32_C(1)
|
|
164
|
+
#define OT_DIRECTION_RTL UINT32_C(2)
|
|
165
|
+
#define OT_FLEX_DIRECTION_COLUMN UINT32_C(0)
|
|
166
|
+
#define OT_FLEX_DIRECTION_COLUMN_REVERSE UINT32_C(1)
|
|
167
|
+
#define OT_FLEX_DIRECTION_ROW UINT32_C(2)
|
|
168
|
+
#define OT_FLEX_DIRECTION_ROW_REVERSE UINT32_C(3)
|
|
169
|
+
#define OT_JUSTIFY_FLEX_START UINT32_C(0)
|
|
170
|
+
#define OT_JUSTIFY_CENTER UINT32_C(1)
|
|
171
|
+
#define OT_JUSTIFY_FLEX_END UINT32_C(2)
|
|
172
|
+
#define OT_JUSTIFY_SPACE_BETWEEN UINT32_C(3)
|
|
173
|
+
#define OT_JUSTIFY_SPACE_AROUND UINT32_C(4)
|
|
174
|
+
#define OT_JUSTIFY_SPACE_EVENLY UINT32_C(5)
|
|
175
|
+
#define OT_ALIGN_AUTO UINT32_C(0)
|
|
176
|
+
#define OT_ALIGN_FLEX_START UINT32_C(1)
|
|
177
|
+
#define OT_ALIGN_CENTER UINT32_C(2)
|
|
178
|
+
#define OT_ALIGN_FLEX_END UINT32_C(3)
|
|
179
|
+
#define OT_ALIGN_STRETCH UINT32_C(4)
|
|
180
|
+
#define OT_ALIGN_BASELINE UINT32_C(5)
|
|
181
|
+
#define OT_ALIGN_SPACE_BETWEEN UINT32_C(6)
|
|
182
|
+
#define OT_ALIGN_SPACE_AROUND UINT32_C(7)
|
|
183
|
+
#define OT_ALIGN_SPACE_EVENLY UINT32_C(8)
|
|
184
|
+
#define OT_POSITION_STATIC UINT32_C(0)
|
|
185
|
+
#define OT_POSITION_RELATIVE UINT32_C(1)
|
|
186
|
+
#define OT_POSITION_ABSOLUTE UINT32_C(2)
|
|
187
|
+
#define OT_FLEX_WRAP_NONE UINT32_C(0)
|
|
188
|
+
#define OT_FLEX_WRAP_WRAP UINT32_C(1)
|
|
189
|
+
#define OT_FLEX_WRAP_REVERSE UINT32_C(2)
|
|
190
|
+
#define OT_OVERFLOW_VISIBLE UINT32_C(0)
|
|
191
|
+
#define OT_OVERFLOW_HIDDEN UINT32_C(1)
|
|
192
|
+
#define OT_OVERFLOW_SCROLL UINT32_C(2)
|
|
193
|
+
#define OT_DISPLAY_FLEX UINT32_C(0)
|
|
194
|
+
#define OT_DISPLAY_NONE UINT32_C(1)
|
|
195
|
+
#define OT_BOX_SIZING_BORDER_BOX UINT32_C(0)
|
|
196
|
+
#define OT_BOX_SIZING_CONTENT_BOX UINT32_C(1)
|
|
197
|
+
#define OT_LAYOUT_MODE_FLEX UINT32_C(0)
|
|
198
|
+
#define OT_LAYOUT_MODE_LIST UINT32_C(1)
|
|
199
|
+
/* Yoga values for the standalone Yoga bindings only; scene styles reject
|
|
200
|
+
* DISPLAY_CONTENTS (OT_STYLE_ENUM_DISPLAY_MAX). */
|
|
201
|
+
#define OT_DISPLAY_CONTENTS UINT32_C(2)
|
|
202
|
+
#define OT_YOGA_ERRATA_NONE UINT32_C(0)
|
|
203
|
+
#define OT_YOGA_ERRATA_STRETCH_FLEX_BASIS UINT32_C(1)
|
|
204
|
+
#define OT_YOGA_ERRATA_ABSOLUTE_POSITION_WITHOUT_INSETS_EXCLUDES_PADDING UINT32_C(2)
|
|
205
|
+
#define OT_YOGA_ERRATA_ABSOLUTE_PERCENT_AGAINST_INNER_SIZE UINT32_C(4)
|
|
206
|
+
#define OT_YOGA_ERRATA_ALL UINT32_C(2147483647)
|
|
207
|
+
#define OT_YOGA_ERRATA_CLASSIC UINT32_C(2147483646)
|
|
208
|
+
#define OT_YOGA_EXPERIMENTAL_FEATURE_WEB_FLEX_BASIS UINT32_C(0)
|
|
209
|
+
#define OT_YOGA_LOG_LEVEL_ERROR UINT32_C(0)
|
|
210
|
+
#define OT_YOGA_LOG_LEVEL_WARN UINT32_C(1)
|
|
211
|
+
#define OT_YOGA_LOG_LEVEL_INFO UINT32_C(2)
|
|
212
|
+
#define OT_YOGA_LOG_LEVEL_DEBUG UINT32_C(3)
|
|
213
|
+
#define OT_YOGA_LOG_LEVEL_VERBOSE UINT32_C(4)
|
|
214
|
+
#define OT_YOGA_LOG_LEVEL_FATAL UINT32_C(5)
|
|
215
|
+
#define OT_YOGA_NODE_TYPE_DEFAULT UINT32_C(0)
|
|
216
|
+
#define OT_YOGA_NODE_TYPE_TEXT UINT32_C(1)
|
|
217
|
+
/* Inclusive enum limits also drive generated host validation. */
|
|
218
|
+
#define OT_STYLE_ENUM_DIRECTION_MAX OT_DIRECTION_RTL
|
|
219
|
+
#define OT_STYLE_ENUM_FLEX_DIRECTION_MAX OT_FLEX_DIRECTION_ROW_REVERSE
|
|
220
|
+
#define OT_STYLE_ENUM_JUSTIFY_CONTENT_MAX OT_JUSTIFY_SPACE_EVENLY
|
|
221
|
+
#define OT_STYLE_ENUM_ALIGN_CONTENT_MAX OT_ALIGN_SPACE_EVENLY
|
|
222
|
+
#define OT_STYLE_ENUM_ALIGN_ITEMS_MAX OT_ALIGN_SPACE_EVENLY
|
|
223
|
+
#define OT_STYLE_ENUM_ALIGN_SELF_MAX OT_ALIGN_SPACE_EVENLY
|
|
224
|
+
#define OT_STYLE_ENUM_POSITION_TYPE_MAX OT_POSITION_ABSOLUTE
|
|
225
|
+
#define OT_STYLE_ENUM_FLEX_WRAP_MAX OT_FLEX_WRAP_REVERSE
|
|
226
|
+
#define OT_STYLE_ENUM_OVERFLOW_MAX OT_OVERFLOW_SCROLL
|
|
227
|
+
#define OT_STYLE_ENUM_DISPLAY_MAX OT_DISPLAY_NONE
|
|
228
|
+
#define OT_STYLE_ENUM_BOX_SIZING_MAX OT_BOX_SIZING_CONTENT_BOX
|
|
229
|
+
#define OT_STYLE_ENUM_LAYOUT_MODE_MAX OT_LAYOUT_MODE_LIST
|
|
230
|
+
#define OT_MEASURE_UNDEFINED UINT32_C(0)
|
|
231
|
+
#define OT_MEASURE_EXACTLY UINT32_C(1)
|
|
232
|
+
#define OT_MEASURE_AT_MOST UINT32_C(2)
|
|
233
|
+
#define OT_LAYOUT_PUBLIC UINT32_C(0)
|
|
234
|
+
#define OT_LAYOUT_YOGA UINT32_C(1)
|
|
235
|
+
#define OT_LAYOUT_PAINT UINT32_C(2)
|
|
236
|
+
#define OT_LAYOUT_CONTENT UINT32_C(3)
|
|
237
|
+
|
|
238
|
+
/* Border masks are paint bits, not OT_EDGE_* layout selectors. */
|
|
239
|
+
#define OT_BORDER_NONE UINT32_C(0)
|
|
240
|
+
#define OT_BORDER_LEFT UINT32_C(1)
|
|
241
|
+
#define OT_BORDER_BOTTOM UINT32_C(2)
|
|
242
|
+
#define OT_BORDER_RIGHT UINT32_C(4)
|
|
243
|
+
#define OT_BORDER_TOP UINT32_C(8)
|
|
244
|
+
#define OT_BORDER_ALL UINT32_C(15)
|
|
245
|
+
#define OT_BORDER_SINGLE UINT32_C(0)
|
|
246
|
+
#define OT_BORDER_DOUBLE UINT32_C(1)
|
|
247
|
+
#define OT_BORDER_ROUNDED UINT32_C(2)
|
|
248
|
+
#define OT_BORDER_HEAVY UINT32_C(3)
|
|
249
|
+
|
|
250
|
+
/* Color words store RGBA bytes in their low eight bits, not 16-bit channels.
|
|
251
|
+
* The high bytes store metadata: word[0] has the palette slot, word[1] has the
|
|
252
|
+
* intent, and word[2..3] have zero high bytes. RGB and DEFAULT require slot=0.
|
|
253
|
+
* INDEXED requires a slot in 0..255. RGB snapshots supply fallback/blending
|
|
254
|
+
* colors for INDEXED and DEFAULT. Alpha is 0..255 for every intent.
|
|
255
|
+
* For example, {255, 0, 0, 255} is opaque red; {255, 0, 0, 0} is transparent.
|
|
256
|
+
* Indexed red at slot 1: {255 | (1 << OT_COLOR_META_SHIFT),
|
|
257
|
+
* OT_COLOR_INDEXED << OT_COLOR_META_SHIFT, 0, 255}.
|
|
258
|
+
* Default white: {255, 255 | (OT_COLOR_DEFAULT << OT_COLOR_META_SHIFT), 255, 255}.
|
|
259
|
+
* Float color outputs such as cursor state instead use normalized 0..1 channels. */
|
|
260
|
+
#define OT_COLOR_RGB UINT32_C(0)
|
|
261
|
+
#define OT_COLOR_INDEXED UINT32_C(1)
|
|
262
|
+
#define OT_COLOR_DEFAULT UINT32_C(2)
|
|
263
|
+
#define OT_COLOR_CHANNEL_MASK UINT32_C(255)
|
|
264
|
+
#define OT_COLOR_META_SHIFT UINT32_C(8)
|
|
265
|
+
/* The RGB snapshot of each palette slot, as 0xRRGGBB: slots 0..15 are ANSI_n;
|
|
266
|
+
* slots 16..231 are a 6x6x6 cube whose channel level n is 0 for n=0 and
|
|
267
|
+
* CUBE_BASE + CUBE_STEP * n otherwise; slots 232..255 are a gray ramp of
|
|
268
|
+
* GRAY_BASE + GRAY_STEP * (slot - 232). */
|
|
269
|
+
#define OT_COLOR_ANSI_0 UINT32_C(0x000000)
|
|
270
|
+
#define OT_COLOR_ANSI_1 UINT32_C(0x800000)
|
|
271
|
+
#define OT_COLOR_ANSI_2 UINT32_C(0x008000)
|
|
272
|
+
#define OT_COLOR_ANSI_3 UINT32_C(0x808000)
|
|
273
|
+
#define OT_COLOR_ANSI_4 UINT32_C(0x000080)
|
|
274
|
+
#define OT_COLOR_ANSI_5 UINT32_C(0x800080)
|
|
275
|
+
#define OT_COLOR_ANSI_6 UINT32_C(0x008080)
|
|
276
|
+
#define OT_COLOR_ANSI_7 UINT32_C(0xC0C0C0)
|
|
277
|
+
#define OT_COLOR_ANSI_8 UINT32_C(0x808080)
|
|
278
|
+
#define OT_COLOR_ANSI_9 UINT32_C(0xFF0000)
|
|
279
|
+
#define OT_COLOR_ANSI_10 UINT32_C(0x00FF00)
|
|
280
|
+
#define OT_COLOR_ANSI_11 UINT32_C(0xFFFF00)
|
|
281
|
+
#define OT_COLOR_ANSI_12 UINT32_C(0x0000FF)
|
|
282
|
+
#define OT_COLOR_ANSI_13 UINT32_C(0xFF00FF)
|
|
283
|
+
#define OT_COLOR_ANSI_14 UINT32_C(0x00FFFF)
|
|
284
|
+
#define OT_COLOR_ANSI_15 UINT32_C(0xFFFFFF)
|
|
285
|
+
#define OT_COLOR_CUBE_BASE UINT32_C(55)
|
|
286
|
+
#define OT_COLOR_CUBE_STEP UINT32_C(40)
|
|
287
|
+
#define OT_COLOR_GRAY_BASE UINT32_C(8)
|
|
288
|
+
#define OT_COLOR_GRAY_STEP UINT32_C(10)
|
|
289
|
+
|
|
290
|
+
/* Text attribute words: bits 0..7 are the ATTR flags. Where a call or plane
|
|
291
|
+
* carries a link, bits 8..31 hold its link ID: (attributes >> LINK_SHIFT) & LINK_MASK. */
|
|
292
|
+
#define OT_ATTR_BOLD UINT32_C(1)
|
|
293
|
+
#define OT_ATTR_DIM UINT32_C(2)
|
|
294
|
+
#define OT_ATTR_ITALIC UINT32_C(4)
|
|
295
|
+
#define OT_ATTR_UNDERLINE UINT32_C(8)
|
|
296
|
+
#define OT_ATTR_BLINK UINT32_C(16)
|
|
297
|
+
#define OT_ATTR_INVERSE UINT32_C(32)
|
|
298
|
+
#define OT_ATTR_HIDDEN UINT32_C(64)
|
|
299
|
+
#define OT_ATTR_STRIKETHROUGH UINT32_C(128)
|
|
300
|
+
#define OT_ATTR_BASE_MASK UINT32_C(255)
|
|
301
|
+
#define OT_ATTR_LINK_SHIFT UINT32_C(8)
|
|
302
|
+
#define OT_ATTR_LINK_MASK UINT32_C(0xFFFFFF)
|
|
303
|
+
|
|
304
|
+
/* Complete slider options. orientation is horizontal=0 or vertical=1. Colors
|
|
305
|
+
* retain terminal color intent. All numbers and derived thumb arithmetic must be finite.
|
|
306
|
+
* Values are not clamped: zero and inverted ranges retain the legacy full thumb. A track
|
|
307
|
+
* longer than the i32 cell range uses that range.
|
|
308
|
+
* reserved must be zero. New sliders default to horizontal, min=0, max=100,
|
|
309
|
+
* value=0, viewport_size=10, foreground=#9a9ea3, background=#252527 (both opaque). */
|
|
310
|
+
typedef struct ot_scene_slider_options {
|
|
311
|
+
uint32_t struct_size;
|
|
312
|
+
uint32_t abi_version;
|
|
313
|
+
uint32_t orientation;
|
|
314
|
+
uint32_t reserved;
|
|
315
|
+
double min;
|
|
316
|
+
double max;
|
|
317
|
+
double value;
|
|
318
|
+
double viewport_size;
|
|
319
|
+
uint16_t foreground[4];
|
|
320
|
+
uint16_t background[4];
|
|
321
|
+
} ot_scene_slider_options;
|
|
322
|
+
|
|
323
|
+
/* Copied virtual half-cell size and start, not terminal-cell coordinates. */
|
|
324
|
+
typedef struct ot_scene_slider_thumb {
|
|
325
|
+
uint32_t struct_size;
|
|
326
|
+
uint32_t abi_version;
|
|
327
|
+
double size;
|
|
328
|
+
double start;
|
|
329
|
+
} ot_scene_slider_thumb;
|
|
330
|
+
|
|
331
|
+
/* direction is up=0, down=1, left=2, right=3, using U+25B2/U+25BC/U+25C0/U+25B6.
|
|
332
|
+
* Only attributes bits 0..7 are accepted. Colors retain terminal color intent.
|
|
333
|
+
* New arrows default to up, white/transparent, and zero attributes. */
|
|
334
|
+
typedef struct ot_scene_arrow_options {
|
|
335
|
+
uint32_t struct_size;
|
|
336
|
+
uint32_t abi_version;
|
|
337
|
+
uint32_t direction;
|
|
338
|
+
uint32_t attributes;
|
|
339
|
+
uint16_t foreground[4];
|
|
340
|
+
uint16_t background[4];
|
|
341
|
+
} ot_scene_arrow_options;
|
|
342
|
+
|
|
343
|
+
/* Complete text options, not a patch. Colors retain terminal color intent;
|
|
344
|
+
* attributes accepts only bits 0..7. truncate is 0 or 1. Offsets are display
|
|
345
|
+
* columns/virtual rows, at most INT32_MAX. Viewport size comes from native layout.
|
|
346
|
+
* New text nodes default to white/transparent, zero attributes/offsets, word wrap,
|
|
347
|
+
* left alignment, and no truncation. No custom providers or raw handles. */
|
|
348
|
+
typedef struct ot_scene_text_options {
|
|
349
|
+
uint32_t struct_size;
|
|
350
|
+
uint32_t abi_version;
|
|
351
|
+
uint16_t foreground[4];
|
|
352
|
+
uint16_t background[4];
|
|
353
|
+
uint32_t attributes;
|
|
354
|
+
uint32_t wrap_mode;
|
|
355
|
+
uint32_t truncate;
|
|
356
|
+
uint32_t first_line_offset;
|
|
357
|
+
/* Logical positions are retained; native view coordinates truncate to cells. */
|
|
358
|
+
double scroll_x;
|
|
359
|
+
double scroll_y;
|
|
360
|
+
uint32_t tab_indicator; /* Unicode scalar, or zero to hide the indicator. */
|
|
361
|
+
uint32_t tab_color_set; /* 0 or 1; absent tab color must be zero. */
|
|
362
|
+
uint16_t tab_color[4];
|
|
363
|
+
uint32_t text_align; /* OT_SCENE_ALIGN_*: left=0, center=1, right=2. */
|
|
364
|
+
} ot_scene_text_options;
|
|
365
|
+
|
|
366
|
+
#define OT_SCENE_TEXT_SELECTION_RESET UINT32_C(0)
|
|
367
|
+
#define OT_SCENE_TEXT_SELECTION_SET UINT32_C(1)
|
|
368
|
+
#define OT_SCENE_TEXT_SELECTION_UPDATE UINT32_C(2)
|
|
369
|
+
#define OT_SCENE_TEXT_SELECTION_CELL UINT32_C(0)
|
|
370
|
+
#define OT_SCENE_TEXT_SELECTION_WORD UINT32_C(1)
|
|
371
|
+
#define OT_SCENE_TEXT_SELECTION_LINE UINT32_C(2)
|
|
372
|
+
#define OT_SCENE_TEXT_SELECTION_BACKGROUND UINT32_C(1)
|
|
373
|
+
#define OT_SCENE_TEXT_SELECTION_FOREGROUND UINT32_C(2)
|
|
374
|
+
|
|
375
|
+
typedef struct ot_scene_text_selection_options {
|
|
376
|
+
uint32_t struct_size;
|
|
377
|
+
uint32_t abi_version;
|
|
378
|
+
uint32_t operation;
|
|
379
|
+
uint32_t behavior;
|
|
380
|
+
int32_t anchor_x;
|
|
381
|
+
int32_t anchor_y;
|
|
382
|
+
int32_t focus_x;
|
|
383
|
+
int32_t focus_y;
|
|
384
|
+
uint32_t flags;
|
|
385
|
+
uint32_t reserved;
|
|
386
|
+
uint16_t background[4];
|
|
387
|
+
uint16_t foreground[4];
|
|
388
|
+
} ot_scene_text_selection_options;
|
|
389
|
+
|
|
390
|
+
#define OT_SCENE_TEXT_FOREGROUND UINT32_C(1)
|
|
391
|
+
#define OT_SCENE_TEXT_BACKGROUND UINT32_C(2)
|
|
392
|
+
#define OT_SCENE_TEXT_LINK UINT32_C(4)
|
|
393
|
+
|
|
394
|
+
typedef struct ot_styled_text_chunk {
|
|
395
|
+
uint32_t struct_size;
|
|
396
|
+
uint32_t abi_version;
|
|
397
|
+
uint32_t byte_count;
|
|
398
|
+
uint32_t flags;
|
|
399
|
+
uint16_t foreground[4];
|
|
400
|
+
uint16_t background[4];
|
|
401
|
+
uint32_t attributes;
|
|
402
|
+
uint32_t reserved;
|
|
403
|
+
uint32_t link_offset;
|
|
404
|
+
uint32_t link_byte_count;
|
|
405
|
+
} ot_styled_text_chunk;
|
|
406
|
+
|
|
407
|
+
/* Copied text metadata. text_length sums unwrapped line widths in display columns,
|
|
408
|
+
* with expanded tabs and no line separators. It is not a byte/code-point count
|
|
409
|
+
* or the final document selection offset: selection offsets count each line
|
|
410
|
+
* separator as one position. width_cols_max is the longest unwrapped line.
|
|
411
|
+
* reserved is zero. */
|
|
412
|
+
typedef struct ot_scene_text_info {
|
|
413
|
+
uint32_t struct_size;
|
|
414
|
+
uint32_t abi_version;
|
|
415
|
+
uint32_t byte_count;
|
|
416
|
+
uint32_t text_length; /* Sum of unwrapped display-column widths, excluding line separators. */
|
|
417
|
+
uint32_t line_count;
|
|
418
|
+
uint32_t virtual_line_count;
|
|
419
|
+
uint32_t width_cols_max;
|
|
420
|
+
uint32_t reserved;
|
|
421
|
+
} ot_scene_text_info;
|
|
422
|
+
|
|
423
|
+
typedef struct ot_scene_text_line {
|
|
424
|
+
uint32_t start_cols;
|
|
425
|
+
uint32_t width_cols;
|
|
426
|
+
uint32_t source_line;
|
|
427
|
+
uint32_t wrap_index;
|
|
428
|
+
} ot_scene_text_line;
|
|
429
|
+
|
|
430
|
+
typedef struct ot_scene_paint_options {
|
|
431
|
+
uint32_t struct_size;
|
|
432
|
+
uint32_t abi_version;
|
|
433
|
+
int32_t z_index;
|
|
434
|
+
float opacity;
|
|
435
|
+
double translate_x;
|
|
436
|
+
double translate_y;
|
|
437
|
+
uint32_t border_sides;
|
|
438
|
+
uint32_t should_fill;
|
|
439
|
+
uint16_t background[4];
|
|
440
|
+
uint16_t border_color[4];
|
|
441
|
+
uint32_t border_style;
|
|
442
|
+
uint32_t focusable;
|
|
443
|
+
uint16_t focused_border_color[4];
|
|
444
|
+
uint32_t reserved;
|
|
445
|
+
} ot_scene_paint_options;
|
|
446
|
+
|
|
447
|
+
#define OT_SCENE_MUTATIONS_MAX UINT32_C(4096)
|
|
448
|
+
|
|
449
|
+
/* Complete Box details. Flags: 1 = title color, 2 = custom border characters.
|
|
450
|
+
* Titles are copied single-row UTF-8; each is bounded by OT_BUFFER_TEXT_BYTES_MAX.
|
|
451
|
+
* Alignments are left=0, center=1, right=2. Custom scalars occupy one display cell.
|
|
452
|
+
* Absent color/characters and reserved fields must be zero. */
|
|
453
|
+
typedef struct ot_scene_box_details {
|
|
454
|
+
uint32_t struct_size;
|
|
455
|
+
uint32_t abi_version;
|
|
456
|
+
uint32_t title_alignment;
|
|
457
|
+
uint32_t bottom_title_alignment;
|
|
458
|
+
uint32_t flags;
|
|
459
|
+
uint32_t reserved;
|
|
460
|
+
uint16_t title_color[4];
|
|
461
|
+
uint32_t border_characters[11];
|
|
462
|
+
} ot_scene_box_details;
|
|
463
|
+
|
|
464
|
+
typedef struct ot_scene_style_value {
|
|
465
|
+
uint32_t struct_size;
|
|
466
|
+
uint32_t abi_version;
|
|
467
|
+
uint32_t unit;
|
|
468
|
+
float value;
|
|
469
|
+
} ot_scene_style_value;
|
|
470
|
+
|
|
471
|
+
typedef struct ot_scene_layout {
|
|
472
|
+
uint32_t struct_size;
|
|
473
|
+
uint32_t abi_version;
|
|
474
|
+
float left;
|
|
475
|
+
float top;
|
|
476
|
+
float right;
|
|
477
|
+
float bottom;
|
|
478
|
+
float width;
|
|
479
|
+
float height;
|
|
480
|
+
double screen_x;
|
|
481
|
+
double screen_y;
|
|
482
|
+
} ot_scene_layout;
|
|
483
|
+
|
|
484
|
+
#define OT_SCENE_FULL_PATH_FORCED UINT32_C(1)
|
|
485
|
+
#define OT_SCENE_FULL_PATH_SCREEN UINT32_C(2)
|
|
486
|
+
#define OT_SCENE_FULL_PATH_IMAGES UINT32_C(4)
|
|
487
|
+
#define OT_SCENE_FULL_PATH_TAINTED UINT32_C(8)
|
|
488
|
+
#define OT_SCENE_FULL_PATH_UNRETAINED UINT32_C(16)
|
|
489
|
+
#define OT_SCENE_FULL_PATH_OPTIONS UINT32_C(32)
|
|
490
|
+
#define OT_SCENE_FULL_PATH_NON_LOCAL UINT32_C(64)
|
|
491
|
+
|
|
492
|
+
/* Fields from work_frame_id on count the work of the last presented scene
|
|
493
|
+
* frame: preparation, paint, and encoding. They are deterministic work
|
|
494
|
+
* counts, not times, and their values may change between versions as the
|
|
495
|
+
* renderer does less work. The three hit_cells fields are zero: paint records
|
|
496
|
+
* one hit rectangle per member, and a hit test walks them. Cancelled, failed, and skipped frames,
|
|
497
|
+
* non-scene renders, and snapshot-only split renders leave them unchanged.
|
|
498
|
+
* work_frame_id is the frame_id of the counted frame, or zero before the first.
|
|
499
|
+
* full_path_reasons holds OT_SCENE_FULL_PATH_* bits: FORCED (debug flag),
|
|
500
|
+
* SCREEN (forced, invalidated, or palette-changed encode), IMAGES (image
|
|
501
|
+
* placements present), TAINTED (the next buffer was written outside scene
|
|
502
|
+
* paint), UNRETAINED (no presented scene frame to compare with: the first
|
|
503
|
+
* frame, a resize, or the frame after a failed, cancelled, or unpresented
|
|
504
|
+
* frame), OPTIONS (background, use_mouse, excluded_hit_num, or
|
|
505
|
+
* preserve_unwritten changed), NON_LOCAL (a recording clears or color-matrixes
|
|
506
|
+
* the frame). IMAGES also counts recorded image draws. Otherwise, without a
|
|
507
|
+
* reason, a frame repaints only when a painted member's inputs changed, its
|
|
508
|
+
* recording included: it clears and repaints only bands around the damage_rows
|
|
509
|
+
* rows they cover (runs one row apart merge, and a sixteenth band takes every
|
|
510
|
+
* later run, so a band can include undamaged rows), and the encoder diffs only
|
|
511
|
+
* the damage_rows rows; an unchanged frame has damage_rows 0 and paints nothing. After a current-buffer session lease the
|
|
512
|
+
* encoder diffs every row, without repainting. */
|
|
513
|
+
typedef struct ot_scene_stats {
|
|
514
|
+
uint32_t struct_size;
|
|
515
|
+
uint32_t abi_version;
|
|
516
|
+
double last_frame_time;
|
|
517
|
+
double average_frame_time;
|
|
518
|
+
double render_time;
|
|
519
|
+
double stdout_write_time;
|
|
520
|
+
uint64_t frame_count;
|
|
521
|
+
uint32_t cells_updated;
|
|
522
|
+
uint32_t average_cells_updated;
|
|
523
|
+
uint32_t render_time_valid;
|
|
524
|
+
uint32_t stdout_write_time_valid;
|
|
525
|
+
uint64_t work_frame_id;
|
|
526
|
+
uint64_t candidate_visits;
|
|
527
|
+
uint64_t paint_visits;
|
|
528
|
+
uint64_t view_preparations;
|
|
529
|
+
uint64_t geometry_reads;
|
|
530
|
+
uint64_t yoga_solves;
|
|
531
|
+
uint64_t feedback_operations;
|
|
532
|
+
uint64_t visibility_steps;
|
|
533
|
+
uint64_t viewport_child_refreshes;
|
|
534
|
+
uint64_t overlap_tests;
|
|
535
|
+
uint64_t members_painted;
|
|
536
|
+
uint64_t member_cells;
|
|
537
|
+
uint64_t cells_cleared;
|
|
538
|
+
uint64_t hit_cells_written;
|
|
539
|
+
uint64_t hit_cells_cleared;
|
|
540
|
+
uint64_t hit_cells_compared;
|
|
541
|
+
uint64_t rows_compared;
|
|
542
|
+
uint64_t rows_diffed;
|
|
543
|
+
uint32_t full_path_reasons;
|
|
544
|
+
uint32_t host_requests;
|
|
545
|
+
uint32_t layout_rounds;
|
|
546
|
+
uint32_t damage_rows;
|
|
547
|
+
} ot_scene_stats;
|
|
548
|
+
|
|
549
|
+
/* Cursor styles of the session cursor, the scene cursor state and editors. */
|
|
550
|
+
#define OT_CURSOR_STYLE_BLOCK UINT32_C(0)
|
|
551
|
+
#define OT_CURSOR_STYLE_LINE UINT32_C(1)
|
|
552
|
+
#define OT_CURSOR_STYLE_UNDERLINE UINT32_C(2)
|
|
553
|
+
#define OT_CURSOR_STYLE_DEFAULT UINT32_C(3)
|
|
554
|
+
typedef struct ot_scene_cursor_state {
|
|
555
|
+
uint32_t struct_size;
|
|
556
|
+
uint32_t abi_version;
|
|
557
|
+
uint32_t x;
|
|
558
|
+
uint32_t y;
|
|
559
|
+
uint32_t visible;
|
|
560
|
+
uint32_t style;
|
|
561
|
+
uint32_t blinking;
|
|
562
|
+
uint32_t reserved;
|
|
563
|
+
float r;
|
|
564
|
+
float g;
|
|
565
|
+
float b;
|
|
566
|
+
float a;
|
|
567
|
+
} ot_scene_cursor_state;
|
|
568
|
+
|
|
569
|
+
#define OT_SCENE_HOOK_UPDATE UINT32_C(1)
|
|
570
|
+
#define OT_SCENE_HOOK_RESIZE UINT32_C(2)
|
|
571
|
+
#define OT_SCENE_HOOK_LAYOUT_CHANGED UINT32_C(4)
|
|
572
|
+
#define OT_SCENE_HOOK_RENDER_BEFORE UINT32_C(8)
|
|
573
|
+
#define OT_SCENE_HOOK_RENDER_AFTER UINT32_C(16)
|
|
574
|
+
#define OT_SCENE_HOOK_RENDER_SELF UINT32_C(32)
|
|
575
|
+
#define OT_SCENE_HOOK_IDLE_UPDATE UINT32_C(64)
|
|
576
|
+
#define OT_SCENE_HOOK_SCROLL UINT32_C(128)
|
|
577
|
+
#define OT_SCENE_FRAME_DONE UINT32_C(0)
|
|
578
|
+
#define OT_SCENE_FRAME_UPDATE UINT32_C(1)
|
|
579
|
+
#define OT_SCENE_FRAME_RESIZE UINT32_C(2)
|
|
580
|
+
#define OT_SCENE_FRAME_LAYOUT_CHANGED UINT32_C(3)
|
|
581
|
+
#define OT_SCENE_FRAME_RECORD UINT32_C(4)
|
|
582
|
+
#define OT_SCENE_FRAME_SCROLL UINT32_C(5)
|
|
583
|
+
|
|
584
|
+
typedef struct ot_scene_hooks {
|
|
585
|
+
uint32_t struct_size;
|
|
586
|
+
uint32_t abi_version;
|
|
587
|
+
uint32_t flags;
|
|
588
|
+
uint32_t reserved;
|
|
589
|
+
uint64_t generation;
|
|
590
|
+
double initial_width;
|
|
591
|
+
double initial_height;
|
|
592
|
+
} ot_scene_hooks;
|
|
593
|
+
|
|
594
|
+
typedef struct ot_scene_frame_options {
|
|
595
|
+
uint32_t struct_size;
|
|
596
|
+
uint32_t abi_version;
|
|
597
|
+
uint16_t background[4];
|
|
598
|
+
uint32_t use_mouse;
|
|
599
|
+
uint32_t excluded_hit_num;
|
|
600
|
+
uint32_t max_layout_rounds;
|
|
601
|
+
uint32_t max_host_requests;
|
|
602
|
+
uint32_t preserve_unwritten; /* 0 clears to spaces; 1 clears untouched snapshot cells to codepoint zero. */
|
|
603
|
+
} ot_scene_frame_options;
|
|
604
|
+
|
|
605
|
+
typedef struct ot_scene_frame_request {
|
|
606
|
+
uint32_t struct_size;
|
|
607
|
+
uint32_t abi_version;
|
|
608
|
+
ot_handle session;
|
|
609
|
+
ot_handle root;
|
|
610
|
+
ot_handle node;
|
|
611
|
+
uint64_t frame_id;
|
|
612
|
+
uint64_t request_id;
|
|
613
|
+
uint64_t layout_epoch;
|
|
614
|
+
uint64_t hook_generation;
|
|
615
|
+
uint32_t kind;
|
|
616
|
+
uint32_t num;
|
|
617
|
+
uint32_t width;
|
|
618
|
+
uint32_t height;
|
|
619
|
+
uint32_t reserved[2];
|
|
620
|
+
} ot_scene_frame_request;
|
|
621
|
+
|
|
622
|
+
#define OT_SCENE_GEOMETRY_PAINT UINT32_C(1)
|
|
623
|
+
#define OT_SCENE_GEOMETRY_PUBLIC UINT32_C(2)
|
|
624
|
+
typedef struct ot_scene_frame_geometry {
|
|
625
|
+
uint32_t struct_size;
|
|
626
|
+
uint32_t abi_version;
|
|
627
|
+
uint32_t flags;
|
|
628
|
+
uint32_t reserved;
|
|
629
|
+
ot_scene_layout paint;
|
|
630
|
+
ot_scene_layout public_layout;
|
|
631
|
+
} ot_scene_frame_geometry;
|
|
632
|
+
|
|
633
|
+
/* One node whose paint hooks a RECORD request asks the host to record, in paint
|
|
634
|
+
* order. hooks holds the RENDER_BEFORE, RENDER_SELF, and RENDER_AFTER bits to
|
|
635
|
+
* record. paint is the prepared geometry native code paints at, clamped like
|
|
636
|
+
* OT_LAYOUT_PAINT; clip and opacity
|
|
637
|
+
* are the inherited paint state. flags has OT_SCENE_GEOMETRY_PAINT and, when the
|
|
638
|
+
* public observation succeeded, OT_SCENE_GEOMETRY_PUBLIC. */
|
|
639
|
+
typedef struct ot_scene_paint_slot {
|
|
640
|
+
ot_handle node;
|
|
641
|
+
uint64_t hook_generation;
|
|
642
|
+
uint32_t num;
|
|
643
|
+
uint32_t hooks;
|
|
644
|
+
int32_t clip_x;
|
|
645
|
+
int32_t clip_y;
|
|
646
|
+
uint32_t clip_width;
|
|
647
|
+
uint32_t clip_height;
|
|
648
|
+
float opacity;
|
|
649
|
+
uint32_t flags;
|
|
650
|
+
ot_scene_layout paint;
|
|
651
|
+
ot_scene_layout public_layout;
|
|
652
|
+
} ot_scene_paint_slot;
|
|
653
|
+
|
|
654
|
+
/* All phase records require exact size/version and zero reserved fields. Hook
|
|
655
|
+
* generations are nonzero and must increase on every change. Initial dimensions
|
|
656
|
+
* seed the resize baseline on the node's first publication. Later subscriptions use
|
|
657
|
+
* completed dimensions. Only the root accepts LAYOUT_CHANGED.
|
|
658
|
+
* IDLE_UPDATE uses up the node's update for a frame without a host request or callback.
|
|
659
|
+
* It does not count as a host hook and cannot be combined with UPDATE.
|
|
660
|
+
* Non-root nodes accept RENDER_BEFORE, RENDER_SELF, and RENDER_AFTER.
|
|
661
|
+
* Root paint flags are rejected.
|
|
662
|
+
* Rejected registrations leave hook flags, generation, and resize baselines unchanged.
|
|
663
|
+
* No custom measurement or native-to-host callbacks are installed. */
|
|
664
|
+
ot_status ot_scene_set_hooks(ot_context *, const ot_handle *node, const ot_scene_hooks *);
|
|
665
|
+
/* NULL previous starts an attempt. Otherwise acknowledge the exact returned
|
|
666
|
+
* request, including all identities and dimensions. Invalid replies consume
|
|
667
|
+
* nothing. One ordered request is outstanding; hooks run between native calls.
|
|
668
|
+
* Paint options are copied on each accepted step; max_layout_rounds and
|
|
669
|
+
* max_host_requests stay positive and fixed for the attempt. Yoga completes before host work. Filtered
|
|
670
|
+
* text viewports advance only when refreshed or painted, not during candidate layout.
|
|
671
|
+
* UPDATE runs at most once per node per attempt; getter refresh
|
|
672
|
+
* and resize ordering preserve the mounted and newly placed node contracts.
|
|
673
|
+
* LAYOUT_CHANGED follows an actual Yoga solve, before updates. Layout/preparation
|
|
674
|
+
* limits fail before paint. Failure cancels the attempt without presenting
|
|
675
|
+
* partial cells or rolling back mutations.
|
|
676
|
+
*
|
|
677
|
+
* When preparation finishes and a visible node has paint hooks, the step returns
|
|
678
|
+
* one RECORD request instead of painting. It names the root and counts as one host
|
|
679
|
+
* request. Read its slots with ot_scene_frame_get_paint_slots, run every slot's
|
|
680
|
+
* hooks in slot order, and acknowledge the RECORD ticket with the recording: one
|
|
681
|
+
* byte stream of ot_scene_record_* records (see ot_scene_record_header). Native
|
|
682
|
+
* code then paints the whole frame in one pass and returns DONE. At each slot,
|
|
683
|
+
* it plays RENDER_BEFORE, then RENDER_SELF in place of the node's native body,
|
|
684
|
+
* then native editor cursor maintenance, then RENDER_AFTER, before the node's
|
|
685
|
+
* children. A slot without a recorded phase draws nothing for that phase. An
|
|
686
|
+
* IMAGE or VIDEO node with a backing buffer from ot_scene_set_image or ot_scene_set_video plays its phases into
|
|
687
|
+
* that buffer, in buffer coordinates, after native code clears it and before
|
|
688
|
+
* composing it.
|
|
689
|
+
* recording must be NULL with zero length for every other acknowledgement.
|
|
690
|
+
*
|
|
691
|
+
* Hooks run before painting starts. Membership, geometry, clipping, and opacity
|
|
692
|
+
* stay as prepared for the RECORD request; later paint values stay live.
|
|
693
|
+
* Destroyed slot nodes and destroyed paint members are skipped with their
|
|
694
|
+
* recordings and hits. New nodes wait for the next frame. Layout mutations mark
|
|
695
|
+
* the next frame dirty. During RECORD, render, resize, setup, and suspend reject
|
|
696
|
+
* with OT_FRAME_BUSY, and the ticket grants no buffer access.
|
|
697
|
+
*
|
|
698
|
+
* DONE names a retained painted draft, not presentation or a preparation attempt.
|
|
699
|
+
* Native code retains its membership, destination, and storage identity. DONE
|
|
700
|
+
* does not acquire a buffer lease automatically. Acquire qualified access below
|
|
701
|
+
* only when needed, and explicitly commit or cancel the draft before another frame.
|
|
702
|
+
* During preparation, render, resize, buffer draw, buffer borrowing, setup, and
|
|
703
|
+
* suspend reject with OT_FRAME_BUSY. Close, cancellation, root destruction, and
|
|
704
|
+
* owner teardown invalidate preparation attempts.
|
|
705
|
+
* After DONE, destroying nodes or the root leaves painted cells and capture intact
|
|
706
|
+
* without repainting. Commit, frame or Session cancellation, and owner teardown
|
|
707
|
+
* still end draft access.
|
|
708
|
+
*
|
|
709
|
+
* Preparation and painting never yield: each step runs until it returns a host
|
|
710
|
+
* request, DONE, or an error.
|
|
711
|
+
*
|
|
712
|
+
* Geometry observations are produced after phase publication.
|
|
713
|
+
* Geometry is not ticket authority and must not be echoed in acknowledgements.
|
|
714
|
+
* Each flag marks a valid snapshot; absent snapshots are zeroed, including for
|
|
715
|
+
* RECORD and DONE. Observation failures do not fail the step: a caller
|
|
716
|
+
* needing that observation must use the checked layout query.
|
|
717
|
+
* Accepted mutations may invalidate these snapshots before the next step.
|
|
718
|
+
* out_geometry requires exact size/version and zero reserved before advancement.
|
|
719
|
+
* All buffers are borrowed only for this call. previous may alias out_request;
|
|
720
|
+
* the two output records must be distinct. */
|
|
721
|
+
ot_status ot_scene_frame_step_with_geometry(ot_context *, const ot_handle *session,
|
|
722
|
+
const ot_scene_frame_request *previous, const ot_scene_frame_options *,
|
|
723
|
+
const uint8_t *recording, uint32_t recording_length,
|
|
724
|
+
ot_scene_frame_request *out_request, ot_scene_frame_geometry *out_geometry);
|
|
725
|
+
/* Copy the slots of the exact pending RECORD request. out_count receives the total
|
|
726
|
+
* slot count; min(capacity, total) slots are written in paint order. NULL out_slots
|
|
727
|
+
* requires zero capacity. Recording refers to slots by their index. */
|
|
728
|
+
ot_status ot_scene_frame_get_paint_slots(ot_context *, const ot_handle *session,
|
|
729
|
+
const ot_scene_frame_request *record_request, ot_scene_paint_slot *out_slots,
|
|
730
|
+
uint32_t capacity, uint32_t *out_count);
|
|
731
|
+
/* Cancel preparation or a retained painted draft. A stale frame ID rejects without
|
|
732
|
+
* cancelling the active frame. Cancellation immediately revokes qualified access
|
|
733
|
+
* and submission; pending hits cannot publish. Release every acquired scope even
|
|
734
|
+
* when validation returns OT_STALE_LEASE. Scratch NEXT bytes intentionally remain
|
|
735
|
+
* readable through an ordinary storage lease afterward for error inspection;
|
|
736
|
+
* cancellation does not guarantee zeroed cells. */
|
|
737
|
+
ot_status ot_scene_frame_cancel(ot_context *, const ot_handle *session, uint64_t frame_id);
|
|
738
|
+
|
|
739
|
+
/* A root creates one Session scene. Other nodes may remain detached. Nonzero public
|
|
740
|
+
* numbers are immutable; native hit tokens do not recycle. Node handles use the
|
|
741
|
+
* Context table. */
|
|
742
|
+
ot_status ot_scene_create_node(ot_context *, const ot_handle *session, uint32_t kind,
|
|
743
|
+
uint32_t num, ot_handle *out_node);
|
|
744
|
+
/* Individual destruction detaches surviving children. Session destruction frees
|
|
745
|
+
* all associated nodes, including detached nodes. NULL parent means detach.
|
|
746
|
+
* A failed layout solve, such as Yoga running out of memory, leaves the tree failed:
|
|
747
|
+
* frames, Yoga layout queries, and style, paint, and text setters return
|
|
748
|
+
* OT_INTERNAL_ERROR until its nodes are destroyed. Destroy, detach, blur, clearing a measure provider, and selection
|
|
749
|
+
* RESET still succeed. */
|
|
750
|
+
ot_status ot_scene_destroy_node(ot_context *, const ot_handle *node);
|
|
751
|
+
ot_status ot_scene_move_node(ot_context *, const ot_handle *node, const ot_handle *parent, uint32_t index);
|
|
752
|
+
/* Detaches every child of node, as moving each to NULL from first to last would, in
|
|
753
|
+
* time linear in the child count. On error no child is detached. */
|
|
754
|
+
ot_status ot_scene_clear_children(ot_context *, const ot_handle *node);
|
|
755
|
+
/* Synchronous owner-thread measurement on leaves. The callback is borrowed until
|
|
756
|
+
* replacement, unset, node destruction, or Context destruction. NULL clears the
|
|
757
|
+
* single provider slot; it does not restore built-in measurement. Each set or clear
|
|
758
|
+
* invalidates the cached measurement. The result is two floats (width, height),
|
|
759
|
+
* initialized to NaN, valid only during the callback. A NaN, negative, or larger
|
|
760
|
+
* than INT32_MAX dimension measures as 0 and queues a Yoga warning diagnostic.
|
|
761
|
+
* Only scene style/layout/text/provider queries may reenter; mutations may not. */
|
|
762
|
+
typedef void (*ot_scene_measure_callback)(uint64_t context_id, uint32_t slot, uint32_t generation,
|
|
763
|
+
float width, uint32_t width_mode, float height, uint32_t height_mode, float *out_size);
|
|
764
|
+
ot_status ot_scene_set_measure(ot_context *, const ot_handle *node, ot_scene_measure_callback);
|
|
765
|
+
ot_status ot_scene_has_measure(ot_context *, const ot_handle *node, uint32_t *out_enabled);
|
|
766
|
+
/* out_reached is 1 when a frame's hooks reach the node: it is attached under the root, it and
|
|
767
|
+
* its ancestors are shown, and each culling ancestor selects its branch at the current offsets
|
|
768
|
+
* and child count from the latest layout (a child moved since then has no position, and is
|
|
769
|
+
* not selected). A node they do not reach gets no hook calls. */
|
|
770
|
+
ot_status ot_scene_reaches_hooks(ot_context *, const ot_handle *node, uint32_t *out_reached);
|
|
771
|
+
/* out_painted is 1 when the last frame that finished paint painted the node, or the presented
|
|
772
|
+
* frame once a later one is cancelled; 0 for the root and before any frame. */
|
|
773
|
+
ot_status ot_scene_painted(ot_context *, const ot_handle *node, uint32_t *out_painted);
|
|
774
|
+
ot_status ot_scene_mark_dirty(ot_context *, const ot_handle *node);
|
|
775
|
+
/* Use OT_STYLE_* groups/kinds, OT_EDGE_* (or OT_GUTTER_* for GAP), and OT_UNIT_*.
|
|
776
|
+
* Only OT_STYLE_DIMENSION accepts OT_STYLE_DISABLE_FLEX_SHRINK, which disables
|
|
777
|
+
* flex shrink atomically with the dimension update. OT_STYLE_CONTENT writes the
|
|
778
|
+
* content layout node of a scroll node (see ot_scene_set_scroll) instead of the
|
|
779
|
+
* node, and rejects DISPLAY; PADDING on a scroll node requires it. Other flags must be zero.
|
|
780
|
+
* Finite MARGIN, PADDING, POSITION, and GAP values beyond ±1e30 are stored as ±1e30, so
|
|
781
|
+
* get_style reads the stored value; Yoga clamps resolved percentages the same way. */
|
|
782
|
+
ot_status ot_scene_set_style(ot_context *, const ot_handle *node, uint32_t group,
|
|
783
|
+
uint32_t kind, uint32_t edge, uint32_t unit, float value, uint32_t flags);
|
|
784
|
+
ot_status ot_scene_get_style(ot_context *, const ot_handle *node, uint32_t group,
|
|
785
|
+
uint32_t kind, uint32_t edge, ot_scene_style_value *out_value);
|
|
786
|
+
/* Exact size/version and zero reserved. Borders use L=1 B=2 R=4 T=8;
|
|
787
|
+
* styles are single=0 double=1 rounded=2 heavy=3. Colors retain terminal color intent.
|
|
788
|
+
* focusable is 0 or 1. New nodes default to 0 and focused color {0,170,255,255}.
|
|
789
|
+
* Translations must be finite with a magnitude of at most FLT_MAX.
|
|
790
|
+
* Border layout widths and paint properties publish together on acceptance. */
|
|
791
|
+
ot_status ot_scene_set_paint(ot_context *, const ot_handle *node, const ot_scene_paint_options *);
|
|
792
|
+
/* --- Staged scene properties ---
|
|
793
|
+
* One borrowed byte stream, one mutation admission. Records apply in stream order;
|
|
794
|
+
* each record publishes atomically, including border appearance and Yoga widths.
|
|
795
|
+
* The first rejected record stops the call. out_applied counts complete accepted
|
|
796
|
+
* RECORDS, not bytes; the rejected record and suffix remain unapplied. No rollback.
|
|
797
|
+
* Admission/null/byte-limit failures consume zero. The record limit stops before
|
|
798
|
+
* record OT_SCENE_MUTATIONS_MAX + 1, preserving the accepted prefix.
|
|
799
|
+
*
|
|
800
|
+
* Each record starts with this 24-byte header. Values use native byte order and
|
|
801
|
+
* follow in increasing field-bit order, tightly packed, with zero padding to an
|
|
802
|
+
* 8-byte record size. Payload values may be unaligned. size_bytes must equal the
|
|
803
|
+
* size implied by fields. Unknown/empty masks and nonzero padding are rejected.
|
|
804
|
+
* Unselected visual fields retain accepted native values. RESET_BORDER_CHARACTERS
|
|
805
|
+
* carries no payload, requires BORDER_STYLE, and clears custom border characters
|
|
806
|
+
* after successful border-width publication.
|
|
807
|
+
*
|
|
808
|
+
* STYLE must be the sole bit and carries ot_scene_style_property (40 bytes total).
|
|
809
|
+
* Visual records are 32..88 bytes; a color/scalar costs 32 and all fields cost 88.
|
|
810
|
+
* NULL input requires zero bytes. out_applied is required, initialized even on
|
|
811
|
+
* failed Context admission, and must not alias input. Input is borrowed only for
|
|
812
|
+
* this call. The ABI requires matching headers and artifacts. */
|
|
813
|
+
#define OT_SCENE_PROPERTY_Z_INDEX UINT32_C(1)
|
|
814
|
+
#define OT_SCENE_PROPERTY_OPACITY UINT32_C(2)
|
|
815
|
+
#define OT_SCENE_PROPERTY_TRANSLATE_X UINT32_C(4)
|
|
816
|
+
#define OT_SCENE_PROPERTY_TRANSLATE_Y UINT32_C(8)
|
|
817
|
+
#define OT_SCENE_PROPERTY_BORDER UINT32_C(16)
|
|
818
|
+
#define OT_SCENE_PROPERTY_SHOULD_FILL UINT32_C(32)
|
|
819
|
+
#define OT_SCENE_PROPERTY_BACKGROUND UINT32_C(64)
|
|
820
|
+
#define OT_SCENE_PROPERTY_BORDER_COLOR UINT32_C(128)
|
|
821
|
+
#define OT_SCENE_PROPERTY_BORDER_STYLE UINT32_C(256)
|
|
822
|
+
#define OT_SCENE_PROPERTY_FOCUSABLE UINT32_C(512)
|
|
823
|
+
#define OT_SCENE_PROPERTY_FOCUSED_BORDER_COLOR UINT32_C(1024)
|
|
824
|
+
#define OT_SCENE_PROPERTY_STYLE UINT32_C(2048)
|
|
825
|
+
#define OT_SCENE_PROPERTY_RESET_BORDER_CHARACTERS UINT32_C(4096)
|
|
826
|
+
#define OT_SCENE_PROPERTY_RECORD_MAX UINT32_C(88)
|
|
827
|
+
#define OT_SCENE_PROPERTY_BYTES_MAX (OT_SCENE_MUTATIONS_MAX * OT_SCENE_PROPERTY_RECORD_MAX)
|
|
828
|
+
|
|
829
|
+
/* Field types, in bit order: int32_t, float, double, double, uint32_t,
|
|
830
|
+
* uint32_t, uint16_t[4], uint16_t[4], uint32_t, uint32_t, uint16_t[4].
|
|
831
|
+
* Field value rules match ot_scene_set_paint. */
|
|
832
|
+
typedef struct ot_scene_property_update {
|
|
833
|
+
ot_handle node;
|
|
834
|
+
uint32_t fields;
|
|
835
|
+
uint32_t size_bytes;
|
|
836
|
+
} ot_scene_property_update;
|
|
837
|
+
|
|
838
|
+
typedef struct ot_scene_style_property {
|
|
839
|
+
uint8_t group;
|
|
840
|
+
uint8_t kind;
|
|
841
|
+
uint8_t edge;
|
|
842
|
+
uint8_t unit;
|
|
843
|
+
uint32_t flags;
|
|
844
|
+
float value;
|
|
845
|
+
uint32_t reserved;
|
|
846
|
+
} ot_scene_style_property;
|
|
847
|
+
|
|
848
|
+
ot_status ot_scene_flush(ot_context *,
|
|
849
|
+
const uint8_t *updates, uint32_t byte_count, uint32_t *out_applied);
|
|
850
|
+
/* Retains a Context-owned buffer for a surface node. NULL clears the binding.
|
|
851
|
+
* Replacement retains the new buffer before releasing the previous binding. */
|
|
852
|
+
ot_status ot_scene_set_surface(ot_context *, const ot_handle *node, const ot_handle *buffer);
|
|
853
|
+
/* tfm fork: bind only BOX nodes. When on != 0 this node's TRANSLUCENT box fill
|
|
854
|
+
* keeps the image placements it covers and dims them (their reservation cells
|
|
855
|
+
* survive; uncovered placements and opaque fills are unchanged), instead of
|
|
856
|
+
* deleting them — the modal scrim overlay. Default 0 keeps the historical
|
|
857
|
+
* behavior. */
|
|
858
|
+
ot_status ot_scene_set_fill_dims_images(ot_context *, const ot_handle *node, uint32_t on);
|
|
859
|
+
ot_status ot_scene_set_box_details(ot_context *, const ot_handle *node, const ot_scene_box_details *,
|
|
860
|
+
const uint8_t *title, uint32_t title_bytes, const uint8_t *bottom_title, uint32_t bottom_title_bytes);
|
|
861
|
+
/* A box may filter its direct children against a root/box in the same Session.
|
|
862
|
+
* The viewport handle is copied, not pinned. NULL disables filtering. A destroyed
|
|
863
|
+
* viewport fails frame preparation until rebound or disabled. Every direct child
|
|
864
|
+
* whose layout, text, view, or hooks changed refreshes before selection,
|
|
865
|
+
* including hidden/culled children; hidden nodes do not update or resize. Fewer than 16 total children bypass overlap filtering.
|
|
866
|
+
* Bounds use the full viewport, not its border-inset paint clip. Row/reverse-row
|
|
867
|
+
* use horizontal overlap; column/reverse-column use vertical overlap. Primary
|
|
868
|
+
* overlap is strict, cross-axis touching is included, and padding is zero.
|
|
869
|
+
* A scroll node rejects a viewport with OT_INVALID_ARGUMENT; as another node's
|
|
870
|
+
* viewport it bounds by its full box. */
|
|
871
|
+
ot_status ot_scene_set_viewport(ot_context *, const ot_handle *node, const ot_handle *viewport);
|
|
872
|
+
|
|
873
|
+
/* --- Scroll nodes ---
|
|
874
|
+
* ot_scene_set_scroll makes a box with no children a scroll node. It owns two
|
|
875
|
+
* hidden layout nodes: a viewport node, the box's only layout child (column,
|
|
876
|
+
* grow 1, overflow hidden, the viewport padding), and a content node inside it
|
|
877
|
+
* (align-self flex-start, shrink 0, min width and height 100%, and max 100% on
|
|
878
|
+
* an axis that does not scroll). The box's scene children lay out in the
|
|
879
|
+
* content node, and the box's own padding holds the gutters of visible inset
|
|
880
|
+
* bars. After each layout solve, max = max(0, content - viewport inner) on a
|
|
881
|
+
* scrolling axis (0 otherwise); if max, the content size, or the viewport
|
|
882
|
+
* changed, a stuck view moves to its follow edge; the offset clamps to
|
|
883
|
+
* [0, max] in whole cells. Children compose at the box origin
|
|
884
|
+
* plus the viewport and content origins minus the offset, clip to the viewport
|
|
885
|
+
* rect, and with culling filter against it like ot_scene_set_viewport. Auto
|
|
886
|
+
* bars show while max > 0; a box toggles its bars at most twice per frame,
|
|
887
|
+
* after which a bar may still appear but not hide. Bars paint after the box's
|
|
888
|
+
* children and hit the box. Options are complete and copied. A later call
|
|
889
|
+
* updates options; a changed follow recomputes stuck. stuck starts true and
|
|
890
|
+
* changes only on explicit scrolls (ot_scene_scroll_to, ot_scene_scroll_request),
|
|
891
|
+
* follow changes, and the solves that apply a request or an anchor: it is true
|
|
892
|
+
* when the offset reached the follow edge or max on that axis is at most 1.
|
|
893
|
+
* Rejection preserves accepted state. */
|
|
894
|
+
#define OT_SCENE_SCROLL_X UINT32_C(1)
|
|
895
|
+
#define OT_SCENE_SCROLL_Y UINT32_C(2)
|
|
896
|
+
#define OT_SCENE_SCROLL_FOLLOW_NONE UINT32_C(0)
|
|
897
|
+
#define OT_SCENE_SCROLL_FOLLOW_TOP UINT32_C(1)
|
|
898
|
+
#define OT_SCENE_SCROLL_FOLLOW_BOTTOM UINT32_C(2)
|
|
899
|
+
#define OT_SCENE_SCROLL_FOLLOW_LEFT UINT32_C(3)
|
|
900
|
+
#define OT_SCENE_SCROLL_FOLLOW_RIGHT UINT32_C(4)
|
|
901
|
+
#define OT_SCENE_SCROLL_FILL_WRAPPER UINT32_C(1)
|
|
902
|
+
#define OT_SCENE_SCROLL_FILL_VIEWPORT UINT32_C(2)
|
|
903
|
+
#define OT_SCENE_SCROLL_FILL_CONTENT UINT32_C(4)
|
|
904
|
+
#define OT_SCENE_SCROLL_BAR_AUTO UINT32_C(0)
|
|
905
|
+
#define OT_SCENE_SCROLL_BAR_ALWAYS UINT32_C(1)
|
|
906
|
+
#define OT_SCENE_SCROLL_BAR_NEVER UINT32_C(2)
|
|
907
|
+
#define OT_SCENE_SCROLL_BAR_INSET UINT32_C(0)
|
|
908
|
+
#define OT_SCENE_SCROLL_BAR_OVERLAY UINT32_C(1)
|
|
909
|
+
#define OT_SCENE_SCROLL_RELATIVE_X UINT32_C(1)
|
|
910
|
+
#define OT_SCENE_SCROLL_RELATIVE_Y UINT32_C(2)
|
|
911
|
+
#define OT_SCENE_SCROLL_REAPPLY UINT32_C(4)
|
|
912
|
+
#define OT_SCENE_SCROLL_REQUEST_INTO_VIEW UINT32_C(0)
|
|
913
|
+
#define OT_SCENE_SCROLL_REQUEST_ANCHOR UINT32_C(1)
|
|
914
|
+
#define OT_SCENE_SCROLL_REQUEST_LAYOUT UINT32_C(2)
|
|
915
|
+
#define OT_SCENE_SCROLL_ALIGN_NEAREST UINT32_C(0)
|
|
916
|
+
#define OT_SCENE_SCROLL_ALIGN_START UINT32_C(1)
|
|
917
|
+
#define OT_SCENE_SCROLL_ALIGN_END UINT32_C(2)
|
|
918
|
+
|
|
919
|
+
/* thickness is 1..255 cells and gap 0..255 cells (between content and track);
|
|
920
|
+
* an inset bar's gutter is gap + thickness, an overlay bar takes none. arrows
|
|
921
|
+
* is 0 or 1. Track colors retain terminal color intent. reserved must be zero. */
|
|
922
|
+
typedef struct ot_scene_scroll_bar_options {
|
|
923
|
+
uint32_t policy;
|
|
924
|
+
uint32_t placement;
|
|
925
|
+
uint32_t thickness;
|
|
926
|
+
uint32_t gap;
|
|
927
|
+
uint32_t arrows;
|
|
928
|
+
uint32_t reserved;
|
|
929
|
+
uint16_t track_foreground[4];
|
|
930
|
+
uint16_t track_background[4];
|
|
931
|
+
} ot_scene_scroll_bar_options;
|
|
932
|
+
|
|
933
|
+
#define OT_SCENE_SCROLL_PADDING_MAX UINT32_C(65535)
|
|
934
|
+
/* axes holds OT_SCENE_SCROLL_X/Y. culling is 0 or 1. padding is the viewport
|
|
935
|
+
* padding in whole cells, left, top, right, bottom, each 0..PADDING_MAX. fills selects
|
|
936
|
+
* which of the wrapper (box inner rect minus the vertical gutter), viewport, and
|
|
937
|
+
* content (moving with the offset) backgrounds paint, in that order, before the
|
|
938
|
+
* children. bars[0] is the horizontal bar, bars[1] the vertical bar. */
|
|
939
|
+
typedef struct ot_scene_scroll_options {
|
|
940
|
+
uint32_t struct_size;
|
|
941
|
+
uint32_t abi_version;
|
|
942
|
+
uint32_t axes;
|
|
943
|
+
uint32_t follow;
|
|
944
|
+
uint32_t culling;
|
|
945
|
+
uint32_t fills;
|
|
946
|
+
float padding[4];
|
|
947
|
+
uint16_t wrapper_background[4];
|
|
948
|
+
uint16_t viewport_background[4];
|
|
949
|
+
uint16_t content_background[4];
|
|
950
|
+
ot_scene_scroll_bar_options bars[2];
|
|
951
|
+
} ot_scene_scroll_options;
|
|
952
|
+
|
|
953
|
+
/* Rects are x, y, width, height in cells. track, arrows, and viewport are screen
|
|
954
|
+
* cells of the last prepared frame; content is local to the node. thumb_start
|
|
955
|
+
* and thumb_size are half cells along the track, as ot_scene_slider_thumb. */
|
|
956
|
+
typedef struct ot_scene_scroll_bar_state {
|
|
957
|
+
uint32_t visible;
|
|
958
|
+
uint32_t reserved;
|
|
959
|
+
double track[4];
|
|
960
|
+
double start_arrow[4];
|
|
961
|
+
double end_arrow[4];
|
|
962
|
+
double thumb_start;
|
|
963
|
+
double thumb_size;
|
|
964
|
+
} ot_scene_scroll_bar_state;
|
|
965
|
+
|
|
966
|
+
/* generation changes with every change of the other fields. changes holds the
|
|
967
|
+
* OT_SCENE_SCROLL_CHANGED_* bits that differed from the last report when the last
|
|
968
|
+
* SCROLL request was issued. Setting OT_SCENE_HOOK_SCROLL on a node that did not
|
|
969
|
+
* have it makes the current state the last report. */
|
|
970
|
+
#define OT_SCENE_SCROLL_CHANGED_OFFSET_X UINT32_C(1)
|
|
971
|
+
#define OT_SCENE_SCROLL_CHANGED_OFFSET_Y UINT32_C(2)
|
|
972
|
+
#define OT_SCENE_SCROLL_CHANGED_CONTENT UINT32_C(4)
|
|
973
|
+
#define OT_SCENE_SCROLL_CHANGED_VIEWPORT UINT32_C(8)
|
|
974
|
+
/* Set on the request that delivers an OT_SCENE_SCROLL_REQUEST_LAYOUT callback. */
|
|
975
|
+
#define OT_SCENE_SCROLL_CHANGED_LAYOUT UINT32_C(16)
|
|
976
|
+
typedef struct ot_scene_scroll_state {
|
|
977
|
+
uint32_t struct_size;
|
|
978
|
+
uint32_t abi_version;
|
|
979
|
+
uint32_t stuck;
|
|
980
|
+
uint32_t changes;
|
|
981
|
+
uint64_t generation;
|
|
982
|
+
double offset[2];
|
|
983
|
+
double max[2];
|
|
984
|
+
double content[4];
|
|
985
|
+
double viewport[4];
|
|
986
|
+
ot_scene_scroll_bar_state bars[2];
|
|
987
|
+
} ot_scene_scroll_state;
|
|
988
|
+
|
|
989
|
+
ot_status ot_scene_set_scroll(ot_context *, const ot_handle *node, const ot_scene_scroll_options *);
|
|
990
|
+
/* axis is 0 (horizontal bar) or 1 (vertical bar); end is 0 (start) or 1 (end).
|
|
991
|
+
* Options and text follow ot_scene_set_arrow; direction must be zero and the
|
|
992
|
+
* axis and end choose the glyph unless text is given. */
|
|
993
|
+
ot_status ot_scene_set_scroll_arrow(ot_context *, const ot_handle *node, uint32_t axis, uint32_t end,
|
|
994
|
+
const ot_scene_arrow_options *, const uint8_t *text, uint32_t byte_count);
|
|
995
|
+
/* An explicit scroll. Without RELATIVE_X/Y the values are absolute offsets; a
|
|
996
|
+
* relative delta of 0 keeps an axis. Values round to whole cells and clamp to
|
|
997
|
+
* the limits of the last solve; ±Infinity clamp, NaN returns
|
|
998
|
+
* OT_INVALID_ARGUMENT. It recomputes stuck, moves a held anchor's row with the
|
|
999
|
+
* offset, marks the offset (not the sizes) as reported to the host, and copies
|
|
1000
|
+
* the new state to out_state unless it is NULL. During a frame attempt the next
|
|
1001
|
+
* round prepares at the new offset.
|
|
1002
|
+
* With REAPPLY each axis it sets also keeps its target, and every solve of the
|
|
1003
|
+
* next frame (the current one during an attempt, or a later one if that frame
|
|
1004
|
+
* is cancelled) moves the offset to the target again, clamped to the new limits,
|
|
1005
|
+
* and recomputes stuck. A relative delta adds to a pending target. A target of
|
|
1006
|
+
* +Infinity, or one at or past a positive max of a laid-out node, is the end:
|
|
1007
|
+
* it lands at the new max and releases a held anchor. A following view that the
|
|
1008
|
+
* scroll left stuck where it asked keeps no target on the follow axis. A later
|
|
1009
|
+
* scroll without REAPPLY drops pending targets. */
|
|
1010
|
+
ot_status ot_scene_scroll_to(ot_context *, const ot_handle *node, double x, double y, uint32_t flags,
|
|
1011
|
+
ot_scene_scroll_state *out_state);
|
|
1012
|
+
/* Requests about a node in the scroll node's subtree, read from the last solve
|
|
1013
|
+
* (OT_INVALID_ARGUMENT for a node outside it):
|
|
1014
|
+
* - INTO_VIEW scrolls now so the target's rect is inside the viewport inset by
|
|
1015
|
+
* inset cells (align NEAREST moves the least, as a browser does; START puts its
|
|
1016
|
+
* start at the inset edge; END its end), and again after each solve of the next
|
|
1017
|
+
* frame, as a REAPPLY scroll does; it replaces pending targets. A target that
|
|
1018
|
+
* was never laid out scrolls only after its first solve.
|
|
1019
|
+
* - ANCHOR holds the target's position in the viewport: after each solve the
|
|
1020
|
+
* offset moves with the target, clamped, and stuck is recomputed; while held,
|
|
1021
|
+
* the anchor decides the offset over sticky follow and pending requests. A
|
|
1022
|
+
* target that was never laid out holds the place its first solve gives it. An
|
|
1023
|
+
* explicit scroll moves the held row. A NULL target releases it; so does
|
|
1024
|
+
* destroying the target or moving it out of the subtree. align and inset are 0.
|
|
1025
|
+
* - LAYOUT asks for one SCROLL request (OT_SCENE_SCROLL_CHANGED_LAYOUT in
|
|
1026
|
+
* changes) in the next frame, after its layout settles and before it paints,
|
|
1027
|
+
* while OT_SCENE_HOOK_SCROLL is set and the node is visible. target is NULL,
|
|
1028
|
+
* align and inset are 0.
|
|
1029
|
+
* out_state follows ot_scene_scroll_to. */
|
|
1030
|
+
ot_status ot_scene_scroll_request(ot_context *, const ot_handle *node, uint32_t kind, const ot_handle *target,
|
|
1031
|
+
uint32_t align, uint32_t inset, ot_scene_scroll_state *out_state);
|
|
1032
|
+
/* Pure: it never changes what an OT_SCENE_FRAME_SCROLL request reports. With
|
|
1033
|
+
* OT_SCENE_HOOK_SCROLL (scroll nodes only) a frame returns one SCROLL request,
|
|
1034
|
+
* after the node's refresh and before paint, when the offset differs from the last
|
|
1035
|
+
* reported or written offset, or the content or viewport size from the last
|
|
1036
|
+
* reported size. */
|
|
1037
|
+
ot_status ot_scene_get_scroll(ot_context *, const ot_handle *node, ot_scene_scroll_state *out_state);
|
|
1038
|
+
/* focused is 0 or 1. Stores one accepted target without host focus/input policy.
|
|
1039
|
+
* Focusable boxes on its current ancestor path use focused_border_color. Zero
|
|
1040
|
+
* clears only a matching target and remains valid after Session cancellation. */
|
|
1041
|
+
ot_status ot_scene_set_focus(ot_context *, const ot_handle *node, uint32_t focused);
|
|
1042
|
+
/* Exact size/version and zero reserved where present. Rejection preserves accepted
|
|
1043
|
+
* options and query output. Slider/arrow paint is separate from common node paint;
|
|
1044
|
+
* borders are unsupported. No custom arrow strings or native-to-host paint calls. */
|
|
1045
|
+
ot_status ot_scene_set_slider(ot_context *, const ot_handle *node, const ot_scene_slider_options *);
|
|
1046
|
+
/* Custom text is copied and bounded by OT_BUFFER_TEXT_BYTES_MAX. NULL selects the standard direction glyph. */
|
|
1047
|
+
ot_status ot_scene_set_arrow(ot_context *, const ot_handle *node, const ot_scene_arrow_options *, const uint8_t *text, uint32_t byte_count);
|
|
1048
|
+
/* Uses current observed wrapper dimensions without running Yoga. Before the first
|
|
1049
|
+
* observed layout, dimensions come from ot_scene_set_hooks initial_width/height
|
|
1050
|
+
* (flags may be zero), or default to zero. Later style changes do not change this
|
|
1051
|
+
* constructor baseline. Painting uses completed geometry, not this projection. */
|
|
1052
|
+
ot_status ot_scene_get_slider_thumb(ot_context *, const ot_handle *node, ot_scene_slider_thumb *out_thumb);
|
|
1053
|
+
/* Text nodes own their buffer/view and native measure target. Replacements copy
|
|
1054
|
+
* UTF-8 and preserve content on rejection. Length is bounded by u32 line/column
|
|
1055
|
+
* counts, accounting for tab expansion, not the offscreen drawing call budget.
|
|
1056
|
+
* C0/C1/DEL controls other than tab, CR, and LF are accepted and returned by
|
|
1057
|
+
* queries; painting gives them no cells and never writes them to the terminal.
|
|
1058
|
+
* Line endings normalize to LF in queries. bytes may be NULL only for zero length. Options require exact
|
|
1059
|
+
* size/version; borders and child nodes are not supported on text. */
|
|
1060
|
+
ot_status ot_scene_set_text(ot_context *, const ot_handle *node, const uint8_t *bytes, uint32_t byte_count);
|
|
1061
|
+
/* Copies a complete styled replacement. Every chunk requires exact size/version,
|
|
1062
|
+
* positive UTF-8 byte_count, and zero reserved. Chunk lengths sum to byte_count.
|
|
1063
|
+
* Only FOREGROUND/BACKGROUND/LINK flags and attributes bits 0..7 are accepted. Present
|
|
1064
|
+
* colors retain terminal color intent; absent colors inherit the node defaults.
|
|
1065
|
+
* Chunk widths retain legacy independently measured display-column ranges.
|
|
1066
|
+
* All bytes, styles, and listener storage are prepared before publication.
|
|
1067
|
+
* Rejection preserves accepted content and resources. No style handles.
|
|
1068
|
+
* Each array may be NULL only when its count is zero. link_offset and
|
|
1069
|
+
* link_byte_count select bytes in urls; without LINK both must be zero. URLs are
|
|
1070
|
+
* copied, not normalized. Empty URLs, URLs over 512 bytes,
|
|
1071
|
+
* URLs that are not UTF-8 or hold a C0, DEL or C1 control, and chunks with zero
|
|
1072
|
+
* independently measured width produce no link; their text stays. Oversized
|
|
1073
|
+
* URLs are not truncated. URLs and their references are prepared before publication;
|
|
1074
|
+
* rejection preserves accepted text, styles, and links. urls may be NULL only
|
|
1075
|
+
* when url_byte_count is zero. Link IDs stay local to the owning Context. */
|
|
1076
|
+
ot_status ot_scene_set_styled_text(ot_context *, const ot_handle *node,
|
|
1077
|
+
const uint8_t *bytes, uint32_t byte_count, const ot_styled_text_chunk *chunks, uint32_t chunk_count,
|
|
1078
|
+
const uint8_t *urls, uint32_t url_byte_count);
|
|
1079
|
+
ot_status ot_scene_set_text_options(ot_context *, const ot_handle *node, const ot_scene_text_options *);
|
|
1080
|
+
/* Select through the owned Text view. Coordinates are local display cells/virtual
|
|
1081
|
+
* rows, with signed offscreen positions clamped by the view. Coordinates plus
|
|
1082
|
+
* viewport scroll offsets must fit int32_t. UPDATE retains an
|
|
1083
|
+
* existing document anchor across scrolling, or acts as SET without an anchor.
|
|
1084
|
+
* Exact size/version, zero reserved, and only BACKGROUND/FOREGROUND flags are
|
|
1085
|
+
* accepted. Present colors retain terminal color intent; absent color arrays must be zero.
|
|
1086
|
+
* out_changed is the view's 0/1 change result. Failure preserves selection and
|
|
1087
|
+
* out_changed. RESET needs no allocation and is allowed after Session cancellation.
|
|
1088
|
+
* Mutation is forbidden during measurement callbacks, including RESET. */
|
|
1089
|
+
ot_status ot_scene_set_text_selection(ot_context *, const ot_handle *node,
|
|
1090
|
+
const ot_scene_text_selection_options *, uint32_t *out_changed);
|
|
1091
|
+
/* Packed display-column offsets: start in the high 32 bits, exclusive end in the
|
|
1092
|
+
* low 32 bits. UINT64_MAX means absent or zero-width selection. */
|
|
1093
|
+
ot_status ot_scene_get_text_selection(ot_context *, const ot_handle *node, uint64_t *out_packed);
|
|
1094
|
+
/* Zero capacity reports the exact selected UTF-8 byte count;
|
|
1095
|
+
* absent/zero-width selection reports zero. A copy requires at least
|
|
1096
|
+
* that count and returns the selected byte count, without a terminating
|
|
1097
|
+
* NUL. Insufficient capacity rejects before writing bytes or out_count. bytes may
|
|
1098
|
+
* be NULL only for zero capacity. These reads follow the text getter rules. */
|
|
1099
|
+
ot_status ot_scene_get_selected_text(ot_context *, const ot_handle *node,
|
|
1100
|
+
uint8_t *bytes, uint32_t capacity, uint32_t *out_count);
|
|
1101
|
+
/* Copied queries retain no native memory. Zero capacity reports the exact count;
|
|
1102
|
+
* otherwise insufficient text capacity rejects without writing either output. bytes
|
|
1103
|
+
* and lines may be NULL only for zero capacity. Text has no terminating NUL.
|
|
1104
|
+
* Lines copies virtual lines [first_line, first_line + capacity), clipped to the
|
|
1105
|
+
* count of all virtual lines, not only visible ones, which out_count reports. Info
|
|
1106
|
+
* requires exact size/version. Queries never perform Yoga layout or resize the viewport. */
|
|
1107
|
+
ot_status ot_scene_get_text(ot_context *, const ot_handle *node, uint8_t *bytes, uint32_t capacity, uint32_t *out_count);
|
|
1108
|
+
ot_status ot_scene_get_text_info(ot_context *, const ot_handle *node, ot_scene_text_info *out_info);
|
|
1109
|
+
ot_status ot_scene_get_text_lines(ot_context *, const ot_handle *node, uint32_t first_line,
|
|
1110
|
+
ot_scene_text_line *lines, uint32_t capacity, uint32_t *out_count);
|
|
1111
|
+
/* The byte offset, in the UTF-8 last set on the text node, where the grapheme the latest
|
|
1112
|
+
* finished frame drew at screen cell (x, y) starts. UINT32_MAX when that frame did not
|
|
1113
|
+
* paint the node, when its text or view options changed since, and when the cell lies
|
|
1114
|
+
* outside the node's painted cells or shows no whole grapheme: padding, a truncation
|
|
1115
|
+
* ellipsis, a wide grapheme an edge cuts, zero opacity, or a RENDER_SELF hook's body
|
|
1116
|
+
* in place of the text. A failed paint attempt leaves the answers of the frame before
|
|
1117
|
+
* it, except for nodes it drew. It never lays text out, and does not check
|
|
1118
|
+
* what covers the cell; ot_scene_hit_test does. Follows the text getter rules. */
|
|
1119
|
+
ot_status ot_scene_get_text_byte_at(ot_context *, const ot_handle *node, int32_t x, int32_t y, uint32_t *out_byte);
|
|
1120
|
+
/* OT_LAYOUT_PUBLIC copies local cell geometry from the node's latest preparation refresh.
|
|
1121
|
+
* Below a child that its filtering parent's latest selection culled, which no refresh
|
|
1122
|
+
* reaches, it copies the latest solved geometry instead, if Yoga has laid the node out since
|
|
1123
|
+
* it was created or moved. During host phases, mounted nodes retain their preceding projection until that
|
|
1124
|
+
* refresh; newly placed children refresh before their own update. screen_x/y
|
|
1125
|
+
* combine that geometry with current accepted ancestor relationships
|
|
1126
|
+
* and translations immediately, without running layout. OT_LAYOUT_YOGA instead
|
|
1127
|
+
* copies the six actual Yoga computed values, including zero dimensions, and
|
|
1128
|
+
* sets screen_x/y to zero. OT_LAYOUT_PAINT copies where the latest paint list painted the
|
|
1129
|
+
* node, or where a frame being prepared places it, including screen_x/y, with each axis
|
|
1130
|
+
* that leaves the signed 32-bit cell range clamped to the whole cells it paints within 2^22
|
|
1131
|
+
* of the origin, at least one unless zero; PUBLIC and YOGA keep the unclamped values.
|
|
1132
|
+
* PUBLIC raises a zero width or height to one cell; PAINT keeps it, and a node with a zero
|
|
1133
|
+
* dimension paints and hits no cell. During a RECORD request, mutations do not change those
|
|
1134
|
+
* coordinates. A node that list did not paint (hidden, culled, or detached), and every node
|
|
1135
|
+
* after a solve or after a change between frames that drops the list, until the next list
|
|
1136
|
+
* paints it, reads its latest solved geometry composed with current translations and
|
|
1137
|
+
* offsets; zeros if Yoga has not laid it out since it was created or moved. While a host
|
|
1138
|
+
* request is pending, such a node's first read holds. OT_LAYOUT_CONTENT is PAINT without a
|
|
1139
|
+
* text node's padding, its content edges rounded as Yoga rounds the node's own edges (no
|
|
1140
|
+
* padding reads the box): the cells its text view fills, which paint, wrapping, text byte
|
|
1141
|
+
* hits, selection and body draws use. Other nodes read PAINT.
|
|
1142
|
+
* These reads do not run layout. Other selectors reject without changing output.
|
|
1143
|
+
* A scroll node's children report YOGA values local to its content node, and their
|
|
1144
|
+
* screen_x/y compose through the viewport and content origins and the offset. */
|
|
1145
|
+
ot_status ot_scene_get_layout(ot_context *, const ot_handle *node, uint32_t observation, ot_scene_layout *out_layout);
|
|
1146
|
+
/* Paint a hook-free scene and retain its DONE draft in out_frame. Commit it with
|
|
1147
|
+
* ot_scene_frame_commit, or cancel it before painting again. Frame-qualified
|
|
1148
|
+
* effects and capture may run before commit. Initialize out_frame's exact
|
|
1149
|
+
* size/version and zero reserved fields; rejection leaves it unchanged.
|
|
1150
|
+
* No output or hit publication occurs until commit and output completion.
|
|
1151
|
+
* Pending presentation rejects painting; accepted scene mutations remain valid.
|
|
1152
|
+
* excluded_hit_num is the captured node's public number, or zero. It excludes
|
|
1153
|
+
* only that node from this frame's hits, not its painting or descendants.
|
|
1154
|
+
* Uses the same phase engine, but rejects registered hooks before layout with
|
|
1155
|
+
* OT_UNSUPPORTED_RESOURCE. Use ot_scene_frame_step_with_geometry for host hooks. */
|
|
1156
|
+
ot_status ot_scene_paint(ot_context *, const ot_handle *session, const uint16_t background[4], uint32_t use_mouse, uint32_t excluded_hit_num, ot_scene_frame_request *out_frame);
|
|
1157
|
+
ot_status ot_scene_hit_test(ot_context *, const ot_handle *session, int32_t x, int32_t y, uint32_t *out_num);
|
|
1158
|
+
/* ot_scene_hit_test as if the node with public number excluded_num painted no hits (zero
|
|
1159
|
+
* excludes none). Its descendants still hit. A drag looks up targets through its source. */
|
|
1160
|
+
ot_status ot_scene_hit_test_excluding(ot_context *, const ot_handle *session, int32_t x, int32_t y, uint32_t excluded_num, uint32_t *out_num);
|
|
1161
|
+
ot_status ot_scene_get_stats(ot_context *, const ot_handle *session, ot_scene_stats *out_stats);
|
|
1162
|
+
#define OT_SCENE_DEBUG_FULL_FRAME UINT32_C(1)
|
|
1163
|
+
#define OT_SCENE_DEBUG_VERIFY UINT32_C(2)
|
|
1164
|
+
/* Diagnostic switches for tests. FULL_FRAME rebuilds each frame's preparation
|
|
1165
|
+
* and paint lists instead of reusing the last frame's, and every later shortcut
|
|
1166
|
+
* that skips frame work also tests it; Yoga still solves only a dirty tree, and
|
|
1167
|
+
* geometry is read only for nodes laid out since the last solve. Output is
|
|
1168
|
+
* unchanged; only the work counts in ot_scene_stats differ, and frames report
|
|
1169
|
+
* OT_SCENE_FULL_PATH_FORCED. A closed or cancelled Session returns
|
|
1170
|
+
* OT_SESSION_CLOSED, a failed one OT_OUTPUT_FAILED, other bits
|
|
1171
|
+
* OT_INVALID_ARGUMENT, a Session without a scene OT_INVALID_PHASE, and an active
|
|
1172
|
+
* frame attempt, draft, or frame lease OT_FRAME_BUSY. Rejection keeps the flags.
|
|
1173
|
+
* Flags persist for the Session. VERIFY checks frames that retained paint skips
|
|
1174
|
+
* or repaints partly: next must still hold the presented frame, a partly
|
|
1175
|
+
* repainted frame's other rows must match it, and a full repaint into a
|
|
1176
|
+
* scratch buffer must match the cells and hits of a skipped or partly
|
|
1177
|
+
* repainted frame. A mismatch fails the frame step
|
|
1178
|
+
* with OT_INTERNAL_ERROR; VERIFY changes no other state or count. */
|
|
1179
|
+
ot_status ot_scene_set_debug_flags(ot_context *, const ot_handle *session, uint32_t flags);
|
|
1180
|
+
/* Copied renderer cursor state. style is an OT_CURSOR_STYLE_* value.
|
|
1181
|
+
* Colors use normalized float channels. Output requires exact size/version. */
|
|
1182
|
+
ot_status ot_scene_get_cursor_state(ot_context *, const ot_handle *session, ot_scene_cursor_state *out_state);
|
|
1183
|
+
|
|
1184
|
+
/* chunk_size, span_capacity, and max_bytes are explicit and positive. max_bytes
|
|
1185
|
+
* is a multiple of chunk_size and must fit at most UINT32_MAX chunks. It bounds
|
|
1186
|
+
* allocated feed chunks and outstanding payload bytes. span_capacity includes
|
|
1187
|
+
* queued and copied output awaiting completion. All chunks are allocated at creation.
|
|
1188
|
+
* control_capacity is zero for no reservation. A positive value reserves bytes
|
|
1189
|
+
* inside max_bytes, rounded up to whole chunks, with one span slot per chunk.
|
|
1190
|
+
* Ordinary writes cannot use this capacity. The reservation must leave at least
|
|
1191
|
+
* one ordinary chunk and one ordinary span slot. Terminal setup requires at least
|
|
1192
|
+
* OT_SESSION_CONTROL_PACKET_BYTES of rounded control storage. reserved is zero. */
|
|
1193
|
+
typedef struct ot_session_options {
|
|
1194
|
+
uint32_t struct_size;
|
|
1195
|
+
uint32_t abi_version;
|
|
1196
|
+
uint32_t chunk_size;
|
|
1197
|
+
uint32_t span_capacity;
|
|
1198
|
+
uint64_t max_bytes;
|
|
1199
|
+
uint32_t control_capacity;
|
|
1200
|
+
uint32_t reserved;
|
|
1201
|
+
} ot_session_options;
|
|
1202
|
+
|
|
1203
|
+
/* Output bytes are copied into caller-owned storage. Complete this exact ticket
|
|
1204
|
+
* only after its bytes reach the transport, not when a write merely queues them.
|
|
1205
|
+
* At most one ticket is pending per session. reserved is always zero. */
|
|
1206
|
+
typedef struct ot_output_ticket {
|
|
1207
|
+
ot_handle session;
|
|
1208
|
+
uint64_t request_id;
|
|
1209
|
+
uint32_t byte_count;
|
|
1210
|
+
uint32_t reserved;
|
|
1211
|
+
} ot_output_ticket;
|
|
1212
|
+
|
|
1213
|
+
#define OT_SESSION_OPEN UINT32_C(0)
|
|
1214
|
+
#define OT_SESSION_CLOSING UINT32_C(1)
|
|
1215
|
+
#define OT_SESSION_CLOSED_STATE UINT32_C(2)
|
|
1216
|
+
#define OT_SESSION_FAILED UINT32_C(3)
|
|
1217
|
+
#define OT_SESSION_CANCELLED_STATE UINT32_C(4)
|
|
1218
|
+
|
|
1219
|
+
/* Attach without terminal setup or output. Dimensions are positive terminal
|
|
1220
|
+
* cells and obey the Context's render_cells_max. remote is 0 or 1; remote
|
|
1221
|
+
* terminals do not inherit the local terminal environment. reserved is zero. */
|
|
1222
|
+
typedef struct ot_session_renderer_options {
|
|
1223
|
+
uint32_t struct_size;
|
|
1224
|
+
uint32_t abi_version;
|
|
1225
|
+
uint32_t width;
|
|
1226
|
+
uint32_t height;
|
|
1227
|
+
uint32_t remote;
|
|
1228
|
+
uint32_t reserved;
|
|
1229
|
+
} ot_session_renderer_options;
|
|
1230
|
+
|
|
1231
|
+
#define OT_SESSION_REMOTE_AUTO UINT32_C(0)
|
|
1232
|
+
#define OT_SESSION_REMOTE_LOCAL UINT32_C(1)
|
|
1233
|
+
#define OT_SESSION_REMOTE_REMOTE UINT32_C(2)
|
|
1234
|
+
#define OT_SESSION_ENV_ENTRIES_MAX UINT32_C(256)
|
|
1235
|
+
#define OT_SESSION_ENV_BYTES_MAX UINT32_C(65536)
|
|
1236
|
+
|
|
1237
|
+
/* Additive attachment with initialization-only copied host environment. For each
|
|
1238
|
+
* of entry_count entries, the payload holds the little-endian u32 key and value
|
|
1239
|
+
* byte lengths, then the key bytes and the value bytes. Keys and values are
|
|
1240
|
+
* UTF-8 without NUL; keys are nonempty and exclude '='. byte_count includes the
|
|
1241
|
+
* eight length bytes per entry. Duplicate keys use the last value. Empty payload opts out.
|
|
1242
|
+
* Auto detects remote sessions but ignores forwarded host hints when remote;
|
|
1243
|
+
* explicit local/remote modes apply all supplied hints. No process env is read.
|
|
1244
|
+
* reserved is zero. Payload and options are borrowed only for the call. */
|
|
1245
|
+
typedef struct ot_session_renderer_env_options {
|
|
1246
|
+
uint32_t struct_size;
|
|
1247
|
+
uint32_t abi_version;
|
|
1248
|
+
uint32_t width;
|
|
1249
|
+
uint32_t height;
|
|
1250
|
+
uint32_t remote_mode;
|
|
1251
|
+
uint32_t entry_count;
|
|
1252
|
+
uint32_t byte_count;
|
|
1253
|
+
uint32_t reserved;
|
|
1254
|
+
} ot_session_renderer_env_options;
|
|
1255
|
+
|
|
1256
|
+
#define OT_RENDER_PRESENTED UINT32_C(0)
|
|
1257
|
+
#define OT_RENDER_PENDING UINT32_C(1)
|
|
1258
|
+
#define OT_RENDER_SKIPPED UINT32_C(2)
|
|
1259
|
+
#define OT_RENDER_FAILED UINT32_C(3)
|
|
1260
|
+
|
|
1261
|
+
typedef struct ot_split_snapshot {
|
|
1262
|
+
ot_handle buffer;
|
|
1263
|
+
uint32_t row_columns;
|
|
1264
|
+
uint32_t flags; /* 1 = start on new line, 2 = trailing newline. */
|
|
1265
|
+
} ot_split_snapshot;
|
|
1266
|
+
|
|
1267
|
+
/* command: reset=0, sync=1, output-offset=2, render-offset=3, transition=4,
|
|
1268
|
+
* clear-transition=5. Reset uses seed rows/pinned offset; sync and offset commands
|
|
1269
|
+
* use argument 0. Transition uses mode (viewport-scroll=1, clear=2), source top,
|
|
1270
|
+
* source height, target top, target height, scroll rows. Unused arguments are zero.
|
|
1271
|
+
* Until a split frame applies it or clear-transition drops it, a pending transition
|
|
1272
|
+
* makes ordinary frames, setup, and resume return OT_OUTPUT_BUSY. Controls, clipboard
|
|
1273
|
+
* writes, and notifications do not move the cursor and do not wait for it. */
|
|
1274
|
+
typedef struct ot_split_control {
|
|
1275
|
+
uint32_t struct_size;
|
|
1276
|
+
uint32_t abi_version;
|
|
1277
|
+
uint32_t command;
|
|
1278
|
+
uint32_t arguments[6];
|
|
1279
|
+
} ot_split_control;
|
|
1280
|
+
|
|
1281
|
+
/* Copy a checked painted draft into a Context buffer without presenting it. */
|
|
1282
|
+
ot_status ot_scene_frame_copy_buffer(ot_context *, const ot_handle *session,
|
|
1283
|
+
const ot_scene_frame_request *, const ot_handle *target);
|
|
1284
|
+
/* Solve an idle scene's existing root without frame preparation, hooks, or painting.
|
|
1285
|
+
* Custom Yoga measurement providers may run. Read computed dimensions with raw_yoga=1. */
|
|
1286
|
+
ot_status ot_scene_measure_layout(ot_context *, const ot_handle *session, const ot_handle *root);
|
|
1287
|
+
#define OT_SPLIT_SNAPSHOTS_MAX UINT32_C(64)
|
|
1288
|
+
/* At most SPLIT_SNAPSHOTS_MAX snapshots; Context identities are checked before native bounded copies.
|
|
1289
|
+
* A null frame submits snapshots only, without painting or publishing the footer draft.
|
|
1290
|
+
* After suspension completes, null-frame snapshots remain permitted without reactivating
|
|
1291
|
+
* terminal modes; their output packet leaves the cursor restored. Non-null frames and
|
|
1292
|
+
* submissions during terminal transitions retain the ordinary rendering restrictions.
|
|
1293
|
+
* force is 0/1. OT_OK writes out_status, including SKIPPED and FAILED.
|
|
1294
|
+
* With a frame, all statuses consume the draft under ot_scene_frame_commit's rules.
|
|
1295
|
+
* Without a frame, PENDING may describe an earlier submission; no new snapshots
|
|
1296
|
+
* were accepted in that case. Admission errors preserve a live draft for retry. */
|
|
1297
|
+
ot_status ot_session_render_split(ot_context *, const ot_handle *session, const ot_scene_frame_request *,
|
|
1298
|
+
const ot_split_snapshot *, uint32_t count, uint32_t pinned_render_offset, uint32_t force,
|
|
1299
|
+
uint32_t *out_status);
|
|
1300
|
+
ot_status ot_session_split_control(ot_context *, const ot_handle *session, const ot_split_control *, uint32_t *out_offset);
|
|
1301
|
+
/* Screen mode, dimensions, and copied trailing output are admitted together.
|
|
1302
|
+
* The screen packet plus trailing output must fit within 4096 bytes. */
|
|
1303
|
+
ot_status ot_session_set_screen(ot_context *, const ot_handle *session, uint32_t alternate, uint32_t width, uint32_t height,
|
|
1304
|
+
const uint8_t *trailing_output, uint32_t byte_count);
|
|
1305
|
+
ot_status ot_session_sync_detached(ot_context *, const ot_handle *session, const ot_handle *parent);
|
|
1306
|
+
|
|
1307
|
+
/* Initialize struct_size and abi_version. The remaining fields are output-only.
|
|
1308
|
+
* frame_count counts complete presentations, not queued frames. frame_pending
|
|
1309
|
+
* is 0 or 1. image_uploads_pending counts presented Kitty and Sixel placements
|
|
1310
|
+
* whose image a later frame still sends: uploads that did not fit one frame
|
|
1311
|
+
* wait, and one larger than a frame draws as blocks next. Submit another frame
|
|
1312
|
+
* while it is nonzero. A frame whose output without image uploads is larger than
|
|
1313
|
+
* the write limit returns FAILED: dropped_frame_bytes is then its size (saturated),
|
|
1314
|
+
* and dropped_frames counts each dropped content once. A frame that wrote only some
|
|
1315
|
+
* cells is counted once its full repaint fails too. The same content returns
|
|
1316
|
+
* FAILED again, with its size, without encoding until it changes; any other result
|
|
1317
|
+
* sets dropped_frame_bytes to 0. This copied record borrows no renderer or framebuffer
|
|
1318
|
+
* storage. */
|
|
1319
|
+
typedef struct ot_session_renderer_state {
|
|
1320
|
+
uint32_t struct_size;
|
|
1321
|
+
uint32_t abi_version;
|
|
1322
|
+
uint32_t width;
|
|
1323
|
+
uint32_t height;
|
|
1324
|
+
uint64_t frame_count;
|
|
1325
|
+
uint32_t frame_pending;
|
|
1326
|
+
uint32_t image_uploads_pending;
|
|
1327
|
+
uint32_t dropped_frames;
|
|
1328
|
+
uint32_t dropped_frame_bytes;
|
|
1329
|
+
} ot_session_renderer_state;
|
|
1330
|
+
|
|
1331
|
+
#define OT_SESSION_BUFFER_CURRENT UINT32_C(0)
|
|
1332
|
+
#define OT_SESSION_BUFFER_NEXT UINT32_C(1)
|
|
1333
|
+
|
|
1334
|
+
#define OT_WIDTH_METHOD_WCWIDTH UINT32_C(0)
|
|
1335
|
+
#define OT_WIDTH_METHOD_UNICODE UINT32_C(1)
|
|
1336
|
+
#define OT_WIDTH_METHOD_NO_ZWJ UINT32_C(2)
|
|
1337
|
+
#define OT_WIDTH_METHOD_UNICODE_WIDE UINT32_C(3)
|
|
1338
|
+
#define OT_BUFFER_RESPECT_ALPHA UINT32_C(1)
|
|
1339
|
+
|
|
1340
|
+
/* Context-owned offscreen storage, independent of any Session. Dimensions are
|
|
1341
|
+
* positive, at most INT32_MAX, and width * height obeys render_cells_max.
|
|
1342
|
+
* width_method is one of OT_WIDTH_METHOD_*. flags is zero or
|
|
1343
|
+
* OT_BUFFER_RESPECT_ALPHA; all other bits are rejected. */
|
|
1344
|
+
typedef struct ot_buffer_options {
|
|
1345
|
+
uint32_t struct_size;
|
|
1346
|
+
uint32_t abi_version;
|
|
1347
|
+
uint32_t width;
|
|
1348
|
+
uint32_t height;
|
|
1349
|
+
uint32_t width_method;
|
|
1350
|
+
uint32_t flags;
|
|
1351
|
+
} ot_buffer_options;
|
|
1352
|
+
|
|
1353
|
+
/* Copied records belong to a live Unicode resource. character is not a portable
|
|
1354
|
+
* scalar: pooled values may only be drawn through their owning Context resource. */
|
|
1355
|
+
typedef struct ot_unicode_char {
|
|
1356
|
+
uint32_t width;
|
|
1357
|
+
uint32_t character;
|
|
1358
|
+
} ot_unicode_char;
|
|
1359
|
+
|
|
1360
|
+
/* Encodes one record per drawn glyph. Controls produce no record. A tab, or a
|
|
1361
|
+
* grapheme over the native 128-byte limit or 16 cells, produces one width-1
|
|
1362
|
+
* space per cell. */
|
|
1363
|
+
ot_status ot_unicode_create(ot_context *, const uint8_t *bytes, uint32_t byte_count,
|
|
1364
|
+
uint32_t width_method, ot_handle *out_unicode);
|
|
1365
|
+
ot_status ot_unicode_destroy(ot_context *, const ot_handle *unicode);
|
|
1366
|
+
/* Zero capacity reports the count; insufficient capacity preserves both outputs. */
|
|
1367
|
+
ot_status ot_unicode_get(ot_context *, const ot_handle *unicode, ot_unicode_char *characters,
|
|
1368
|
+
uint32_t capacity, uint32_t *out_count);
|
|
1369
|
+
ot_status ot_buffer_draw_unicode(ot_context *, const ot_handle *target,
|
|
1370
|
+
const ot_scene_frame_request *frame, const ot_handle *unicode, uint32_t index,
|
|
1371
|
+
int32_t x, int32_t y, const uint16_t foreground[4], const uint16_t background[4], uint32_t attributes);
|
|
1372
|
+
|
|
1373
|
+
typedef struct ot_embedded_terminal_options {
|
|
1374
|
+
uint32_t struct_size;
|
|
1375
|
+
uint32_t abi_version;
|
|
1376
|
+
uint32_t cols;
|
|
1377
|
+
uint32_t rows;
|
|
1378
|
+
uint32_t max_scrollback;
|
|
1379
|
+
/* Cell pixel geometry of the host terminal. Kitty image placements are
|
|
1380
|
+
* sized in pixels, so the terminal needs it to place them. Zero falls back
|
|
1381
|
+
* to a nominal 8x16 cell. */
|
|
1382
|
+
uint32_t cell_width_px;
|
|
1383
|
+
uint32_t cell_height_px;
|
|
1384
|
+
uint32_t reserved;
|
|
1385
|
+
} ot_embedded_terminal_options;
|
|
1386
|
+
|
|
1387
|
+
typedef struct ot_embedded_terminal_cursor {
|
|
1388
|
+
uint32_t struct_size;
|
|
1389
|
+
uint32_t abi_version;
|
|
1390
|
+
uint32_t x;
|
|
1391
|
+
uint32_t y;
|
|
1392
|
+
uint32_t has_value;
|
|
1393
|
+
uint32_t visible;
|
|
1394
|
+
uint32_t blinking;
|
|
1395
|
+
uint32_t wide_tail;
|
|
1396
|
+
uint32_t style;
|
|
1397
|
+
uint32_t color_has_value;
|
|
1398
|
+
uint32_t color_r;
|
|
1399
|
+
uint32_t color_g;
|
|
1400
|
+
uint32_t color_b;
|
|
1401
|
+
uint32_t reserved;
|
|
1402
|
+
} ot_embedded_terminal_cursor;
|
|
1403
|
+
/* The emulator's cursor styles for style above; not the OT_CURSOR_STYLE_* order. */
|
|
1404
|
+
#define OT_EMBEDDED_TERMINAL_CURSOR_BAR UINT32_C(0)
|
|
1405
|
+
#define OT_EMBEDDED_TERMINAL_CURSOR_BLOCK UINT32_C(1)
|
|
1406
|
+
#define OT_EMBEDDED_TERMINAL_CURSOR_UNDERLINE UINT32_C(2)
|
|
1407
|
+
#define OT_EMBEDDED_TERMINAL_CURSOR_BLOCK_HOLLOW UINT32_C(3)
|
|
1408
|
+
|
|
1409
|
+
/* The active screen's viewport, in rows. offset is the distance from the live
|
|
1410
|
+
* screen (0 there; total - visible at the top of history). total includes the
|
|
1411
|
+
* visible rows; the alternate screen has no history. Output, resizes, scrollback
|
|
1412
|
+
* clears, and screen switches move the viewport too; read it after each. */
|
|
1413
|
+
typedef struct ot_embedded_terminal_scrollbar {
|
|
1414
|
+
uint32_t struct_size;
|
|
1415
|
+
uint32_t abi_version;
|
|
1416
|
+
uint32_t offset;
|
|
1417
|
+
uint32_t total;
|
|
1418
|
+
uint32_t visible;
|
|
1419
|
+
uint32_t reserved;
|
|
1420
|
+
} ot_embedded_terminal_scrollbar;
|
|
1421
|
+
|
|
1422
|
+
typedef struct ot_embedded_terminal_key {
|
|
1423
|
+
uint32_t struct_size;
|
|
1424
|
+
uint32_t abi_version;
|
|
1425
|
+
uint32_t action;
|
|
1426
|
+
uint32_t composing;
|
|
1427
|
+
uint32_t mods;
|
|
1428
|
+
uint32_t consumed_mods;
|
|
1429
|
+
uint32_t unshifted_codepoint;
|
|
1430
|
+
uint32_t reserved;
|
|
1431
|
+
} ot_embedded_terminal_key;
|
|
1432
|
+
|
|
1433
|
+
typedef struct ot_embedded_terminal_mouse {
|
|
1434
|
+
uint32_t struct_size;
|
|
1435
|
+
uint32_t abi_version;
|
|
1436
|
+
uint32_t action;
|
|
1437
|
+
int32_t button;
|
|
1438
|
+
uint32_t mods;
|
|
1439
|
+
uint32_t any_button_pressed;
|
|
1440
|
+
float x;
|
|
1441
|
+
float y;
|
|
1442
|
+
} ot_embedded_terminal_mouse;
|
|
1443
|
+
|
|
1444
|
+
/* mods and consumed_mods use the emulator's bits, not OT_INPUT_MOD_*. It has no
|
|
1445
|
+
* Hyper or Meta: hosts send Kitty Meta as ALT. button is BUTTON_NONE for motion
|
|
1446
|
+
* without a pressed button. */
|
|
1447
|
+
#define OT_EMBEDDED_TERMINAL_MOD_SHIFT UINT32_C(1)
|
|
1448
|
+
#define OT_EMBEDDED_TERMINAL_MOD_CTRL UINT32_C(2)
|
|
1449
|
+
#define OT_EMBEDDED_TERMINAL_MOD_ALT UINT32_C(4)
|
|
1450
|
+
#define OT_EMBEDDED_TERMINAL_MOD_SUPER UINT32_C(8)
|
|
1451
|
+
#define OT_EMBEDDED_TERMINAL_MOD_CAPS_LOCK UINT32_C(16)
|
|
1452
|
+
#define OT_EMBEDDED_TERMINAL_MOD_NUM_LOCK UINT32_C(32)
|
|
1453
|
+
#define OT_EMBEDDED_TERMINAL_KEY_RELEASE UINT32_C(0)
|
|
1454
|
+
#define OT_EMBEDDED_TERMINAL_KEY_PRESS UINT32_C(1)
|
|
1455
|
+
#define OT_EMBEDDED_TERMINAL_KEY_REPEAT UINT32_C(2)
|
|
1456
|
+
#define OT_EMBEDDED_TERMINAL_MOUSE_PRESS UINT32_C(0)
|
|
1457
|
+
#define OT_EMBEDDED_TERMINAL_MOUSE_RELEASE UINT32_C(1)
|
|
1458
|
+
#define OT_EMBEDDED_TERMINAL_MOUSE_MOTION UINT32_C(2)
|
|
1459
|
+
#define OT_EMBEDDED_TERMINAL_BUTTON_NONE INT32_C(-1)
|
|
1460
|
+
#define OT_EMBEDDED_TERMINAL_BUTTON_UNKNOWN INT32_C(0)
|
|
1461
|
+
#define OT_EMBEDDED_TERMINAL_BUTTON_LEFT INT32_C(1)
|
|
1462
|
+
#define OT_EMBEDDED_TERMINAL_BUTTON_RIGHT INT32_C(2)
|
|
1463
|
+
#define OT_EMBEDDED_TERMINAL_BUTTON_MIDDLE INT32_C(3)
|
|
1464
|
+
#define OT_EMBEDDED_TERMINAL_BUTTON_FOUR INT32_C(4)
|
|
1465
|
+
#define OT_EMBEDDED_TERMINAL_BUTTON_FIVE INT32_C(5)
|
|
1466
|
+
#define OT_EMBEDDED_TERMINAL_BUTTON_SIX INT32_C(6)
|
|
1467
|
+
#define OT_EMBEDDED_TERMINAL_BUTTON_SEVEN INT32_C(7)
|
|
1468
|
+
|
|
1469
|
+
/* All option records require exact size/version and zero reserved fields.
|
|
1470
|
+
* Booleans are 0/1. Input and output buffers are borrowed only during the call.
|
|
1471
|
+
* Columns and rows are positive u16 values within the Context cell budget.
|
|
1472
|
+
* Write, key-name, key-text, and paste inputs are each limited to INPUT_BYTES_MAX. */
|
|
1473
|
+
#define OT_EMBEDDED_TERMINAL_INPUT_BYTES_MAX UINT32_C(1048576)
|
|
1474
|
+
ot_status ot_embedded_terminal_create(ot_context *, const ot_embedded_terminal_options *, ot_handle *out_terminal);
|
|
1475
|
+
ot_status ot_embedded_terminal_destroy(ot_context *, const ot_handle *terminal);
|
|
1476
|
+
ot_status ot_embedded_terminal_write(ot_context *, const ot_handle *terminal, const uint8_t *bytes, uint32_t byte_count);
|
|
1477
|
+
ot_status ot_embedded_terminal_resize(ot_context *, const ot_handle *terminal, uint32_t cols, uint32_t rows);
|
|
1478
|
+
/* Cell pixel geometry of the host terminal. Zero keeps the current value. */
|
|
1479
|
+
ot_status ot_embedded_terminal_set_cell_size(ot_context *, const ot_handle *terminal, uint32_t cell_width_px, uint32_t cell_height_px);
|
|
1480
|
+
#define OT_EMBEDDED_TERMINAL_INVALIDATE UINT32_C(0)
|
|
1481
|
+
#define OT_EMBEDDED_TERMINAL_SCROLL UINT32_C(1)
|
|
1482
|
+
#define OT_EMBEDDED_TERMINAL_CLEAR_SELECTION UINT32_C(2)
|
|
1483
|
+
#define OT_EMBEDDED_TERMINAL_SET_TRANSPARENT_BACKGROUND UINT32_C(3)
|
|
1484
|
+
/* argument is a signed row delta for SCROLL, zero otherwise. */
|
|
1485
|
+
ot_status ot_embedded_terminal_command(ot_context *, const ot_handle *terminal, uint32_t command, int32_t argument);
|
|
1486
|
+
ot_status ot_embedded_terminal_set_selection(ot_context *, const ot_handle *terminal,
|
|
1487
|
+
uint32_t start_x, uint32_t start_y, uint32_t end_x, uint32_t end_y);
|
|
1488
|
+
/* Selected text and encode calls accept zero capacity to query exact byte counts.
|
|
1489
|
+
* Insufficient nonzero capacity preserves output bytes/count and mouse state.
|
|
1490
|
+
* No returned buffer includes a terminating NUL. */
|
|
1491
|
+
ot_status ot_embedded_terminal_get_selected_text(ot_context *, const ot_handle *terminal,
|
|
1492
|
+
uint8_t *bytes, uint32_t capacity, uint32_t *out_count);
|
|
1493
|
+
ot_status ot_embedded_terminal_compose(ot_context *, const ot_handle *terminal, const ot_handle *target,
|
|
1494
|
+
const ot_scene_frame_request *frame, int32_t x, int32_t y);
|
|
1495
|
+
ot_status ot_embedded_terminal_cursor_get(ot_context *, const ot_handle *terminal, ot_embedded_terminal_cursor *out_cursor);
|
|
1496
|
+
ot_status ot_embedded_terminal_scrollbar_get(ot_context *, const ot_handle *terminal, ot_embedded_terminal_scrollbar *out_scrollbar);
|
|
1497
|
+
ot_status ot_embedded_terminal_encode_key(ot_context *, const ot_handle *terminal, const ot_embedded_terminal_key *,
|
|
1498
|
+
const uint8_t *key, uint32_t key_count, const uint8_t *text, uint32_t text_count,
|
|
1499
|
+
uint8_t *bytes, uint32_t capacity, uint32_t *out_count);
|
|
1500
|
+
ot_status ot_embedded_terminal_encode_mouse(ot_context *, const ot_handle *terminal, const ot_embedded_terminal_mouse *,
|
|
1501
|
+
uint8_t *bytes, uint32_t capacity, uint32_t *out_count);
|
|
1502
|
+
ot_status ot_embedded_terminal_encode_paste(ot_context *, const ot_handle *terminal,
|
|
1503
|
+
const uint8_t *input, uint32_t input_count, uint8_t *bytes, uint32_t capacity, uint32_t *out_count);
|
|
1504
|
+
ot_status ot_embedded_terminal_encode_focus(ot_context *, const ot_handle *terminal,
|
|
1505
|
+
uint32_t focused, uint8_t *bytes, uint32_t capacity, uint32_t *out_count);
|
|
1506
|
+
#define OT_EMBEDDED_TERMINAL_RESPONSE_BYTES_MAX UINT32_C(1048576)
|
|
1507
|
+
/* Drains at most capacity bytes, not a sizing query. Response overflow returns
|
|
1508
|
+
* OT_OUTPUT_BACKPRESSURE once without consuming the retained RESPONSE_BYTES_MAX prefix. */
|
|
1509
|
+
ot_status ot_embedded_terminal_drain_responses(ot_context *, const ot_handle *terminal,
|
|
1510
|
+
uint8_t *bytes, uint32_t capacity, uint32_t *out_count);
|
|
1511
|
+
|
|
1512
|
+
/* Context-owned editor resources use checked handles, never legacy pointers.
|
|
1513
|
+
* Options require exact size/version and zero reserved. width_method uses
|
|
1514
|
+
* OT_WIDTH_METHOD_*. Creation failures leave output handles unchanged. */
|
|
1515
|
+
typedef struct ot_edit_buffer_options {
|
|
1516
|
+
uint32_t struct_size;
|
|
1517
|
+
uint32_t abi_version;
|
|
1518
|
+
uint32_t width_method;
|
|
1519
|
+
uint32_t reserved;
|
|
1520
|
+
} ot_edit_buffer_options;
|
|
1521
|
+
|
|
1522
|
+
/* Initialize size/version and zero remaining fields. Other fields are copied output.
|
|
1523
|
+
* Cursor row is a zero-based document line; col and offset count display columns,
|
|
1524
|
+
* not UTF-8 bytes or code points. can_undo and can_redo are 0 or 1.
|
|
1525
|
+
* tab_width is the even display-cell width in [2, 254].
|
|
1526
|
+
* content_epoch is an invalidation token, not a count of user edits. */
|
|
1527
|
+
typedef struct ot_edit_buffer_info {
|
|
1528
|
+
uint32_t struct_size;
|
|
1529
|
+
uint32_t abi_version;
|
|
1530
|
+
uint64_t content_epoch;
|
|
1531
|
+
uint32_t byte_count;
|
|
1532
|
+
uint32_t line_count;
|
|
1533
|
+
uint32_t cursor_row;
|
|
1534
|
+
uint32_t cursor_col;
|
|
1535
|
+
uint32_t cursor_offset;
|
|
1536
|
+
uint32_t can_undo;
|
|
1537
|
+
uint32_t can_redo;
|
|
1538
|
+
uint32_t tab_width;
|
|
1539
|
+
} ot_edit_buffer_info;
|
|
1540
|
+
|
|
1541
|
+
#define OT_EDIT_CURSOR_CHANGED UINT32_C(1)
|
|
1542
|
+
#define OT_EDIT_CONTENT_CHANGED UINT32_C(2)
|
|
1543
|
+
#define OT_EDIT_HISTORY_CURSOR_CHANGED UINT32_C(4)
|
|
1544
|
+
|
|
1545
|
+
/* Mouse pointer shapes, named after CSS cursor values. */
|
|
1546
|
+
#define OT_MOUSE_POINTER_AUTO UINT32_C(0)
|
|
1547
|
+
#define OT_MOUSE_POINTER_DEFAULT UINT32_C(1)
|
|
1548
|
+
#define OT_MOUSE_POINTER_NONE UINT32_C(2)
|
|
1549
|
+
#define OT_MOUSE_POINTER_CONTEXT_MENU UINT32_C(3)
|
|
1550
|
+
#define OT_MOUSE_POINTER_HELP UINT32_C(4)
|
|
1551
|
+
#define OT_MOUSE_POINTER_POINTER UINT32_C(5)
|
|
1552
|
+
#define OT_MOUSE_POINTER_PROGRESS UINT32_C(6)
|
|
1553
|
+
#define OT_MOUSE_POINTER_WAIT UINT32_C(7)
|
|
1554
|
+
#define OT_MOUSE_POINTER_CELL UINT32_C(8)
|
|
1555
|
+
#define OT_MOUSE_POINTER_CROSSHAIR UINT32_C(9)
|
|
1556
|
+
#define OT_MOUSE_POINTER_TEXT UINT32_C(10)
|
|
1557
|
+
#define OT_MOUSE_POINTER_VERTICAL_TEXT UINT32_C(11)
|
|
1558
|
+
#define OT_MOUSE_POINTER_ALIAS UINT32_C(12)
|
|
1559
|
+
#define OT_MOUSE_POINTER_COPY UINT32_C(13)
|
|
1560
|
+
#define OT_MOUSE_POINTER_MOVE UINT32_C(14)
|
|
1561
|
+
#define OT_MOUSE_POINTER_NO_DROP UINT32_C(15)
|
|
1562
|
+
#define OT_MOUSE_POINTER_NOT_ALLOWED UINT32_C(16)
|
|
1563
|
+
#define OT_MOUSE_POINTER_GRAB UINT32_C(17)
|
|
1564
|
+
#define OT_MOUSE_POINTER_GRABBING UINT32_C(18)
|
|
1565
|
+
#define OT_MOUSE_POINTER_ALL_SCROLL UINT32_C(19)
|
|
1566
|
+
#define OT_MOUSE_POINTER_COL_RESIZE UINT32_C(20)
|
|
1567
|
+
#define OT_MOUSE_POINTER_ROW_RESIZE UINT32_C(21)
|
|
1568
|
+
#define OT_MOUSE_POINTER_N_RESIZE UINT32_C(22)
|
|
1569
|
+
#define OT_MOUSE_POINTER_E_RESIZE UINT32_C(23)
|
|
1570
|
+
#define OT_MOUSE_POINTER_S_RESIZE UINT32_C(24)
|
|
1571
|
+
#define OT_MOUSE_POINTER_W_RESIZE UINT32_C(25)
|
|
1572
|
+
#define OT_MOUSE_POINTER_NE_RESIZE UINT32_C(26)
|
|
1573
|
+
#define OT_MOUSE_POINTER_NW_RESIZE UINT32_C(27)
|
|
1574
|
+
#define OT_MOUSE_POINTER_SE_RESIZE UINT32_C(28)
|
|
1575
|
+
#define OT_MOUSE_POINTER_SW_RESIZE UINT32_C(29)
|
|
1576
|
+
#define OT_MOUSE_POINTER_EW_RESIZE UINT32_C(30)
|
|
1577
|
+
#define OT_MOUSE_POINTER_NS_RESIZE UINT32_C(31)
|
|
1578
|
+
#define OT_MOUSE_POINTER_NESW_RESIZE UINT32_C(32)
|
|
1579
|
+
#define OT_MOUSE_POINTER_NWSE_RESIZE UINT32_C(33)
|
|
1580
|
+
#define OT_MOUSE_POINTER_ZOOM_IN UINT32_C(34)
|
|
1581
|
+
#define OT_MOUSE_POINTER_ZOOM_OUT UINT32_C(35)
|
|
1582
|
+
#define OT_MOUSE_POINTER_MAX OT_MOUSE_POINTER_ZOOM_OUT
|
|
1583
|
+
/* Editor options only: leave the current mouse pointer unchanged. */
|
|
1584
|
+
#define OT_MOUSE_POINTER_UNCHANGED UINT32_C(0xFFFFFFFF)
|
|
1585
|
+
|
|
1586
|
+
/* Complete cursor options, not a patch. Exact size/version and zero reserved.
|
|
1587
|
+
* show_cursor and blinking are 0 or 1. style is an OT_CURSOR_STYLE_* value.
|
|
1588
|
+
* color retains packed intent for capture; cursor output uses its RGB snapshot.
|
|
1589
|
+
* mouse_pointer is an OT_MOUSE_POINTER_* shape or OT_MOUSE_POINTER_UNCHANGED. */
|
|
1590
|
+
typedef struct ot_scene_editor_options {
|
|
1591
|
+
uint32_t struct_size;
|
|
1592
|
+
uint32_t abi_version;
|
|
1593
|
+
uint32_t show_cursor;
|
|
1594
|
+
uint32_t style;
|
|
1595
|
+
uint32_t blinking;
|
|
1596
|
+
uint32_t reserved;
|
|
1597
|
+
uint16_t color[4];
|
|
1598
|
+
uint32_t mouse_pointer;
|
|
1599
|
+
uint32_t reserved2;
|
|
1600
|
+
} ot_scene_editor_options;
|
|
1601
|
+
|
|
1602
|
+
ot_status ot_edit_buffer_create(ot_context *, const ot_edit_buffer_options *, ot_handle *out_edit_buffer);
|
|
1603
|
+
/* Destroying an edit buffer also destroys its views and unbinds their scene nodes.
|
|
1604
|
+
* Destroying a view alone leaves its edit buffer alive. */
|
|
1605
|
+
ot_status ot_edit_buffer_destroy(ot_context *, const ot_handle *edit_buffer);
|
|
1606
|
+
/* Initial viewport dimensions are display cells, from zero through INT32_MAX. */
|
|
1607
|
+
ot_status ot_editor_view_create(ot_context *, const ot_handle *edit_buffer,
|
|
1608
|
+
uint32_t width, uint32_t height, ot_handle *out_view);
|
|
1609
|
+
ot_status ot_editor_view_destroy(ot_context *, const ot_handle *view);
|
|
1610
|
+
/* Creates an empty style table. Destroying it clears attached native references. */
|
|
1611
|
+
ot_status ot_syntax_style_create(ot_context *, ot_handle *out_style);
|
|
1612
|
+
ot_status ot_syntax_style_destroy(ot_context *, const ot_handle *style);
|
|
1613
|
+
/* NULL clears the binding. A non-NULL style must belong to this Context. */
|
|
1614
|
+
ot_status ot_edit_buffer_set_syntax_style(ot_context *, const ot_handle *edit_buffer, const ot_handle *style);
|
|
1615
|
+
/* Copy UTF-8 bytes into owned storage; bytes may be NULL only for zero length.
|
|
1616
|
+
* Editors keep C0, DEL, and C1 controls and show them as notation: ^@..^_ and ^?
|
|
1617
|
+
* in two cells, <80>..<9f> in four. Tab, CR, and LF keep their meaning. Queries
|
|
1618
|
+
* normalize line endings to LF. preserve_history is 0 (clear history) or 1 (create an undo point).
|
|
1619
|
+
* Replacement resets the cursor to the origin; insertion uses the primary cursor.
|
|
1620
|
+
* No input memory remains borrowed after return. */
|
|
1621
|
+
ot_status ot_edit_buffer_set_text(ot_context *, const ot_handle *edit_buffer,
|
|
1622
|
+
const uint8_t *bytes, uint32_t byte_count, uint32_t preserve_history);
|
|
1623
|
+
ot_status ot_edit_buffer_insert_text(ot_context *, const ot_handle *edit_buffer,
|
|
1624
|
+
const uint8_t *bytes, uint32_t byte_count);
|
|
1625
|
+
/* Zero-based document rows and display columns. Deletion orders its endpoints and
|
|
1626
|
+
* excludes the end; equal endpoints do nothing. Cursor setting clamps to the text. */
|
|
1627
|
+
ot_status ot_edit_buffer_delete_range(ot_context *, const ot_handle *edit_buffer,
|
|
1628
|
+
uint32_t start_row, uint32_t start_col, uint32_t end_row, uint32_t end_col);
|
|
1629
|
+
ot_status ot_edit_buffer_set_cursor(ot_context *, const ot_handle *edit_buffer, uint32_t row, uint32_t col);
|
|
1630
|
+
/* Zero capacity reports the exact UTF-8 byte count. Otherwise capacity must fit
|
|
1631
|
+
* all bytes; undersized calls preserve both outputs. No terminating NUL is added.
|
|
1632
|
+
* bytes may be NULL only for zero capacity. Copied outputs borrow no native memory.
|
|
1633
|
+
* These getters and the view getter allow readonly measurement-callback reentry,
|
|
1634
|
+
* but not reentry from an edit notification during a mutation. */
|
|
1635
|
+
ot_status ot_edit_buffer_get_text(ot_context *, const ot_handle *edit_buffer,
|
|
1636
|
+
uint8_t *bytes, uint32_t capacity, uint32_t *out_count);
|
|
1637
|
+
ot_status ot_edit_buffer_get_info(ot_context *, const ot_handle *edit_buffer, ot_edit_buffer_info *out_info);
|
|
1638
|
+
/* width is a display-cell tab stop. Native code rounds it up to an even value in [2, 254]. */
|
|
1639
|
+
ot_status ot_edit_buffer_set_tab_width(ot_context *, const ot_handle *edit_buffer, uint32_t width);
|
|
1640
|
+
|
|
1641
|
+
/* Editor transport records require exact size/version. Unknown selectors and
|
|
1642
|
+
* unused nonzero arguments reject. Mutations reject callback reentry and validate
|
|
1643
|
+
* every native measure dependency. Invalidation never reinstalls an unset provider.
|
|
1644
|
+
* All coordinates and offsets count display cells, never UTF-8 bytes. */
|
|
1645
|
+
#define OT_EDIT_DELETE_FORWARD UINT32_C(0)
|
|
1646
|
+
#define OT_EDIT_BACKSPACE UINT32_C(1)
|
|
1647
|
+
#define OT_EDIT_NEW_LINE UINT32_C(2)
|
|
1648
|
+
#define OT_EDIT_DELETE_LINE UINT32_C(3)
|
|
1649
|
+
#define OT_EDIT_MOVE_LEFT UINT32_C(4)
|
|
1650
|
+
#define OT_EDIT_MOVE_RIGHT UINT32_C(5)
|
|
1651
|
+
#define OT_EDIT_MOVE_UP UINT32_C(6)
|
|
1652
|
+
#define OT_EDIT_MOVE_DOWN UINT32_C(7)
|
|
1653
|
+
#define OT_EDIT_GOTO_LINE UINT32_C(8)
|
|
1654
|
+
#define OT_EDIT_CURSOR_OFFSET UINT32_C(9)
|
|
1655
|
+
#define OT_EDIT_CLEAR UINT32_C(10)
|
|
1656
|
+
#define OT_EDIT_CLEAR_HISTORY UINT32_C(11)
|
|
1657
|
+
#define OT_EDIT_DEBUG_ROPE UINT32_C(12)
|
|
1658
|
+
/* argument is a line/offset for GOTO_LINE/CURSOR_OFFSET, zero otherwise. */
|
|
1659
|
+
ot_status ot_edit_buffer_command(ot_context *, const ot_handle *, uint32_t command, uint32_t argument);
|
|
1660
|
+
/* redo is 0/1. Capacity must be at least 64, the native cursor-metadata bound,
|
|
1661
|
+
* before history is changed. No history returns zero bytes. */
|
|
1662
|
+
ot_status ot_edit_buffer_history(ot_context *, const ot_handle *, uint32_t redo,
|
|
1663
|
+
uint8_t *bytes, uint32_t capacity, uint32_t *out_count);
|
|
1664
|
+
|
|
1665
|
+
#define OT_EDIT_POSITION_CURSOR UINT32_C(0)
|
|
1666
|
+
#define OT_EDIT_POSITION_NEXT_WORD UINT32_C(1)
|
|
1667
|
+
#define OT_EDIT_POSITION_PREV_WORD UINT32_C(2)
|
|
1668
|
+
#define OT_EDIT_POSITION_EOL UINT32_C(3)
|
|
1669
|
+
#define OT_EDIT_POSITION_OFFSET UINT32_C(4)
|
|
1670
|
+
#define OT_EDIT_POSITION_COORDS UINT32_C(5)
|
|
1671
|
+
#define OT_EDIT_POSITION_LINE_START UINT32_C(6)
|
|
1672
|
+
#define OT_EDIT_POSITION_END UINT32_C(7)
|
|
1673
|
+
#define OT_EDIT_POSITION_PREV_CHAR UINT32_C(8)
|
|
1674
|
+
typedef struct ot_edit_position {
|
|
1675
|
+
uint32_t struct_size;
|
|
1676
|
+
uint32_t abi_version;
|
|
1677
|
+
uint32_t valid;
|
|
1678
|
+
uint32_t row;
|
|
1679
|
+
uint32_t col;
|
|
1680
|
+
uint32_t offset;
|
|
1681
|
+
} ot_edit_position;
|
|
1682
|
+
/* a is offset, row, or line for OFFSET, COORDS, LINE_START; b is col for COORDS.
|
|
1683
|
+
* Other inputs are zero. Invalid positions return valid=0 and zero coordinates.
|
|
1684
|
+
* END is the text's end, PREV_CHAR where MOVE_LEFT would go; no query moves the cursor. */
|
|
1685
|
+
ot_status ot_edit_buffer_get_position(ot_context *, const ot_handle *, uint32_t query,
|
|
1686
|
+
uint32_t a, uint32_t b, ot_edit_position *out_position);
|
|
1687
|
+
/* by_coords=0 uses start_col/end_col as offsets and requires zero rows;
|
|
1688
|
+
* by_coords=1 uses all coordinates. Offsets and columns are display cells, not
|
|
1689
|
+
* UTF-8 bytes. Zero capacity returns the exact selected UTF-8 byte count;
|
|
1690
|
+
* nonzero capacity must fit that count. Short copies preserve both outputs.
|
|
1691
|
+
* Grapheme boundaries follow the text range rules below. */
|
|
1692
|
+
ot_status ot_edit_buffer_get_range(ot_context *, const ot_handle *, uint32_t by_coords,
|
|
1693
|
+
uint32_t start_row, uint32_t start_col, uint32_t end_row, uint32_t end_col,
|
|
1694
|
+
uint8_t *bytes, uint32_t capacity, uint32_t *out_count);
|
|
1695
|
+
/* Lays UTF-8 bytes out as set_text would, without storing them, and reports the offset at
|
|
1696
|
+
* their end: display cells under the buffer's width method, tab width, and control notation,
|
|
1697
|
+
* plus one per line break (LF, CR, or CRLF). bytes may be NULL only for zero length; the
|
|
1698
|
+
* byte limit and UTF-8 validation of set_text apply. Failures preserve out_width. */
|
|
1699
|
+
ot_status ot_edit_buffer_measure_text(ot_context *, const ot_handle *edit_buffer,
|
|
1700
|
+
const uint8_t *bytes, uint32_t byte_count, uint32_t *out_width);
|
|
1701
|
+
/* Measures as ot_edit_buffer_measure_text does on an edit buffer with this width method and
|
|
1702
|
+
* tab width, without a buffer. tab_width rounds as in ot_edit_buffer_set_tab_width, so 0
|
|
1703
|
+
* gives the tab width of a new edit buffer; a tab_width over 255 fails. */
|
|
1704
|
+
ot_status ot_edit_measure_text(ot_context *, const uint8_t *bytes, uint32_t byte_count,
|
|
1705
|
+
uint32_t width_method, uint32_t tab_width, uint32_t *out_width);
|
|
1706
|
+
|
|
1707
|
+
#define OT_EDITOR_STYLE_FOREGROUND UINT32_C(1)
|
|
1708
|
+
#define OT_EDITOR_STYLE_BACKGROUND UINT32_C(2)
|
|
1709
|
+
#define OT_EDITOR_STYLE_ATTRIBUTES UINT32_C(4)
|
|
1710
|
+
/* Syntax styles only, with OT_EDITOR_STYLE_ATTRIBUTES: attributes bits 16..23 say which of bits
|
|
1711
|
+
* 0..7 the style supplies. */
|
|
1712
|
+
#define OT_EDITOR_STYLE_ATTRIBUTE_MASK UINT32_C(8)
|
|
1713
|
+
typedef struct ot_editor_style {
|
|
1714
|
+
uint32_t struct_size;
|
|
1715
|
+
uint32_t abi_version;
|
|
1716
|
+
uint32_t flags;
|
|
1717
|
+
uint32_t attributes;
|
|
1718
|
+
uint16_t foreground[4];
|
|
1719
|
+
uint16_t background[4];
|
|
1720
|
+
} ot_editor_style;
|
|
1721
|
+
/* mask selects fields to update. flags identifies present (non-null) values.
|
|
1722
|
+
* Absent fields are zero; colors retain terminal color intent, attributes bits 0..7.
|
|
1723
|
+
* Reset uses mask=7 and flags=0. */
|
|
1724
|
+
ot_status ot_edit_buffer_set_defaults(ot_context *, const ot_handle *, uint32_t mask, const ot_editor_style *);
|
|
1725
|
+
/* Names are copied UTF-8; registering an existing name replaces its definition.
|
|
1726
|
+
* Empty names are valid; name may be NULL only when byte_count is zero. Ids are
|
|
1727
|
+
* below OT_STYLE_RUN_FLAG. A group set composes its names in order: each later name
|
|
1728
|
+
* replaces fg, bg, and the attribute bits it supplies. Without
|
|
1729
|
+
* OT_EDITOR_STYLE_ATTRIBUTE_MASK, a style with OT_EDITOR_STYLE_ATTRIBUTES supplies all
|
|
1730
|
+
* eight bits and one without supplies none. Set bits 0..7 outside the supplied bits fail. */
|
|
1731
|
+
ot_status ot_syntax_style_register(ot_context *, const ot_handle *, const uint8_t *name,
|
|
1732
|
+
uint32_t byte_count, const ot_editor_style *, uint32_t *out_id);
|
|
1733
|
+
/* Unknown names return id=0. Names are borrowed only for the query. */
|
|
1734
|
+
ot_status ot_syntax_style_resolve(ot_context *, const ot_handle *, const uint8_t *name,
|
|
1735
|
+
uint32_t byte_count, uint32_t *out_id);
|
|
1736
|
+
ot_status ot_syntax_style_get_count(ot_context *, const ot_handle *, uint32_t *out_count);
|
|
1737
|
+
|
|
1738
|
+
#define OT_EDIT_HIGHLIGHT_ADD_LINE UINT32_C(0)
|
|
1739
|
+
#define OT_EDIT_HIGHLIGHT_ADD_RANGE UINT32_C(1)
|
|
1740
|
+
#define OT_EDIT_HIGHLIGHT_REMOVE_REF UINT32_C(2)
|
|
1741
|
+
#define OT_EDIT_HIGHLIGHT_CLEAR_LINE UINT32_C(3)
|
|
1742
|
+
#define OT_EDIT_HIGHLIGHT_CLEAR_ALL UINT32_C(4)
|
|
1743
|
+
/* Highlight style ids with this bit name a text buffer's styled-text styles; styled
|
|
1744
|
+
* text interns them by value in the buffer and never writes the attached SyntaxStyle.
|
|
1745
|
+
* get_highlights reports them; equal styles share one id, unstyled text has id 0. */
|
|
1746
|
+
#define OT_STYLE_RUN_FLAG UINT32_C(0x80000000)
|
|
1747
|
+
typedef struct ot_edit_highlight {
|
|
1748
|
+
uint32_t start;
|
|
1749
|
+
uint32_t end;
|
|
1750
|
+
uint32_t style_id;
|
|
1751
|
+
uint32_t priority;
|
|
1752
|
+
uint32_t ref;
|
|
1753
|
+
} ot_edit_highlight;
|
|
1754
|
+
/* highlight is required only for ADD operations. argument is line for ADD_LINE/
|
|
1755
|
+
* CLEAR_LINE, ref for REMOVE_REF, zero otherwise. priority<=255, ref<=65535, and
|
|
1756
|
+
* style_id has no OT_STYLE_RUN_FLAG.
|
|
1757
|
+
* start/end are display columns: within line argument for ADD_LINE; for ADD_RANGE,
|
|
1758
|
+
* document offsets that skip line breaks, unlike cursor, selection, and get_range
|
|
1759
|
+
* offsets, which count one cell per line break. In "ab\ncd", range 3..4 is "d". */
|
|
1760
|
+
ot_status ot_edit_buffer_highlight(ot_context *, const ot_handle *, uint32_t operation,
|
|
1761
|
+
uint32_t argument, const ot_edit_highlight *highlight);
|
|
1762
|
+
/* Copies the highlights on line in ADD_LINE columns; a range gives one record per line
|
|
1763
|
+
* where it covers a column. Zero capacity reports the count; otherwise all records
|
|
1764
|
+
* must fit, and undersized calls preserve both outputs. */
|
|
1765
|
+
ot_status ot_edit_buffer_get_highlights(ot_context *, const ot_handle *, uint32_t line,
|
|
1766
|
+
ot_edit_highlight *highlights, uint32_t capacity, uint32_t *out_count);
|
|
1767
|
+
|
|
1768
|
+
/* Interns an ordered list of SyntaxStyle names as a group set. names is a pool of UTF-8
|
|
1769
|
+
* names; name_end_bytes[i] is the exclusive end of name i, and the last end is
|
|
1770
|
+
* name_byte_count. Equal lists give equal ids on this Context, whatever style a buffer binds;
|
|
1771
|
+
* ids are never freed. Paint composes the names against the buffer's bound style, later names
|
|
1772
|
+
* winning, and a missing name falls back to its first dotted component. Names must be
|
|
1773
|
+
* nonempty. More than OT_GROUP_SET_NAME_COUNT_MAX names, a name over
|
|
1774
|
+
* OT_GROUP_SET_NAME_BYTE_COUNT_MAX bytes, or a new set past 4,096 sets or 64 KiB of names fails
|
|
1775
|
+
* with OT_OBJECT_LIMIT. Failures preserve out_group_set. */
|
|
1776
|
+
#define OT_GROUP_SET_NAME_COUNT_MAX UINT32_C(16)
|
|
1777
|
+
#define OT_GROUP_SET_NAME_BYTE_COUNT_MAX UINT32_C(64)
|
|
1778
|
+
ot_status ot_context_group_set(ot_context *, const uint8_t *names, uint32_t name_byte_count,
|
|
1779
|
+
const uint32_t *name_end_bytes, uint32_t name_count, uint32_t *out_group_set);
|
|
1780
|
+
|
|
1781
|
+
typedef struct ot_highlight_run {
|
|
1782
|
+
uint32_t start_byte;
|
|
1783
|
+
uint32_t end_byte;
|
|
1784
|
+
uint32_t group_set; /* id from ot_context_group_set */
|
|
1785
|
+
} ot_highlight_run;
|
|
1786
|
+
/* Replaces layer layer_id of the buffer inside [start_byte, end_byte), start_byte <= end_byte,
|
|
1787
|
+
* with runs, in UTF-8 bytes of the text as get_text returns it (one byte per line break);
|
|
1788
|
+
* runs may be NULL only when run_count is zero. Runs are nonempty,
|
|
1789
|
+
* sorted, non-overlapping, inside the range and inside the text, and start and end on code
|
|
1790
|
+
* point boundaries; so must range edges inside the text. A range end past the text reaches
|
|
1791
|
+
* its end. Runs that cross the range edges keep their outside parts. One transaction: a
|
|
1792
|
+
* rejection leaves the layer unchanged. Runs move with edits: they shift, a run grows when
|
|
1793
|
+
* text is inserted strictly inside it, and deleted bytes clip them. set_text, clear, undo,
|
|
1794
|
+
* redo and the CLEAR_ALL highlight operation empty every layer; REMOVE_REF and CLEAR_LINE
|
|
1795
|
+
* leave layers alone. Layers paint at priority 0: above highlights of priority 0, below
|
|
1796
|
+
* higher priorities; where layers overlap, the higher layer_id wins. A run without a link
|
|
1797
|
+
* whose group set supplies no field (fg, bg or attribute bit) paints as if absent. At most 4 nonempty
|
|
1798
|
+
* layers per buffer: a fifth fails with OT_OBJECT_LIMIT, and a layer left empty is dropped. */
|
|
1799
|
+
ot_status ot_edit_buffer_set_layer(ot_context *, const ot_handle *, uint32_t layer_id,
|
|
1800
|
+
uint32_t start_byte, uint32_t end_byte, const ot_highlight_run *runs, uint32_t run_count);
|
|
1801
|
+
|
|
1802
|
+
/* A streamed Markdown document (CommonMark 0.31.2 with GFM tables, strikethrough, task lists and
|
|
1803
|
+
* extended autolinks), parsed incrementally. Blocks have preorder indices, which are their ids;
|
|
1804
|
+
* a removal is always a suffix. Complete lines parse exactly; the bytes after the last line
|
|
1805
|
+
* ending are laid out provisionally, held while their kind can still change. Limits: source
|
|
1806
|
+
* 64 MiB, 1,048,576 blocks, 4,096 link definitions, 32 levels of nesting, hook filter 256
|
|
1807
|
+
* bytes, 32 emphasis runs waiting for a closer (past it the oldest is text and never matches).
|
|
1808
|
+
* A rejected call changes nothing: the document, its bound nodes and its pending
|
|
1809
|
+
* changes stay as they were. An accepted call writes its bound nodes after its change; a node
|
|
1810
|
+
* write that runs out of memory leaves that node behind until a later call writes it whole. */
|
|
1811
|
+
#define OT_MD_CONCEAL UINT32_C(1) /* hide markers; off, a leaf shows its source, styled */
|
|
1812
|
+
#define OT_MD_HYPERLINKS UINT32_C(2) /* the terminal shows links; off, a label that is not its
|
|
1813
|
+
URL is followed by " (url)" */
|
|
1814
|
+
#define OT_MD_MATH UINT32_C(4) /* $…$, \(…\) inline math; $$ and \[ blocks (code, MATH) */
|
|
1815
|
+
#define OT_MD_HOOK UINT32_C(8) /* prose leaves whose source holds a filter substring latch
|
|
1816
|
+
HOOKED: the host writes them */
|
|
1817
|
+
typedef struct ot_markdown_options {
|
|
1818
|
+
uint32_t struct_size;
|
|
1819
|
+
uint32_t abi_version;
|
|
1820
|
+
uint32_t flags; /* OT_MD_* */
|
|
1821
|
+
uint32_t source_byte_limit; /* 0 = 64 MiB; may only lower it */
|
|
1822
|
+
ot_handle syntax_style; /* style the bound nodes and read_leaf resolve with; zero = none */
|
|
1823
|
+
uint32_t hook_filter_byte_count; /* <= OT_MD_HOOK_FILTER_BYTE_COUNT_MAX */
|
|
1824
|
+
uint32_t reserved;
|
|
1825
|
+
/* At most 16 NUL-separated substrings, each 1..64 bytes, in the first
|
|
1826
|
+
* hook_filter_byte_count bytes; none with OT_MD_HOOK = every prose leaf is hooked. */
|
|
1827
|
+
uint8_t hook_filter[256];
|
|
1828
|
+
} ot_markdown_options;
|
|
1829
|
+
#define OT_MD_HOOK_FILTER_BYTE_COUNT_MAX UINT32_C(256)
|
|
1830
|
+
typedef struct ot_markdown_result {
|
|
1831
|
+
uint32_t changed_block_count; /* blocks read_changes lists now */
|
|
1832
|
+
uint32_t committed_top_level_count; /* leading top-level blocks that are final */
|
|
1833
|
+
uint32_t removed_from_index; /* blocks at this index and after were removed since
|
|
1834
|
+
the last read; UINT32_MAX = none */
|
|
1835
|
+
} ot_markdown_result;
|
|
1836
|
+
/* The doc keeps a copy of the filter. syntax_style must name a live style. */
|
|
1837
|
+
ot_status ot_markdown_create(ot_context *, const ot_markdown_options *, ot_handle *out_doc);
|
|
1838
|
+
/* Bound nodes keep their last text. */
|
|
1839
|
+
ot_status ot_markdown_destroy(ot_context *, const ot_handle *doc);
|
|
1840
|
+
/* Conceal, hyperlink, math, hook and limit changes parse the source again: blocks equal to the
|
|
1841
|
+
* old ones keep their indices, bound nodes whose leaf output changed are written again (the
|
|
1842
|
+
* listed ones the host writes), and the blocks after the first difference are removed. A style
|
|
1843
|
+
* change binds the bound nodes to the new style without a rewrite. A finished doc stays
|
|
1844
|
+
* finished. */
|
|
1845
|
+
ot_status ot_markdown_set_options(ot_context *, const ot_handle *doc, const ot_markdown_options *,
|
|
1846
|
+
ot_markdown_result *out);
|
|
1847
|
+
/* bytes is valid UTF-8 and may be NULL only when byte_count is zero. After finish, an append is
|
|
1848
|
+
* a fresh parse of the whole source and the bytes. */
|
|
1849
|
+
ot_status ot_markdown_append(ot_context *, const ot_handle *doc, const uint8_t *bytes,
|
|
1850
|
+
uint32_t byte_count, ot_markdown_result *out);
|
|
1851
|
+
/* A fresh parse of bytes; leading blocks equal to the old ones keep their indices unreported. */
|
|
1852
|
+
ot_status ot_markdown_set(ot_context *, const ot_handle *doc, const uint8_t *bytes,
|
|
1853
|
+
uint32_t byte_count, ot_markdown_result *out);
|
|
1854
|
+
/* Ends the document: the pending line is complete and every block closes. A fence or math
|
|
1855
|
+
* block without its closer stays without OT_MD_BLOCK_CLOSED. */
|
|
1856
|
+
ot_status ot_markdown_finish(ot_context *, const ot_handle *doc, ot_markdown_result *out);
|
|
1857
|
+
/* The source, borrowed until the next mutating call on doc or its destruction. */
|
|
1858
|
+
ot_status ot_markdown_get_source(ot_context *, const ot_handle *doc, const uint8_t **out_bytes,
|
|
1859
|
+
uint32_t *out_byte_count);
|
|
1860
|
+
|
|
1861
|
+
#define OT_MD_PARAGRAPH UINT32_C(0)
|
|
1862
|
+
#define OT_MD_HEADING UINT32_C(1)
|
|
1863
|
+
#define OT_MD_CODE UINT32_C(2) /* fenced, indented, or display math (OT_MD_BLOCK_MATH) */
|
|
1864
|
+
#define OT_MD_HTML UINT32_C(3) /* shown as its source text */
|
|
1865
|
+
#define OT_MD_RULE UINT32_C(4)
|
|
1866
|
+
#define OT_MD_TABLE UINT32_C(5)
|
|
1867
|
+
#define OT_MD_TABLE_ROW UINT32_C(6)
|
|
1868
|
+
#define OT_MD_TABLE_CELL UINT32_C(7) /* a row's source cells only; shorter rows have fewer */
|
|
1869
|
+
#define OT_MD_QUOTE UINT32_C(8)
|
|
1870
|
+
#define OT_MD_LIST UINT32_C(9)
|
|
1871
|
+
#define OT_MD_ITEM UINT32_C(10)
|
|
1872
|
+
#define OT_MD_BLOCK_CLOSED UINT32_C(1) /* a fence's or math block's closer arrived */
|
|
1873
|
+
#define OT_MD_BLOCK_SETEXT UINT32_C(2)
|
|
1874
|
+
#define OT_MD_BLOCK_ORDERED UINT32_C(4)
|
|
1875
|
+
#define OT_MD_BLOCK_TIGHT UINT32_C(8) /* set when the list closes */
|
|
1876
|
+
#define OT_MD_BLOCK_TASK UINT32_C(16)
|
|
1877
|
+
#define OT_MD_BLOCK_CHECKED UINT32_C(32)
|
|
1878
|
+
#define OT_MD_BLOCK_BLANK_AFTER UINT32_C(64) /* a blank line separates the item from the next */
|
|
1879
|
+
#define OT_MD_BLOCK_FENCED UINT32_C(128)
|
|
1880
|
+
#define OT_MD_BLOCK_HOOKED UINT32_C(256)
|
|
1881
|
+
#define OT_MD_BLOCK_MATH UINT32_C(512) /* display math: a code block of the language math */
|
|
1882
|
+
#define OT_MD_BLOCK_HEADER UINT32_C(1024) /* a table's header row */
|
|
1883
|
+
#define OT_MD_BLOCK_OPEN UINT32_C(2048) /* later lines may still extend the block */
|
|
1884
|
+
typedef struct ot_markdown_block {
|
|
1885
|
+
uint32_t index; /* preorder index = block id */
|
|
1886
|
+
uint32_t parent_index; /* UINT32_MAX at top level */
|
|
1887
|
+
uint16_t kind; /* OT_MD_PARAGRAPH .. OT_MD_ITEM */
|
|
1888
|
+
uint16_t flags; /* OT_MD_BLOCK_* */
|
|
1889
|
+
uint32_t source_start_byte;
|
|
1890
|
+
uint32_t source_end_byte;
|
|
1891
|
+
uint32_t info_start_byte; /* a fence's info string; empty otherwise */
|
|
1892
|
+
uint32_t info_end_byte;
|
|
1893
|
+
uint32_t number; /* heading level, list start, table column count, cell column */
|
|
1894
|
+
} ot_markdown_block;
|
|
1895
|
+
/* Lists every block changed since the last successful read, in document order, and clears the
|
|
1896
|
+
* pending changes and removed_from_index. A zero or short capacity reports the count and
|
|
1897
|
+
* acknowledges nothing. blocks may be NULL only when block_capacity is zero. */
|
|
1898
|
+
ot_status ot_markdown_read_changes(ot_context *, const ot_handle *doc, ot_markdown_block *blocks,
|
|
1899
|
+
uint32_t block_capacity, uint32_t *out_block_count);
|
|
1900
|
+
#define OT_MD_SPAN_CODE UINT32_C(1)
|
|
1901
|
+
#define OT_MD_SPAN_MATH UINT32_C(2)
|
|
1902
|
+
/* The parser's output for a leaf (paragraph, heading, code, HTML block or table cell), never a
|
|
1903
|
+
* host's: its display bytes, styled chunks resolved through the doc's style (links point into
|
|
1904
|
+
* urls, as ot_scene_set_styled_text takes them), and, when spans is not NULL, one OT_MD_SPAN_*
|
|
1905
|
+
* word per chunk. All capacities zero report the three counts; otherwise each must hold its
|
|
1906
|
+
* count, and an undersized call writes nothing. A pointer may be NULL only with zero capacity. */
|
|
1907
|
+
/* A paragraph's, heading's or table cell's inline source: its content with container markers
|
|
1908
|
+
* and leading whitespace removed, lines joined by '\n', trailing whitespace and leading link
|
|
1909
|
+
* definitions dropped, a cell's escaped pipes unescaped (what an inline hook gets as the
|
|
1910
|
+
* block's source). Zero capacity reports the count; a short one writes nothing. */
|
|
1911
|
+
ot_status ot_markdown_read_source(ot_context *, const ot_handle *doc, uint32_t block_index,
|
|
1912
|
+
uint8_t *bytes, uint32_t byte_capacity, uint32_t *out_byte_count);
|
|
1913
|
+
ot_status ot_markdown_read_leaf(ot_context *, const ot_handle *doc, uint32_t block_index,
|
|
1914
|
+
uint8_t *bytes, uint32_t byte_capacity, uint32_t *out_byte_count,
|
|
1915
|
+
ot_styled_text_chunk *chunks, uint32_t *spans, uint32_t chunk_capacity, uint32_t *out_chunk_count,
|
|
1916
|
+
uint8_t *urls, uint32_t url_byte_capacity, uint32_t *out_url_byte_count);
|
|
1917
|
+
/* Binds a scene text node to a paragraph or heading: the node draws with the doc's style, and
|
|
1918
|
+
* while the leaf is not hooked and the doc conceals and shows hyperlinks, the doc writes the
|
|
1919
|
+
* leaf's display and Markdown runs to it now and on every change. A removal of the block
|
|
1920
|
+
* unbinds it; a destroyed node is skipped. A node the host writes (the doc does not) is never
|
|
1921
|
+
* written by another call: when a call makes the doc write such a leaf, it unbinds the node and
|
|
1922
|
+
* lists the leaf, and binding the node again hands it over. */
|
|
1923
|
+
ot_status ot_markdown_bind(ot_context *, const ot_handle *doc, uint32_t block_index,
|
|
1924
|
+
const ot_handle *text_node);
|
|
1925
|
+
|
|
1926
|
+
typedef struct ot_editor_viewport {
|
|
1927
|
+
uint32_t struct_size;
|
|
1928
|
+
uint32_t abi_version;
|
|
1929
|
+
uint32_t x;
|
|
1930
|
+
uint32_t y;
|
|
1931
|
+
uint32_t width;
|
|
1932
|
+
uint32_t height;
|
|
1933
|
+
} ot_editor_viewport;
|
|
1934
|
+
/* size_only and move_cursor are 0/1. size_only requires zero x/y and move_cursor.
|
|
1935
|
+
* Viewports and their coordinate sums must fit INT32_MAX. */
|
|
1936
|
+
ot_status ot_editor_view_set_viewport(ot_context *, const ot_handle *, const ot_editor_viewport *,
|
|
1937
|
+
uint32_t size_only, uint32_t move_cursor);
|
|
1938
|
+
/* Cursor changes (edits and moves) do not lay out text; they make a scroll to the cursor
|
|
1939
|
+
* due. The viewport read and the other editor view calls apply a due scroll first, so the
|
|
1940
|
+
* viewport read can lay out text and return OT_OUT_OF_MEMORY, but only while a scroll is due. */
|
|
1941
|
+
ot_status ot_editor_view_get_viewport(ot_context *, const ot_handle *, ot_editor_viewport *out_viewport);
|
|
1942
|
+
ot_status ot_editor_view_set_scroll_margin(ot_context *, const ot_handle *, float margin);
|
|
1943
|
+
#define OT_EDITOR_MOVE_UP UINT32_C(0)
|
|
1944
|
+
#define OT_EDITOR_MOVE_DOWN UINT32_C(1)
|
|
1945
|
+
#define OT_EDITOR_GOTO_LINE_END UINT32_C(2)
|
|
1946
|
+
#define OT_EDITOR_DELETE_SELECTION UINT32_C(3)
|
|
1947
|
+
#define OT_EDITOR_CURSOR_OFFSET UINT32_C(4)
|
|
1948
|
+
#define OT_EDITOR_WRAP_MODE UINT32_C(5)
|
|
1949
|
+
#define OT_EDITOR_TAB_INDICATOR UINT32_C(6)
|
|
1950
|
+
/* argument is offset, OT_SCENE_WRAP_*, or Unicode scalar (0 disables) for the
|
|
1951
|
+
* last three commands, and zero otherwise. */
|
|
1952
|
+
ot_status ot_editor_view_command(ot_context *, const ot_handle *, uint32_t command, uint32_t argument);
|
|
1953
|
+
/* Atomic selected delete-then-insert using native editor history and event order.
|
|
1954
|
+
* Without a selection inserts at the primary cursor. Input bytes are copied. */
|
|
1955
|
+
/* out_steps reports committed history steps: 1 = deletion, 2 = insertion. */
|
|
1956
|
+
ot_status ot_editor_view_replace_selection(ot_context *, const ot_handle *, const uint8_t *bytes,
|
|
1957
|
+
uint32_t byte_count, uint32_t *out_steps);
|
|
1958
|
+
/* NULL clears the tab color. */
|
|
1959
|
+
ot_status ot_editor_view_set_tab_color(ot_context *, const ot_handle *, const uint16_t color[4]);
|
|
1960
|
+
|
|
1961
|
+
#define OT_EDITOR_SELECT_SET UINT32_C(0)
|
|
1962
|
+
#define OT_EDITOR_SELECT_UPDATE UINT32_C(1)
|
|
1963
|
+
#define OT_EDITOR_SELECT_RESET UINT32_C(2)
|
|
1964
|
+
#define OT_EDITOR_SELECT_LOCAL UINT32_C(3)
|
|
1965
|
+
#define OT_EDITOR_SELECT_LOCAL_UPDATE UINT32_C(4)
|
|
1966
|
+
#define OT_EDITOR_SELECT_LOCAL_RESET UINT32_C(5)
|
|
1967
|
+
#define OT_EDITOR_SELECT_CELL UINT32_C(6)
|
|
1968
|
+
#define OT_EDITOR_SELECT_OCCUPANCY UINT32_C(7)
|
|
1969
|
+
#define OT_EDITOR_SELECT_INCLUSIVE UINT32_C(8)
|
|
1970
|
+
#define OT_EDITOR_SELECT_COLORS UINT32_C(9)
|
|
1971
|
+
/* SET/UPDATE use flattened document display-column offsets (start/end), with an
|
|
1972
|
+
* exclusive end and one position per line separator. LOCAL/LOCAL_UPDATE use viewport-local display cells (x) and
|
|
1973
|
+
* virtual rows (y). Scene text selection always uses that local coordinate space.
|
|
1974
|
+
* These aliases name the coordinate space as well as the operation. */
|
|
1975
|
+
#define OT_SELECT_DOCUMENT_SET OT_EDITOR_SELECT_SET
|
|
1976
|
+
#define OT_SELECT_DOCUMENT_UPDATE OT_EDITOR_SELECT_UPDATE
|
|
1977
|
+
#define OT_SELECT_DOCUMENT_RESET OT_EDITOR_SELECT_RESET
|
|
1978
|
+
#define OT_SELECT_VIEWPORT_SET OT_EDITOR_SELECT_LOCAL
|
|
1979
|
+
#define OT_SELECT_VIEWPORT_UPDATE OT_EDITOR_SELECT_LOCAL_UPDATE
|
|
1980
|
+
#define OT_SELECT_VIEWPORT_RESET OT_EDITOR_SELECT_LOCAL_RESET
|
|
1981
|
+
#define OT_SELECTION_CELL UINT32_C(0)
|
|
1982
|
+
#define OT_SELECTION_WORD UINT32_C(1)
|
|
1983
|
+
#define OT_SELECTION_LINE UINT32_C(2)
|
|
1984
|
+
#define OT_SELECTION_OCCUPANCY_CELL UINT32_C(0)
|
|
1985
|
+
#define OT_SELECTION_OCCUPANCY_BOUNDARY UINT32_C(1)
|
|
1986
|
+
typedef struct ot_editor_selection {
|
|
1987
|
+
uint32_t struct_size;
|
|
1988
|
+
uint32_t abi_version;
|
|
1989
|
+
uint32_t operation;
|
|
1990
|
+
uint32_t behavior;
|
|
1991
|
+
uint32_t start;
|
|
1992
|
+
uint32_t end;
|
|
1993
|
+
int32_t anchor_x;
|
|
1994
|
+
int32_t anchor_y;
|
|
1995
|
+
int32_t focus_x;
|
|
1996
|
+
int32_t focus_y;
|
|
1997
|
+
uint32_t update_cursor;
|
|
1998
|
+
uint32_t follow_cursor;
|
|
1999
|
+
uint32_t flags;
|
|
2000
|
+
uint32_t reserved;
|
|
2001
|
+
uint16_t foreground[4];
|
|
2002
|
+
uint16_t background[4];
|
|
2003
|
+
} ot_editor_selection;
|
|
2004
|
+
/* flags uses FOREGROUND/BACKGROUND; behavior is OT_SELECTION_CELL/WORD/LINE for local
|
|
2005
|
+
* operations, or OT_SELECTION_OCCUPANCY_* for OCCUPANCY. Unused fields are zero.
|
|
2006
|
+
* out_changed is meaningful for LOCAL/LOCAL_UPDATE/CELL, otherwise zero. */
|
|
2007
|
+
ot_status ot_editor_view_select(ot_context *, const ot_handle *, const ot_editor_selection *, uint32_t *out_changed);
|
|
2008
|
+
typedef struct ot_editor_view_info {
|
|
2009
|
+
uint32_t struct_size;
|
|
2010
|
+
uint32_t abi_version;
|
|
2011
|
+
uint32_t virtual_line_count;
|
|
2012
|
+
uint32_t total_virtual_line_count;
|
|
2013
|
+
uint32_t selection_present;
|
|
2014
|
+
uint32_t selection_start;
|
|
2015
|
+
uint32_t selection_end;
|
|
2016
|
+
uint32_t selection_occupancy;
|
|
2017
|
+
} ot_editor_view_info;
|
|
2018
|
+
/* follow_cursor is 0/1. Zero preserves the viewport during observational queries, apart
|
|
2019
|
+
* from a scroll that an earlier cursor change made due; one retains editor render-preparation
|
|
2020
|
+
* behavior for visible line-count queries. */
|
|
2021
|
+
ot_status ot_editor_view_get_info(ot_context *, const ot_handle *, uint32_t follow_cursor, ot_editor_view_info *out_info);
|
|
2022
|
+
/* Reads selection without preparing lines or following the cursor. Reuses the
|
|
2023
|
+
* info record with both line counts zero; absent or zero-width selections report
|
|
2024
|
+
* selection_present=0 and zero offsets. */
|
|
2025
|
+
ot_status ot_editor_view_get_selection(ot_context *, const ot_handle *, ot_editor_view_info *out_info);
|
|
2026
|
+
/* Exact selected UTF-8 byte query/copy, as for ot_scene_get_selected_text.
|
|
2027
|
+
* Does not prepare lines or follow the cursor. */
|
|
2028
|
+
ot_status ot_editor_view_get_selected_text(ot_context *, const ot_handle *,
|
|
2029
|
+
uint8_t *bytes, uint32_t capacity, uint32_t *out_count);
|
|
2030
|
+
#define OT_EDITOR_POSITION_CURSOR UINT32_C(0)
|
|
2031
|
+
#define OT_EDITOR_POSITION_NEXT_WORD UINT32_C(1)
|
|
2032
|
+
#define OT_EDITOR_POSITION_PREV_WORD UINT32_C(2)
|
|
2033
|
+
#define OT_EDITOR_POSITION_EOL UINT32_C(3)
|
|
2034
|
+
#define OT_EDITOR_POSITION_VISUAL_SOL UINT32_C(4)
|
|
2035
|
+
#define OT_EDITOR_POSITION_VISUAL_EOL UINT32_C(5)
|
|
2036
|
+
typedef struct ot_editor_position {
|
|
2037
|
+
uint32_t struct_size;
|
|
2038
|
+
uint32_t abi_version;
|
|
2039
|
+
uint32_t visual_row;
|
|
2040
|
+
uint32_t visual_col;
|
|
2041
|
+
uint32_t logical_row;
|
|
2042
|
+
uint32_t logical_col;
|
|
2043
|
+
uint32_t offset;
|
|
2044
|
+
} ot_editor_position;
|
|
2045
|
+
ot_status ot_editor_view_get_position(ot_context *, const ot_handle *, uint32_t query, ot_editor_position *out_position);
|
|
2046
|
+
typedef struct ot_editor_measure {
|
|
2047
|
+
uint32_t struct_size;
|
|
2048
|
+
uint32_t abi_version;
|
|
2049
|
+
uint32_t line_count;
|
|
2050
|
+
uint32_t width_cols_max;
|
|
2051
|
+
} ot_editor_measure;
|
|
2052
|
+
/* Both modes copy wrapped rows. logical=0 first scrolls the viewport to the cursor, as
|
|
2053
|
+
* ot_editor_view_get_info does with follow_cursor=1, then copies the viewport's rows,
|
|
2054
|
+
* numbered from its first visible row; width_cols_max is the widest of them. logical=1
|
|
2055
|
+
* copies every row of the document; width_cols_max is the widest unwrapped line. While
|
|
2056
|
+
* the placeholder shows, both modes copy its rows.
|
|
2057
|
+
* Zero capacity reports the count; otherwise all records must fit. */
|
|
2058
|
+
ot_status ot_editor_view_get_lines(ot_context *, const ot_handle *, uint32_t logical,
|
|
2059
|
+
ot_scene_text_line *lines, uint32_t capacity, ot_editor_measure *out_info);
|
|
2060
|
+
ot_status ot_editor_view_measure(ot_context *, const ot_handle *, uint32_t width, uint32_t height, ot_editor_measure *out_info);
|
|
2061
|
+
/* Copies owned placeholder text and styles; zero chunks clears the placeholder.
|
|
2062
|
+
* Uses the same chunk validation as ot_scene_set_styled_text, but LINK,
|
|
2063
|
+
* link_offset, and link_byte_count must be zero. */
|
|
2064
|
+
ot_status ot_editor_view_set_placeholder(ot_context *, const ot_handle *, const uint8_t *bytes,
|
|
2065
|
+
uint32_t byte_count, const ot_styled_text_chunk *chunks, uint32_t chunk_count);
|
|
2066
|
+
/* One synchronous owner-thread observer per Context, borrowed until replacement,
|
|
2067
|
+
* NULL clearing, or Context destruction. event is one OT_EDIT_* value, not a mask.
|
|
2068
|
+
* The identity names the edit buffer in this native image. Queue host work before
|
|
2069
|
+
* returning: mutations, callback replacement, drains, and destruction reject
|
|
2070
|
+
* reentry with OT_CONTEXT_BUSY. */
|
|
2071
|
+
typedef void (*ot_edit_event_callback)(uint64_t context_id, uint32_t slot, uint32_t generation, uint32_t event);
|
|
2072
|
+
ot_status ot_context_set_edit_event_callback(ot_context *, ot_edit_event_callback);
|
|
2073
|
+
/* Bind only OT_SCENE_EDITOR nodes. A view binds at most one node at a time.
|
|
2074
|
+
* NULL unbinds. Binding retains no host memory and does not transfer ownership.
|
|
2075
|
+
* Session/node destruction unbinds without destroying the view or edit buffer. */
|
|
2076
|
+
ot_status ot_scene_set_editor_view(ot_context *, const ot_handle *node, const ot_handle *view);
|
|
2077
|
+
ot_status ot_scene_set_editor_options(ot_context *, const ot_handle *node, const ot_scene_editor_options *);
|
|
2078
|
+
|
|
2079
|
+
#define OT_IMAGE_FIT UINT32_C(0)
|
|
2080
|
+
#define OT_IMAGE_COVER UINT32_C(1)
|
|
2081
|
+
#define OT_IMAGE_FILL UINT32_C(2)
|
|
2082
|
+
#define OT_IMAGE_PROTOCOL_AUTO UINT32_C(0)
|
|
2083
|
+
#define OT_IMAGE_PROTOCOL_KITTY UINT32_C(1)
|
|
2084
|
+
#define OT_IMAGE_PROTOCOL_SIXEL UINT32_C(2)
|
|
2085
|
+
#define OT_IMAGE_PROTOCOL_BLOCKS UINT32_C(3)
|
|
2086
|
+
#define OT_IMAGE_DRAW_SOURCE_WIDTH UINT32_C(1)
|
|
2087
|
+
#define OT_IMAGE_DRAW_SOURCE_HEIGHT UINT32_C(2)
|
|
2088
|
+
/* tfm fork: read opacity_override (0..1) instead of the inherited render-tree
|
|
2089
|
+
* opacity. Without the flag the field is ignored, so a zeroed struct inherits. */
|
|
2090
|
+
#define OT_IMAGE_DRAW_OPACITY_OVERRIDE UINT32_C(4)
|
|
2091
|
+
/* Keep the source's aspect inside the pixel box: the protocol writers
|
|
2092
|
+
* letterbox the image (centered, transparent margins) instead of stretching it
|
|
2093
|
+
* to the box. Without the flag the source is stretched to the box. */
|
|
2094
|
+
#define OT_IMAGE_DRAW_PRESERVE_ASPECT UINT32_C(8)
|
|
2095
|
+
|
|
2096
|
+
ot_status ot_image_destroy(ot_context *, const ot_handle *image);
|
|
2097
|
+
|
|
2098
|
+
#define OT_IMAGE_ENCODED_BYTES_MAX UINT32_C(67108864)
|
|
2099
|
+
/* Image resources use Context allocation, I/O and handle capacity. Encoded inputs
|
|
2100
|
+
* are limited to ENCODED_BYTES_MAX; dimensions to 16384 per axis and 25000000 pixels.
|
|
2101
|
+
* Inputs are copied during creation. Failed operations leave outputs unchanged.
|
|
2102
|
+
* Transform/clone/retain return independently releasable handles. Clone copies
|
|
2103
|
+
* pixels and encoded data; retain shares immutable storage within one Context.
|
|
2104
|
+
* Nodes and buffers retain storage after ot_image_destroy releases the public handle.
|
|
2105
|
+
* Only update_pixels mutates an existing image; retained storage returns OT_IMAGE_BUSY.
|
|
2106
|
+
* Successful updates assign fresh render-cache identities. */
|
|
2107
|
+
typedef struct ot_image_info {
|
|
2108
|
+
uint32_t width, height, source_width, source_height;
|
|
2109
|
+
uint32_t format, color_status, orientation, has_alpha;
|
|
2110
|
+
} ot_image_info;
|
|
2111
|
+
#define OT_IMAGE_FORMAT_UNKNOWN UINT32_C(0)
|
|
2112
|
+
#define OT_IMAGE_FORMAT_PNG UINT32_C(1)
|
|
2113
|
+
#define OT_IMAGE_FORMAT_RGBA UINT32_C(2)
|
|
2114
|
+
#define OT_IMAGE_FORMAT_JPEG UINT32_C(3)
|
|
2115
|
+
#define OT_IMAGE_FORMAT_WEBP UINT32_C(4)
|
|
2116
|
+
#define OT_IMAGE_FORMAT_GIF UINT32_C(5)
|
|
2117
|
+
#define OT_IMAGE_ASSUMED_SRGB UINT32_C(0)
|
|
2118
|
+
#define OT_IMAGE_EXPLICIT_SRGB UINT32_C(1)
|
|
2119
|
+
#define OT_IMAGE_RGBA8 UINT32_C(0)
|
|
2120
|
+
#define OT_IMAGE_BGRA8 UINT32_C(1)
|
|
2121
|
+
#define OT_IMAGE_ALPHA_STRAIGHT UINT32_C(0)
|
|
2122
|
+
#define OT_IMAGE_ALPHA_OPAQUE UINT32_C(1)
|
|
2123
|
+
#define OT_IMAGE_FILTER_DEFAULT UINT32_C(0)
|
|
2124
|
+
#define OT_IMAGE_FILTER_AREA UINT32_C(1)
|
|
2125
|
+
#define OT_IMAGE_FILTER_TRIANGLE UINT32_C(2)
|
|
2126
|
+
#define OT_IMAGE_FILTER_CUBIC_BSPLINE UINT32_C(3)
|
|
2127
|
+
#define OT_IMAGE_FILTER_CATMULL_ROM UINT32_C(4)
|
|
2128
|
+
#define OT_IMAGE_FILTER_MITCHELL UINT32_C(5)
|
|
2129
|
+
#define OT_IMAGE_FILTER_NEAREST UINT32_C(6)
|
|
2130
|
+
#define OT_IMAGE_ROTATE_90 UINT32_C(0)
|
|
2131
|
+
#define OT_IMAGE_ROTATE_180 UINT32_C(1)
|
|
2132
|
+
#define OT_IMAGE_ROTATE_270 UINT32_C(2)
|
|
2133
|
+
#define OT_IMAGE_FLIP UINT32_C(3)
|
|
2134
|
+
#define OT_IMAGE_FLOP UINT32_C(4)
|
|
2135
|
+
#define OT_IMAGE_BLEND_SOURCE_OVER UINT32_C(0)
|
|
2136
|
+
#define OT_IMAGE_BLEND_SOURCE UINT32_C(1)
|
|
2137
|
+
#define OT_IMAGE_BLEND_DESTINATION_OVER UINT32_C(2)
|
|
2138
|
+
ot_status ot_image_inspect(ot_context *, const uint8_t *bytes, uint64_t byte_count, ot_image_info *out_info);
|
|
2139
|
+
ot_status ot_image_decode(ot_context *, const uint8_t *bytes, uint64_t byte_count, ot_handle *out_image);
|
|
2140
|
+
ot_status ot_image_create_pixels(ot_context *, const uint8_t *pixels, uint64_t byte_count,
|
|
2141
|
+
uint32_t width, uint32_t height, uint32_t stride, uint32_t format, uint32_t alpha, ot_handle *out_image);
|
|
2142
|
+
ot_status ot_image_update_pixels(ot_context *, const ot_handle *image, const uint8_t *pixels,
|
|
2143
|
+
uint64_t byte_count, uint32_t stride, uint32_t format, uint32_t alpha);
|
|
2144
|
+
ot_status ot_image_clone(ot_context *destination, ot_context *source, const ot_handle *image, ot_handle *out_image);
|
|
2145
|
+
ot_status ot_image_retain(ot_context *, const ot_handle *image, ot_handle *out_image);
|
|
2146
|
+
ot_status ot_image_get_info(ot_context *, const ot_handle *image, ot_image_info *out_info);
|
|
2147
|
+
ot_status ot_image_resize(ot_context *, const ot_handle *image, uint32_t width, uint32_t height,
|
|
2148
|
+
uint32_t filter, ot_handle *out_image);
|
|
2149
|
+
ot_status ot_image_extract(ot_context *, const ot_handle *image, uint32_t left, uint32_t top,
|
|
2150
|
+
uint32_t width, uint32_t height, ot_handle *out_image);
|
|
2151
|
+
ot_status ot_image_extend(ot_context *, const ot_handle *image, uint32_t top, uint32_t right,
|
|
2152
|
+
uint32_t bottom, uint32_t left, const uint8_t *background_rgba, ot_handle *out_image);
|
|
2153
|
+
ot_status ot_image_transform(ot_context *, const ot_handle *image, uint32_t operation, ot_handle *out_image);
|
|
2154
|
+
ot_status ot_image_composite(ot_context *, const ot_handle *base, const ot_handle *overlay,
|
|
2155
|
+
int32_t left, int32_t top, uint32_t blend, uint8_t opacity, ot_handle *out_image);
|
|
2156
|
+
ot_status ot_image_copy_pixels(ot_context *, const ot_handle *image, uint8_t *destination,
|
|
2157
|
+
uint64_t byte_count, uint32_t stride, uint32_t format);
|
|
2158
|
+
/* Zero capacity reports the exact PNG byte count and ensures its cached encoding.
|
|
2159
|
+
* A short nonempty destination returns OT_IMAGE_OUTPUT_TOO_SMALL without writing. */
|
|
2160
|
+
ot_status ot_image_copy_png(ot_context *, const ot_handle *image, uint8_t *destination,
|
|
2161
|
+
uint64_t capacity, uint64_t *out_byte_count);
|
|
2162
|
+
/* Transfer requires exclusive storage. Success consumes image and returns a mutable
|
|
2163
|
+
* pixel lease; the old handle becomes stale. Leases share Context lease count/byte
|
|
2164
|
+
* limits and prevent Context destruction until release. Admission needs one free
|
|
2165
|
+
* handle slot; lease bytes include pixels and their native image header. Pixels
|
|
2166
|
+
* are packed straight sRGB RGBA8. No image operation accepts the lease. All aliases
|
|
2167
|
+
* expire on release. */
|
|
2168
|
+
typedef struct ot_image_pixels {
|
|
2169
|
+
ot_handle lease;
|
|
2170
|
+
uint64_t pixels;
|
|
2171
|
+
uint64_t byte_count;
|
|
2172
|
+
} ot_image_pixels;
|
|
2173
|
+
ot_status ot_image_take_pixels(ot_context *, const ot_handle *image, ot_image_pixels *out_pixels);
|
|
2174
|
+
ot_status ot_image_pixels_release(ot_context *, const ot_handle *lease);
|
|
2175
|
+
/* Bind only IMAGE nodes. NULL image clears the binding. Nodes and drawn placements
|
|
2176
|
+
* retain their image independently of the imported handle. Optional buffer names
|
|
2177
|
+
* Context-owned backing storage for buffered Image drawing, not a legacy buffer.
|
|
2178
|
+
* fit and protocol use OT_IMAGE_*; mutations reject measurement-callback reentry.
|
|
2179
|
+
* opacity_override is a tfm fork addition: a negative value (including NaN)
|
|
2180
|
+
* inherits the render-tree opacity; 0..1 replaces it for this node's placements
|
|
2181
|
+
* so an image can stay opaque (or scale independently) under a node-opacity dim. */
|
|
2182
|
+
ot_status ot_scene_set_image(ot_context *, const ot_handle *node, const ot_handle *image,
|
|
2183
|
+
uint32_t fit, uint32_t protocol, const ot_handle *buffer, float opacity_override);
|
|
2184
|
+
/* Sets the region of the source, in source pixels, that an IMAGE or VIDEO node shows; fit
|
|
2185
|
+
* applies to the region. All four zero show the whole source; otherwise width and height
|
|
2186
|
+
* are positive. A region that does not lie inside the source shows the whole source. A VIDEO
|
|
2187
|
+
* node scales and copies only the region of each frame. Setting the image or video keeps it. */
|
|
2188
|
+
ot_status ot_scene_set_crop(ot_context *, const ot_handle *node, uint32_t left, uint32_t top,
|
|
2189
|
+
uint32_t width, uint32_t height);
|
|
2190
|
+
|
|
2191
|
+
/* A VIDEO node owns one decoder and player. Decoded frames stay native: each paint
|
|
2192
|
+
* of the node draws the current frame as the IMAGE node does, from a small set of
|
|
2193
|
+
* images that the decoder refreshes in place while no buffer retains them. Audio
|
|
2194
|
+
* plays from a native thread; paints and ot_video_get_state advance the clock and
|
|
2195
|
+
* end or loop playback, so an unpainted node keeps time. Hosts keep frames painting
|
|
2196
|
+
* while playback runs, for example with a live renderable. ot_scene_set_video sets fit and buffer as ot_scene_set_image does;
|
|
2197
|
+
* frames draw with OT_IMAGE_PROTOCOL_AUTO.
|
|
2198
|
+
* ot_video_open replaces the player; a zero path_length closes it, and path may then
|
|
2199
|
+
* be NULL. Audio plays through a private audio engine and is the media clock while it
|
|
2200
|
+
* plays. A decode worker thread starts when the node first needs a frame; an audio
|
|
2201
|
+
* thread starts on the first play of a source with audio and makes every audio engine
|
|
2202
|
+
* call. Failed opens, seeks, and decodes return OT_VIDEO_FAILED; ot_video_get_error
|
|
2203
|
+
* copies the detail. After a failure, ot_video_play and ot_video_seek retry; other
|
|
2204
|
+
* controls still apply and succeed. A paused seek decodes its frame once the node has
|
|
2205
|
+
* painted, so decode failures return from the seek. Audio failures leave playback running silently on the wall clock. Control and
|
|
2206
|
+
* state calls on a node without an open player return OT_INVALID_PHASE.
|
|
2207
|
+
* With OT_VIDEO_OPEN_NO_AUDIO, the only accepted flag, ot_video_open creates no audio engine: playback opens no
|
|
2208
|
+
* audio device and follows the wall clock, and has_audio still reports the file's audio track.
|
|
2209
|
+
* In ot_video_info, zero duration_us or fps_num means unknown. */
|
|
2210
|
+
#define OT_VIDEO_OPEN_NO_AUDIO UINT32_C(1)
|
|
2211
|
+
typedef struct ot_video_info {
|
|
2212
|
+
int64_t duration_us;
|
|
2213
|
+
uint32_t width, height, fps_num, fps_den, has_audio, reserved;
|
|
2214
|
+
} ot_video_info;
|
|
2215
|
+
/* BUFFERING: playing, and the audio clock waits for queued audio. AUDIO: playing, and
|
|
2216
|
+
* audio output drives the media clock. Without either, playback follows the wall clock. */
|
|
2217
|
+
#define OT_VIDEO_PLAYING UINT32_C(1)
|
|
2218
|
+
#define OT_VIDEO_ENDED UINT32_C(2)
|
|
2219
|
+
#define OT_VIDEO_BUFFERING UINT32_C(4)
|
|
2220
|
+
#define OT_VIDEO_AUDIO UINT32_C(8)
|
|
2221
|
+
#define OT_VIDEO_HAS_FRAME UINT32_C(16)
|
|
2222
|
+
#define OT_VIDEO_ERROR UINT32_C(32)
|
|
2223
|
+
typedef struct ot_video_state {
|
|
2224
|
+
int64_t current_time_us;
|
|
2225
|
+
int64_t frame_pts_us;
|
|
2226
|
+
/* quality_tier: 0 is full decode size; each higher tier decodes Kitty output smaller to keep up. */
|
|
2227
|
+
uint32_t flags, quality_tier;
|
|
2228
|
+
} ot_video_state;
|
|
2229
|
+
ot_status ot_scene_set_video(ot_context *, const ot_handle *node, uint32_t fit, const ot_handle *buffer);
|
|
2230
|
+
ot_status ot_video_open(ot_context *, const ot_handle *node, const uint8_t *path, uint32_t path_length,
|
|
2231
|
+
uint32_t flags, ot_video_info *out_info);
|
|
2232
|
+
ot_status ot_video_play(ot_context *, const ot_handle *node);
|
|
2233
|
+
ot_status ot_video_pause(ot_context *, const ot_handle *node);
|
|
2234
|
+
ot_status ot_video_seek(ot_context *, const ot_handle *node, int64_t time_us);
|
|
2235
|
+
ot_status ot_video_set_loop(ot_context *, const ot_handle *node, uint32_t loop);
|
|
2236
|
+
ot_status ot_video_set_muted(ot_context *, const ot_handle *node, uint32_t muted);
|
|
2237
|
+
ot_status ot_video_set_volume(ot_context *, const ot_handle *node, float volume);
|
|
2238
|
+
/* Positive offsets show frames earlier relative to the media clock. Offsets beyond
|
|
2239
|
+
* +-60 s return OT_INVALID_ARGUMENT. */
|
|
2240
|
+
ot_status ot_video_set_av_sync_offset(ot_context *, const ot_handle *node, int64_t offset_us);
|
|
2241
|
+
/* Frames present at the lower of fps and the source frame rate. fps is 1 to 120; default 30. */
|
|
2242
|
+
ot_status ot_video_set_max_fps(ot_context *, const ot_handle *node, uint32_t fps);
|
|
2243
|
+
ot_status ot_video_get_state(ot_context *, const ot_handle *node, ot_video_state *out_state);
|
|
2244
|
+
/* Copies the detail of the last failure, empty without one. Zero capacity reports the
|
|
2245
|
+
* exact byte count; otherwise insufficient capacity rejects without writing bytes or
|
|
2246
|
+
* out_count. bytes may be NULL only for zero capacity. No terminating NUL is added. */
|
|
2247
|
+
ot_status ot_video_get_error(ot_context *, const ot_handle *node, uint8_t *bytes, uint32_t capacity,
|
|
2248
|
+
uint32_t *out_count);
|
|
2249
|
+
|
|
2250
|
+
/* An audio engine decodes sounds into Context memory and mixes up to 32 voices at
|
|
2251
|
+
* 48 kHz. ot_audio_create opens no device. ot_audio_start opens the default playback
|
|
2252
|
+
* device, whose thread then mixes; that thread never calls the host, and writes silence
|
|
2253
|
+
* while another call holds the engine. With OT_AUDIO_START_NO_DEVICE, the only accepted
|
|
2254
|
+
* flag, the engine mixes only when ot_audio_mix asks, and nothing opens a device; while
|
|
2255
|
+
* a device plays, it returns OT_INVALID_PHASE, so stop first to change modes.
|
|
2256
|
+
* ot_audio_stop silences the engine and releases its device; ot_audio_start resumes.
|
|
2257
|
+
* ot_audio_destroy and Context destruction stop the device, then free every sound.
|
|
2258
|
+
* ot_audio_load copies and decodes WAV, MP3 or FLAC bytes. Sound IDs are nonzero and
|
|
2259
|
+
* stay valid until the engine is destroyed. Voice IDs are nonzero; a voice ends when
|
|
2260
|
+
* its sound ends or is stopped, and its ID never names a later voice. An ID that names
|
|
2261
|
+
* no sound or playing voice, including 0, returns OT_STALE_HANDLE.
|
|
2262
|
+
* volume is a gain from 0 to 4, 1 unchanged; others return OT_INVALID_ARGUMENT.
|
|
2263
|
+
* More than 32 playing voices return OT_OBJECT_LIMIT. */
|
|
2264
|
+
#define OT_AUDIO_START_NO_DEVICE UINT32_C(1)
|
|
2265
|
+
ot_status ot_audio_create(ot_context *, ot_handle *out_engine);
|
|
2266
|
+
ot_status ot_audio_destroy(ot_context *, const ot_handle *engine);
|
|
2267
|
+
ot_status ot_audio_start(ot_context *, const ot_handle *engine, uint32_t flags);
|
|
2268
|
+
ot_status ot_audio_stop(ot_context *, const ot_handle *engine);
|
|
2269
|
+
ot_status ot_audio_load(ot_context *, const ot_handle *engine, const uint8_t *bytes, uint64_t byte_count,
|
|
2270
|
+
uint32_t *out_sound);
|
|
2271
|
+
ot_status ot_audio_play(ot_context *, const ot_handle *engine, uint32_t sound, float volume, uint32_t *out_voice);
|
|
2272
|
+
ot_status ot_audio_stop_voice(ot_context *, const ot_handle *engine, uint32_t voice);
|
|
2273
|
+
ot_status ot_audio_set_volume(ot_context *, const ot_handle *engine, float volume);
|
|
2274
|
+
/* Writes frame_count frames of channels (1 or 2) interleaved samples: the mix after
|
|
2275
|
+
* OT_AUDIO_START_NO_DEVICE, silence while stopped. Returns OT_INVALID_PHASE while a
|
|
2276
|
+
* device plays. */
|
|
2277
|
+
ot_status ot_audio_mix(ot_context *, const ot_handle *engine, float *samples, uint32_t frame_count,
|
|
2278
|
+
uint32_t channels);
|
|
2279
|
+
|
|
2280
|
+
/* x/y and width/height count terminal cells. pixel_* and source_* count image
|
|
2281
|
+
* pixels. Absent source extents and reserved fields must be zero. Exact size and
|
|
2282
|
+
* version are required. Only the two SOURCE_* flags plus
|
|
2283
|
+
* OT_IMAGE_DRAW_OPACITY_OVERRIDE and OT_IMAGE_DRAW_PRESERVE_ASPECT (tfm fork)
|
|
2284
|
+
* are accepted. opacity_override is read only with that flag and must be 0..1
|
|
2285
|
+
* (absent source extents inherit). */
|
|
2286
|
+
typedef struct ot_image_draw_options {
|
|
2287
|
+
uint32_t struct_size;
|
|
2288
|
+
uint32_t abi_version;
|
|
2289
|
+
uint32_t flags;
|
|
2290
|
+
uint32_t protocol;
|
|
2291
|
+
int32_t x;
|
|
2292
|
+
int32_t y;
|
|
2293
|
+
uint32_t width;
|
|
2294
|
+
uint32_t height;
|
|
2295
|
+
uint32_t pixel_width;
|
|
2296
|
+
uint32_t pixel_height;
|
|
2297
|
+
uint32_t source_x;
|
|
2298
|
+
uint32_t source_y;
|
|
2299
|
+
uint32_t source_width;
|
|
2300
|
+
uint32_t source_height;
|
|
2301
|
+
float opacity_override;
|
|
2302
|
+
uint32_t reserved[1];
|
|
2303
|
+
} ot_image_draw_options;
|
|
2304
|
+
|
|
2305
|
+
/* Offscreen buffers require NULL frame; Session drawing requires its current
|
|
2306
|
+
* frame ticket. out_drawn is 0 for empty/clipped draws and 1 for accepted drawing.
|
|
2307
|
+
* Invalid options preserve both target cells and out_drawn. */
|
|
2308
|
+
ot_status ot_buffer_draw_image(ot_context *, const ot_handle *target, const ot_scene_frame_request *frame,
|
|
2309
|
+
const ot_handle *image, const ot_image_draw_options *, uint32_t *out_drawn);
|
|
2310
|
+
/* Store terminal cell and pixel dimensions for native Image fit calculations.
|
|
2311
|
+
* All four values are positive, or all zero to clear the resolution. */
|
|
2312
|
+
ot_status ot_session_set_image_resolution(ot_context *, const ot_handle *session,
|
|
2313
|
+
uint32_t terminal_width, uint32_t terminal_height, uint32_t pixel_width, uint32_t pixel_height);
|
|
2314
|
+
|
|
2315
|
+
/* Kitty image transport is renderer state, not a terminal control packet.
|
|
2316
|
+
* requested is 0=raw, 1=zlib, 2=file. effective is 0=raw, 1=zlib, 2=png, 3=file.
|
|
2317
|
+
* file_state is 0=disabled, 1=probing, 2=ready, 3=unsupported, 4=timeout,
|
|
2318
|
+
* 5=io-error, 6=cancelled. fallback is 0=none, 1=not-ready, 2=unavailable,
|
|
2319
|
+
* 3=budget, 4=busy, 5=preparation, 6=compression. pending_bytes fits u32.
|
|
2320
|
+
* Set, poll, cancel, and reply require an attached renderer and may run in any
|
|
2321
|
+
* open phase so resume can consume probe replies before JS restores control.
|
|
2322
|
+
* File probes emit only while the terminal is active and not suspended. A probe
|
|
2323
|
+
* that ordinary output cannot admit is not started: file_state stays disabled
|
|
2324
|
+
* until a later set or start call after output drains. */
|
|
2325
|
+
typedef struct ot_session_kitty_image_transport {
|
|
2326
|
+
uint32_t struct_size;
|
|
2327
|
+
uint32_t abi_version;
|
|
2328
|
+
uint32_t requested;
|
|
2329
|
+
uint32_t effective;
|
|
2330
|
+
uint32_t file_state;
|
|
2331
|
+
uint32_t fallback;
|
|
2332
|
+
uint32_t pending_files;
|
|
2333
|
+
uint32_t pending_bytes;
|
|
2334
|
+
} ot_session_kitty_image_transport;
|
|
2335
|
+
|
|
2336
|
+
ot_status ot_session_set_kitty_image_transport(ot_context *, const ot_handle *session, uint32_t mode);
|
|
2337
|
+
ot_status ot_session_get_kitty_image_transport(
|
|
2338
|
+
ot_context *,
|
|
2339
|
+
const ot_handle *session,
|
|
2340
|
+
ot_session_kitty_image_transport *out_status);
|
|
2341
|
+
/* now_ns shares the Session pump clock. Earlier samples return OT_INVALID_ARGUMENT
|
|
2342
|
+
* before changing leases or consuming retry notifications. Equal samples are valid.
|
|
2343
|
+
* Each pump or poll visits at most eight files, even while output is pending.
|
|
2344
|
+
* The first observation after creation arms a five-second lease deadline,
|
|
2345
|
+
* saturating at UINT64_MAX. Expiry cancels file transport; it is not an ACK.
|
|
2346
|
+
* Poll regularly while files may be pending, including after changing modes.
|
|
2347
|
+
* Poll does not advance terminal lifecycle or deliver output. */
|
|
2348
|
+
ot_status ot_session_poll_kitty_image_transport(ot_context *, const ot_handle *session,
|
|
2349
|
+
uint64_t now_ns, uint32_t *out_retry);
|
|
2350
|
+
ot_status ot_session_cancel_kitty_image_transport(ot_context *, const ot_handle *session, uint32_t failed);
|
|
2351
|
+
/* out_result is 0=ignored, 1=consumed, 2=consumed and images should retransmit. */
|
|
2352
|
+
ot_status ot_session_process_kitty_image_reply(
|
|
2353
|
+
ot_context *,
|
|
2354
|
+
const ot_handle *session,
|
|
2355
|
+
const uint8_t *bytes,
|
|
2356
|
+
uint32_t byte_count,
|
|
2357
|
+
uint32_t *out_result);
|
|
2358
|
+
ot_status ot_session_start_kitty_file_probe(ot_context *, const ot_handle *session);
|
|
2359
|
+
|
|
2360
|
+
/* Shared text buffers own copied bytes, styles and links. Destroying a buffer
|
|
2361
|
+
* destroys its dependent views; destroying a node only unbinds its view.
|
|
2362
|
+
* Existing editor style, highlight, viewport, selection and measurement records
|
|
2363
|
+
* retain their ABI1 layouts. Text selection rejects cursor-only flags. */
|
|
2364
|
+
typedef struct ot_text_buffer_info {
|
|
2365
|
+
uint32_t struct_size;
|
|
2366
|
+
uint32_t abi_version;
|
|
2367
|
+
uint64_t content_epoch;
|
|
2368
|
+
uint32_t byte_count;
|
|
2369
|
+
uint32_t text_length; /* Sum of unwrapped display-column widths, excluding line separators. */
|
|
2370
|
+
uint32_t line_count;
|
|
2371
|
+
uint32_t highlight_count;
|
|
2372
|
+
uint32_t tab_width;
|
|
2373
|
+
uint32_t reserved;
|
|
2374
|
+
} ot_text_buffer_info;
|
|
2375
|
+
|
|
2376
|
+
#define OT_TEXT_VIEW_WRAP_WIDTH UINT32_C(0)
|
|
2377
|
+
#define OT_TEXT_VIEW_WRAP_MODE UINT32_C(1)
|
|
2378
|
+
#define OT_TEXT_VIEW_FIRST_LINE_OFFSET UINT32_C(2)
|
|
2379
|
+
#define OT_TEXT_VIEW_TAB_INDICATOR UINT32_C(3)
|
|
2380
|
+
#define OT_TEXT_VIEW_TRUNCATE UINT32_C(4)
|
|
2381
|
+
#define OT_TEXT_VIEW_TEXT_ALIGN UINT32_C(5)
|
|
2382
|
+
|
|
2383
|
+
ot_status ot_text_buffer_create(ot_context *, const ot_edit_buffer_options *, ot_handle *out_buffer);
|
|
2384
|
+
ot_status ot_text_buffer_destroy(ot_context *, const ot_handle *);
|
|
2385
|
+
ot_status ot_text_buffer_view_create(ot_context *, const ot_handle *buffer, ot_handle *out_view);
|
|
2386
|
+
ot_status ot_text_buffer_view_destroy(ot_context *, const ot_handle *);
|
|
2387
|
+
ot_status ot_text_buffer_set_text(ot_context *, const ot_handle *, const uint8_t *, uint32_t byte_count);
|
|
2388
|
+
ot_status ot_text_buffer_append(ot_context *, const ot_handle *, const uint8_t *, uint32_t byte_count);
|
|
2389
|
+
ot_status ot_text_buffer_clear(ot_context *, const ot_handle *, uint32_t reset);
|
|
2390
|
+
/* Empty chunks register no style or link. Unlike direct scene text, chunk_count can
|
|
2391
|
+
* exceed byte_count. clear without reset keeps styled highlights but drops their links. */
|
|
2392
|
+
ot_status ot_text_buffer_set_styled_text(ot_context *, const ot_handle *, const uint8_t *, uint32_t byte_count,
|
|
2393
|
+
const ot_styled_text_chunk *, uint32_t chunk_count, const uint8_t *urls, uint32_t url_byte_count);
|
|
2394
|
+
/* Atomic replacement of buffer-owned styled text. Every buffer appears once and
|
|
2395
|
+
* view must be its dependent view.
|
|
2396
|
+
* Success resets selection on each named view, retaining defaults and geometry.
|
|
2397
|
+
* Failure leaves every buffer, view and output unchanged. Inputs are borrowed
|
|
2398
|
+
* only for the call. Output has count entries; NULL spans require zero count.
|
|
2399
|
+
* These aggregate limits bound synchronous preparation and temporary storage. */
|
|
2400
|
+
#define OT_TEXT_REPLACEMENT_COUNT_MAX UINT32_C(256)
|
|
2401
|
+
#define OT_TEXT_REPLACEMENT_CHUNKS_MAX UINT32_C(4096)
|
|
2402
|
+
#define OT_TEXT_REPLACEMENT_BYTES_MAX UINT32_C(4194304)
|
|
2403
|
+
#define OT_TEXT_REPLACEMENT_URL_BYTES_MAX UINT32_C(1048576)
|
|
2404
|
+
typedef struct ot_text_buffer_replacement {
|
|
2405
|
+
uint32_t struct_size;
|
|
2406
|
+
uint32_t abi_version;
|
|
2407
|
+
ot_handle buffer;
|
|
2408
|
+
ot_handle view;
|
|
2409
|
+
uint32_t byte_offset;
|
|
2410
|
+
uint32_t byte_count;
|
|
2411
|
+
uint32_t chunk_offset;
|
|
2412
|
+
uint32_t chunk_count;
|
|
2413
|
+
} ot_text_buffer_replacement;
|
|
2414
|
+
typedef struct ot_text_buffer_replacement_info {
|
|
2415
|
+
uint32_t text_length; /* Sum of unwrapped display-column widths, as in ot_text_buffer_info. */
|
|
2416
|
+
uint32_t byte_count;
|
|
2417
|
+
} ot_text_buffer_replacement_info;
|
|
2418
|
+
ot_status ot_text_buffer_replace_styled_batch(ot_context *, const ot_text_buffer_replacement *, uint32_t count,
|
|
2419
|
+
const uint8_t *bytes, uint32_t byte_count, const ot_styled_text_chunk *, uint32_t chunk_count,
|
|
2420
|
+
const uint8_t *urls, uint32_t url_byte_count, ot_text_buffer_replacement_info *out);
|
|
2421
|
+
ot_status ot_text_buffer_set_syntax_style(ot_context *, const ot_handle *, const ot_handle *style);
|
|
2422
|
+
ot_status ot_text_buffer_get_info(ot_context *, const ot_handle *, ot_text_buffer_info *);
|
|
2423
|
+
/* Zero capacity reports the exact UTF-8 byte count. Nonzero capacity must fit
|
|
2424
|
+
* that count; no terminating NUL is copied. Outputs are unchanged on rejection. */
|
|
2425
|
+
ot_status ot_text_buffer_get_text(ot_context *, const ot_handle *, uint8_t *, uint32_t capacity, uint32_t *out_count);
|
|
2426
|
+
/* Same exact byte query/copy convention. start/end are display-column offsets,
|
|
2427
|
+
* including one cell per LF. start snaps backward to the containing grapheme;
|
|
2428
|
+
* exclusive end snaps forward to include a partially selected grapheme. Empty, reversed, and
|
|
2429
|
+
* out-of-document ranges return zero. End is clamped to the document length. */
|
|
2430
|
+
ot_status ot_text_buffer_get_range(ot_context *, const ot_handle *, uint32_t start, uint32_t end,
|
|
2431
|
+
uint8_t *, uint32_t capacity, uint32_t *out_count);
|
|
2432
|
+
ot_status ot_text_buffer_set_defaults(ot_context *, const ot_handle *, uint32_t mask, const ot_editor_style *);
|
|
2433
|
+
ot_status ot_text_buffer_set_tab_width(ot_context *, const ot_handle *, uint32_t width);
|
|
2434
|
+
/* Same operations, units, and copy rules as ot_edit_buffer_highlight and
|
|
2435
|
+
* ot_edit_buffer_get_highlights. Styled text is stored as highlights with ref 0 and
|
|
2436
|
+
* priority 1: get_highlights returns them, and REMOVE_REF 0 and CLEAR_* remove them. */
|
|
2437
|
+
ot_status ot_text_buffer_highlight(ot_context *, const ot_handle *, uint32_t operation,
|
|
2438
|
+
uint32_t argument, const ot_edit_highlight *);
|
|
2439
|
+
ot_status ot_text_buffer_get_highlights(ot_context *, const ot_handle *, uint32_t line,
|
|
2440
|
+
ot_edit_highlight *, uint32_t capacity, uint32_t *out_count);
|
|
2441
|
+
ot_status ot_text_buffer_view_set_viewport(ot_context *, const ot_handle *, const ot_editor_viewport *, uint32_t size_only);
|
|
2442
|
+
ot_status ot_text_buffer_view_command(ot_context *, const ot_handle *, uint32_t command, uint32_t argument);
|
|
2443
|
+
ot_status ot_text_buffer_view_set_tab_color(ot_context *, const ot_handle *, const uint16_t color[4]);
|
|
2444
|
+
ot_status ot_text_buffer_view_select(ot_context *, const ot_handle *, const ot_editor_selection *, uint32_t *out_changed);
|
|
2445
|
+
ot_status ot_text_buffer_view_get_info(ot_context *, const ot_handle *, ot_editor_view_info *);
|
|
2446
|
+
/* Exact selected UTF-8 byte query/copy, as for ot_scene_get_selected_text.
|
|
2447
|
+
* Does not prepare lines or change the viewport. */
|
|
2448
|
+
ot_status ot_text_buffer_view_get_selected_text(ot_context *, const ot_handle *, uint8_t *, uint32_t capacity, uint32_t *out_count);
|
|
2449
|
+
/* Rows and width_cols_max as for ot_editor_view_get_lines, but a text view has no
|
|
2450
|
+
* cursor to follow or placeholder, and until a viewport is set, logical=0 matches
|
|
2451
|
+
* logical=1. Copies rows [first_line, first_line + capacity) clipped to the row count,
|
|
2452
|
+
* which out reports. A caller receives min(capacity, line_count - first_line) rows,
|
|
2453
|
+
* or none when first_line >= line_count; zero capacity only reports the count. */
|
|
2454
|
+
ot_status ot_text_buffer_view_get_lines(ot_context *, const ot_handle *, uint32_t logical, uint32_t first_line,
|
|
2455
|
+
ot_scene_text_line *, uint32_t capacity, ot_editor_measure *);
|
|
2456
|
+
ot_status ot_text_buffer_view_measure(ot_context *, const ot_handle *, uint32_t width, uint32_t height, ot_editor_measure *);
|
|
2457
|
+
ot_status ot_scene_set_text_view(ot_context *, const ot_handle *node, const ot_handle *view);
|
|
2458
|
+
/* Only gates built-in painting, not layout, viewport preparation or hit membership. */
|
|
2459
|
+
ot_status ot_scene_set_text_view_paint(ot_context *, const ot_handle *node, uint32_t enabled);
|
|
2460
|
+
/* NULL frame selects an owned offscreen buffer. A frame requires the exact active
|
|
2461
|
+
* custom paint destination. The source view must belong to this Context. */
|
|
2462
|
+
ot_status ot_buffer_draw_text_view(ot_context *, const ot_handle *target, const ot_scene_frame_request *,
|
|
2463
|
+
const ot_handle *view, int32_t x, int32_t y);
|
|
2464
|
+
/* Same destination rules as ot_buffer_draw_text_view. Paints synchronously with
|
|
2465
|
+
* the destination's current clipping and opacity, without publishing cursor state.
|
|
2466
|
+
* The scene-body source is a Text, Box, Slider or Arrow scene node, drawn as its
|
|
2467
|
+
* built-in painting would draw it at x, y with the node's paint size and the
|
|
2468
|
+
* current focus. */
|
|
2469
|
+
ot_status ot_buffer_draw_editor_view(ot_context *, const ot_handle *target, const ot_scene_frame_request *,
|
|
2470
|
+
const ot_handle *view, int32_t x, int32_t y);
|
|
2471
|
+
ot_status ot_buffer_draw_scene_body(ot_context *, const ot_handle *target, const ot_scene_frame_request *,
|
|
2472
|
+
const ot_handle *node, int32_t x, int32_t y);
|
|
2473
|
+
|
|
2474
|
+
#define OT_BUFFER_TEXT_BYTES_MAX UINT32_C(65536)
|
|
2475
|
+
|
|
2476
|
+
#define OT_BUFFER_DRAW_CLEAR UINT32_C(0)
|
|
2477
|
+
#define OT_BUFFER_DRAW_FILL UINT32_C(1)
|
|
2478
|
+
#define OT_BUFFER_DRAW_TEXT UINT32_C(2)
|
|
2479
|
+
#define OT_BUFFER_DRAW_CELL UINT32_C(3)
|
|
2480
|
+
#define OT_BUFFER_DRAW_CELL_BLEND UINT32_C(4)
|
|
2481
|
+
#define OT_BUFFER_DRAW_CHAR UINT32_C(5)
|
|
2482
|
+
#define OT_BUFFER_DRAW_BOX UINT32_C(6)
|
|
2483
|
+
#define OT_BUFFER_DRAW_COMPOSE UINT32_C(7)
|
|
2484
|
+
#define OT_BUFFER_DRAW_RESPECT_ALPHA UINT32_C(8)
|
|
2485
|
+
#define OT_BUFFER_DRAW_HAS_BACKGROUND UINT32_C(1)
|
|
2486
|
+
#define OT_BUFFER_DRAW_HAS_SOURCE_WIDTH UINT32_C(2)
|
|
2487
|
+
#define OT_BUFFER_DRAW_HAS_SOURCE_HEIGHT UINT32_C(4)
|
|
2488
|
+
#define OT_BUFFER_DRAW_FIT_ELLIPSIS UINT32_C(16)
|
|
2489
|
+
|
|
2490
|
+
#define OT_BUFFER_STACK_DEPTH_MAX UINT32_C(256)
|
|
2491
|
+
#define OT_BUFFER_STACK_GET_OPACITY UINT32_C(0)
|
|
2492
|
+
#define OT_BUFFER_STACK_PUSH_SCISSOR UINT32_C(1)
|
|
2493
|
+
#define OT_BUFFER_STACK_POP_SCISSOR UINT32_C(2)
|
|
2494
|
+
#define OT_BUFFER_STACK_CLEAR_SCISSORS UINT32_C(3)
|
|
2495
|
+
#define OT_BUFFER_STACK_PUSH_OPACITY UINT32_C(4)
|
|
2496
|
+
#define OT_BUFFER_STACK_POP_OPACITY UINT32_C(5)
|
|
2497
|
+
#define OT_BUFFER_STACK_CLEAR_OPACITY UINT32_C(6)
|
|
2498
|
+
|
|
2499
|
+
/* Pass the header of the record matching operation to ot_buffer_draw.
|
|
2500
|
+
* struct_size is sizeof(the complete record), not sizeof(this header).
|
|
2501
|
+
* CLEAR/FILL/TEXT/BOX/COMPOSE use their named records below; CELL, CELL_BLEND,
|
|
2502
|
+
* and CHAR share ot_buffer_draw_cell; RESPECT_ALPHA uses ot_buffer_draw_alpha.
|
|
2503
|
+
* flags is zero except for TEXT (HAS_BACKGROUND, FIT_ELLIPSIS) and COMPOSE
|
|
2504
|
+
* (HAS_SOURCE_WIDTH and HAS_SOURCE_HEIGHT). Without HAS_BACKGROUND, text
|
|
2505
|
+
* uses the background at each glyph or tab start. A nonzero TEXT max_width
|
|
2506
|
+
* stops the text before the first glyph that would end more than max_width
|
|
2507
|
+
* cells right of x; a tab clips cell by cell. FIT_ELLIPSIS needs max_width
|
|
2508
|
+
* and applies only to text wider than max_width: it keeps the glyphs that
|
|
2509
|
+
* leave room for U+2026 and draws U+2026 right after them. A TEXT record of
|
|
2510
|
+
* offsetof(ot_buffer_draw_text_record, max_width) bytes has no limit.
|
|
2511
|
+
* Omitted source extents use the remaining source dimensions; an explicit
|
|
2512
|
+
* zero extent draws nothing.
|
|
2513
|
+
* Positions are signed cells. FILL and TEXT draw only their cells inside the
|
|
2514
|
+
* target; TEXT skips a wide glyph that starts left of column 0. CELL, CELL_BLEND,
|
|
2515
|
+
* and CHAR at a position outside the target draw nothing.
|
|
2516
|
+
* All records and byte spans are borrowed only for the call. */
|
|
2517
|
+
typedef struct ot_buffer_draw_header {
|
|
2518
|
+
uint32_t struct_size;
|
|
2519
|
+
uint32_t abi_version;
|
|
2520
|
+
uint32_t operation;
|
|
2521
|
+
uint32_t flags;
|
|
2522
|
+
} ot_buffer_draw_header;
|
|
2523
|
+
|
|
2524
|
+
typedef struct ot_buffer_draw_clear {
|
|
2525
|
+
ot_buffer_draw_header header;
|
|
2526
|
+
uint16_t background[4];
|
|
2527
|
+
} ot_buffer_draw_clear;
|
|
2528
|
+
|
|
2529
|
+
typedef struct ot_buffer_draw_fill {
|
|
2530
|
+
ot_buffer_draw_header header;
|
|
2531
|
+
int32_t x;
|
|
2532
|
+
int32_t y;
|
|
2533
|
+
uint32_t width;
|
|
2534
|
+
uint32_t height;
|
|
2535
|
+
uint16_t background[4];
|
|
2536
|
+
} ot_buffer_draw_fill;
|
|
2537
|
+
|
|
2538
|
+
typedef struct ot_buffer_draw_text_record {
|
|
2539
|
+
ot_buffer_draw_header header;
|
|
2540
|
+
int32_t x;
|
|
2541
|
+
int32_t y;
|
|
2542
|
+
uint32_t attributes;
|
|
2543
|
+
uint16_t foreground[4];
|
|
2544
|
+
uint16_t background[4];
|
|
2545
|
+
uint32_t max_width;
|
|
2546
|
+
} ot_buffer_draw_text_record;
|
|
2547
|
+
|
|
2548
|
+
typedef struct ot_buffer_draw_cell {
|
|
2549
|
+
ot_buffer_draw_header header;
|
|
2550
|
+
int32_t x;
|
|
2551
|
+
int32_t y;
|
|
2552
|
+
uint32_t character;
|
|
2553
|
+
uint32_t attributes;
|
|
2554
|
+
uint16_t foreground[4];
|
|
2555
|
+
uint16_t background[4];
|
|
2556
|
+
} ot_buffer_draw_cell;
|
|
2557
|
+
|
|
2558
|
+
typedef struct ot_buffer_draw_box {
|
|
2559
|
+
ot_buffer_draw_header header;
|
|
2560
|
+
int32_t x;
|
|
2561
|
+
int32_t y;
|
|
2562
|
+
uint32_t width;
|
|
2563
|
+
uint32_t height;
|
|
2564
|
+
uint32_t packed_options;
|
|
2565
|
+
uint16_t foreground[4];
|
|
2566
|
+
uint16_t background[4];
|
|
2567
|
+
uint16_t title_color[4];
|
|
2568
|
+
uint32_t border_chars[11];
|
|
2569
|
+
} ot_buffer_draw_box;
|
|
2570
|
+
|
|
2571
|
+
typedef struct ot_buffer_draw_compose {
|
|
2572
|
+
ot_buffer_draw_header header;
|
|
2573
|
+
int32_t x;
|
|
2574
|
+
int32_t y;
|
|
2575
|
+
uint32_t source_x;
|
|
2576
|
+
uint32_t source_y;
|
|
2577
|
+
uint32_t source_width;
|
|
2578
|
+
uint32_t source_height;
|
|
2579
|
+
} ot_buffer_draw_compose;
|
|
2580
|
+
|
|
2581
|
+
typedef struct ot_buffer_draw_alpha {
|
|
2582
|
+
ot_buffer_draw_header header;
|
|
2583
|
+
/* Zero or one. Valid only for an owned-buffer target. */
|
|
2584
|
+
uint32_t enabled;
|
|
2585
|
+
} ot_buffer_draw_alpha;
|
|
2586
|
+
|
|
2587
|
+
#define OT_BUFFER_GRID_INNER UINT32_C(1)
|
|
2588
|
+
#define OT_BUFFER_GRID_OUTER UINT32_C(2)
|
|
2589
|
+
|
|
2590
|
+
typedef struct ot_buffer_grid_options {
|
|
2591
|
+
uint32_t struct_size;
|
|
2592
|
+
uint32_t abi_version;
|
|
2593
|
+
uint32_t flags;
|
|
2594
|
+
uint32_t reserved;
|
|
2595
|
+
uint16_t foreground[4];
|
|
2596
|
+
uint16_t background[4];
|
|
2597
|
+
uint32_t border_chars[11];
|
|
2598
|
+
} ot_buffer_grid_options;
|
|
2599
|
+
|
|
2600
|
+
/* Initialize struct_size, abi_version, and zero reserved before acquisition.
|
|
2601
|
+
* All other fields are output-only. The record has an exact 80-byte layout on
|
|
2602
|
+
* supported 64-bit targets. Addresses are native-endian uint64_t values; convert
|
|
2603
|
+
* through uintptr_t, for example (uint32_t *)(uintptr_t)record.char_ptr.
|
|
2604
|
+
* char_ptr and attributes_ptr each address width * height uint32_t elements.
|
|
2605
|
+
* fg_ptr and bg_ptr each address width * height * 4 uint16_t RGBA components.
|
|
2606
|
+
* Literal RGBA channels use 0..255; high bytes carry native color metadata.
|
|
2607
|
+
* This retains storage, not a frozen frame. Rendering can change cells without
|
|
2608
|
+
* changing generation. CURRENT is the encoder's comparison buffer, which can
|
|
2609
|
+
* change before output admission or presentation; it is not a last-presented
|
|
2610
|
+
* snapshot. NEXT is drawing storage and rendering clears it after encoding.
|
|
2611
|
+
* Raw planes must not add, replace, or remove pooled grapheme/link IDs. Use
|
|
2612
|
+
* ot_buffer_draw TEXT for checked plain UTF-8 on an owned offscreen buffer.
|
|
2613
|
+
* Styled-text/editor resources, hyperlinks, and images need separate checked APIs. */
|
|
2614
|
+
typedef struct ot_buffer_lease_snapshot {
|
|
2615
|
+
uint32_t struct_size;
|
|
2616
|
+
uint32_t abi_version;
|
|
2617
|
+
ot_handle lease;
|
|
2618
|
+
uint32_t width;
|
|
2619
|
+
uint32_t height;
|
|
2620
|
+
uint64_t generation;
|
|
2621
|
+
uint64_t char_ptr;
|
|
2622
|
+
uint64_t fg_ptr;
|
|
2623
|
+
uint64_t bg_ptr;
|
|
2624
|
+
uint64_t attributes_ptr;
|
|
2625
|
+
uint64_t reserved;
|
|
2626
|
+
} ot_buffer_lease_snapshot;
|
|
2627
|
+
|
|
2628
|
+
/* Bits 31..30 of a char plane element (KIND_MASK) select its kind: 00 is a
|
|
2629
|
+
* Unicode scalar; IMAGE, GRAPHEME (a pooled grapheme's first cell) and
|
|
2630
|
+
* CONTINUATION (a later cell of a wide glyph) carry native payloads. */
|
|
2631
|
+
#define OT_CELL_CHAR_KIND_MASK UINT32_C(0xC0000000)
|
|
2632
|
+
#define OT_CELL_CHAR_IMAGE UINT32_C(0x40000000)
|
|
2633
|
+
#define OT_CELL_CHAR_GRAPHEME UINT32_C(0x80000000)
|
|
2634
|
+
#define OT_CELL_CHAR_CONTINUATION UINT32_C(0xC0000000)
|
|
2635
|
+
|
|
2636
|
+
/* Acquire local frame access for the exact retained DONE record. which is
|
|
2637
|
+
* OT_SESSION_BUFFER_CURRENT or NEXT. Both require this qualified operation while
|
|
2638
|
+
* a draft is live; ordinary Session draw, render, and borrowing cannot bypass it.
|
|
2639
|
+
* The frame and snapshot require exact size/version and zero reserved fields.
|
|
2640
|
+
* Rejection leaves out_snapshot unchanged and acquires no lease. Native code
|
|
2641
|
+
* validates frame membership, destination, and storage identity; copied or forged
|
|
2642
|
+
* record fields do not replace that validation. Existing lease limits, raw-plane
|
|
2643
|
+
* restrictions, validation, capture, and release operations apply.
|
|
2644
|
+
* Release all qualified scopes before commit or a new frame, including stale ones.
|
|
2645
|
+
* An accepted size-changing resize replaces and requalifies draft storage natively
|
|
2646
|
+
* without repainting. Old scopes return OT_STALE_LEASE; later acquisitions use the
|
|
2647
|
+
* new size with the same request record. Setup before the first accepted frame and
|
|
2648
|
+
* suspend retain existing scopes, but new acquisitions and commit return
|
|
2649
|
+
* OT_INVALID_PHASE outside a rendering phase. */
|
|
2650
|
+
ot_status ot_scene_frame_acquire_buffer_lease(ot_context *, const ot_handle *session,
|
|
2651
|
+
const ot_scene_frame_request *frame_request, uint32_t which, ot_buffer_lease_snapshot *out_snapshot);
|
|
2652
|
+
|
|
2653
|
+
/* Submit the exact retained DONE record through ordered Session output. force is
|
|
2654
|
+
* 0 or 1; out_status uses OT_RENDER_* and the existing Session output admission
|
|
2655
|
+
* and publication rules. Only output completion publishes frame_count and pending
|
|
2656
|
+
* hits. No qualified scope may remain, or commit returns OT_FRAME_BUSY. The frame
|
|
2657
|
+
* requires exact size/version and zero reserved fields. Rejection leaves out_status
|
|
2658
|
+
* unchanged and preserves a live draft for retry after the admission error is
|
|
2659
|
+
* resolved. OT_OK consumes the draft for EVERY out_status:
|
|
2660
|
+
* PRESENTED: output accepted and presentation complete, including no-byte frames.
|
|
2661
|
+
* PENDING: this draft accepted; output completion is still pending.
|
|
2662
|
+
* SKIPPED: output pressure; paint a new draft after queued output drains.
|
|
2663
|
+
* FAILED: the frame is larger than the empty output queue, or encoding or
|
|
2664
|
+
* allocation failed; no output was accepted.
|
|
2665
|
+
* In particular, OT_OK with OT_RENDER_FAILED is not an ot_status error.
|
|
2666
|
+
* A consumed, cancelled, foreign, or altered frame cannot submit again. */
|
|
2667
|
+
ot_status ot_scene_frame_commit(ot_context *, const ot_handle *session,
|
|
2668
|
+
const ot_scene_frame_request *frame_request, uint32_t force, uint32_t *out_status);
|
|
2669
|
+
|
|
2670
|
+
#define OT_SESSION_CONTROL_PACKET_BYTES UINT32_C(4096)
|
|
2671
|
+
#define OT_TERMINAL_ALTERNATE_SCREEN UINT32_C(1)
|
|
2672
|
+
#define OT_TERMINAL_MOUSE UINT32_C(2)
|
|
2673
|
+
#define OT_TERMINAL_MOUSE_MOVEMENT UINT32_C(4)
|
|
2674
|
+
#define OT_TERMINAL_CLEAR_ON_CLOSE UINT32_C(8)
|
|
2675
|
+
#define OT_TERMINAL_REPLY_SENTINEL UINT32_C(16)
|
|
2676
|
+
#define OT_TERMINAL_SYNC_ALWAYS UINT32_C(32)
|
|
2677
|
+
#define OT_TERMINAL_SYNC_NEVER UINT32_C(64)
|
|
2678
|
+
#define OT_TERMINAL_HOST_MULTIPLEXER UINT32_C(128)
|
|
2679
|
+
|
|
2680
|
+
/* flags is a combination of the eight OT_TERMINAL_* option bits above. Other bits
|
|
2681
|
+
* must be zero. REPLY_SENTINEL ends the startup query packet with DA1 (CSI c),
|
|
2682
|
+
* also inside tmux, and sends no other DA1; the host waits for its reply instead
|
|
2683
|
+
* of a timer. A DA1 reply then also ends the startup cursor-report probes.
|
|
2684
|
+
* Frames that paint are wrapped in synchronized output (DEC mode 2026) unless the terminal
|
|
2685
|
+
* is remote and, once its replies passed the 2026 query (a width-probe report
|
|
2686
|
+
* or DA1), either did not report the mode or HOST_MULTIPLEXER is set: the host
|
|
2687
|
+
* runs inside tmux, screen or Zellij between the app and the link.
|
|
2688
|
+
* SYNC_ALWAYS or SYNC_NEVER (not both) forces the wrapper on or off. kitty_keyboard_flags accepts OT_KITTY_KEYBOARD_* bits, or zero to
|
|
2689
|
+
* disable Kitty keyboard. clear-on-close also controls surface clearing on suspend. It
|
|
2690
|
+
* clears only a surface that setup or resume claimed: a close before their mode
|
|
2691
|
+
* packet leaves visible shell output in place. */
|
|
2692
|
+
typedef struct ot_session_terminal_options {
|
|
2693
|
+
uint32_t struct_size;
|
|
2694
|
+
uint32_t abi_version;
|
|
2695
|
+
uint32_t flags;
|
|
2696
|
+
uint32_t kitty_keyboard_flags;
|
|
2697
|
+
} ot_session_terminal_options;
|
|
2698
|
+
|
|
2699
|
+
/* Kitty keyboard protocol progressive-enhancement flags. */
|
|
2700
|
+
#define OT_KITTY_KEYBOARD_DISAMBIGUATE UINT32_C(1)
|
|
2701
|
+
#define OT_KITTY_KEYBOARD_EVENT_TYPES UINT32_C(2)
|
|
2702
|
+
#define OT_KITTY_KEYBOARD_ALTERNATE_KEYS UINT32_C(4)
|
|
2703
|
+
#define OT_KITTY_KEYBOARD_ALL_KEYS_AS_ESCAPES UINT32_C(8)
|
|
2704
|
+
#define OT_KITTY_KEYBOARD_REPORT_TEXT UINT32_C(16)
|
|
2705
|
+
#define OT_KITTY_KEYBOARD_ALL (OT_KITTY_KEYBOARD_DISAMBIGUATE | OT_KITTY_KEYBOARD_EVENT_TYPES | \
|
|
2706
|
+
OT_KITTY_KEYBOARD_ALTERNATE_KEYS | OT_KITTY_KEYBOARD_ALL_KEYS_AS_ESCAPES | OT_KITTY_KEYBOARD_REPORT_TEXT)
|
|
2707
|
+
|
|
2708
|
+
#define OT_CONTROL_CAPABILITY_RESPONSE UINT32_C(1)
|
|
2709
|
+
#define OT_CONTROL_TITLE UINT32_C(2)
|
|
2710
|
+
#define OT_CONTROL_MOUSE UINT32_C(3)
|
|
2711
|
+
#define OT_CONTROL_KITTY_KEYBOARD_FLAGS UINT32_C(4)
|
|
2712
|
+
#define OT_CONTROL_RESTORE_MODES UINT32_C(5)
|
|
2713
|
+
#define OT_CONTROL_QUERY_PIXEL_RESOLUTION UINT32_C(6)
|
|
2714
|
+
#define OT_CONTROL_QUERY_THEME_COLORS UINT32_C(7)
|
|
2715
|
+
#define OT_CONTROL_CURSOR UINT32_C(8)
|
|
2716
|
+
#define OT_CONTROL_RESET_BACKGROUND UINT32_C(9)
|
|
2717
|
+
#define OT_CONTROL_PALETTE_QUERY UINT32_C(10)
|
|
2718
|
+
#define OT_CONTROL_PROGRAM_STATUS UINT32_C(11)
|
|
2719
|
+
#define OT_CONTROL_END_REPLY_SENTINEL UINT32_C(12)
|
|
2720
|
+
|
|
2721
|
+
/* argument is 0/1/2 (disabled/drag/motion) for MOUSE, 0..31 for Kitty flags,
|
|
2722
|
+
* 0/1 for QUERY_PIXEL_RESOLUTION, QUERY_THEME_COLORS and PALETTE_QUERY (1 appends
|
|
2723
|
+
* the DA1 sentinel, after the validated palette queries in the same packet; a
|
|
2724
|
+
* tmux-wrapped query's replies trail tmux's own DA1, so it takes 0), and zero
|
|
2725
|
+
* otherwise. CAPABILITY_RESPONSE, TITLE, CURSOR, PALETTE_QUERY, and
|
|
2726
|
+
* PROGRAM_STATUS accept payload bytes. reserved must be zero. END_REPLY_SENTINEL,
|
|
2727
|
+
* accepted in every open phase, turns REPLY_SENTINEL off for good once a DA1
|
|
2728
|
+
* reply never came: later Kitty keyboard pushes send no CSI ? u query. */
|
|
2729
|
+
typedef struct ot_session_control_options {
|
|
2730
|
+
uint32_t struct_size;
|
|
2731
|
+
uint32_t abi_version;
|
|
2732
|
+
uint32_t kind;
|
|
2733
|
+
uint32_t argument;
|
|
2734
|
+
uint32_t reserved;
|
|
2735
|
+
} ot_session_control_options;
|
|
2736
|
+
|
|
2737
|
+
#define OT_CURSOR_POSITION UINT32_C(1)
|
|
2738
|
+
#define OT_CURSOR_STYLE UINT32_C(2)
|
|
2739
|
+
#define OT_CURSOR_BLINKING UINT32_C(4)
|
|
2740
|
+
#define OT_CURSOR_COLOR UINT32_C(8)
|
|
2741
|
+
#define OT_CURSOR_MOUSE_POINTER UINT32_C(16)
|
|
2742
|
+
|
|
2743
|
+
/* CURSOR payload is exactly one copied ot_session_cursor_update, with native
|
|
2744
|
+
* byte order and no alignment requirement. fields selects updated properties;
|
|
2745
|
+
* other bits must be zero. x/y clamp to 1 and must not exceed 65536. visible and
|
|
2746
|
+
* blinking are 0/1. style is an OT_CURSOR_STYLE_* value. mouse_pointer
|
|
2747
|
+
* is an OT_MOUSE_POINTER_* shape. Color uses the packed RGBA lanes. Unselected
|
|
2748
|
+
* fields must be zero. */
|
|
2749
|
+
typedef struct ot_session_cursor_update {
|
|
2750
|
+
uint32_t fields;
|
|
2751
|
+
int32_t x;
|
|
2752
|
+
int32_t y;
|
|
2753
|
+
uint8_t visible;
|
|
2754
|
+
uint8_t style;
|
|
2755
|
+
uint8_t blinking;
|
|
2756
|
+
uint8_t mouse_pointer;
|
|
2757
|
+
uint16_t color[4];
|
|
2758
|
+
} ot_session_cursor_update;
|
|
2759
|
+
|
|
2760
|
+
#define OT_PROGRAM_STATE_IDLE UINT32_C(1)
|
|
2761
|
+
#define OT_PROGRAM_STATE_WORKING UINT32_C(2)
|
|
2762
|
+
#define OT_PROGRAM_STATE_DONE UINT32_C(3)
|
|
2763
|
+
#define OT_PROGRAM_STATE_BLOCKED UINT32_C(4)
|
|
2764
|
+
#define OT_PROGRAM_STATE_ERROR UINT32_C(5)
|
|
2765
|
+
#define OT_PROGRAM_STATE_CLEAR UINT32_C(6)
|
|
2766
|
+
|
|
2767
|
+
#define OT_PROGRAM_KIND_PERMISSION UINT32_C(1)
|
|
2768
|
+
#define OT_PROGRAM_KIND_QUESTION UINT32_C(2)
|
|
2769
|
+
#define OT_PROGRAM_KIND_AUTH UINT32_C(3)
|
|
2770
|
+
|
|
2771
|
+
#define OT_PROGRAM_STATUS_PROGRESS UINT32_C(1)
|
|
2772
|
+
|
|
2773
|
+
/* PROGRAM_STATUS payload is one copied ot_session_program_status, with native
|
|
2774
|
+
* byte order and no alignment requirement, followed by exactly id_len, app_len,
|
|
2775
|
+
* title_len, and message_len bytes in that order. It writes one OSC 7501
|
|
2776
|
+
* Program Status Protocol report. A zero length omits that key; an empty id
|
|
2777
|
+
* addresses the root record. kind is zero or an OT_PROGRAM_KIND_* value and
|
|
2778
|
+
* requires BLOCKED. fields selects progress, 0..100, which requires WORKING or
|
|
2779
|
+
* BLOCKED; unselected progress must be zero. CLEAR accepts only an id.
|
|
2780
|
+
* id is at most 8 '/'-separated segments of 1..32 [A-Za-z0-9_.+-] bytes and 128
|
|
2781
|
+
* bytes in total. app is at most 32 [A-Za-z0-9_.+-] bytes. title (at most 192
|
|
2782
|
+
* bytes) and message (at most 2048 bytes) are UTF-8 without C0, DEL, or C1
|
|
2783
|
+
* controls; output encodes them as base64. Output is never multiplexer-wrapped. */
|
|
2784
|
+
typedef struct ot_session_program_status {
|
|
2785
|
+
uint32_t state;
|
|
2786
|
+
uint32_t kind;
|
|
2787
|
+
uint32_t fields;
|
|
2788
|
+
uint32_t progress;
|
|
2789
|
+
uint32_t id_len;
|
|
2790
|
+
uint32_t app_len;
|
|
2791
|
+
uint32_t title_len;
|
|
2792
|
+
uint32_t message_len;
|
|
2793
|
+
} ot_session_program_status;
|
|
2794
|
+
|
|
2795
|
+
#define OT_CAP_KITTY_KEYBOARD UINT32_C(1)
|
|
2796
|
+
#define OT_CAP_KITTY_GRAPHICS UINT32_C(2)
|
|
2797
|
+
#define OT_CAP_RGB UINT32_C(4)
|
|
2798
|
+
#define OT_CAP_ANSI256 UINT32_C(8)
|
|
2799
|
+
#define OT_CAP_SGR_PIXELS UINT32_C(16)
|
|
2800
|
+
#define OT_CAP_COLOR_SCHEME_UPDATES UINT32_C(32)
|
|
2801
|
+
#define OT_CAP_EXPLICIT_WIDTH UINT32_C(64)
|
|
2802
|
+
#define OT_CAP_SCALED_TEXT UINT32_C(128)
|
|
2803
|
+
#define OT_CAP_SIXEL UINT32_C(256)
|
|
2804
|
+
#define OT_CAP_FOCUS_TRACKING UINT32_C(512)
|
|
2805
|
+
#define OT_CAP_SYNC UINT32_C(1024)
|
|
2806
|
+
#define OT_CAP_BRACKETED_PASTE UINT32_C(2048)
|
|
2807
|
+
#define OT_CAP_HYPERLINKS UINT32_C(4096)
|
|
2808
|
+
#define OT_CAP_OSC52 UINT32_C(8192)
|
|
2809
|
+
#define OT_CAP_NOTIFICATIONS UINT32_C(16384)
|
|
2810
|
+
#define OT_CAP_EXPLICIT_CURSOR_POSITIONING UINT32_C(32768)
|
|
2811
|
+
#define OT_CAP_REMOTE UINT32_C(65536)
|
|
2812
|
+
#define OT_CAP_PROGRAM_STATUS UINT32_C(131072)
|
|
2813
|
+
|
|
2814
|
+
/* Initialize struct_size and abi_version. All other fields are copied output.
|
|
2815
|
+
* width_method is 0=wcwidth, 1=unicode, 2=no_zwj, 3=unicode_wide.
|
|
2816
|
+
* multiplexer is 0=none, 1=tmux, 2=zellij, 3=screen, 4=unknown.
|
|
2817
|
+
* image_protocol is 0=auto, 1=kitty, 2=sixel, 3=blocks.
|
|
2818
|
+
* osc52_support is 0=unknown, 1=supported, 2=unsupported.
|
|
2819
|
+
* kitty_keyboard_flags is accepted intent, not confirmation of enabled modes.
|
|
2820
|
+
* String lengths count bytes, not NUL terminators. Unused bytes and reserved
|
|
2821
|
+
* are zero. No native memory is borrowed; failure leaves the record unchanged. */
|
|
2822
|
+
typedef struct ot_session_capabilities {
|
|
2823
|
+
uint32_t struct_size;
|
|
2824
|
+
uint32_t abi_version;
|
|
2825
|
+
uint32_t flags;
|
|
2826
|
+
uint32_t width_method;
|
|
2827
|
+
uint32_t multiplexer;
|
|
2828
|
+
uint32_t image_protocol;
|
|
2829
|
+
uint32_t osc52_support;
|
|
2830
|
+
uint32_t kitty_keyboard_flags;
|
|
2831
|
+
uint32_t term_name_len;
|
|
2832
|
+
uint32_t term_version_len;
|
|
2833
|
+
uint32_t term_from_xtversion;
|
|
2834
|
+
uint32_t reserved;
|
|
2835
|
+
uint8_t term_name[64];
|
|
2836
|
+
uint8_t term_version[32];
|
|
2837
|
+
} ot_session_capabilities;
|
|
2838
|
+
|
|
2839
|
+
#define OT_TERMINAL_UNINITIALIZED UINT32_C(0)
|
|
2840
|
+
#define OT_TERMINAL_SETTING_UP UINT32_C(1)
|
|
2841
|
+
#define OT_TERMINAL_ACTIVE UINT32_C(2)
|
|
2842
|
+
#define OT_TERMINAL_SUSPENDING UINT32_C(3)
|
|
2843
|
+
#define OT_TERMINAL_SUSPENDED UINT32_C(4)
|
|
2844
|
+
#define OT_TERMINAL_RESUMING UINT32_C(5)
|
|
2845
|
+
#define OT_TERMINAL_CLOSING UINT32_C(6)
|
|
2846
|
+
#define OT_TERMINAL_RESTORED UINT32_C(7)
|
|
2847
|
+
#define OT_TERMINAL_FAILED UINT32_C(8)
|
|
2848
|
+
#define OT_TERMINAL_CANCELLED UINT32_C(9)
|
|
2849
|
+
|
|
2850
|
+
#define OT_PUMP_IDLE UINT32_C(0)
|
|
2851
|
+
#define OT_PUMP_AGAIN UINT32_C(1)
|
|
2852
|
+
#define OT_PUMP_OUTPUT_PENDING UINT32_C(2)
|
|
2853
|
+
#define OT_PUMP_WAIT_UNTIL UINT32_C(3)
|
|
2854
|
+
#define OT_PUMP_CLOSED UINT32_C(4)
|
|
2855
|
+
|
|
2856
|
+
/* ot_session_post_stdout states. */
|
|
2857
|
+
#define OT_STDOUT_IDLE UINT32_C(0)
|
|
2858
|
+
#define OT_STDOUT_IN_FLIGHT UINT32_C(1)
|
|
2859
|
+
|
|
2860
|
+
/* Initialize struct_size and abi_version. status, reserved, and deadline_ns are
|
|
2861
|
+
* output-only. deadline_ns is nonzero only for OT_PUMP_WAIT_UNTIL. No memory is
|
|
2862
|
+
* borrowed. A rejected call leaves the entire output record unchanged. */
|
|
2863
|
+
typedef struct ot_session_pump_result {
|
|
2864
|
+
uint32_t struct_size;
|
|
2865
|
+
uint32_t abi_version;
|
|
2866
|
+
uint32_t status;
|
|
2867
|
+
uint32_t reserved;
|
|
2868
|
+
uint64_t deadline_ns;
|
|
2869
|
+
} ot_session_pump_result;
|
|
2870
|
+
|
|
2871
|
+
#define OT_INPUT_KEY UINT32_C(1)
|
|
2872
|
+
#define OT_INPUT_MOUSE UINT32_C(2)
|
|
2873
|
+
#define OT_INPUT_PASTE UINT32_C(3)
|
|
2874
|
+
#define OT_INPUT_FOCUS UINT32_C(4)
|
|
2875
|
+
#define OT_INPUT_REPLY UINT32_C(5)
|
|
2876
|
+
|
|
2877
|
+
#define OT_INPUT_KEY_PRESS UINT32_C(1)
|
|
2878
|
+
#define OT_INPUT_KEY_REPEAT UINT32_C(2)
|
|
2879
|
+
#define OT_INPUT_KEY_RELEASE UINT32_C(3)
|
|
2880
|
+
#define OT_INPUT_MOUSE_DOWN UINT32_C(1)
|
|
2881
|
+
#define OT_INPUT_MOUSE_UP UINT32_C(2)
|
|
2882
|
+
#define OT_INPUT_MOUSE_MOVE UINT32_C(3)
|
|
2883
|
+
#define OT_INPUT_MOUSE_DRAG UINT32_C(4)
|
|
2884
|
+
#define OT_INPUT_MOUSE_SCROLL UINT32_C(5)
|
|
2885
|
+
#define OT_INPUT_MOUSE_BUTTON_NONE UINT32_C(255)
|
|
2886
|
+
#define OT_INPUT_FOCUS_OUT UINT32_C(0)
|
|
2887
|
+
#define OT_INPUT_FOCUS_IN UINT32_C(1)
|
|
2888
|
+
|
|
2889
|
+
/* Modifier bits use Kitty's layout: the wire modifier parameter minus one. Mouse
|
|
2890
|
+
* events report only Shift, Alt, and Ctrl. */
|
|
2891
|
+
#define OT_INPUT_MOD_SHIFT UINT32_C(1)
|
|
2892
|
+
#define OT_INPUT_MOD_ALT UINT32_C(2)
|
|
2893
|
+
#define OT_INPUT_MOD_CTRL UINT32_C(4)
|
|
2894
|
+
#define OT_INPUT_MOD_SUPER UINT32_C(8)
|
|
2895
|
+
#define OT_INPUT_MOD_HYPER UINT32_C(16)
|
|
2896
|
+
#define OT_INPUT_MOD_META UINT32_C(32)
|
|
2897
|
+
#define OT_INPUT_MOD_CAPS_LOCK UINT32_C(64)
|
|
2898
|
+
#define OT_INPUT_MOD_NUM_LOCK UINT32_C(128)
|
|
2899
|
+
|
|
2900
|
+
#define OT_INPUT_KEY_KITTY UINT32_C(1)
|
|
2901
|
+
#define OT_INPUT_KEY_TEXT_TRUNCATED UINT32_C(2)
|
|
2902
|
+
#define OT_INPUT_KEY_TYPED UINT32_C(4)
|
|
2903
|
+
#define OT_INPUT_PASTE_START UINT32_C(1)
|
|
2904
|
+
#define OT_INPUT_PASTE_END UINT32_C(2)
|
|
2905
|
+
#define OT_INPUT_REPLY_FRAGMENT UINT32_C(1)
|
|
2906
|
+
#define OT_INPUT_REPLY_CURSOR_POSITION UINT32_C(2)
|
|
2907
|
+
|
|
2908
|
+
#define OT_INPUT_REPLY_CSI UINT32_C(1)
|
|
2909
|
+
#define OT_INPUT_REPLY_SS3 UINT32_C(2)
|
|
2910
|
+
#define OT_INPUT_REPLY_OSC UINT32_C(3)
|
|
2911
|
+
#define OT_INPUT_REPLY_DCS UINT32_C(4)
|
|
2912
|
+
#define OT_INPUT_REPLY_APC UINT32_C(5)
|
|
2913
|
+
|
|
2914
|
+
/* Key codes are Unicode scalars; functional keys use the Kitty keyboard protocol
|
|
2915
|
+
* assignments. Escape, Enter, Tab, and Backspace are 27, 13, 9, and 127. A key
|
|
2916
|
+
* typed from the private-use area shares the Kitty range: OT_INPUT_KEY_TYPED
|
|
2917
|
+
* marks a code that is a printable character the terminal sent as text or as
|
|
2918
|
+
* xterm's CSI 27 ; mods ; code ~, never a functional key. Code 0 is a text-only
|
|
2919
|
+
* key (input method output). */
|
|
2920
|
+
#define OT_INPUT_KEY_ESCAPE UINT32_C(27)
|
|
2921
|
+
#define OT_INPUT_KEY_ENTER UINT32_C(13)
|
|
2922
|
+
#define OT_INPUT_KEY_TAB UINT32_C(9)
|
|
2923
|
+
#define OT_INPUT_KEY_BACKSPACE UINT32_C(127)
|
|
2924
|
+
#define OT_INPUT_KEY_INSERT UINT32_C(57348)
|
|
2925
|
+
#define OT_INPUT_KEY_DELETE UINT32_C(57349)
|
|
2926
|
+
#define OT_INPUT_KEY_LEFT UINT32_C(57350)
|
|
2927
|
+
#define OT_INPUT_KEY_RIGHT UINT32_C(57351)
|
|
2928
|
+
#define OT_INPUT_KEY_UP UINT32_C(57352)
|
|
2929
|
+
#define OT_INPUT_KEY_DOWN UINT32_C(57353)
|
|
2930
|
+
#define OT_INPUT_KEY_PAGE_UP UINT32_C(57354)
|
|
2931
|
+
#define OT_INPUT_KEY_PAGE_DOWN UINT32_C(57355)
|
|
2932
|
+
#define OT_INPUT_KEY_HOME UINT32_C(57356)
|
|
2933
|
+
#define OT_INPUT_KEY_END UINT32_C(57357)
|
|
2934
|
+
#define OT_INPUT_KEY_CAPS_LOCK UINT32_C(57358)
|
|
2935
|
+
#define OT_INPUT_KEY_SCROLL_LOCK UINT32_C(57359)
|
|
2936
|
+
#define OT_INPUT_KEY_NUM_LOCK UINT32_C(57360)
|
|
2937
|
+
#define OT_INPUT_KEY_PRINT_SCREEN UINT32_C(57361)
|
|
2938
|
+
#define OT_INPUT_KEY_PAUSE UINT32_C(57362)
|
|
2939
|
+
#define OT_INPUT_KEY_MENU UINT32_C(57363)
|
|
2940
|
+
#define OT_INPUT_KEY_F1 UINT32_C(57364) /* F(n) is 57363 + n, n in 1..35 */
|
|
2941
|
+
#define OT_INPUT_KEY_F35 UINT32_C(57398)
|
|
2942
|
+
#define OT_INPUT_KEY_KP_0 UINT32_C(57399) /* KP(n) is 57399 + n, n in 0..9 */
|
|
2943
|
+
#define OT_INPUT_KEY_KP_9 UINT32_C(57408)
|
|
2944
|
+
#define OT_INPUT_KEY_KP_DECIMAL UINT32_C(57409)
|
|
2945
|
+
#define OT_INPUT_KEY_KP_DIVIDE UINT32_C(57410)
|
|
2946
|
+
#define OT_INPUT_KEY_KP_MULTIPLY UINT32_C(57411)
|
|
2947
|
+
#define OT_INPUT_KEY_KP_SUBTRACT UINT32_C(57412)
|
|
2948
|
+
#define OT_INPUT_KEY_KP_ADD UINT32_C(57413)
|
|
2949
|
+
#define OT_INPUT_KEY_KP_ENTER UINT32_C(57414)
|
|
2950
|
+
#define OT_INPUT_KEY_KP_EQUAL UINT32_C(57415)
|
|
2951
|
+
#define OT_INPUT_KEY_KP_SEPARATOR UINT32_C(57416)
|
|
2952
|
+
#define OT_INPUT_KEY_KP_LEFT UINT32_C(57417)
|
|
2953
|
+
#define OT_INPUT_KEY_KP_RIGHT UINT32_C(57418)
|
|
2954
|
+
#define OT_INPUT_KEY_KP_UP UINT32_C(57419)
|
|
2955
|
+
#define OT_INPUT_KEY_KP_DOWN UINT32_C(57420)
|
|
2956
|
+
#define OT_INPUT_KEY_KP_PAGE_UP UINT32_C(57421)
|
|
2957
|
+
#define OT_INPUT_KEY_KP_PAGE_DOWN UINT32_C(57422)
|
|
2958
|
+
#define OT_INPUT_KEY_KP_HOME UINT32_C(57423)
|
|
2959
|
+
#define OT_INPUT_KEY_KP_END UINT32_C(57424)
|
|
2960
|
+
#define OT_INPUT_KEY_KP_INSERT UINT32_C(57425)
|
|
2961
|
+
#define OT_INPUT_KEY_KP_DELETE UINT32_C(57426)
|
|
2962
|
+
#define OT_INPUT_KEY_KP_BEGIN UINT32_C(57427)
|
|
2963
|
+
#define OT_INPUT_KEY_MEDIA_PLAY UINT32_C(57428)
|
|
2964
|
+
#define OT_INPUT_KEY_MEDIA_PAUSE UINT32_C(57429)
|
|
2965
|
+
#define OT_INPUT_KEY_MEDIA_PLAY_PAUSE UINT32_C(57430)
|
|
2966
|
+
#define OT_INPUT_KEY_MEDIA_REVERSE UINT32_C(57431)
|
|
2967
|
+
#define OT_INPUT_KEY_MEDIA_STOP UINT32_C(57432)
|
|
2968
|
+
#define OT_INPUT_KEY_MEDIA_FAST_FORWARD UINT32_C(57433)
|
|
2969
|
+
#define OT_INPUT_KEY_MEDIA_REWIND UINT32_C(57434)
|
|
2970
|
+
#define OT_INPUT_KEY_MEDIA_TRACK_NEXT UINT32_C(57435)
|
|
2971
|
+
#define OT_INPUT_KEY_MEDIA_TRACK_PREVIOUS UINT32_C(57436)
|
|
2972
|
+
#define OT_INPUT_KEY_MEDIA_RECORD UINT32_C(57437)
|
|
2973
|
+
#define OT_INPUT_KEY_LOWER_VOLUME UINT32_C(57438)
|
|
2974
|
+
#define OT_INPUT_KEY_RAISE_VOLUME UINT32_C(57439)
|
|
2975
|
+
#define OT_INPUT_KEY_MUTE_VOLUME UINT32_C(57440)
|
|
2976
|
+
#define OT_INPUT_KEY_LEFT_SHIFT UINT32_C(57441)
|
|
2977
|
+
#define OT_INPUT_KEY_LEFT_CONTROL UINT32_C(57442)
|
|
2978
|
+
#define OT_INPUT_KEY_LEFT_ALT UINT32_C(57443)
|
|
2979
|
+
#define OT_INPUT_KEY_LEFT_SUPER UINT32_C(57444)
|
|
2980
|
+
#define OT_INPUT_KEY_LEFT_HYPER UINT32_C(57445)
|
|
2981
|
+
#define OT_INPUT_KEY_LEFT_META UINT32_C(57446)
|
|
2982
|
+
#define OT_INPUT_KEY_RIGHT_SHIFT UINT32_C(57447)
|
|
2983
|
+
#define OT_INPUT_KEY_RIGHT_CONTROL UINT32_C(57448)
|
|
2984
|
+
#define OT_INPUT_KEY_RIGHT_ALT UINT32_C(57449)
|
|
2985
|
+
#define OT_INPUT_KEY_RIGHT_SUPER UINT32_C(57450)
|
|
2986
|
+
#define OT_INPUT_KEY_RIGHT_HYPER UINT32_C(57451)
|
|
2987
|
+
#define OT_INPUT_KEY_RIGHT_META UINT32_C(57452)
|
|
2988
|
+
#define OT_INPUT_KEY_ISO_LEVEL3_SHIFT UINT32_C(57453)
|
|
2989
|
+
#define OT_INPUT_KEY_ISO_LEVEL5_SHIFT UINT32_C(57454)
|
|
2990
|
+
|
|
2991
|
+
#define OT_INPUT_EXPECT_REPLIES UINT32_C(1)
|
|
2992
|
+
#define OT_INPUT_EXPECT_KITTY_KEYBOARD UINT32_C(2)
|
|
2993
|
+
#define OT_INPUT_EXPECT_CURSOR_POSITION UINT32_C(4)
|
|
2994
|
+
#define OT_INPUT_EXPECT_SENTINEL UINT32_C(8)
|
|
2995
|
+
#define OT_INPUT_EXPECT_ESCAPE_PREFIX UINT32_C(16)
|
|
2996
|
+
|
|
2997
|
+
#define OT_INPUT_EVENTS_MIN UINT32_C(4)
|
|
2998
|
+
#define OT_INPUT_PAYLOAD_BYTES_MIN UINT32_C(4384)
|
|
2999
|
+
#define OT_INPUT_TIMEOUT_NS UINT64_C(20000000)
|
|
3000
|
+
|
|
3001
|
+
/* One parsed input event. raw and text are byte spans into the payload buffer of
|
|
3002
|
+
* the same call. kind selects the meaning of action, code, x, and y:
|
|
3003
|
+
* KEY: action is OT_INPUT_KEY_PRESS/REPEAT/RELEASE, code a key code, base_code a
|
|
3004
|
+
* nonzero base-layout scalar when the terminal reports one, text what an editor
|
|
3005
|
+
* inserts. MOUSE: action is OT_INPUT_MOUSE_*, code a button (0..2, 8+, or NONE)
|
|
3006
|
+
* or a scroll direction (0 up, 1 down, 2 left, 3 right), x and y a zero-based
|
|
3007
|
+
* cell. PASTE: text is one chunk of pasted bytes and raw is empty. FOCUS: action
|
|
3008
|
+
* is OT_INPUT_FOCUS_IN/OUT. REPLY: code is an OT_INPUT_REPLY_* protocol and raw
|
|
3009
|
+
* the wire bytes. flags hold the kind's OT_INPUT_* flags. */
|
|
3010
|
+
typedef struct ot_input_event {
|
|
3011
|
+
uint8_t kind;
|
|
3012
|
+
uint8_t action;
|
|
3013
|
+
uint8_t modifiers;
|
|
3014
|
+
uint8_t flags;
|
|
3015
|
+
uint32_t code;
|
|
3016
|
+
uint32_t base_code;
|
|
3017
|
+
uint16_t x;
|
|
3018
|
+
uint16_t y;
|
|
3019
|
+
uint32_t raw_offset;
|
|
3020
|
+
uint32_t raw_len;
|
|
3021
|
+
uint32_t text_offset;
|
|
3022
|
+
uint32_t text_len;
|
|
3023
|
+
} ot_input_event;
|
|
3024
|
+
|
|
3025
|
+
/* Initialize struct_size and abi_version. The remaining fields are output-only.
|
|
3026
|
+
* consumed is the number of input bytes parsed; call again with the rest when it
|
|
3027
|
+
* is less than byte_count. A call can consume nothing after it reported events.
|
|
3028
|
+
* deadline_ns is nonzero when a partial unit waits for the timeout: call feed
|
|
3029
|
+
* with zero bytes at or after it. discarded is a saturating lifetime count of
|
|
3030
|
+
* overlong units dropped. */
|
|
3031
|
+
typedef struct ot_input_drain {
|
|
3032
|
+
uint32_t struct_size;
|
|
3033
|
+
uint32_t abi_version;
|
|
3034
|
+
uint32_t consumed;
|
|
3035
|
+
uint32_t count;
|
|
3036
|
+
uint32_t payload_len;
|
|
3037
|
+
uint32_t discarded;
|
|
3038
|
+
uint64_t deadline_ns;
|
|
3039
|
+
} ot_input_drain;
|
|
3040
|
+
|
|
3041
|
+
/* Zero-initialize, then set struct_size to sizeof(ot_context_options) and
|
|
3042
|
+
* abi_version to OT_CONTEXT_ABI_VERSION. Version 2 requires the exact size,
|
|
3043
|
+
* zero flags, zero reserved fields, and positive resource limits.
|
|
3044
|
+
* object_capacity is the initial count of native object slots, not bytes. A full
|
|
3045
|
+
* table doubles, up to 4194304 slots or object_capacity, whichever is larger;
|
|
3046
|
+
* past that, creation returns OT_OBJECT_LIMIT. render_cells_max bounds each
|
|
3047
|
+
* renderer's width * height in terminal cells, not bytes or total context
|
|
3048
|
+
* memory. Neither limit uses a default when zero.
|
|
3049
|
+
* Allocator and I/O injection are available only through the direct Zig API. */
|
|
3050
|
+
typedef struct ot_context_options {
|
|
3051
|
+
uint32_t struct_size;
|
|
3052
|
+
uint32_t abi_version;
|
|
3053
|
+
uint32_t flags;
|
|
3054
|
+
uint32_t object_capacity;
|
|
3055
|
+
uint32_t render_cells_max;
|
|
3056
|
+
uint32_t reserved[3];
|
|
3057
|
+
} ot_context_options;
|
|
3058
|
+
|
|
3059
|
+
/* Initialize struct_size and abi_version before querying. The library writes
|
|
3060
|
+
* status and clears reserved on success. This record contains no borrowed
|
|
3061
|
+
* memory and remains valid after context destruction. */
|
|
3062
|
+
typedef struct ot_context_error {
|
|
3063
|
+
uint32_t struct_size;
|
|
3064
|
+
uint32_t abi_version;
|
|
3065
|
+
ot_status status;
|
|
3066
|
+
uint32_t reserved;
|
|
3067
|
+
} ot_context_error;
|
|
3068
|
+
|
|
3069
|
+
#define OT_DIAGNOSTIC_MESSAGE_BYTES UINT32_C(4096)
|
|
3070
|
+
#define OT_DIAGNOSTIC_TRUNCATED UINT32_C(1)
|
|
3071
|
+
#define OT_DIAGNOSTIC_QUEUE_MAX UINT32_C(64)
|
|
3072
|
+
|
|
3073
|
+
/* Copied diagnostic record. level is 0 (error), 1 (warning), 2 (info), or
|
|
3074
|
+
* 3 (debug). message_len counts bytes, not a terminating NUL. Unused message
|
|
3075
|
+
* bytes and reserved are zero. Truncation can split a UTF-8 sequence. */
|
|
3076
|
+
typedef struct ot_diagnostic {
|
|
3077
|
+
uint32_t level;
|
|
3078
|
+
uint32_t message_len;
|
|
3079
|
+
uint32_t flags;
|
|
3080
|
+
uint32_t reserved;
|
|
3081
|
+
uint8_t message[OT_DIAGNOSTIC_MESSAGE_BYTES];
|
|
3082
|
+
} ot_diagnostic;
|
|
3083
|
+
|
|
3084
|
+
/* Initialize struct_size and abi_version before each drain. dropped is a
|
|
3085
|
+
* saturating lifetime total. Draining does not reset it. */
|
|
3086
|
+
typedef struct ot_diagnostic_drain {
|
|
3087
|
+
uint32_t struct_size;
|
|
3088
|
+
uint32_t abi_version;
|
|
3089
|
+
uint32_t count;
|
|
3090
|
+
uint32_t remaining;
|
|
3091
|
+
uint64_t dropped;
|
|
3092
|
+
} ot_diagnostic_drain;
|
|
3093
|
+
|
|
3094
|
+
uint32_t ot_context_abi_version(void);
|
|
3095
|
+
|
|
3096
|
+
/* Create a context without setting up a terminal or starting worker threads.
|
|
3097
|
+
* Both pointers must be non-NULL and correctly aligned. Options are borrowed
|
|
3098
|
+
* only for this call. The function checks options before native allocation
|
|
3099
|
+
* and sets *out_context to NULL on every failure when out_context is non-NULL.
|
|
3100
|
+
* Creation failures have no context-local error record; use the return status.
|
|
3101
|
+
* OT_OUT_OF_MEMORY includes Yoga configuration allocation failure. Yoga C++
|
|
3102
|
+
* allocations use separate failure-injection tests, not Zig allocators.
|
|
3103
|
+
* Destroy a successful result with ot_context_destroy, never free(). */
|
|
3104
|
+
ot_status ot_context_create(const ot_context_options *options, ot_context **out_context);
|
|
3105
|
+
|
|
3106
|
+
/* Destroy a live context on its owner thread. NULL returns OT_INVALID_ARGUMENT.
|
|
3107
|
+
* OT_WRONG_THREAD leaves the context alive and does not change its error.
|
|
3108
|
+
* An active operation, teardown, or unreleased checked storage lease returns and
|
|
3109
|
+
* records OT_CONTEXT_BUSY without releasing the context or its I/O storage. */
|
|
3110
|
+
ot_status ot_context_destroy(ot_context *context);
|
|
3111
|
+
|
|
3112
|
+
/* Copy this context's most recent owner-thread error, initially OT_OK.
|
|
3113
|
+
* Successful queries do not clear it. Invalid query arguments update it.
|
|
3114
|
+
* The output requires the exact version-1 size and version; its status and
|
|
3115
|
+
* reserved fields are output-only. On failure, the output remains unchanged.
|
|
3116
|
+
* NULL contexts and wrong-thread calls return a status without changing any
|
|
3117
|
+
* context-local state. The caller owns the output for the entire call. */
|
|
3118
|
+
ot_status ot_context_get_last_error(ot_context *context, ot_context_error *out_error);
|
|
3119
|
+
|
|
3120
|
+
/* Copy up to capacity records in arrival order without allocation or callbacks.
|
|
3121
|
+
* Version 2 C contexts hold at most OT_DIAGNOSTIC_QUEUE_MAX records and drop newest on overflow.
|
|
3122
|
+
* records may be NULL only when capacity is zero. A zero-capacity drain reports
|
|
3123
|
+
* queue pressure without removing records. out_drain must have the exact size
|
|
3124
|
+
* and version. The caller owns both outputs for the call. Outputs and queued
|
|
3125
|
+
* records remain unchanged on failure. Active operations return OT_CONTEXT_BUSY.
|
|
3126
|
+
* Copied records remain valid after context destruction. */
|
|
3127
|
+
ot_status ot_context_drain_diagnostics(
|
|
3128
|
+
ot_context *context,
|
|
3129
|
+
ot_diagnostic *records,
|
|
3130
|
+
uint32_t capacity,
|
|
3131
|
+
ot_diagnostic_drain *out_drain);
|
|
3132
|
+
|
|
3133
|
+
/* Copy a live interned hyperlink URL. Zero capacity reports the byte count.
|
|
3134
|
+
* Nonzero capacity must fit that count; out_count is the copied byte count.
|
|
3135
|
+
* bytes may be NULL only when capacity is zero. URLs are at most 512 bytes.
|
|
3136
|
+
* Unknown or retired IDs return OT_INVALID_ARGUMENT. Outputs are unchanged on
|
|
3137
|
+
* rejection. Owner-thread and busy-operation rules apply. */
|
|
3138
|
+
ot_status ot_context_get_link_url(ot_context *context, uint32_t link_id,
|
|
3139
|
+
uint8_t *bytes, uint32_t capacity, uint32_t *out_count);
|
|
3140
|
+
|
|
3141
|
+
/* Options require the exact size and version. Failure leaves out_buffer unchanged.
|
|
3142
|
+
* The Context owns the buffer and its pools.
|
|
3143
|
+
* These functions obey the Context owner-thread and busy-operation rules. */
|
|
3144
|
+
ot_status ot_buffer_create(
|
|
3145
|
+
ot_context *context,
|
|
3146
|
+
const ot_buffer_options *options,
|
|
3147
|
+
ot_handle *out_buffer);
|
|
3148
|
+
ot_status ot_buffer_destroy(ot_context *context, const ot_handle *buffer);
|
|
3149
|
+
|
|
3150
|
+
/* Rejected resize preserves dimensions and cells. Size-changing resize or
|
|
3151
|
+
* destruction retires leased storage, which stays allocated until release. */
|
|
3152
|
+
ot_status ot_buffer_resize(
|
|
3153
|
+
ot_context *context,
|
|
3154
|
+
const ot_handle *buffer,
|
|
3155
|
+
uint32_t width,
|
|
3156
|
+
uint32_t height);
|
|
3157
|
+
|
|
3158
|
+
/* Draw into an owned buffer, or a Session's next buffer with the exact retained
|
|
3159
|
+
* DONE ticket. frame must be NULL for an owned buffer and non-NULL
|
|
3160
|
+
* for a Session. source is a same-Context buffer for COMPOSE only.
|
|
3161
|
+
* text is used only for TEXT or the BOX top title; bottom_title is BOX-only.
|
|
3162
|
+
* Other operations require zero byte counts for unused spans.
|
|
3163
|
+
* CLEAR fills spaces, zero attributes, and white foreground using the record
|
|
3164
|
+
* background. FILL clips to the destination; zero-sized or offscreen rectangles
|
|
3165
|
+
* are no-ops. Neither replaces storage or invalidates leases. TEXT draws only its
|
|
3166
|
+
* cells inside the target and skips a glyph that starts left of column 0.
|
|
3167
|
+
* Text/title byte counts are bounded by OT_BUFFER_TEXT_BYTES_MAX; invalid UTF-8
|
|
3168
|
+
* returns OT_INVALID_ARGUMENT. C0/C1/DEL controls occupy no cells. A tab (two
|
|
3169
|
+
* cells) and a grapheme over the native 128-byte limit or 16 cells draw as
|
|
3170
|
+
* spaces of their width. CELL, CELL_BLEND, and CHAR write a space for a control character.
|
|
3171
|
+
* Image-bearing targets return OT_UNSUPPORTED_RESOURCE.
|
|
3172
|
+
* Raw resource IDs are rejected. Rejection preserves cells except that any Box
|
|
3173
|
+
* title drawing failure may partially modify the destination; callers must
|
|
3174
|
+
* cancel the frame or discard the offscreen draft. No native framebuffer
|
|
3175
|
+
* pointer is accepted. */
|
|
3176
|
+
ot_status ot_buffer_draw(ot_context *context, const ot_handle *target,
|
|
3177
|
+
const ot_scene_frame_request *frame, const ot_buffer_draw_header *options,
|
|
3178
|
+
const ot_handle *source, const uint8_t *text, uint32_t text_len,
|
|
3179
|
+
const uint8_t *bottom_title, uint32_t bottom_title_len);
|
|
3180
|
+
|
|
3181
|
+
/* Checked drawing stacks use the same target/frame authority as ot_buffer_draw.
|
|
3182
|
+
* Pushes intersect clips or multiply opacity using the native buffer rules.
|
|
3183
|
+
* At most OT_BUFFER_STACK_DEPTH_MAX custom entries per stack are permitted;
|
|
3184
|
+
* exceeding this limit returns OT_OBJECT_LIMIT without changing either stack.
|
|
3185
|
+
* Clip sizes and signed endpoints must fit int32_t; empty clips are valid.
|
|
3186
|
+
* Opacity must be finite and is clamped to [0, 1]. Pass it as a one-float
|
|
3187
|
+
* buffer so host FFI can keep the portable integer/buffer calling convention.
|
|
3188
|
+
* Only PUSH operations use their corresponding rectangle/opacity arguments.
|
|
3189
|
+
* Pop on an empty custom stack is a no-op. Custom frame stacks reset on commit
|
|
3190
|
+
* or frame cancellation; owned buffer stacks persist until explicitly
|
|
3191
|
+
* popped/cleared or destroyed. out_opacity is required and receives the
|
|
3192
|
+
* effective opacity on success only. */
|
|
3193
|
+
ot_status ot_buffer_stack(ot_context *context, const ot_handle *target,
|
|
3194
|
+
const ot_scene_frame_request *frame, uint32_t operation,
|
|
3195
|
+
int32_t x, int32_t y, uint32_t width, uint32_t height,
|
|
3196
|
+
const float *opacity, float *out_opacity);
|
|
3197
|
+
|
|
3198
|
+
/* Draw a grid with the same target/frame authority as ot_buffer_draw. Counts are
|
|
3199
|
+
* offset-array lengths, not cell counts. Arrays must be strictly increasing,
|
|
3200
|
+
* with at most render_cells_max + 1 entries each; fewer than two is a no-op.
|
|
3201
|
+
* NULL arrays require zero length. Glyphs must be single-cell Unicode scalars
|
|
3202
|
+
* or zero. Colors use packed RGBA with canonical color intent. Input is borrowed only for this
|
|
3203
|
+
* call. Invalid input preserves the destination. Image-bearing targets reject. */
|
|
3204
|
+
ot_status ot_buffer_draw_grid(ot_context *context, const ot_handle *target,
|
|
3205
|
+
const ot_scene_frame_request *frame, const ot_buffer_grid_options *options,
|
|
3206
|
+
const int32_t *columns, uint32_t column_count,
|
|
3207
|
+
const int32_t *rows, uint32_t row_count);
|
|
3208
|
+
|
|
3209
|
+
/* Pixel drawing uses the same target/frame authority as ot_buffer_draw. Input
|
|
3210
|
+
* spans are borrowed for this call only and must not overlap destination planes.
|
|
3211
|
+
* NULL input requires zero length. Images reject; clipping, opacity, and pooled
|
|
3212
|
+
* cell replacement use the native buffer rules. Rejection preserves cells.
|
|
3213
|
+
* Packed cells are 48 native-endian bytes: bg[4] f32, fg[4] f32, character u32,
|
|
3214
|
+
* and 12 padding bytes. Input may be unaligned and must contain complete cells,
|
|
3215
|
+
* at least width * height. Visible color samples must be finite; finite channels
|
|
3216
|
+
* are clamped to 0..1. Invalid/non-cell characters use the existing block fallback.
|
|
3217
|
+
* Supersampling uses format 0=BGRA, 1=RGBA, and a nonzero stride divisible by 4.
|
|
3218
|
+
* Input must contain whole rows. Row padding is input; destination width clips it.
|
|
3219
|
+
* Missing neighbors at odd source edges are transparent.
|
|
3220
|
+
* Packed and supersampled positions are signed cells; a negative position clips
|
|
3221
|
+
* the source cells left of or above the destination.
|
|
3222
|
+
* Grayscale sample_count counts floats, not bytes; width * height must fit u32
|
|
3223
|
+
* and the supplied span. Visible samples must be finite. supersampled is 0 or 1;
|
|
3224
|
+
* 2x grayscale ignores an incomplete final sample row/column. Optional colors
|
|
3225
|
+
* contain packed RGBA with canonical color intent. Preflight work is destination-bounded. */
|
|
3226
|
+
ot_status ot_buffer_draw_packed(ot_context *, const ot_handle *, const ot_scene_frame_request *,
|
|
3227
|
+
const uint8_t *data, uint32_t byte_count, int32_t x, int32_t y, uint32_t width, uint32_t height);
|
|
3228
|
+
ot_status ot_buffer_draw_supersample(ot_context *, const ot_handle *, const ot_scene_frame_request *,
|
|
3229
|
+
const uint8_t *data, uint32_t byte_count, int32_t x, int32_t y, uint32_t format, uint32_t stride);
|
|
3230
|
+
ot_status ot_buffer_draw_grayscale(ot_context *, const ot_handle *, const ot_scene_frame_request *,
|
|
3231
|
+
const float *data, uint32_t sample_count, int32_t x, int32_t y, uint32_t width, uint32_t height,
|
|
3232
|
+
const uint16_t *foreground, const uint16_t *background, uint32_t supersampled);
|
|
3233
|
+
|
|
3234
|
+
/* Color matrices borrow 16 floats and optional (x, y, weight) triples for this
|
|
3235
|
+
* call. NULL mask selects uniform application and requires zero mask_count;
|
|
3236
|
+
* a non-NULL empty mask selects no cells. Counts are floats, not bytes; incomplete
|
|
3237
|
+
* triples are ignored. Matrix/global strength must be finite. channel is 1=FG,
|
|
3238
|
+
* 2=BG, 3=both. Mask triples are bounded by render_cells_max; invalid coordinates
|
|
3239
|
+
* and non-finite effective cell strengths are skipped. Effects retain whole-buffer
|
|
3240
|
+
* semantics without applying scissor/opacity again. Target/frame authority is the
|
|
3241
|
+
* same as ot_buffer_draw, including no-ops. Inputs are not retained. */
|
|
3242
|
+
ot_status ot_buffer_color_matrix(ot_context *, const ot_handle *, const ot_scene_frame_request *,
|
|
3243
|
+
const float *matrix, uint32_t matrix_count, const float *mask, uint32_t mask_count,
|
|
3244
|
+
const float *strength, uint32_t channel);
|
|
3245
|
+
|
|
3246
|
+
/* A paint recording acknowledges a RECORD request. It is one byte stream of
|
|
3247
|
+
* records. The stream must be 8-byte aligned and at most OT_SCENE_RECORD_BYTES_MAX
|
|
3248
|
+
* bytes. Every record starts with ot_scene_record_header; size counts the whole
|
|
3249
|
+
* record, including its trailing variable data, rounded up to a multiple of 8.
|
|
3250
|
+
* Native code ignores padding bytes. Reserved fields must be zero.
|
|
3251
|
+
*
|
|
3252
|
+
* A SLOT record starts the commands for one phase of one slot. Slots and phases
|
|
3253
|
+
* must appear in increasing order, at most once, and only for phases set in the
|
|
3254
|
+
* slot's hooks. Every other record belongs to the latest SLOT record. The stream
|
|
3255
|
+
* is validated before painting; an invalid stream fails the step and cancels the
|
|
3256
|
+
* attempt without presenting cells.
|
|
3257
|
+
*
|
|
3258
|
+
* Commands draw into the Session's next buffer with the same rules as the named
|
|
3259
|
+
* operations, inside the slot's clip and opacity. STACK entries apply above that
|
|
3260
|
+
* scene-owned entry and reset between phases. Exceptions: a DRAW with
|
|
3261
|
+
* OT_BUFFER_DRAW_CLEAR and COLOR_MATRIX act on the whole buffer, like their named
|
|
3262
|
+
* operations, and ignore the clip and opacity. CLEAR overwrites every cell and
|
|
3263
|
+
* removes the image placements that earlier slots painted. Native code plays each
|
|
3264
|
+
* command when it paints the slot, so a command that names a buffer, view, image,
|
|
3265
|
+
* node, or Unicode handle reads that resource then, not when it was recorded. A
|
|
3266
|
+
* command whose resource was destroyed before playback draws nothing. Other
|
|
3267
|
+
* invalid commands fail the step without presenting cells. */
|
|
3268
|
+
#define OT_SCENE_RECORD_BYTES_MAX UINT32_C(67108864)
|
|
3269
|
+
#define OT_SCENE_RECORD_PHASE_BEFORE UINT32_C(0)
|
|
3270
|
+
#define OT_SCENE_RECORD_PHASE_SELF UINT32_C(1)
|
|
3271
|
+
#define OT_SCENE_RECORD_PHASE_AFTER UINT32_C(2)
|
|
3272
|
+
#define OT_SCENE_RECORD_SLOT UINT32_C(0)
|
|
3273
|
+
#define OT_SCENE_RECORD_DRAW UINT32_C(1)
|
|
3274
|
+
#define OT_SCENE_RECORD_STACK UINT32_C(2)
|
|
3275
|
+
#define OT_SCENE_RECORD_GRID UINT32_C(3)
|
|
3276
|
+
#define OT_SCENE_RECORD_PACKED UINT32_C(4)
|
|
3277
|
+
#define OT_SCENE_RECORD_SUPERSAMPLE UINT32_C(5)
|
|
3278
|
+
#define OT_SCENE_RECORD_GRAYSCALE UINT32_C(6)
|
|
3279
|
+
#define OT_SCENE_RECORD_COLOR_MATRIX UINT32_C(7)
|
|
3280
|
+
#define OT_SCENE_RECORD_TEXT_VIEW UINT32_C(8)
|
|
3281
|
+
#define OT_SCENE_RECORD_EDITOR_VIEW UINT32_C(9)
|
|
3282
|
+
#define OT_SCENE_RECORD_SCENE_BODY UINT32_C(10)
|
|
3283
|
+
#define OT_SCENE_RECORD_IMAGE UINT32_C(11)
|
|
3284
|
+
#define OT_SCENE_RECORD_UNICODE UINT32_C(12)
|
|
3285
|
+
#define OT_SCENE_RECORD_GRAYSCALE_FOREGROUND UINT32_C(1)
|
|
3286
|
+
#define OT_SCENE_RECORD_GRAYSCALE_BACKGROUND UINT32_C(2)
|
|
3287
|
+
#define OT_SCENE_RECORD_GRAYSCALE_SUPERSAMPLED UINT32_C(4)
|
|
3288
|
+
|
|
3289
|
+
typedef struct ot_scene_record_header {
|
|
3290
|
+
uint32_t size;
|
|
3291
|
+
uint32_t operation;
|
|
3292
|
+
} ot_scene_record_header;
|
|
3293
|
+
|
|
3294
|
+
typedef struct ot_scene_record_slot {
|
|
3295
|
+
ot_scene_record_header header;
|
|
3296
|
+
uint32_t slot;
|
|
3297
|
+
uint32_t phase;
|
|
3298
|
+
} ot_scene_record_slot;
|
|
3299
|
+
|
|
3300
|
+
/* Followed by one complete ot_buffer_draw_* record, then text_length text bytes
|
|
3301
|
+
* and bottom_length bottom-title bytes, as for ot_buffer_draw. source names the
|
|
3302
|
+
* COMPOSE source and must be zero otherwise. RESPECT_ALPHA rejects. */
|
|
3303
|
+
typedef struct ot_scene_record_draw {
|
|
3304
|
+
ot_scene_record_header header;
|
|
3305
|
+
ot_handle source;
|
|
3306
|
+
uint32_t text_length;
|
|
3307
|
+
uint32_t bottom_length;
|
|
3308
|
+
} ot_scene_record_draw;
|
|
3309
|
+
|
|
3310
|
+
/* As for ot_buffer_stack. */
|
|
3311
|
+
typedef struct ot_scene_record_stack {
|
|
3312
|
+
ot_scene_record_header header;
|
|
3313
|
+
uint32_t operation;
|
|
3314
|
+
int32_t x;
|
|
3315
|
+
int32_t y;
|
|
3316
|
+
uint32_t width;
|
|
3317
|
+
uint32_t height;
|
|
3318
|
+
float opacity;
|
|
3319
|
+
} ot_scene_record_stack;
|
|
3320
|
+
|
|
3321
|
+
/* Followed by column_count and then row_count int32_t offsets, as for
|
|
3322
|
+
* ot_buffer_draw_grid. */
|
|
3323
|
+
typedef struct ot_scene_record_grid {
|
|
3324
|
+
ot_scene_record_header header;
|
|
3325
|
+
ot_buffer_grid_options options;
|
|
3326
|
+
uint32_t column_count;
|
|
3327
|
+
uint32_t row_count;
|
|
3328
|
+
} ot_scene_record_grid;
|
|
3329
|
+
|
|
3330
|
+
/* Followed by byte_count bytes, as for ot_buffer_draw_packed. */
|
|
3331
|
+
typedef struct ot_scene_record_packed {
|
|
3332
|
+
ot_scene_record_header header;
|
|
3333
|
+
int32_t x;
|
|
3334
|
+
int32_t y;
|
|
3335
|
+
uint32_t width;
|
|
3336
|
+
uint32_t height;
|
|
3337
|
+
uint32_t byte_count;
|
|
3338
|
+
uint32_t reserved;
|
|
3339
|
+
} ot_scene_record_packed;
|
|
3340
|
+
|
|
3341
|
+
/* Followed by byte_count bytes, as for ot_buffer_draw_supersample. */
|
|
3342
|
+
typedef struct ot_scene_record_supersample {
|
|
3343
|
+
ot_scene_record_header header;
|
|
3344
|
+
int32_t x;
|
|
3345
|
+
int32_t y;
|
|
3346
|
+
uint32_t format;
|
|
3347
|
+
uint32_t stride;
|
|
3348
|
+
uint32_t byte_count;
|
|
3349
|
+
uint32_t reserved;
|
|
3350
|
+
} ot_scene_record_supersample;
|
|
3351
|
+
|
|
3352
|
+
/* Followed by sample_count floats, as for ot_buffer_draw_grayscale. flags
|
|
3353
|
+
* selects the optional colors and supersampling. */
|
|
3354
|
+
typedef struct ot_scene_record_grayscale {
|
|
3355
|
+
ot_scene_record_header header;
|
|
3356
|
+
int32_t x;
|
|
3357
|
+
int32_t y;
|
|
3358
|
+
uint32_t width;
|
|
3359
|
+
uint32_t height;
|
|
3360
|
+
uint32_t flags;
|
|
3361
|
+
uint32_t sample_count;
|
|
3362
|
+
uint16_t foreground[4];
|
|
3363
|
+
uint16_t background[4];
|
|
3364
|
+
} ot_scene_record_grayscale;
|
|
3365
|
+
|
|
3366
|
+
/* Followed by mask_count floats, as for ot_buffer_color_matrix. has_mask 0
|
|
3367
|
+
* selects uniform application and requires zero mask_count. */
|
|
3368
|
+
typedef struct ot_scene_record_color_matrix {
|
|
3369
|
+
ot_scene_record_header header;
|
|
3370
|
+
float matrix[16];
|
|
3371
|
+
float strength;
|
|
3372
|
+
uint32_t channel;
|
|
3373
|
+
uint32_t has_mask;
|
|
3374
|
+
uint32_t mask_count;
|
|
3375
|
+
} ot_scene_record_color_matrix;
|
|
3376
|
+
|
|
3377
|
+
/* TEXT_VIEW, EDITOR_VIEW, and SCENE_BODY draw a text-buffer view, an editor
|
|
3378
|
+
* view, or a scene node's body, as for their ot_buffer_draw_* operations. */
|
|
3379
|
+
typedef struct ot_scene_record_view {
|
|
3380
|
+
ot_scene_record_header header;
|
|
3381
|
+
ot_handle source;
|
|
3382
|
+
int32_t x;
|
|
3383
|
+
int32_t y;
|
|
3384
|
+
} ot_scene_record_view;
|
|
3385
|
+
|
|
3386
|
+
/* As for ot_buffer_draw_image. */
|
|
3387
|
+
typedef struct ot_scene_record_image {
|
|
3388
|
+
ot_scene_record_header header;
|
|
3389
|
+
ot_handle image;
|
|
3390
|
+
ot_image_draw_options options;
|
|
3391
|
+
} ot_scene_record_image;
|
|
3392
|
+
|
|
3393
|
+
/* As for ot_buffer_draw_unicode. */
|
|
3394
|
+
typedef struct ot_scene_record_unicode {
|
|
3395
|
+
ot_scene_record_header header;
|
|
3396
|
+
ot_handle unicode;
|
|
3397
|
+
uint32_t index;
|
|
3398
|
+
int32_t x;
|
|
3399
|
+
int32_t y;
|
|
3400
|
+
uint32_t attributes;
|
|
3401
|
+
uint16_t foreground[4];
|
|
3402
|
+
uint16_t background[4];
|
|
3403
|
+
} ot_scene_record_unicode;
|
|
3404
|
+
|
|
3405
|
+
/* Retain one offscreen storage generation under the same limits and raw-plane
|
|
3406
|
+
* restrictions as Session leases. The snapshot requires exact size/version and
|
|
3407
|
+
* zero reserved. Rejection leaves it unchanged and acquires no lease. */
|
|
3408
|
+
ot_status ot_buffer_acquire_lease(
|
|
3409
|
+
ot_context *context,
|
|
3410
|
+
const ot_handle *buffer,
|
|
3411
|
+
ot_buffer_lease_snapshot *out_snapshot);
|
|
3412
|
+
|
|
3413
|
+
/* Create only the transport. No renderer, terminal modes, or worker starts.
|
|
3414
|
+
* Options require the exact size and OT_CONTEXT_ABI_VERSION. A failed call leaves
|
|
3415
|
+
* out_session unchanged. All session functions obey the context thread rule. */
|
|
3416
|
+
ot_status ot_session_create(
|
|
3417
|
+
ot_context *context,
|
|
3418
|
+
const ot_session_options *options,
|
|
3419
|
+
ot_handle *out_session);
|
|
3420
|
+
|
|
3421
|
+
/* Attach once. A rejected call preserves the Session and its queued output.
|
|
3422
|
+
* The renderer uses its Context's pools. */
|
|
3423
|
+
ot_status ot_session_attach_renderer(
|
|
3424
|
+
ot_context *context,
|
|
3425
|
+
const ot_handle *session,
|
|
3426
|
+
const ot_session_renderer_options *options);
|
|
3427
|
+
ot_status ot_session_attach_renderer_with_env(
|
|
3428
|
+
ot_context *context,
|
|
3429
|
+
const ot_handle *session,
|
|
3430
|
+
const ot_session_renderer_env_options *options,
|
|
3431
|
+
const uint8_t *environment);
|
|
3432
|
+
|
|
3433
|
+
/* Submit at most one frame. force is 0 or 1. OT_RENDER_PENDING also means that
|
|
3434
|
+
* an earlier accepted frame is still pending; no second frame was accepted.
|
|
3435
|
+
* SKIPPED and FAILED accept no output and require an explicit new submission.
|
|
3436
|
+
* Only output completion publishes frame_count. A frame submitted here has no
|
|
3437
|
+
* scene hits: after it, ot_scene_hit_test returns 0 until a scene frame presents.
|
|
3438
|
+
* A live scene preparation or painted draft returns OT_FRAME_BUSY; submit a
|
|
3439
|
+
* painted draft with ot_scene_frame_commit instead.
|
|
3440
|
+
* On an error return, out_result remains unchanged. */
|
|
3441
|
+
ot_status ot_session_render(
|
|
3442
|
+
ot_context *context,
|
|
3443
|
+
const ot_handle *session,
|
|
3444
|
+
uint32_t force,
|
|
3445
|
+
uint32_t *out_result);
|
|
3446
|
+
|
|
3447
|
+
/* A frame whose presentation is pending returns OT_OUTPUT_BUSY. Queued raw and
|
|
3448
|
+
* control output does not prevent resize and stays ahead of the next frame.
|
|
3449
|
+
* Rejection preserves accepted dimensions. Scene preparation returns
|
|
3450
|
+
* OT_FRAME_BUSY. A painted draft allows resize under the storage
|
|
3451
|
+
* requalification rules of ot_scene_frame_acquire_buffer_lease. */
|
|
3452
|
+
ot_status ot_session_resize_renderer(
|
|
3453
|
+
ot_context *context,
|
|
3454
|
+
const ot_handle *session,
|
|
3455
|
+
uint32_t width,
|
|
3456
|
+
uint32_t height);
|
|
3457
|
+
|
|
3458
|
+
/* Copy the full offscreen source into the Session's next framebuffer, clipped
|
|
3459
|
+
* at signed cell coordinates. Both handles must belong to this Context.
|
|
3460
|
+
* Pending presentation and non-rendering phases reject drawing. Images in the
|
|
3461
|
+
* source or destination return OT_UNSUPPORTED_RESOURCE. Rejection preserves
|
|
3462
|
+
* cells and output; success retains no source borrow and emits no output. */
|
|
3463
|
+
ot_status ot_session_draw_buffer(
|
|
3464
|
+
ot_context *context,
|
|
3465
|
+
const ot_handle *session,
|
|
3466
|
+
const ot_handle *source,
|
|
3467
|
+
int32_t x,
|
|
3468
|
+
int32_t y);
|
|
3469
|
+
|
|
3470
|
+
/* Same resource and coordinate rules as ot_session_draw_buffer, but authorized
|
|
3471
|
+
* by a retained DONE draft. No source borrow
|
|
3472
|
+
* survives return; pending presentation and stale tickets reject drawing. */
|
|
3473
|
+
ot_status ot_scene_frame_draw_buffer(ot_context *context, const ot_handle *session,
|
|
3474
|
+
const ot_scene_frame_request *frame_request, const ot_handle *source, int32_t x, int32_t y);
|
|
3475
|
+
|
|
3476
|
+
/* Diagnostics require an open Session and attached renderer, not terminal setup
|
|
3477
|
+
* or an idle frame. They emit no terminal output. enabled is 0 or 1; corner is
|
|
3478
|
+
* 0 top-left, 1 top-right, 2 bottom-left, or 3 bottom-right. Times must be finite
|
|
3479
|
+
* and nonnegative. Memory byte counts use the renderer's existing u32 range.
|
|
3480
|
+
* Hit-grid dumping writes, per cell, the last digit of the presented hit token
|
|
3481
|
+
* (or '.') with best-effort file I/O through Context I/O, to
|
|
3482
|
+
* hitgrid_<timestamp>.txt in the working directory. */
|
|
3483
|
+
ot_status ot_session_set_debug_overlay(ot_context *, const ot_handle *session, uint32_t enabled, uint32_t corner);
|
|
3484
|
+
ot_status ot_session_update_stats(ot_context *, const ot_handle *session, double overall_ms, uint32_t fps, double callback_ms);
|
|
3485
|
+
ot_status ot_session_update_memory_stats(ot_context *, const ot_handle *session, uint32_t heap_used, uint32_t heap_total, uint32_t array_buffers);
|
|
3486
|
+
ot_status ot_session_dump_hit_grid(ot_context *, const ot_handle *session);
|
|
3487
|
+
|
|
3488
|
+
/* The record requires the exact size and version. Failure preserves it. */
|
|
3489
|
+
ot_status ot_session_get_renderer_state(
|
|
3490
|
+
ot_context *context,
|
|
3491
|
+
const ot_handle *session,
|
|
3492
|
+
ot_session_renderer_state *out_state);
|
|
3493
|
+
|
|
3494
|
+
/* Retain one Session-owned framebuffer storage generation without creating a
|
|
3495
|
+
* renderer or buffer owner. which is OT_SESSION_BUFFER_CURRENT or NEXT.
|
|
3496
|
+
* Acquisition requires a rendering phase and no pending presentation. Finish
|
|
3497
|
+
* drawing before submitting a frame; an ordinary storage lease does not block
|
|
3498
|
+
* rendering. A live scene preparation or painted draft returns OT_FRAME_BUSY;
|
|
3499
|
+
* use ot_scene_frame_acquire_buffer_lease for painted-frame access.
|
|
3500
|
+
* The output requires the exact size/version and zero reserved. Rejection leaves
|
|
3501
|
+
* it unchanged and acquires no lease. Leases take object slots; C contexts
|
|
3502
|
+
* allow at most 4096 leases and 64 MiB of distinct leased storage, including
|
|
3503
|
+
* retired arrays and tracker capacity. Shared Context pools are not in that charge.
|
|
3504
|
+
* Release every accepted lease, even after Session resize or destruction. */
|
|
3505
|
+
ot_status ot_session_acquire_buffer_lease(
|
|
3506
|
+
ot_context *context,
|
|
3507
|
+
const ot_handle *session,
|
|
3508
|
+
uint32_t which,
|
|
3509
|
+
ot_buffer_lease_snapshot *out_snapshot);
|
|
3510
|
+
|
|
3511
|
+
/* Read the link id stored in one current-framebuffer cell. Does not retain
|
|
3512
|
+
* storage and does not require an idle frame. Encode syncs those cells before
|
|
3513
|
+
* presentation is pending, so the read stays valid while output drains.
|
|
3514
|
+
* Negative or out-of-range coordinates write 0 and succeed. out_link_id is
|
|
3515
|
+
* required; rejection leaves it unchanged. */
|
|
3516
|
+
ot_status ot_session_get_link_id(
|
|
3517
|
+
ot_context *context,
|
|
3518
|
+
const ot_handle *session,
|
|
3519
|
+
int32_t x,
|
|
3520
|
+
int32_t y,
|
|
3521
|
+
uint32_t *out_link_id);
|
|
3522
|
+
|
|
3523
|
+
/* Ordinary leases check storage lifetime, not contents or Session phase. Qualified
|
|
3524
|
+
* leases also check retained painted-frame membership, destination, and storage
|
|
3525
|
+
* identity. Buffer replacement, destruction, or frame cancellation makes affected
|
|
3526
|
+
* leases return OT_STALE_LEASE. Arrays remain allocated until release, but stale
|
|
3527
|
+
* qualified access is revoked.
|
|
3528
|
+
* Duplicate release or a reused lease slot returns OT_STALE_HANDLE. All calls obey the Context
|
|
3529
|
+
* owner-thread rule. Keep the Context and native image alive until release.
|
|
3530
|
+
* Copies of the record do not retain storage. Release cannot revoke saved raw
|
|
3531
|
+
* addresses: callers must not use them after release. */
|
|
3532
|
+
ot_status ot_buffer_lease_validate(ot_context *context, const ot_handle *lease);
|
|
3533
|
+
ot_status ot_buffer_lease_release(ot_context *context, const ot_handle *lease);
|
|
3534
|
+
|
|
3535
|
+
/* Resolve text through the leased storage's own grapheme pool. Keep one lease
|
|
3536
|
+
* across sizing and writing. add_line_breaks is 0 or 1. An undersized output
|
|
3537
|
+
* returns OT_INVALID_ARGUMENT and may contain a partial prefix; out_written
|
|
3538
|
+
* remains unchanged on error. Stale or released leases reject both operations.
|
|
3539
|
+
* Optional cell_lengths receives one UTF-8 byte length per cell, excluding row
|
|
3540
|
+
* separators. Continuations have length zero. Set it to NULL with cell_capacity
|
|
3541
|
+
* zero when lengths are not needed; otherwise reserve at least width * height. */
|
|
3542
|
+
ot_status ot_buffer_lease_get_real_char_size(
|
|
3543
|
+
ot_context *context, const ot_handle *lease,
|
|
3544
|
+
uint32_t add_line_breaks, uint32_t *out_size);
|
|
3545
|
+
ot_status ot_buffer_lease_write_resolved_chars(
|
|
3546
|
+
ot_context *context, const ot_handle *lease,
|
|
3547
|
+
uint8_t *bytes, uint32_t capacity,
|
|
3548
|
+
uint32_t add_line_breaks, uint8_t *cell_lengths, uint32_t cell_capacity,
|
|
3549
|
+
uint32_t *out_written);
|
|
3550
|
+
|
|
3551
|
+
/* Accept a terminal lifecycle request; pump performs output and timed work.
|
|
3552
|
+
* Setup requires an attached renderer and sufficient reserved control storage,
|
|
3553
|
+
* and must precede the first accepted frame. Earlier raw output is allowed.
|
|
3554
|
+
* It does not wait for capability replies. Ordinary writes and rendering are
|
|
3555
|
+
* rejected during transitions. Suspended sessions allow raw writes and null-frame
|
|
3556
|
+
* split snapshots, not ordinary frames.
|
|
3557
|
+
* Resume reuses the accepted setup options without repeating detection. */
|
|
3558
|
+
ot_status ot_session_setup_terminal(
|
|
3559
|
+
ot_context *context,
|
|
3560
|
+
const ot_handle *session,
|
|
3561
|
+
const ot_session_terminal_options *options);
|
|
3562
|
+
ot_status ot_session_suspend(ot_context *context, const ot_handle *session);
|
|
3563
|
+
ot_status ot_session_resume(ot_context *context, const ot_handle *session);
|
|
3564
|
+
ot_status ot_session_get_terminal_state(ot_context *context, const ot_handle *session, uint32_t *out_phase);
|
|
3565
|
+
|
|
3566
|
+
/* Accept capability replies during setup after pump publishes the initial query
|
|
3567
|
+
* packet, even before output completion. Also accept replies during resume.
|
|
3568
|
+
* CURSOR updates synchronous intent in any open phase; only a subsequent accepted
|
|
3569
|
+
* frame emits it. Other controls require an active terminal. Capability payloads
|
|
3570
|
+
* contain complete supported 7-bit CSI/DCS/OSC/APC replies, not stream fragments,
|
|
3571
|
+
* at most 4096 bytes.
|
|
3572
|
+
* Titles are UTF-8 without C0, DEL, or C1 controls, at most 4091 bytes.
|
|
3573
|
+
* Program status reports do not depend on detected support; terminals ignore
|
|
3574
|
+
* OSC 7501 they do not implement. OT_CAP_PROGRAM_STATUS reports a query reply.
|
|
3575
|
+
* All output uses ordinary capacity and stays behind earlier raw/frame bytes,
|
|
3576
|
+
* including copied tickets. Setup enables detected features after screen selection.
|
|
3577
|
+
* Admission failure changes neither terminal state nor accepted output.
|
|
3578
|
+
* Zero Kitty flags disable; other flags apply when support is detected. Mouse
|
|
3579
|
+
* and Kitty intent survive suspend/resume. bytes may be NULL only for zero length. */
|
|
3580
|
+
ot_status ot_session_control(
|
|
3581
|
+
ot_context *context,
|
|
3582
|
+
const ot_handle *session,
|
|
3583
|
+
const ot_session_control_options *options,
|
|
3584
|
+
const uint8_t *bytes,
|
|
3585
|
+
uint32_t byte_count);
|
|
3586
|
+
ot_status ot_session_get_capabilities(
|
|
3587
|
+
ot_context *context,
|
|
3588
|
+
const ot_handle *session,
|
|
3589
|
+
ot_session_capabilities *out_capabilities);
|
|
3590
|
+
|
|
3591
|
+
/* Write or clear terminal clipboard selection 0..3 (clipboard/primary/select/secondary).
|
|
3592
|
+
* Empty bytes clear the selection. Requires an active terminal. Uses ordinary output
|
|
3593
|
+
* capacity behind earlier raw/frame bytes. Unsupported capability or rejected output
|
|
3594
|
+
* returns out_written=0 without accepting bytes. Payloads retain the terminal's u32 byte limit.
|
|
3595
|
+
* bytes may be NULL only for zero length; all input is consumed during this call. */
|
|
3596
|
+
ot_status ot_session_clipboard(
|
|
3597
|
+
ot_context *context,
|
|
3598
|
+
const ot_handle *session,
|
|
3599
|
+
uint32_t target,
|
|
3600
|
+
const uint8_t *bytes,
|
|
3601
|
+
uint32_t byte_count,
|
|
3602
|
+
uint32_t *out_written);
|
|
3603
|
+
|
|
3604
|
+
/* Palette queries are bounded, validated OSC query packets admitted through
|
|
3605
|
+
* ot_session_control. Palette publication copies up to 256 literal RGBA colors;
|
|
3606
|
+
* every channel must be 0..255. All operations require an active terminal. */
|
|
3607
|
+
ot_status ot_session_set_palette_state(ot_context *, const ot_handle *,
|
|
3608
|
+
const uint16_t *palette, uint32_t color_count, const uint16_t *foreground,
|
|
3609
|
+
const uint16_t *background, uint32_t epoch);
|
|
3610
|
+
|
|
3611
|
+
/* Notifications reuse terminal protocol selection and ordinary output capacity.
|
|
3612
|
+
* Unsupported capability, text that is not UTF-8, or rejected output returns
|
|
3613
|
+
* out_written=0; C0, DEL, and C1 controls in the text become spaces. Message and
|
|
3614
|
+
* optional title are consumed only during this call; NULL requires zero length. */
|
|
3615
|
+
ot_status ot_session_notification(ot_context *, const ot_handle *,
|
|
3616
|
+
const uint8_t *message, uint32_t message_len, const uint8_t *title,
|
|
3617
|
+
uint32_t title_len, uint32_t *out_written);
|
|
3618
|
+
|
|
3619
|
+
/* Run bounded owner-thread work without sleeping or sampling a clock.
|
|
3620
|
+
* now_ns must be monotonic across accepted pumps and Kitty polls; equal samples
|
|
3621
|
+
* are valid. work_budget must be positive;
|
|
3622
|
+
* one unit visits one image entry, emits at most OT_SESSION_CONTROL_PACKET_BYTES,
|
|
3623
|
+
* or advances one lifecycle step. AGAIN needs another turn, OUTPUT_PENDING needs
|
|
3624
|
+
* output completion, and WAIT_UNTIL needs a clock turn at deadline_ns. Cursor
|
|
3625
|
+
* delays start at the first pump observing completed restoration output.
|
|
3626
|
+
* The first wait requires time range for both cursor waits. Later retry times
|
|
3627
|
+
* must leave room for the final wait. Exhausted clock range returns
|
|
3628
|
+
* OT_INVALID_ARGUMENT; a host with no valid later time must cancel explicitly.
|
|
3629
|
+
* Each accepted pump also visits at most eight Kitty file leases and can unlink
|
|
3630
|
+
* expired files through Context I/O, even while terminal output is pending.
|
|
3631
|
+
* WAIT_UNTIL describes lifecycle waits; Kitty expiry still requires regular polls.
|
|
3632
|
+
* No second frame is accepted or implicitly retried by this operation. */
|
|
3633
|
+
ot_status ot_session_pump(
|
|
3634
|
+
ot_context *context,
|
|
3635
|
+
const ot_handle *session,
|
|
3636
|
+
uint64_t now_ns,
|
|
3637
|
+
uint32_t work_budget,
|
|
3638
|
+
ot_session_pump_result *out_result);
|
|
3639
|
+
|
|
3640
|
+
/* Parse terminal input into events written to caller-owned records and payload.
|
|
3641
|
+
* bytes may be NULL only when byte_count is zero; zero bytes only resolves the
|
|
3642
|
+
* timeout. now_ns is a host monotonic clock in nanoseconds that must not go
|
|
3643
|
+
* backwards across feeds; it is independent of the pump clock. capacity must be
|
|
3644
|
+
* at least OT_INPUT_EVENTS_MIN and payload_capacity at least
|
|
3645
|
+
* OT_INPUT_PAYLOAD_BYTES_MIN; the call consumes input until either runs low and
|
|
3646
|
+
* reports consumed. A bracketed paste arrives as one or more PASTE records from
|
|
3647
|
+
* START to END; a start marker cut by the timeout waits for a feed that begins with its
|
|
3648
|
+
* rest and more bytes. Records and payload are borrowed for the call and never retained.
|
|
3649
|
+
* bytes, records, payload, and out_drain must not overlap.
|
|
3650
|
+
* Accepted in any open session state; closing, closed, failed, and cancelled
|
|
3651
|
+
* sessions reject. A rejected call leaves out_drain, the records, and parser
|
|
3652
|
+
* state unchanged. No allocation, no I/O. */
|
|
3653
|
+
ot_status ot_session_input_feed(
|
|
3654
|
+
ot_context *context,
|
|
3655
|
+
const ot_handle *session,
|
|
3656
|
+
const uint8_t *bytes,
|
|
3657
|
+
uint32_t byte_count,
|
|
3658
|
+
uint64_t now_ns,
|
|
3659
|
+
ot_input_event *records,
|
|
3660
|
+
uint32_t capacity,
|
|
3661
|
+
uint8_t *payload,
|
|
3662
|
+
uint32_t payload_capacity,
|
|
3663
|
+
ot_input_drain *out_drain);
|
|
3664
|
+
|
|
3665
|
+
/* flags is a combination of OT_INPUT_EXPECT_* bits; other bits must be zero.
|
|
3666
|
+
* Set REPLIES while any query is outstanding, including the capability queries
|
|
3667
|
+
* that setup publishes. It keeps a partial CSI reply waiting past the timeout.
|
|
3668
|
+
* CURSOR_POSITION, which implies REPLIES, marks a cursor position request: it
|
|
3669
|
+
* makes a complete CSI 1 ; N R (N >= 2) a CURSOR_POSITION reply instead of a
|
|
3670
|
+
* modified F3 key. KITTY_KEYBOARD keeps a partial Kitty key waiting and makes
|
|
3671
|
+
* CSI R and CSI 1 ; N R replies, since the Kitty protocol sends F3 as CSI 13 ~;
|
|
3672
|
+
* a session with a renderer applies its terminal's negotiated state instead.
|
|
3673
|
+
* SENTINEL, which implies REPLIES, means that a DA1 reply (CSI ? ... c) ends the
|
|
3674
|
+
* outstanding queries; clear it when that reply arrives. While it is set, a
|
|
3675
|
+
* partial reply waits without a deadline: an OSC, DCS, or APC string that begins
|
|
3676
|
+
* like one (OSC and a digit, DCS and > or a digit, APC and G), a bare CSI, OSC,
|
|
3677
|
+
* DCS, or APC introducer, and a CSI of digits. A held string continues only
|
|
3678
|
+
* while it matches a reply prefix, and a CSI that timed out completes only as a
|
|
3679
|
+
* reply; another byte ends either one and is typed. A lone Escape still times
|
|
3680
|
+
* out, and a reply that follows it is not typed; if what follows that Escape is
|
|
3681
|
+
* cut before it matches a reply, its introducer is typed. KEEP_REPLY also keeps such a CSI.
|
|
3682
|
+
* ESCAPE_PREFIX, which implies KITTY_KEYBOARD, means the terminal confirmed
|
|
3683
|
+
* Kitty disambiguate or report-all keys, so no unit has a deadline. A raw ESC and the byte after it in the same
|
|
3684
|
+
* feed are Alt and that key as without the flag; a raw ESC that ends a feed is the Escape key at once. If the next
|
|
3685
|
+
* feed, however late, begins with [ and a byte that begins a CSI such a terminal sends (a digit, ?, >, <, or one of
|
|
3686
|
+
* ABCDEFHIOPQS), the CSI is kept whole and is never a key; _G begins a Kitty graphics reply, kept whole once that
|
|
3687
|
+
* feed matches its key= prefix and typed otherwise; other bytes are typed. With SENTINEL, an OSC, DCS, or APC
|
|
3688
|
+
* introducer or a lone [ after that Escape is recovered as after a timeout until SENTINEL is cleared.
|
|
3689
|
+
* A session with a renderer sets it itself once the terminal answers the CSI ? u
|
|
3690
|
+
* query that follows its current push (only with OT_TERMINAL_REPLY_SENTINEL).
|
|
3691
|
+
* Changing flags emits nothing; the next feed resolves a unit that may no longer wait. */
|
|
3692
|
+
ot_status ot_session_input_expect(ot_context *context, const ot_handle *session, uint32_t flags);
|
|
3693
|
+
|
|
3694
|
+
#define OT_INPUT_RESET_KEEP_REPLY UINT32_C(1)
|
|
3695
|
+
|
|
3696
|
+
/* Drop any partial unit and mouse button state. Expectations are kept. flags is
|
|
3697
|
+
* 0 or OT_INPUT_RESET_KEEP_REPLY. Call with KEEP_REPLY after feeding the input
|
|
3698
|
+
* drained on resume: then a partial CSI unit that may begin a reply survives
|
|
3699
|
+
* while REPLIES is set, and waits for its rest without a deadline. */
|
|
3700
|
+
ot_status ot_session_input_reset(ot_context *context, const ot_handle *session, uint32_t flags);
|
|
3701
|
+
|
|
3702
|
+
/* Maximum ordinary atomic write in an empty queue, excluding control reservations
|
|
3703
|
+
* and bounded by both chunk storage and span slots, at most UINT32_MAX bytes.
|
|
3704
|
+
* This is not current free capacity; pending output can still reject a smaller
|
|
3705
|
+
* write. Failure leaves out_bytes unchanged. */
|
|
3706
|
+
ot_status ot_session_get_write_limit(ot_context *context, const ot_handle *session, uint64_t *out_bytes);
|
|
3707
|
+
|
|
3708
|
+
/* Copy the complete write or reject it without changing accepted output.
|
|
3709
|
+
* bytes may be NULL only when byte_count is zero. Queued and unacknowledged
|
|
3710
|
+
* bytes share the finite limits. The caller retains no native memory borrow. */
|
|
3711
|
+
ot_status ot_session_write(
|
|
3712
|
+
ot_context *context,
|
|
3713
|
+
const ot_handle *session,
|
|
3714
|
+
const uint8_t *bytes,
|
|
3715
|
+
uint32_t byte_count);
|
|
3716
|
+
|
|
3717
|
+
/* Copy at most capacity bytes in write order. bytes may be NULL only for zero
|
|
3718
|
+
* capacity. A successful empty read returns a zero byte_count and request_id.
|
|
3719
|
+
* Failure leaves both outputs unchanged. The next read requires completion of
|
|
3720
|
+
* the previous ticket. Copied bytes remain valid after cancellation/destruction. */
|
|
3721
|
+
ot_status ot_session_read_output(
|
|
3722
|
+
ot_context *context,
|
|
3723
|
+
const ot_handle *session,
|
|
3724
|
+
uint8_t *bytes,
|
|
3725
|
+
uint32_t capacity,
|
|
3726
|
+
ot_output_ticket *out_ticket);
|
|
3727
|
+
|
|
3728
|
+
/* Borrow the next queued span for one synchronous writer call, at most max_bytes
|
|
3729
|
+
* (which must be positive). The callback returns the delivered prefix length,
|
|
3730
|
+
* zero for backpressure, or -1 for failure. It must not retain bytes, report
|
|
3731
|
+
* buffered-but-unwritten bytes as delivered, or reenter mutating Context calls.
|
|
3732
|
+
* No callback or user_data is retained. A pending copy ticket returns OT_OUTPUT_BUSY.
|
|
3733
|
+
* Partial writes keep the remaining bytes queued. Failure or an invalid count
|
|
3734
|
+
* stops transport with OT_OUTPUT_FAILED; bytes are never replayed. Successful
|
|
3735
|
+
* writes publish frame presentation at the same endpoint as complete_output.
|
|
3736
|
+
* out_written is zero for an empty/closed queue or backpressure, and is unchanged
|
|
3737
|
+
* on error. A nonempty writer call can block only as long as its writer does. */
|
|
3738
|
+
typedef int64_t (*ot_output_write_callback)(void *user_data, const uint8_t *bytes, uint32_t byte_count);
|
|
3739
|
+
ot_status ot_session_drain_output(
|
|
3740
|
+
ot_context *context,
|
|
3741
|
+
const ot_handle *session,
|
|
3742
|
+
uint32_t max_bytes,
|
|
3743
|
+
uint32_t *out_written,
|
|
3744
|
+
void *user_data,
|
|
3745
|
+
ot_output_write_callback writer);
|
|
3746
|
+
|
|
3747
|
+
/* Deliver directly to process stdout through Context I/O, without a host byte
|
|
3748
|
+
* buffer or completion ticket. Same completion/failure rules as drain_output.
|
|
3749
|
+
* max_bytes must be at least four for a complete UTF-8 scalar on Windows consoles;
|
|
3750
|
+
* console writes preserve the code page and may span queue chunk boundaries.
|
|
3751
|
+
* An overlapped or unrecognized Windows byte handle returns OT_UNSUPPORTED_RESOURCE
|
|
3752
|
+
* before consuming output; use the host writer for that handle. An incomplete
|
|
3753
|
+
* console scalar followed by a byte that cannot continue it, with no room for more
|
|
3754
|
+
* input, or while new writes are disabled, returns OT_INVALID_ARGUMENT with its
|
|
3755
|
+
* bytes retained for another delivery method.
|
|
3756
|
+
* Nonblocking stdout pressure returns zero; retry on a later turn. A blocking
|
|
3757
|
+
* stdout can block this call. This operation neither closes nor reconfigures stdout. */
|
|
3758
|
+
ot_status ot_session_drain_stdout(
|
|
3759
|
+
ot_context *context,
|
|
3760
|
+
const ot_handle *session,
|
|
3761
|
+
uint32_t max_bytes,
|
|
3762
|
+
uint32_t *out_written);
|
|
3763
|
+
|
|
3764
|
+
/* Write process stdout from a native thread that the Session owns, so this call
|
|
3765
|
+
* never waits in write(2) on a slow terminal.
|
|
3766
|
+
* wait=0: if the running copy has ended, complete its bytes as complete_output
|
|
3767
|
+
* would; then, when max_bytes is positive and output is queued, copy the next
|
|
3768
|
+
* prefix (at most max_bytes and 64 KiB) to the thread and start it. max_bytes
|
|
3769
|
+
* zero only collects.
|
|
3770
|
+
* wait=1 (process exit only): never starts a copy. Waits for the running copy
|
|
3771
|
+
* without a limit and completes it. A copy the thread has not picked up within
|
|
3772
|
+
* 100 ms is taken back unwritten, stays queued for drain_stdout, and the thread
|
|
3773
|
+
* is stopped. With no copy running, or no thread: OT_OK and OT_STDOUT_IDLE.
|
|
3774
|
+
* out_written is the bytes this call completed; out_state is OT_STDOUT_IN_FLIGHT
|
|
3775
|
+
* when a copy is still running on return, else OT_STDOUT_IDLE. A failed write
|
|
3776
|
+
* returns OT_OUTPUT_FAILED and stops the transport without replay; outputs are
|
|
3777
|
+
* then unchanged. wait above 1 or a null output: OT_INVALID_ARGUMENT. A pending
|
|
3778
|
+
* read_output ticket: OT_OUTPUT_BUSY. Before consuming output, wait=0 returns
|
|
3779
|
+
* OT_UNSUPPORTED_RESOURCE when stdout is not a terminal, on platforms without the
|
|
3780
|
+
* writer (it runs on Linux and macOS), or when the thread cannot start: use
|
|
3781
|
+
* drain_stdout.
|
|
3782
|
+
* While a copy is posted, read_output, drain_output and drain_stdout return
|
|
3783
|
+
* OT_OUTPUT_BUSY and complete_output returns OT_STALE_OUTPUT for any ticket.
|
|
3784
|
+
* Cancel and destroy never wait for a running copy. The thread calls nothing
|
|
3785
|
+
* back and keeps the library loaded until process exit. */
|
|
3786
|
+
ot_status ot_session_post_stdout(
|
|
3787
|
+
ot_context *context,
|
|
3788
|
+
const ot_handle *session,
|
|
3789
|
+
uint32_t max_bytes,
|
|
3790
|
+
uint32_t wait,
|
|
3791
|
+
uint32_t *out_state,
|
|
3792
|
+
uint32_t *out_written);
|
|
3793
|
+
|
|
3794
|
+
/* success must be 0 or 1. Failure stops the transport without replaying bytes.
|
|
3795
|
+
* Wrong-session, stale, altered, and repeated tickets do not consume output. */
|
|
3796
|
+
ot_status ot_session_complete_output(
|
|
3797
|
+
ot_context *context,
|
|
3798
|
+
const ot_handle *session,
|
|
3799
|
+
const ot_output_ticket *ticket,
|
|
3800
|
+
uint32_t success);
|
|
3801
|
+
|
|
3802
|
+
/* Stop new writes. Queued output and terminal restoration must finish before
|
|
3803
|
+
* the session becomes closed. Terminal-managed sessions require continued pumping.
|
|
3804
|
+
* cancel explicitly discards pending output after transport disconnection.
|
|
3805
|
+
* Neither operation waits or sleeps. */
|
|
3806
|
+
ot_status ot_session_close(ot_context *context, const ot_handle *session);
|
|
3807
|
+
/* A close past its deadline: begin closing if needed, then discard the output
|
|
3808
|
+
* queued before the close, except the copy an outstanding ticket or stdout
|
|
3809
|
+
* copy holds. Only that copy and terminal restoration remain; once restoration
|
|
3810
|
+
* output is queued, this discards nothing. Continue pumping as after close. */
|
|
3811
|
+
ot_status ot_session_drop_output(ot_context *context, const ot_handle *session);
|
|
3812
|
+
/* Process-exit fallback: stop admission and visit one restoration work unit
|
|
3813
|
+
* without cursor-settle waits. Returns OT_PUMP_AGAIN, OT_PUMP_OUTPUT_PENDING, or
|
|
3814
|
+
* OT_PUMP_CLOSED. The host must still deliver and complete output in order.
|
|
3815
|
+
* Never acknowledges or replays pending copies, and rejects failed transports.
|
|
3816
|
+
* Normal asynchronous shutdown must use close and pump instead. */
|
|
3817
|
+
ot_status ot_session_pump_exit(ot_context *context, const ot_handle *session, uint32_t *out_status);
|
|
3818
|
+
/* Process-wide and best effort: discard input that the terminal queued on process stdin
|
|
3819
|
+
* and the host has not read (tcflush TCIFLUSH, or FlushConsoleInputBuffer on Windows).
|
|
3820
|
+
* Call it after restoration disables mouse reporting, so the shell does not receive
|
|
3821
|
+
* stale reports. A no-op when stdin is not a terminal. Always returns OT_OK. */
|
|
3822
|
+
ot_status ot_terminal_flush_input(void);
|
|
3823
|
+
ot_status ot_session_cancel(ot_context *context, const ot_handle *session);
|
|
3824
|
+
ot_status ot_session_get_state(ot_context *context, const ot_handle *session, uint32_t *out_state);
|
|
3825
|
+
|
|
3826
|
+
/* Pending output or an unrestored terminal prevents destruction unless cancelled.
|
|
3827
|
+
* Context destruction follows the same rule. Successful destruction invalidates
|
|
3828
|
+
* the session handle and all its tickets, but not caller-owned output copies. */
|
|
3829
|
+
ot_status ot_session_destroy(ot_context *context, const ot_handle *session);
|
|
3830
|
+
|
|
3831
|
+
/* Host clipboard service owned by a Context. Distinct from ot_session_clipboard,
|
|
3832
|
+
* which writes terminal OSC selection bytes. These calls return domain-specific
|
|
3833
|
+
* uint8 codes, not ot_status. Create returns 0 or -1. The service is the Context's
|
|
3834
|
+
* sole clipboard_service object: a second create returns -1 while one exists, even
|
|
3835
|
+
* one shutting down. ot_context_destroy begins the service's shutdown and returns
|
|
3836
|
+
* OT_CONTEXT_BUSY until it is ready. wayland_seat may be NULL only when its length
|
|
3837
|
+
* is zero. Request, text, and result bytes are borrowed for the call. */
|
|
3838
|
+
#define OT_CLIPBOARD_OPERATION_PENDING UINT32_C(0)
|
|
3839
|
+
#define OT_CLIPBOARD_OPERATION_READ UINT32_C(1)
|
|
3840
|
+
#define OT_CLIPBOARD_OPERATION_EMPTY UINT32_C(2)
|
|
3841
|
+
#define OT_CLIPBOARD_OPERATION_WRITTEN UINT32_C(3)
|
|
3842
|
+
#define OT_CLIPBOARD_OPERATION_CLEARED UINT32_C(4)
|
|
3843
|
+
#define OT_CLIPBOARD_OPERATION_UNSUPPORTED UINT32_C(5)
|
|
3844
|
+
#define OT_CLIPBOARD_OPERATION_CANCELLED UINT32_C(6)
|
|
3845
|
+
#define OT_CLIPBOARD_OPERATION_TIMED_OUT UINT32_C(7)
|
|
3846
|
+
#define OT_CLIPBOARD_OPERATION_LIMIT_EXCEEDED UINT32_C(8)
|
|
3847
|
+
#define OT_CLIPBOARD_OPERATION_FAILED UINT32_C(9)
|
|
3848
|
+
#define OT_CLIPBOARD_OPERATION_INVALID_HANDLE UINT32_C(10)
|
|
3849
|
+
#define OT_CLIPBOARD_START_OK UINT32_C(0)
|
|
3850
|
+
#define OT_CLIPBOARD_START_INVALID_SERVICE UINT32_C(1)
|
|
3851
|
+
#define OT_CLIPBOARD_START_SHUTTING_DOWN UINT32_C(2)
|
|
3852
|
+
#define OT_CLIPBOARD_START_LIMIT_EXCEEDED UINT32_C(3)
|
|
3853
|
+
#define OT_CLIPBOARD_START_INVALID_ARGUMENT UINT32_C(4)
|
|
3854
|
+
#define OT_CLIPBOARD_START_OUT_OF_MEMORY UINT32_C(5)
|
|
3855
|
+
#define OT_CLIPBOARD_CANCEL_REQUESTED UINT32_C(0)
|
|
3856
|
+
#define OT_CLIPBOARD_CANCEL_ALREADY_TERMINAL UINT32_C(1)
|
|
3857
|
+
#define OT_CLIPBOARD_CANCEL_INVALID_HANDLE UINT32_C(2)
|
|
3858
|
+
#define OT_CLIPBOARD_COPY_OK UINT32_C(0)
|
|
3859
|
+
#define OT_CLIPBOARD_COPY_BUFFER_TOO_SMALL UINT32_C(1)
|
|
3860
|
+
#define OT_CLIPBOARD_COPY_INVALID_HANDLE UINT32_C(2)
|
|
3861
|
+
#define OT_CLIPBOARD_COPY_INVALID_STATE UINT32_C(3)
|
|
3862
|
+
#define OT_CLIPBOARD_COPY_INVALID_ARGUMENT UINT32_C(4)
|
|
3863
|
+
#define OT_CLIPBOARD_DESTROY_DESTROYED UINT32_C(0)
|
|
3864
|
+
#define OT_CLIPBOARD_DESTROY_NOT_READY UINT32_C(1)
|
|
3865
|
+
#define OT_CLIPBOARD_DESTROY_INVALID_HANDLE UINT32_C(2)
|
|
3866
|
+
#define OT_CLIPBOARD_SHUTDOWN_PENDING UINT32_C(0)
|
|
3867
|
+
#define OT_CLIPBOARD_SHUTDOWN_READY UINT32_C(1)
|
|
3868
|
+
#define OT_CLIPBOARD_SHUTDOWN_INVALID_HANDLE UINT32_C(2)
|
|
3869
|
+
|
|
3870
|
+
int32_t ot_clipboard_service_create(
|
|
3871
|
+
ot_context *context,
|
|
3872
|
+
uint32_t max_operations,
|
|
3873
|
+
uint32_t max_provider_transfers,
|
|
3874
|
+
const uint8_t *wayland_seat,
|
|
3875
|
+
uint32_t wayland_seat_length);
|
|
3876
|
+
uint8_t ot_clipboard_service_begin_shutdown(ot_context *context);
|
|
3877
|
+
uint8_t ot_clipboard_service_poll_shutdown(ot_context *context);
|
|
3878
|
+
uint8_t ot_clipboard_service_destroy(ot_context *context);
|
|
3879
|
+
uint8_t ot_clipboard_service_drain(ot_context *context);
|
|
3880
|
+
uint8_t ot_clipboard_read_operation_start(
|
|
3881
|
+
ot_context *context,
|
|
3882
|
+
const uint8_t *request, uint32_t request_length,
|
|
3883
|
+
uint8_t selection,
|
|
3884
|
+
uint32_t max_bytes, uint32_t max_image_pixels, uint32_t max_conversion_bytes,
|
|
3885
|
+
uint32_t timeout_ms,
|
|
3886
|
+
ot_handle *out_operation);
|
|
3887
|
+
uint8_t ot_clipboard_write_operation_start(
|
|
3888
|
+
ot_context *context,
|
|
3889
|
+
const uint8_t *text, uint32_t text_length,
|
|
3890
|
+
uint8_t selection, uint32_t timeout_ms,
|
|
3891
|
+
ot_handle *out_operation);
|
|
3892
|
+
uint8_t ot_clipboard_clear_operation_start(
|
|
3893
|
+
ot_context *context,
|
|
3894
|
+
uint8_t selection, uint32_t timeout_ms,
|
|
3895
|
+
ot_handle *out_operation);
|
|
3896
|
+
uint8_t ot_clipboard_operation_poll(ot_context *context, const ot_handle *operation);
|
|
3897
|
+
uint8_t ot_clipboard_operation_cancel(ot_context *context, const ot_handle *operation);
|
|
3898
|
+
uint8_t ot_clipboard_operation_result_mime_length(
|
|
3899
|
+
ot_context *context, const ot_handle *operation, uint32_t *out_length);
|
|
3900
|
+
uint8_t ot_clipboard_operation_result_mime_copy(
|
|
3901
|
+
ot_context *context, const ot_handle *operation, uint8_t *out_bytes, uint32_t capacity);
|
|
3902
|
+
uint8_t ot_clipboard_operation_result_data_length(
|
|
3903
|
+
ot_context *context, const ot_handle *operation, uint32_t *out_length);
|
|
3904
|
+
uint8_t ot_clipboard_operation_result_data_copy(
|
|
3905
|
+
ot_context *context, const ot_handle *operation, uint8_t *out_bytes, uint32_t capacity);
|
|
3906
|
+
uint8_t ot_clipboard_operation_result_error_code(
|
|
3907
|
+
ot_context *context, const ot_handle *operation, uint32_t *out_error_code);
|
|
3908
|
+
uint8_t ot_clipboard_operation_result_diagnostic_length(
|
|
3909
|
+
ot_context *context, const ot_handle *operation, uint32_t *out_length);
|
|
3910
|
+
uint8_t ot_clipboard_operation_result_diagnostic_copy(
|
|
3911
|
+
ot_context *context, const ot_handle *operation, uint8_t *out_bytes, uint32_t capacity);
|
|
3912
|
+
uint8_t ot_clipboard_operation_destroy(ot_context *context, const ot_handle *operation);
|
|
3913
|
+
|
|
3914
|
+
#ifdef __cplusplus
|
|
3915
|
+
}
|
|
3916
|
+
#endif
|
|
3917
|
+
|
|
3918
|
+
#endif
|