@opentui/core-darwin-arm64 0.8.4 → 0.9.0

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 CHANGED
@@ -2,4 +2,4 @@
2
2
 
3
3
  > Prebuilt darwin-arm64 binaries for `@opentui/core`.
4
4
 
5
- `opentui.h` beside `libopentui.dylib` is the C ABI header that this library was built from (FNV-1a 64 `0x32e4ccfcdaff96ec`). A C host compiles against it and links the library in this directory. For opentui-rust, set `OPENTUI_LIB_DIR` to this directory; its build fails when the header differs from the one its bindings were generated from. See [C](https://opentui.com/docs/native/c).
5
+ `opentui.h` beside `libopentui.dylib` is the C ABI header that this library was built from (FNV-1a 64 `0xfcf352f7f1c874b8`). A C host compiles against it and links the library in this directory. For the Rust crates in packages/rust, set `OPENTUI_LIB_DIR` to this directory and turn off their default `static` feature (`default-features = false`), since this package has no static library; their build fails when the header differs from the one their bindings were generated from. See [C](https://opentui.com/docs/native/c).
package/libopentui.dylib CHANGED
Binary file
package/opentui.h CHANGED
@@ -123,6 +123,8 @@ typedef struct ot_handle {
123
123
  #define OT_STYLE_ENUM_OVERFLOW UINT32_C(8)
124
124
  #define OT_STYLE_ENUM_DISPLAY UINT32_C(9)
125
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)
126
128
  #define OT_STYLE_FLOAT_FLEX UINT32_C(0)
127
129
  #define OT_STYLE_FLOAT_FLEX_GROW UINT32_C(1)
128
130
  #define OT_STYLE_FLOAT_FLEX_SHRINK UINT32_C(2)
@@ -192,6 +194,26 @@ typedef struct ot_handle {
192
194
  #define OT_DISPLAY_NONE UINT32_C(1)
193
195
  #define OT_BOX_SIZING_BORDER_BOX UINT32_C(0)
194
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)
195
217
  /* Inclusive enum limits also drive generated host validation. */
196
218
  #define OT_STYLE_ENUM_DIRECTION_MAX OT_DIRECTION_RTL
197
219
  #define OT_STYLE_ENUM_FLEX_DIRECTION_MAX OT_FLEX_DIRECTION_ROW_REVERSE
@@ -204,12 +226,14 @@ typedef struct ot_handle {
204
226
  #define OT_STYLE_ENUM_OVERFLOW_MAX OT_OVERFLOW_SCROLL
205
227
  #define OT_STYLE_ENUM_DISPLAY_MAX OT_DISPLAY_NONE
206
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
207
230
  #define OT_MEASURE_UNDEFINED UINT32_C(0)
208
231
  #define OT_MEASURE_EXACTLY UINT32_C(1)
209
232
  #define OT_MEASURE_AT_MOST UINT32_C(2)
210
233
  #define OT_LAYOUT_PUBLIC UINT32_C(0)
211
234
  #define OT_LAYOUT_YOGA UINT32_C(1)
212
235
  #define OT_LAYOUT_PAINT UINT32_C(2)
236
+ #define OT_LAYOUT_CONTENT UINT32_C(3)
213
237
 
214
238
  /* Border masks are paint bits, not OT_EDGE_* layout selectors. */
215
239
  #define OT_BORDER_NONE UINT32_C(0)
@@ -238,6 +262,44 @@ typedef struct ot_handle {
238
262
  #define OT_COLOR_DEFAULT UINT32_C(2)
239
263
  #define OT_COLOR_CHANNEL_MASK UINT32_C(255)
240
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)
241
303
 
242
304
  /* Complete slider options. orientation is horizontal=0 or vertical=1. Colors
243
305
  * retain terminal color intent. All numbers and derived thumb arithmetic must be finite.
@@ -484,6 +546,11 @@ typedef struct ot_scene_stats {
484
546
  uint32_t damage_rows;
485
547
  } ot_scene_stats;
486
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)
487
554
  typedef struct ot_scene_cursor_state {
488
555
  uint32_t struct_size;
489
556
  uint32_t abi_version;
@@ -601,8 +668,15 @@ ot_status ot_scene_set_hooks(ot_context *, const ot_handle *node, const ot_scene
601
668
  * Paint options are copied on each accepted step; max_layout_rounds and
602
669
  * max_host_requests stay positive and fixed for the attempt. Yoga completes before host work. Filtered
603
670
  * text viewports advance only when refreshed or painted, not during candidate layout.
604
- * UPDATE runs at most once per node per attempt; getter refresh
605
- * and resize ordering preserve the mounted and newly placed node contracts.
671
+ * UPDATE runs at most once per node per attempt. Each layout round walks the
672
+ * tree depth first in paint order (z_index, then child order): a node's UPDATE,
673
+ * its RESIZE, then its children's subtrees, so its requests follow those of every
674
+ * earlier sibling's subtree. A child inserted or moved since its last refresh gets
675
+ * its RESIZE when the walk reaches its parent, before its siblings' subtrees; a
676
+ * move to the index the child already has counts. A
677
+ * node with a viewport (ot_scene_set_viewport) or a culling scroll node refreshes
678
+ * all its children before walking the subtrees of those it does not cull. A node
679
+ * inserted during the walk waits for the next round.
606
680
  * LAYOUT_CHANGED follows an actual Yoga solve, before updates. Layout/preparation
607
681
  * limits fail before paint. Failure cancels the attempt without presenting
608
682
  * partial cells or rolling back mutations.
@@ -681,7 +755,11 @@ ot_status ot_scene_create_node(ot_context *, const ot_handle *session, uint32_t
681
755
  * OT_INTERNAL_ERROR until its nodes are destroyed. Destroy, detach, blur, clearing a measure provider, and selection
682
756
  * RESET still succeed. */
683
757
  ot_status ot_scene_destroy_node(ot_context *, const ot_handle *node);
758
+ /* Siblings with equal z_index paint in child order. At an overlap, the later child wins the hit test. */
684
759
  ot_status ot_scene_move_node(ot_context *, const ot_handle *node, const ot_handle *parent, uint32_t index);
760
+ /* Detaches every child of node, as moving each to NULL from first to last would, in
761
+ * time linear in the child count. On error no child is detached. */
762
+ ot_status ot_scene_clear_children(ot_context *, const ot_handle *node);
685
763
  /* Synchronous owner-thread measurement on leaves. The callback is borrowed until
686
764
  * replacement, unset, node destruction, or Context destruction. NULL clears the
687
765
  * single provider slot; it does not restore built-in measurement. Each set or clear
@@ -698,6 +776,9 @@ ot_status ot_scene_has_measure(ot_context *, const ot_handle *node, uint32_t *ou
698
776
  * and child count from the latest layout (a child moved since then has no position, and is
699
777
  * not selected). A node they do not reach gets no hook calls. */
700
778
  ot_status ot_scene_reaches_hooks(ot_context *, const ot_handle *node, uint32_t *out_reached);
779
+ /* out_painted is 1 when the last frame that finished paint painted the node, or the presented
780
+ * frame once a later one is cancelled; 0 for the root and before any frame. */
781
+ ot_status ot_scene_painted(ot_context *, const ot_handle *node, uint32_t *out_painted);
701
782
  ot_status ot_scene_mark_dirty(ot_context *, const ot_handle *node);
702
783
  /* Use OT_STYLE_* groups/kinds, OT_EDGE_* (or OT_GUTTER_* for GAP), and OT_UNIT_*.
703
784
  * Only OT_STYLE_DIMENSION accepts OT_STYLE_DISABLE_FLEX_SHRINK, which disables
@@ -851,8 +932,9 @@ typedef struct ot_scene_scroll_bar_options {
851
932
  uint16_t track_background[4];
852
933
  } ot_scene_scroll_bar_options;
853
934
 
935
+ #define OT_SCENE_SCROLL_PADDING_MAX UINT32_C(65535)
854
936
  /* axes holds OT_SCENE_SCROLL_X/Y. culling is 0 or 1. padding is the viewport
855
- * padding in whole cells, left, top, right, bottom, each 0..65535. fills selects
937
+ * padding in whole cells, left, top, right, bottom, each 0..PADDING_MAX. fills selects
856
938
  * which of the wrapper (box inner rect minus the vertical gutter), viewport, and
857
939
  * content (moving with the offset) backgrounds paint, in that order, before the
858
940
  * children. bars[0] is the horizontal bar, bars[1] the vertical bar. */
@@ -987,8 +1069,9 @@ ot_status ot_scene_set_text(ot_context *, const ot_handle *node, const uint8_t *
987
1069
  * Rejection preserves accepted content and resources. No style handles.
988
1070
  * Each array may be NULL only when its count is zero. link_offset and
989
1071
  * link_byte_count select bytes in urls; without LINK both must be zero. URLs are
990
- * copied raw metadata, not parsed or normalized. Empty URLs, URLs over 512 bytes,
991
- * and chunks with zero independently measured width produce no link. Oversized
1072
+ * copied, not normalized. Empty URLs, URLs over 512 bytes,
1073
+ * URLs that are not UTF-8 or hold a C0, DEL or C1 control, and chunks with zero
1074
+ * independently measured width produce no link; their text stays. Oversized
992
1075
  * URLs are not truncated. URLs and their references are prepared before publication;
993
1076
  * rejection preserves accepted text, styles, and links. urls may be NULL only
994
1077
  * when url_byte_count is zero. Link IDs stay local to the owning Context. */
@@ -1027,8 +1110,19 @@ ot_status ot_scene_get_text(ot_context *, const ot_handle *node, uint8_t *bytes,
1027
1110
  ot_status ot_scene_get_text_info(ot_context *, const ot_handle *node, ot_scene_text_info *out_info);
1028
1111
  ot_status ot_scene_get_text_lines(ot_context *, const ot_handle *node, uint32_t first_line,
1029
1112
  ot_scene_text_line *lines, uint32_t capacity, uint32_t *out_count);
1113
+ /* The byte offset, in the UTF-8 last set on the text node, where the grapheme the latest
1114
+ * finished frame drew at screen cell (x, y) starts. UINT32_MAX when that frame did not
1115
+ * paint the node, when its text or view options changed since, and when the cell lies
1116
+ * outside the node's painted cells or shows no whole grapheme: padding, a truncation
1117
+ * ellipsis, a wide grapheme an edge cuts, zero opacity, or a RENDER_SELF hook's body
1118
+ * in place of the text. A failed paint attempt leaves the answers of the frame before
1119
+ * it, except for nodes it drew. It never lays text out, and does not check
1120
+ * what covers the cell; ot_scene_hit_test does. Follows the text getter rules. */
1121
+ ot_status ot_scene_get_text_byte_at(ot_context *, const ot_handle *node, int32_t x, int32_t y, uint32_t *out_byte);
1030
1122
  /* OT_LAYOUT_PUBLIC copies local cell geometry from the node's latest preparation refresh.
1031
- * During host phases, mounted nodes retain their preceding projection until that
1123
+ * Below a child that its filtering parent's latest selection culled, which no refresh
1124
+ * reaches, it copies the latest solved geometry instead, if Yoga has laid the node out since
1125
+ * it was created or moved. During host phases, mounted nodes retain their preceding projection until that
1032
1126
  * refresh; newly placed children refresh before their own update. screen_x/y
1033
1127
  * combine that geometry with current accepted ancestor relationships
1034
1128
  * and translations immediately, without running layout. OT_LAYOUT_YOGA instead
@@ -1043,7 +1137,10 @@ ot_status ot_scene_get_text_lines(ot_context *, const ot_handle *node, uint32_t
1043
1137
  * after a solve or after a change between frames that drops the list, until the next list
1044
1138
  * paints it, reads its latest solved geometry composed with current translations and
1045
1139
  * offsets; zeros if Yoga has not laid it out since it was created or moved. While a host
1046
- * request is pending, such a node's first read holds.
1140
+ * request is pending, such a node's first read holds. OT_LAYOUT_CONTENT is PAINT without a
1141
+ * text node's padding, its content edges rounded as Yoga rounds the node's own edges (no
1142
+ * padding reads the box): the cells its text view fills, which paint, wrapping, text byte
1143
+ * hits, selection and body draws use. Other nodes read PAINT.
1047
1144
  * These reads do not run layout. Other selectors reject without changing output.
1048
1145
  * A scroll node's children report YOGA values local to its content node, and their
1049
1146
  * screen_x/y compose through the viewport and content origins and the offset. */
@@ -1060,6 +1157,9 @@ ot_status ot_scene_get_layout(ot_context *, const ot_handle *node, uint32_t obse
1060
1157
  * OT_UNSUPPORTED_RESOURCE. Use ot_scene_frame_step_with_geometry for host hooks. */
1061
1158
  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);
1062
1159
  ot_status ot_scene_hit_test(ot_context *, const ot_handle *session, int32_t x, int32_t y, uint32_t *out_num);
1160
+ /* ot_scene_hit_test as if the node with public number excluded_num painted no hits (zero
1161
+ * excludes none). Its descendants still hit. A drag looks up targets through its source. */
1162
+ 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);
1063
1163
  ot_status ot_scene_get_stats(ot_context *, const ot_handle *session, ot_scene_stats *out_stats);
1064
1164
  #define OT_SCENE_DEBUG_FULL_FRAME UINT32_C(1)
1065
1165
  #define OT_SCENE_DEBUG_VERIFY UINT32_C(2)
@@ -1079,7 +1179,7 @@ ot_status ot_scene_get_stats(ot_context *, const ot_handle *session, ot_scene_st
1079
1179
  * repainted frame. A mismatch fails the frame step
1080
1180
  * with OT_INTERNAL_ERROR; VERIFY changes no other state or count. */
1081
1181
  ot_status ot_scene_set_debug_flags(ot_context *, const ot_handle *session, uint32_t flags);
1082
- /* Copied renderer cursor state. Style: block=0 line=1 underline=2 default=3.
1182
+ /* Copied renderer cursor state. style is an OT_CURSOR_STYLE_* value.
1083
1183
  * Colors use normalized float channels. Output requires exact size/version. */
1084
1184
  ot_status ot_scene_get_cursor_state(ot_context *, const ot_handle *session, ot_scene_cursor_state *out_state);
1085
1185
 
@@ -1186,7 +1286,8 @@ ot_status ot_scene_frame_copy_buffer(ot_context *, const ot_handle *session,
1186
1286
  /* Solve an idle scene's existing root without frame preparation, hooks, or painting.
1187
1287
  * Custom Yoga measurement providers may run. Read computed dimensions with raw_yoga=1. */
1188
1288
  ot_status ot_scene_measure_layout(ot_context *, const ot_handle *session, const ot_handle *root);
1189
- /* At most 64 snapshots; Context identities are checked before native bounded copies.
1289
+ #define OT_SPLIT_SNAPSHOTS_MAX UINT32_C(64)
1290
+ /* At most SPLIT_SNAPSHOTS_MAX snapshots; Context identities are checked before native bounded copies.
1190
1291
  * A null frame submits snapshots only, without painting or publishing the footer draft.
1191
1292
  * After suspension completes, null-frame snapshots remain permitted without reactivating
1192
1293
  * terminal modes; their output packet leaves the cursor restored. Non-null frames and
@@ -1296,6 +1397,11 @@ typedef struct ot_embedded_terminal_cursor {
1296
1397
  uint32_t color_b;
1297
1398
  uint32_t reserved;
1298
1399
  } ot_embedded_terminal_cursor;
1400
+ /* The emulator's cursor styles for style above; not the OT_CURSOR_STYLE_* order. */
1401
+ #define OT_EMBEDDED_TERMINAL_CURSOR_BAR UINT32_C(0)
1402
+ #define OT_EMBEDDED_TERMINAL_CURSOR_BLOCK UINT32_C(1)
1403
+ #define OT_EMBEDDED_TERMINAL_CURSOR_UNDERLINE UINT32_C(2)
1404
+ #define OT_EMBEDDED_TERMINAL_CURSOR_BLOCK_HOLLOW UINT32_C(3)
1299
1405
 
1300
1406
  /* The active screen's viewport, in rows. offset is the distance from the live
1301
1407
  * screen (0 there; total - visible at the top of history). total includes the
@@ -1332,10 +1438,36 @@ typedef struct ot_embedded_terminal_mouse {
1332
1438
  float y;
1333
1439
  } ot_embedded_terminal_mouse;
1334
1440
 
1441
+ /* mods and consumed_mods use the emulator's bits, not OT_INPUT_MOD_*. It has no
1442
+ * Hyper or Meta: hosts send Kitty Meta as ALT. button is BUTTON_NONE for motion
1443
+ * without a pressed button. */
1444
+ #define OT_EMBEDDED_TERMINAL_MOD_SHIFT UINT32_C(1)
1445
+ #define OT_EMBEDDED_TERMINAL_MOD_CTRL UINT32_C(2)
1446
+ #define OT_EMBEDDED_TERMINAL_MOD_ALT UINT32_C(4)
1447
+ #define OT_EMBEDDED_TERMINAL_MOD_SUPER UINT32_C(8)
1448
+ #define OT_EMBEDDED_TERMINAL_MOD_CAPS_LOCK UINT32_C(16)
1449
+ #define OT_EMBEDDED_TERMINAL_MOD_NUM_LOCK UINT32_C(32)
1450
+ #define OT_EMBEDDED_TERMINAL_KEY_RELEASE UINT32_C(0)
1451
+ #define OT_EMBEDDED_TERMINAL_KEY_PRESS UINT32_C(1)
1452
+ #define OT_EMBEDDED_TERMINAL_KEY_REPEAT UINT32_C(2)
1453
+ #define OT_EMBEDDED_TERMINAL_MOUSE_PRESS UINT32_C(0)
1454
+ #define OT_EMBEDDED_TERMINAL_MOUSE_RELEASE UINT32_C(1)
1455
+ #define OT_EMBEDDED_TERMINAL_MOUSE_MOTION UINT32_C(2)
1456
+ #define OT_EMBEDDED_TERMINAL_BUTTON_NONE INT32_C(-1)
1457
+ #define OT_EMBEDDED_TERMINAL_BUTTON_UNKNOWN INT32_C(0)
1458
+ #define OT_EMBEDDED_TERMINAL_BUTTON_LEFT INT32_C(1)
1459
+ #define OT_EMBEDDED_TERMINAL_BUTTON_RIGHT INT32_C(2)
1460
+ #define OT_EMBEDDED_TERMINAL_BUTTON_MIDDLE INT32_C(3)
1461
+ #define OT_EMBEDDED_TERMINAL_BUTTON_FOUR INT32_C(4)
1462
+ #define OT_EMBEDDED_TERMINAL_BUTTON_FIVE INT32_C(5)
1463
+ #define OT_EMBEDDED_TERMINAL_BUTTON_SIX INT32_C(6)
1464
+ #define OT_EMBEDDED_TERMINAL_BUTTON_SEVEN INT32_C(7)
1465
+
1335
1466
  /* All option records require exact size/version and zero reserved fields.
1336
1467
  * Booleans are 0/1. Input and output buffers are borrowed only during the call.
1337
1468
  * Columns and rows are positive u16 values within the Context cell budget.
1338
- * Write, key-name, key-text, and paste inputs are each limited to 1 MiB. */
1469
+ * Write, key-name, key-text, and paste inputs are each limited to INPUT_BYTES_MAX. */
1470
+ #define OT_EMBEDDED_TERMINAL_INPUT_BYTES_MAX UINT32_C(1048576)
1339
1471
  ot_status ot_embedded_terminal_create(ot_context *, const ot_embedded_terminal_options *, ot_handle *out_terminal);
1340
1472
  ot_status ot_embedded_terminal_destroy(ot_context *, const ot_handle *terminal);
1341
1473
  ot_status ot_embedded_terminal_write(ot_context *, const ot_handle *terminal, const uint8_t *bytes, uint32_t byte_count);
@@ -1366,8 +1498,9 @@ ot_status ot_embedded_terminal_encode_paste(ot_context *, const ot_handle *termi
1366
1498
  const uint8_t *input, uint32_t input_count, uint8_t *bytes, uint32_t capacity, uint32_t *out_count);
1367
1499
  ot_status ot_embedded_terminal_encode_focus(ot_context *, const ot_handle *terminal,
1368
1500
  uint32_t focused, uint8_t *bytes, uint32_t capacity, uint32_t *out_count);
1501
+ #define OT_EMBEDDED_TERMINAL_RESPONSE_BYTES_MAX UINT32_C(1048576)
1369
1502
  /* Drains at most capacity bytes, not a sizing query. Response overflow returns
1370
- * OT_OUTPUT_BACKPRESSURE once without consuming the retained 1 MiB prefix. */
1503
+ * OT_OUTPUT_BACKPRESSURE once without consuming the retained RESPONSE_BYTES_MAX prefix. */
1371
1504
  ot_status ot_embedded_terminal_drain_responses(ot_context *, const ot_handle *terminal,
1372
1505
  uint8_t *bytes, uint32_t capacity, uint32_t *out_count);
1373
1506
 
@@ -1446,7 +1579,7 @@ typedef struct ot_edit_buffer_info {
1446
1579
  #define OT_MOUSE_POINTER_UNCHANGED UINT32_C(0xFFFFFFFF)
1447
1580
 
1448
1581
  /* Complete cursor options, not a patch. Exact size/version and zero reserved.
1449
- * show_cursor and blinking are 0 or 1. style is block=0, line=1, underline=2, default=3.
1582
+ * show_cursor and blinking are 0 or 1. style is an OT_CURSOR_STYLE_* value.
1450
1583
  * color retains packed intent for capture; cursor output uses its RGB snapshot.
1451
1584
  * mouse_pointer is an OT_MOUSE_POINTER_* shape or OT_MOUSE_POINTER_UNCHANGED. */
1452
1585
  typedef struct ot_scene_editor_options {
@@ -1517,7 +1650,21 @@ ot_status ot_edit_buffer_set_tab_width(ot_context *, const ot_handle *edit_buffe
1517
1650
  #define OT_EDIT_CLEAR UINT32_C(10)
1518
1651
  #define OT_EDIT_CLEAR_HISTORY UINT32_C(11)
1519
1652
  #define OT_EDIT_DEBUG_ROPE UINT32_C(12)
1520
- /* argument is a line/offset for GOTO_LINE/CURSOR_OFFSET, zero otherwise. */
1653
+ #define OT_EDIT_CURSOR_OFFSET_ATOMIC UINT32_C(13)
1654
+ #define OT_EDIT_KEEP_OUTSIDE UINT32_C(14)
1655
+ #define OT_EDIT_ATOMIC UINT32_C(1)
1656
+ /* argument is a line/offset for GOTO_LINE/CURSOR_OFFSET/CURSOR_OFFSET_ATOMIC, zero or OT_EDIT_ATOMIC
1657
+ * for DELETE_FORWARD, BACKSPACE, MOVE_LEFT and MOVE_RIGHT, the edge for KEEP_OUTSIDE (0 the nearer,
1658
+ * ties to the end; 1 the end; 2 the start), zero otherwise.
1659
+ * OT_EDIT_ATOMIC applies the cursor rules around atomic edit marks; of overlapping marks the oldest
1660
+ * counts first. Each move steps over one mark: Left from a mark's end goes one unit before its
1661
+ * start, or to the start when another mark ends there; Right from its start, or from one cell before
1662
+ * it, goes to its end. Backspace at a mark's end or Delete at its start deletes the whole mark as
1663
+ * one edit (of marks with that edge there, the oldest). CURSOR_OFFSET_ATOMIC moves to the offset as
1664
+ * Left (toward the start) or Right (toward the end) would, past a mark it lands in. KEEP_OUTSIDE
1665
+ * moves the cursor to the start of its unit, then out of the atomic marks that surround it to the
1666
+ * outer edge of all of them. A move under these rules ends on a unit start outside every atomic
1667
+ * mark. */
1521
1668
  ot_status ot_edit_buffer_command(ot_context *, const ot_handle *, uint32_t command, uint32_t argument);
1522
1669
  /* redo is 0/1. Capacity must be at least 64, the native cursor-metadata bound,
1523
1670
  * before history is changed. No history returns zero bytes. */
@@ -1554,6 +1701,16 @@ ot_status ot_edit_buffer_get_position(ot_context *, const ot_handle *, uint32_t
1554
1701
  ot_status ot_edit_buffer_get_range(ot_context *, const ot_handle *, uint32_t by_coords,
1555
1702
  uint32_t start_row, uint32_t start_col, uint32_t end_row, uint32_t end_col,
1556
1703
  uint8_t *bytes, uint32_t capacity, uint32_t *out_count);
1704
+ #define OT_EDIT_BYTE_TO_CELL UINT32_C(0)
1705
+ #define OT_EDIT_CELL_TO_BYTE UINT32_C(1)
1706
+ #define OT_EDIT_UTF16_TO_CELL UINT32_C(2)
1707
+ #define OT_EDIT_CELL_TO_UTF16 UINT32_C(3)
1708
+ /* Converts an index in get_text (UTF-8 bytes or UTF-16 code units) to or from document
1709
+ * display cells, one per LF. Interior positions round down to the buffer grapheme's start;
1710
+ * a cell shared by zero-width text maps after it. Past the end clamps to the end.
1711
+ * Read-only. Unknown conversions fail and failures preserve out_value. */
1712
+ ot_status ot_edit_buffer_convert_offset(ot_context *, const ot_handle *edit_buffer,
1713
+ uint32_t conversion, uint32_t value, uint32_t *out_value);
1557
1714
  /* Lays UTF-8 bytes out as set_text would, without storing them, and reports the offset at
1558
1715
  * their end: display cells under the buffer's width method, tab width, and control notation,
1559
1716
  * plus one per line break (LF, CR, or CRLF). bytes may be NULL only for zero length; the
@@ -1569,6 +1726,9 @@ ot_status ot_edit_measure_text(ot_context *, const uint8_t *bytes, uint32_t byte
1569
1726
  #define OT_EDITOR_STYLE_FOREGROUND UINT32_C(1)
1570
1727
  #define OT_EDITOR_STYLE_BACKGROUND UINT32_C(2)
1571
1728
  #define OT_EDITOR_STYLE_ATTRIBUTES UINT32_C(4)
1729
+ /* Syntax styles only, with OT_EDITOR_STYLE_ATTRIBUTES: attributes bits 16..23 say which of bits
1730
+ * 0..7 the style supplies. */
1731
+ #define OT_EDITOR_STYLE_ATTRIBUTE_MASK UINT32_C(8)
1572
1732
  typedef struct ot_editor_style {
1573
1733
  uint32_t struct_size;
1574
1734
  uint32_t abi_version;
@@ -1583,7 +1743,10 @@ typedef struct ot_editor_style {
1583
1743
  ot_status ot_edit_buffer_set_defaults(ot_context *, const ot_handle *, uint32_t mask, const ot_editor_style *);
1584
1744
  /* Names are copied UTF-8; registering an existing name replaces its definition.
1585
1745
  * Empty names are valid; name may be NULL only when byte_count is zero. Ids are
1586
- * below OT_STYLE_RUN_FLAG. */
1746
+ * below OT_STYLE_RUN_FLAG. A group set composes its names in order: each later name
1747
+ * replaces fg, bg, and the attribute bits it supplies. Without
1748
+ * OT_EDITOR_STYLE_ATTRIBUTE_MASK, a style with OT_EDITOR_STYLE_ATTRIBUTES supplies all
1749
+ * eight bits and one without supplies none. Set bits 0..7 outside the supplied bits fail. */
1587
1750
  ot_status ot_syntax_style_register(ot_context *, const ot_handle *, const uint8_t *name,
1588
1751
  uint32_t byte_count, const ot_editor_style *, uint32_t *out_id);
1589
1752
  /* Unknown names return id=0. Names are borrowed only for the query. */
@@ -1621,6 +1784,213 @@ ot_status ot_edit_buffer_highlight(ot_context *, const ot_handle *, uint32_t ope
1621
1784
  ot_status ot_edit_buffer_get_highlights(ot_context *, const ot_handle *, uint32_t line,
1622
1785
  ot_edit_highlight *highlights, uint32_t capacity, uint32_t *out_count);
1623
1786
 
1787
+ /* Interns an ordered list of SyntaxStyle names as a group set. names is a pool of UTF-8
1788
+ * names; name_end_bytes[i] is the exclusive end of name i, and the last end is
1789
+ * name_byte_count. Equal lists give equal ids on this Context, whatever style a buffer binds;
1790
+ * ids are never freed. Paint composes the names against the buffer's bound style, later names
1791
+ * winning, and a missing name falls back to its first dotted component. Names must be
1792
+ * nonempty. More than OT_GROUP_SET_NAME_COUNT_MAX names, a name over
1793
+ * OT_GROUP_SET_NAME_BYTE_COUNT_MAX bytes, or a new set past 4,096 sets or 64 KiB of names fails
1794
+ * with OT_OBJECT_LIMIT. Failures preserve out_group_set. */
1795
+ #define OT_GROUP_SET_NAME_COUNT_MAX UINT32_C(16)
1796
+ #define OT_GROUP_SET_NAME_BYTE_COUNT_MAX UINT32_C(64)
1797
+ ot_status ot_context_group_set(ot_context *, const uint8_t *names, uint32_t name_byte_count,
1798
+ const uint32_t *name_end_bytes, uint32_t name_count, uint32_t *out_group_set);
1799
+
1800
+ typedef struct ot_highlight_run {
1801
+ uint32_t start_byte;
1802
+ uint32_t end_byte;
1803
+ uint32_t group_set; /* id from ot_context_group_set */
1804
+ } ot_highlight_run;
1805
+ /* Replaces layer layer_id of the buffer inside [start_byte, end_byte), start_byte <= end_byte,
1806
+ * with runs, in UTF-8 bytes of the text as get_text returns it (one byte per line break);
1807
+ * runs may be NULL only when run_count is zero. Runs are nonempty,
1808
+ * sorted, non-overlapping, inside the range and inside the text, and start and end on code
1809
+ * point boundaries; so must range edges inside the text. A range end past the text reaches
1810
+ * its end. Runs that cross the range edges keep their outside parts. One transaction: a
1811
+ * rejection leaves the layer unchanged. Runs move with edits: they shift, a run grows when
1812
+ * text is inserted strictly inside it, and deleted bytes clip them. set_text, clear, undo,
1813
+ * redo and the CLEAR_ALL highlight operation empty every layer; REMOVE_REF and CLEAR_LINE
1814
+ * leave layers alone. Layers paint at priority 0: above highlights of priority 0, below
1815
+ * higher priorities; where layers overlap, the higher layer_id wins. A run without a link
1816
+ * whose group set supplies no field (fg, bg or attribute bit) paints as if absent. At most 4 nonempty
1817
+ * layers per buffer: a fifth fails with OT_OBJECT_LIMIT, and a layer left empty is dropped. */
1818
+ ot_status ot_edit_buffer_set_layer(ot_context *, const ot_handle *, uint32_t layer_id,
1819
+ uint32_t start_byte, uint32_t end_byte, const ot_highlight_run *runs, uint32_t run_count);
1820
+
1821
+ /* Edit marks: ranges of the text that move with edits. Text inserted at a mark's start shifts it,
1822
+ * at its end leaves it (so an empty mark stays), and strictly inside grows it. A delete clips a
1823
+ * mark and drops it once none of its text is left. An OT_EDIT_MARK_ATOMIC mark is one unit: an
1824
+ * edit that changes part of its text drops it, and the edit changes exactly the text it asked
1825
+ * for. set_text and clear drop every mark. Undo and redo restore the marks of the text they
1826
+ * restore. Ids start at 1 and are never reused, undo included. At most 65,536 marks per buffer
1827
+ * (OT_OBJECT_LIMIT).
1828
+ * start and end are cursor offsets, start <= end; past the text they mean its end. On output a
1829
+ * start rounds down and an end up to a cursor stop, and start_byte/end_byte give the mark in
1830
+ * UTF-8 bytes of get_text; on input both are zero.
1831
+ * A styled mark paints and get_highlights reports it as one ADD_RANGE highlight with its style,
1832
+ * priority and ref = id & 0xFFFF, added after the buffer's own highlights in id order. style is
1833
+ * a SyntaxStyle id (0 for none); with OT_EDIT_MARK_STYLE_VALUE, style is 0 and value is the
1834
+ * style itself, kept by the buffer (at most 4,096 values; past it OT_OBJECT_LIMIT), and
1835
+ * get_highlights reports style id 0. Without it, value is all zero. */
1836
+ #define OT_EDIT_MARK_ADD UINT32_C(0)
1837
+ #define OT_EDIT_MARK_REMOVE UINT32_C(1)
1838
+ #define OT_EDIT_MARK_CLEAR UINT32_C(2)
1839
+ #define OT_EDIT_MARK_ATOMIC UINT32_C(1)
1840
+ #define OT_EDIT_MARK_STYLE_VALUE UINT32_C(2)
1841
+ #define OT_EDIT_MARK_ANY_KIND UINT32_C(0xFFFFFFFF)
1842
+ typedef struct ot_edit_mark {
1843
+ uint32_t struct_size;
1844
+ uint32_t abi_version;
1845
+ uint32_t id;
1846
+ uint32_t kind;
1847
+ uint32_t flags;
1848
+ uint32_t style;
1849
+ ot_editor_style value;
1850
+ uint32_t priority;
1851
+ uint32_t start;
1852
+ uint32_t end;
1853
+ uint32_t start_byte;
1854
+ uint32_t end_byte;
1855
+ } ot_edit_mark;
1856
+ /* ADD takes mark (id 0, priority <= 255 when styled) and writes the new id. REMOVE takes
1857
+ * mark->id (the rest zero) and writes it back, or 0 when there was no such mark. CLEAR drops
1858
+ * every mark; mark and out_id are NULL. */
1859
+ ot_status ot_edit_buffer_mark(ot_context *, const ot_handle *, uint32_t operation,
1860
+ const ot_edit_mark *mark, uint32_t *out_id);
1861
+ /* Copies the marks in (start, id) order: mark id, or all for id 0, of kind kind, or any for
1862
+ * OT_EDIT_MARK_ANY_KIND. Zero capacity reports the count; otherwise all must fit, and
1863
+ * undersized calls preserve both outputs. */
1864
+ ot_status ot_edit_buffer_get_marks(ot_context *, const ot_handle *, uint32_t id, uint32_t kind,
1865
+ ot_edit_mark *marks, uint32_t capacity, uint32_t *out_count);
1866
+
1867
+ /* A streamed Markdown document (CommonMark 0.31.2 with GFM tables, strikethrough, task lists and
1868
+ * extended autolinks), parsed incrementally. Blocks have preorder indices, which are their ids;
1869
+ * a removal is always a suffix. Complete lines parse exactly; the bytes after the last line
1870
+ * ending are laid out provisionally, held while their kind can still change. Limits: source
1871
+ * 64 MiB, 1,048,576 blocks, 4,096 link definitions, 32 levels of nesting, hook filter 256
1872
+ * bytes, 32 emphasis runs waiting for a closer (past it the oldest is text and never matches).
1873
+ * A rejected call changes nothing: the document, its bound nodes and its pending
1874
+ * changes stay as they were. An accepted call writes its bound nodes after its change; a node
1875
+ * write that runs out of memory leaves that node behind until a later call writes it whole. */
1876
+ #define OT_MD_CONCEAL UINT32_C(1) /* hide markers; off, a leaf shows its source, styled */
1877
+ #define OT_MD_HYPERLINKS UINT32_C(2) /* the terminal shows links; off, a label that is not its
1878
+ URL is followed by " (url)" */
1879
+ #define OT_MD_MATH UINT32_C(4) /* $…$, \(…\) inline math; $$ and \[ blocks (code, MATH) */
1880
+ #define OT_MD_HOOK UINT32_C(8) /* prose leaves whose source holds a filter substring latch
1881
+ HOOKED: the host writes them */
1882
+ typedef struct ot_markdown_options {
1883
+ uint32_t struct_size;
1884
+ uint32_t abi_version;
1885
+ uint32_t flags; /* OT_MD_* */
1886
+ uint32_t source_byte_limit; /* 0 = 64 MiB; may only lower it */
1887
+ ot_handle syntax_style; /* style the bound nodes and read_leaf resolve with; zero = none */
1888
+ uint32_t hook_filter_byte_count; /* <= OT_MD_HOOK_FILTER_BYTE_COUNT_MAX */
1889
+ uint32_t reserved;
1890
+ /* At most 16 NUL-separated substrings, each 1..64 bytes, in the first
1891
+ * hook_filter_byte_count bytes; none with OT_MD_HOOK = every prose leaf is hooked. */
1892
+ uint8_t hook_filter[256];
1893
+ } ot_markdown_options;
1894
+ #define OT_MD_HOOK_FILTER_BYTE_COUNT_MAX UINT32_C(256)
1895
+ typedef struct ot_markdown_result {
1896
+ uint32_t changed_block_count; /* blocks read_changes lists now */
1897
+ uint32_t committed_top_level_count; /* leading top-level blocks that are final */
1898
+ uint32_t removed_from_index; /* blocks at this index and after were removed since
1899
+ the last read; UINT32_MAX = none */
1900
+ } ot_markdown_result;
1901
+ /* The doc keeps a copy of the filter. syntax_style must name a live style. */
1902
+ ot_status ot_markdown_create(ot_context *, const ot_markdown_options *, ot_handle *out_doc);
1903
+ /* Bound nodes keep their last text. */
1904
+ ot_status ot_markdown_destroy(ot_context *, const ot_handle *doc);
1905
+ /* Conceal, hyperlink, math, hook and limit changes parse the source again: blocks equal to the
1906
+ * old ones keep their indices, bound nodes whose leaf output changed are written again (the
1907
+ * listed ones the host writes), and the blocks after the first difference are removed. A style
1908
+ * change binds the bound nodes to the new style without a rewrite. A finished doc stays
1909
+ * finished. */
1910
+ ot_status ot_markdown_set_options(ot_context *, const ot_handle *doc, const ot_markdown_options *,
1911
+ ot_markdown_result *out);
1912
+ /* bytes is valid UTF-8 and may be NULL only when byte_count is zero. After finish, an append is
1913
+ * a fresh parse of the whole source and the bytes. */
1914
+ ot_status ot_markdown_append(ot_context *, const ot_handle *doc, const uint8_t *bytes,
1915
+ uint32_t byte_count, ot_markdown_result *out);
1916
+ /* A fresh parse of bytes; leading blocks equal to the old ones keep their indices unreported. */
1917
+ ot_status ot_markdown_set(ot_context *, const ot_handle *doc, const uint8_t *bytes,
1918
+ uint32_t byte_count, ot_markdown_result *out);
1919
+ /* Ends the document: the pending line is complete and every block closes. A fence or math
1920
+ * block without its closer stays without OT_MD_BLOCK_CLOSED. */
1921
+ ot_status ot_markdown_finish(ot_context *, const ot_handle *doc, ot_markdown_result *out);
1922
+ /* The source, borrowed until the next mutating call on doc or its destruction. */
1923
+ ot_status ot_markdown_get_source(ot_context *, const ot_handle *doc, const uint8_t **out_bytes,
1924
+ uint32_t *out_byte_count);
1925
+
1926
+ #define OT_MD_PARAGRAPH UINT32_C(0)
1927
+ #define OT_MD_HEADING UINT32_C(1)
1928
+ #define OT_MD_CODE UINT32_C(2) /* fenced, indented, or display math (OT_MD_BLOCK_MATH) */
1929
+ #define OT_MD_HTML UINT32_C(3) /* shown as its source text */
1930
+ #define OT_MD_RULE UINT32_C(4)
1931
+ #define OT_MD_TABLE UINT32_C(5)
1932
+ #define OT_MD_TABLE_ROW UINT32_C(6)
1933
+ #define OT_MD_TABLE_CELL UINT32_C(7) /* a row's source cells only; shorter rows have fewer */
1934
+ #define OT_MD_QUOTE UINT32_C(8)
1935
+ #define OT_MD_LIST UINT32_C(9)
1936
+ #define OT_MD_ITEM UINT32_C(10)
1937
+ #define OT_MD_BLOCK_CLOSED UINT32_C(1) /* a fence's or math block's closer arrived */
1938
+ #define OT_MD_BLOCK_SETEXT UINT32_C(2)
1939
+ #define OT_MD_BLOCK_ORDERED UINT32_C(4)
1940
+ #define OT_MD_BLOCK_TIGHT UINT32_C(8) /* set when the list closes */
1941
+ #define OT_MD_BLOCK_TASK UINT32_C(16)
1942
+ #define OT_MD_BLOCK_CHECKED UINT32_C(32)
1943
+ #define OT_MD_BLOCK_BLANK_AFTER UINT32_C(64) /* a blank line separates the item from the next */
1944
+ #define OT_MD_BLOCK_FENCED UINT32_C(128)
1945
+ #define OT_MD_BLOCK_HOOKED UINT32_C(256)
1946
+ #define OT_MD_BLOCK_MATH UINT32_C(512) /* display math: a code block of the language math */
1947
+ #define OT_MD_BLOCK_HEADER UINT32_C(1024) /* a table's header row */
1948
+ #define OT_MD_BLOCK_OPEN UINT32_C(2048) /* later lines may still extend the block */
1949
+ /* A table cell's column alignment from the delimiter row: both = centred, neither = none. */
1950
+ #define OT_MD_BLOCK_ALIGN_LEFT UINT32_C(4096)
1951
+ #define OT_MD_BLOCK_ALIGN_RIGHT UINT32_C(8192)
1952
+ typedef struct ot_markdown_block {
1953
+ uint32_t index; /* preorder index = block id */
1954
+ uint32_t parent_index; /* UINT32_MAX at top level */
1955
+ uint16_t kind; /* OT_MD_PARAGRAPH .. OT_MD_ITEM */
1956
+ uint16_t flags; /* OT_MD_BLOCK_* */
1957
+ uint32_t source_start_byte;
1958
+ uint32_t source_end_byte;
1959
+ uint32_t info_start_byte; /* a fence's info string; empty otherwise */
1960
+ uint32_t info_end_byte;
1961
+ uint32_t number; /* heading level, list start, table column count, cell column */
1962
+ } ot_markdown_block;
1963
+ /* Lists every block changed since the last successful read, in document order, and clears the
1964
+ * pending changes and removed_from_index. A zero or short capacity reports the count and
1965
+ * acknowledges nothing. blocks may be NULL only when block_capacity is zero. */
1966
+ ot_status ot_markdown_read_changes(ot_context *, const ot_handle *doc, ot_markdown_block *blocks,
1967
+ uint32_t block_capacity, uint32_t *out_block_count);
1968
+ #define OT_MD_SPAN_CODE UINT32_C(1)
1969
+ #define OT_MD_SPAN_MATH UINT32_C(2)
1970
+ /* The parser's output for a leaf (paragraph, heading, code, HTML block or table cell), never a
1971
+ * host's: its display bytes, styled chunks resolved through the doc's style (links point into
1972
+ * urls, as ot_scene_set_styled_text takes them), and, when spans is not NULL, one OT_MD_SPAN_*
1973
+ * word per chunk. All capacities zero report the three counts; otherwise each must hold its
1974
+ * count, and an undersized call writes nothing. A pointer may be NULL only with zero capacity. */
1975
+ /* A paragraph's, heading's or table cell's inline source: its content with container markers
1976
+ * and leading whitespace removed, lines joined by '\n', trailing whitespace and leading link
1977
+ * definitions dropped, a cell's escaped pipes unescaped (what an inline hook gets as the
1978
+ * block's source). Zero capacity reports the count; a short one writes nothing. */
1979
+ ot_status ot_markdown_read_source(ot_context *, const ot_handle *doc, uint32_t block_index,
1980
+ uint8_t *bytes, uint32_t byte_capacity, uint32_t *out_byte_count);
1981
+ ot_status ot_markdown_read_leaf(ot_context *, const ot_handle *doc, uint32_t block_index,
1982
+ uint8_t *bytes, uint32_t byte_capacity, uint32_t *out_byte_count,
1983
+ ot_styled_text_chunk *chunks, uint32_t *spans, uint32_t chunk_capacity, uint32_t *out_chunk_count,
1984
+ uint8_t *urls, uint32_t url_byte_capacity, uint32_t *out_url_byte_count);
1985
+ /* Binds a scene text node to a paragraph or heading: the node draws with the doc's style, and
1986
+ * while the leaf is not hooked and the doc conceals and shows hyperlinks, the doc writes the
1987
+ * leaf's display and Markdown runs to it now and on every change. A removal of the block
1988
+ * unbinds it; a destroyed node is skipped. A node the host writes (the doc does not) is never
1989
+ * written by another call: when a call makes the doc write such a leaf, it unbinds the node and
1990
+ * lists the leaf, and binding the node again hands it over. */
1991
+ ot_status ot_markdown_bind(ot_context *, const ot_handle *doc, uint32_t block_index,
1992
+ const ot_handle *text_node);
1993
+
1624
1994
  typedef struct ot_editor_viewport {
1625
1995
  uint32_t struct_size;
1626
1996
  uint32_t abi_version;
@@ -1646,7 +2016,10 @@ ot_status ot_editor_view_set_scroll_margin(ot_context *, const ot_handle *, floa
1646
2016
  #define OT_EDITOR_WRAP_MODE UINT32_C(5)
1647
2017
  #define OT_EDITOR_TAB_INDICATOR UINT32_C(6)
1648
2018
  /* argument is offset, OT_SCENE_WRAP_*, or Unicode scalar (0 disables) for the
1649
- * last three commands, and zero otherwise. */
2019
+ * last three commands, zero or OT_EDIT_ATOMIC for MOVE_UP/MOVE_DOWN, and zero otherwise. With
2020
+ * OT_EDIT_ATOMIC a move that lands in an atomic edit mark leaves it: nearer its start, one unit
2021
+ * before it (outside the marks there); nearer its end, past it and the marks that surround that
2022
+ * end. Down never ends at or before where it started, nor Up at or after it. */
1650
2023
  ot_status ot_editor_view_command(ot_context *, const ot_handle *, uint32_t command, uint32_t argument);
1651
2024
  /* Atomic selected delete-then-insert using native editor history and event order.
1652
2025
  * Without a selection inserts at the primary cursor. Input bytes are copied. */
@@ -1786,8 +2159,9 @@ ot_status ot_scene_set_editor_options(ot_context *, const ot_handle *node, const
1786
2159
 
1787
2160
  ot_status ot_image_destroy(ot_context *, const ot_handle *image);
1788
2161
 
2162
+ #define OT_IMAGE_ENCODED_BYTES_MAX UINT32_C(67108864)
1789
2163
  /* Image resources use Context allocation, I/O and handle capacity. Encoded inputs
1790
- * are limited to 64 MiB; dimensions to 16384 per axis and 25000000 pixels.
2164
+ * are limited to ENCODED_BYTES_MAX; dimensions to 16384 per axis and 25000000 pixels.
1791
2165
  * Inputs are copied during creation. Failed operations leave outputs unchanged.
1792
2166
  * Transform/clone/retain return independently releasable handles. Clone copies
1793
2167
  * pixels and encoded data; retain shares immutable storage within one Context.
@@ -2121,6 +2495,11 @@ ot_status ot_text_buffer_highlight(ot_context *, const ot_handle *, uint32_t ope
2121
2495
  uint32_t argument, const ot_edit_highlight *);
2122
2496
  ot_status ot_text_buffer_get_highlights(ot_context *, const ot_handle *, uint32_t line,
2123
2497
  ot_edit_highlight *, uint32_t capacity, uint32_t *out_count);
2498
+ /* Same arguments, validation, transaction and paint as ot_edit_buffer_set_layer. Appending
2499
+ * keeps the layers; set_text, set_styled_text, clear and the CLEAR_ALL highlight operation
2500
+ * empty them. */
2501
+ ot_status ot_text_buffer_set_layer(ot_context *, const ot_handle *, uint32_t layer_id,
2502
+ uint32_t start_byte, uint32_t end_byte, const ot_highlight_run *runs, uint32_t run_count);
2124
2503
  ot_status ot_text_buffer_view_set_viewport(ot_context *, const ot_handle *, const ot_editor_viewport *, uint32_t size_only);
2125
2504
  ot_status ot_text_buffer_view_command(ot_context *, const ot_handle *, uint32_t command, uint32_t argument);
2126
2505
  ot_status ot_text_buffer_view_set_tab_color(ot_context *, const ot_handle *, const uint16_t color[4]);
@@ -2308,6 +2687,14 @@ typedef struct ot_buffer_lease_snapshot {
2308
2687
  uint64_t reserved;
2309
2688
  } ot_buffer_lease_snapshot;
2310
2689
 
2690
+ /* Bits 31..30 of a char plane element (KIND_MASK) select its kind: 00 is a
2691
+ * Unicode scalar; IMAGE, GRAPHEME (a pooled grapheme's first cell) and
2692
+ * CONTINUATION (a later cell of a wide glyph) carry native payloads. */
2693
+ #define OT_CELL_CHAR_KIND_MASK UINT32_C(0xC0000000)
2694
+ #define OT_CELL_CHAR_IMAGE UINT32_C(0x40000000)
2695
+ #define OT_CELL_CHAR_GRAPHEME UINT32_C(0x80000000)
2696
+ #define OT_CELL_CHAR_CONTINUATION UINT32_C(0xC0000000)
2697
+
2311
2698
  /* Acquire local frame access for the exact retained DONE record. which is
2312
2699
  * OT_SESSION_BUFFER_CURRENT or NEXT. Both require this qualified operation while
2313
2700
  * a draft is live; ordinary Session draw, render, and borrowing cannot bypass it.
@@ -2353,15 +2740,16 @@ ot_status ot_scene_frame_commit(ot_context *, const ot_handle *session,
2353
2740
  #define OT_TERMINAL_HOST_MULTIPLEXER UINT32_C(128)
2354
2741
 
2355
2742
  /* flags is a combination of the eight OT_TERMINAL_* option bits above. Other bits
2356
- * must be zero. REPLY_SENTINEL ends the startup query packet with DA1 (CSI c),
2357
- * also inside tmux, and sends no other DA1; the host waits for its reply instead
2358
- * of a timer. A DA1 reply then also ends the startup cursor-report probes.
2743
+ * must be zero. REPLY_SENTINEL ends setup with DA1 (CSI c), after every other query,
2744
+ * also inside tmux, and sends no other DA1; the host waits for its reply instead of a
2745
+ * timer, and it ends the startup cursor reports. Otherwise the query packet ends with DA1.
2746
+ * Only an alternate screen of 3+ rows probes OSC 66 width, on row 2 after the switch.
2359
2747
  * Frames that paint are wrapped in synchronized output (DEC mode 2026) unless the terminal
2360
2748
  * is remote and, once its replies passed the 2026 query (a width-probe report
2361
2749
  * or DA1), either did not report the mode or HOST_MULTIPLEXER is set: the host
2362
2750
  * runs inside tmux, screen or Zellij between the app and the link.
2363
- * SYNC_ALWAYS or SYNC_NEVER (not both) forces the wrapper on or off. kitty_keyboard_flags accepts bits 0 through 4, or zero to disable
2364
- * Kitty keyboard. clear-on-close also controls surface clearing on suspend. It
2751
+ * SYNC_ALWAYS or SYNC_NEVER (not both) forces the wrapper on or off. kitty_keyboard_flags accepts OT_KITTY_KEYBOARD_* bits, or zero to
2752
+ * disable Kitty keyboard. clear-on-close also controls surface clearing on suspend. It
2365
2753
  * clears only a surface that setup or resume claimed: a close before their mode
2366
2754
  * packet leaves visible shell output in place. */
2367
2755
  typedef struct ot_session_terminal_options {
@@ -2371,6 +2759,15 @@ typedef struct ot_session_terminal_options {
2371
2759
  uint32_t kitty_keyboard_flags;
2372
2760
  } ot_session_terminal_options;
2373
2761
 
2762
+ /* Kitty keyboard protocol progressive-enhancement flags. */
2763
+ #define OT_KITTY_KEYBOARD_DISAMBIGUATE UINT32_C(1)
2764
+ #define OT_KITTY_KEYBOARD_EVENT_TYPES UINT32_C(2)
2765
+ #define OT_KITTY_KEYBOARD_ALTERNATE_KEYS UINT32_C(4)
2766
+ #define OT_KITTY_KEYBOARD_ALL_KEYS_AS_ESCAPES UINT32_C(8)
2767
+ #define OT_KITTY_KEYBOARD_REPORT_TEXT UINT32_C(16)
2768
+ #define OT_KITTY_KEYBOARD_ALL (OT_KITTY_KEYBOARD_DISAMBIGUATE | OT_KITTY_KEYBOARD_EVENT_TYPES | \
2769
+ OT_KITTY_KEYBOARD_ALTERNATE_KEYS | OT_KITTY_KEYBOARD_ALL_KEYS_AS_ESCAPES | OT_KITTY_KEYBOARD_REPORT_TEXT)
2770
+
2374
2771
  #define OT_CONTROL_CAPABILITY_RESPONSE UINT32_C(1)
2375
2772
  #define OT_CONTROL_TITLE UINT32_C(2)
2376
2773
  #define OT_CONTROL_MOUSE UINT32_C(3)
@@ -2382,10 +2779,16 @@ typedef struct ot_session_terminal_options {
2382
2779
  #define OT_CONTROL_RESET_BACKGROUND UINT32_C(9)
2383
2780
  #define OT_CONTROL_PALETTE_QUERY UINT32_C(10)
2384
2781
  #define OT_CONTROL_PROGRAM_STATUS UINT32_C(11)
2782
+ #define OT_CONTROL_END_REPLY_SENTINEL UINT32_C(12)
2385
2783
 
2386
2784
  /* argument is 0/1/2 (disabled/drag/motion) for MOUSE, 0..31 for Kitty flags,
2387
- * 0/1 for QUERY_PIXEL_RESOLUTION (1 appends the DA1 sentinel), and zero otherwise. CAPABILITY_RESPONSE, TITLE, CURSOR, PALETTE_QUERY, and
2388
- * PROGRAM_STATUS accept payload bytes. reserved must be zero. */
2785
+ * 0/1 for QUERY_PIXEL_RESOLUTION, QUERY_THEME_COLORS and PALETTE_QUERY (1 appends
2786
+ * the DA1 sentinel, after the validated palette queries in the same packet; a
2787
+ * tmux-wrapped query's replies trail tmux's own DA1, so it takes 0), and zero
2788
+ * otherwise. CAPABILITY_RESPONSE, TITLE, CURSOR, PALETTE_QUERY, and
2789
+ * PROGRAM_STATUS accept payload bytes. reserved must be zero. END_REPLY_SENTINEL,
2790
+ * accepted in every open phase, turns REPLY_SENTINEL off for good once a DA1
2791
+ * reply never came: later Kitty keyboard pushes send no CSI ? u query. */
2389
2792
  typedef struct ot_session_control_options {
2390
2793
  uint32_t struct_size;
2391
2794
  uint32_t abi_version;
@@ -2403,7 +2806,7 @@ typedef struct ot_session_control_options {
2403
2806
  /* CURSOR payload is exactly one copied ot_session_cursor_update, with native
2404
2807
  * byte order and no alignment requirement. fields selects updated properties;
2405
2808
  * other bits must be zero. x/y clamp to 1 and must not exceed 65536. visible and
2406
- * blinking are 0/1. style is 0=block, 1=line, 2=underline, 3=default. mouse_pointer
2809
+ * blinking are 0/1. style is an OT_CURSOR_STYLE_* value. mouse_pointer
2407
2810
  * is an OT_MOUSE_POINTER_* shape. Color uses the packed RGBA lanes. Unselected
2408
2811
  * fields must be zero. */
2409
2812
  typedef struct ot_session_cursor_update {
@@ -2652,6 +3055,7 @@ typedef struct ot_session_pump_result {
2652
3055
  #define OT_INPUT_EXPECT_KITTY_KEYBOARD UINT32_C(2)
2653
3056
  #define OT_INPUT_EXPECT_CURSOR_POSITION UINT32_C(4)
2654
3057
  #define OT_INPUT_EXPECT_SENTINEL UINT32_C(8)
3058
+ #define OT_INPUT_EXPECT_ESCAPE_PREFIX UINT32_C(16)
2655
3059
 
2656
3060
  #define OT_INPUT_EVENTS_MIN UINT32_C(4)
2657
3061
  #define OT_INPUT_PAYLOAD_BYTES_MIN UINT32_C(4384)
@@ -2727,6 +3131,7 @@ typedef struct ot_context_error {
2727
3131
 
2728
3132
  #define OT_DIAGNOSTIC_MESSAGE_BYTES UINT32_C(4096)
2729
3133
  #define OT_DIAGNOSTIC_TRUNCATED UINT32_C(1)
3134
+ #define OT_DIAGNOSTIC_QUEUE_MAX UINT32_C(64)
2730
3135
 
2731
3136
  /* Copied diagnostic record. level is 0 (error), 1 (warning), 2 (info), or
2732
3137
  * 3 (debug). message_len counts bytes, not a terminating NUL. Unused message
@@ -2776,7 +3181,7 @@ ot_status ot_context_destroy(ot_context *context);
2776
3181
  ot_status ot_context_get_last_error(ot_context *context, ot_context_error *out_error);
2777
3182
 
2778
3183
  /* Copy up to capacity records in arrival order without allocation or callbacks.
2779
- * Version 2 C contexts hold at most 64 records and drop newest on overflow.
3184
+ * Version 2 C contexts hold at most OT_DIAGNOSTIC_QUEUE_MAX records and drop newest on overflow.
2780
3185
  * records may be NULL only when capacity is zero. A zero-capacity drain reports
2781
3186
  * queue pressure without removing records. out_drain must have the exact size
2782
3187
  * and version. The caller owns both outputs for the call. Outputs and queued
@@ -2940,6 +3345,7 @@ ot_status ot_buffer_color_matrix(ot_context *, const ot_handle *, const ot_scene
2940
3345
  #define OT_SCENE_RECORD_SCENE_BODY UINT32_C(10)
2941
3346
  #define OT_SCENE_RECORD_IMAGE UINT32_C(11)
2942
3347
  #define OT_SCENE_RECORD_UNICODE UINT32_C(12)
3348
+ #define OT_SCENE_RECORD_CELLS UINT32_C(13)
2943
3349
  #define OT_SCENE_RECORD_GRAYSCALE_FOREGROUND UINT32_C(1)
2944
3350
  #define OT_SCENE_RECORD_GRAYSCALE_BACKGROUND UINT32_C(2)
2945
3351
  #define OT_SCENE_RECORD_GRAYSCALE_SUPERSAMPLED UINT32_C(4)
@@ -3060,6 +3466,25 @@ typedef struct ot_scene_record_unicode {
3060
3466
  uint16_t background[4];
3061
3467
  } ot_scene_record_unicode;
3062
3468
 
3469
+ /* One cell of a CELLS record, with the fields of ot_buffer_draw_cell. */
3470
+ typedef struct ot_scene_cell {
3471
+ uint32_t character;
3472
+ uint32_t attributes;
3473
+ uint16_t foreground[4];
3474
+ uint16_t background[4];
3475
+ } ot_scene_cell;
3476
+
3477
+ /* Followed by count ot_scene_cell records, in rows of width cells from (x, y).
3478
+ * Each cell draws as an OT_BUFFER_DRAW_CELL_BLEND record at its position would,
3479
+ * in order. width must be nonzero. */
3480
+ typedef struct ot_scene_record_cells {
3481
+ ot_scene_record_header header;
3482
+ int32_t x;
3483
+ int32_t y;
3484
+ uint32_t width;
3485
+ uint32_t count;
3486
+ } ot_scene_record_cells;
3487
+
3063
3488
  /* Retain one offscreen storage generation under the same limits and raw-plane
3064
3489
  * restrictions as Session leases. The snapshot requires exact size/version and
3065
3490
  * zero reserved. Rejection leaves it unchanged and acquires no lease. */
@@ -3267,7 +3692,8 @@ ot_status ot_session_set_palette_state(ot_context *, const ot_handle *,
3267
3692
  const uint16_t *background, uint32_t epoch);
3268
3693
 
3269
3694
  /* Notifications reuse terminal protocol selection and ordinary output capacity.
3270
- * Unsupported capability or rejected output returns out_written=0. Message and
3695
+ * Unsupported capability, text that is not UTF-8, or rejected output returns
3696
+ * out_written=0; C0, DEL, and C1 controls in the text become spaces. Message and
3271
3697
  * optional title are consumed only during this call; NULL requires zero length. */
3272
3698
  ot_status ot_session_notification(ot_context *, const ot_handle *,
3273
3699
  const uint8_t *message, uint32_t message_len, const uint8_t *title,
@@ -3301,7 +3727,8 @@ ot_status ot_session_pump(
3301
3727
  * at least OT_INPUT_EVENTS_MIN and payload_capacity at least
3302
3728
  * OT_INPUT_PAYLOAD_BYTES_MIN; the call consumes input until either runs low and
3303
3729
  * reports consumed. A bracketed paste arrives as one or more PASTE records from
3304
- * START to END. Records and payload are borrowed for the call and never retained.
3730
+ * START to END; a start marker cut by the timeout waits for a feed that begins with its
3731
+ * rest and more bytes. Records and payload are borrowed for the call and never retained.
3305
3732
  * bytes, records, payload, and out_drain must not overlap.
3306
3733
  * Accepted in any open session state; closing, closed, failed, and cancelled
3307
3734
  * sessions reject. A rejected call leaves out_drain, the records, and parser
@@ -3335,6 +3762,15 @@ ot_status ot_session_input_feed(
3335
3762
  * reply; another byte ends either one and is typed. A lone Escape still times
3336
3763
  * out, and a reply that follows it is not typed; if what follows that Escape is
3337
3764
  * cut before it matches a reply, its introducer is typed. KEEP_REPLY also keeps such a CSI.
3765
+ * ESCAPE_PREFIX, which implies KITTY_KEYBOARD, means the terminal confirmed
3766
+ * Kitty disambiguate or report-all keys, so no unit has a deadline. A raw ESC and the byte after it in the same
3767
+ * 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
3768
+ * feed, however late, begins with [ and a byte that begins a CSI such a terminal sends (a digit, ?, >, <, or one of
3769
+ * ABCDEFHIOPQS), the CSI is kept whole and is never a key; _G begins a Kitty graphics reply, kept whole once that
3770
+ * feed matches its key= prefix and typed otherwise; other bytes are typed. With SENTINEL, an OSC, DCS, or APC
3771
+ * introducer or a lone [ after that Escape is recovered as after a timeout until SENTINEL is cleared.
3772
+ * A session with a renderer sets it itself once the terminal answers the CSI ? u
3773
+ * query that follows its current push (only with OT_TERMINAL_REPLY_SENTINEL).
3338
3774
  * Changing flags emits nothing; the next feed resolves a unit that may no longer wait. */
3339
3775
  ot_status ot_session_input_expect(ot_context *context, const ot_handle *session, uint32_t flags);
3340
3776
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentui/core-darwin-arm64",
3
- "version": "0.8.4",
3
+ "version": "0.9.0",
4
4
  "description": "Prebuilt darwin-arm64 binaries for @opentui/core",
5
5
  "type": "module",
6
6
  "main": "index.js",