Skip to content

Commit 56d4e70

Browse files
Merge pull request #202 from RtlZeroMemory/release/alpha-40
chore(release): bump Zireael vendor and prepare alpha.40
2 parents 0b3d790 + c93920b commit 56d4e70

27 files changed

+525
-208
lines changed

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,27 @@ The format is based on Keep a Changelog and the project follows Semantic Version
66

77
## [Unreleased]
88

9+
## [0.1.0-alpha.40] - 2026-02-25
10+
11+
### Bug Fixes
12+
13+
- **native/vendor**: Bumped vendored Zireael engine to `v1.3.8-alpha.7` (`8d8b5f8`) and synchronized `packages/native/vendor` sources.
14+
- **runtime/errors**: Hardened dev warning paths for swallowed callback exceptions, including safe thrown-value formatting in catch blocks.
15+
- **runtime/ids**: Strengthened widget ID validation; whitespace-only interactive IDs are now rejected deterministically.
16+
- **collections**: `each()` / `eachInline()` now detect duplicate keys at construction time with deterministic diagnostics.
17+
- **forms**: Async form validation no longer applies canceled/stale rejection results and now preserves actionable wrapped error context.
18+
- **router**: Hardened route guard error handling and param validation paths.
19+
- **keybindings**: Added max chord length enforcement and duplicate keybinding warnings.
20+
21+
### Merged Pull Requests
22+
23+
- [#195](https://github.com/RtlZeroMemory/Rezi/pull/195) fix(core): dev-mode warnings for silently swallowed callback errors
24+
- [#196](https://github.com/RtlZeroMemory/Rezi/pull/196) fix(core): harden widget ID validation and view function return checks
25+
- [#197](https://github.com/RtlZeroMemory/Rezi/pull/197) fix(core): detect duplicate keys in each()/eachInline() at construction time
26+
- [#198](https://github.com/RtlZeroMemory/Rezi/pull/198) fix(core): stop swallowing async form validation errors
27+
- [#199](https://github.com/RtlZeroMemory/Rezi/pull/199) fix(core): harden router guard error handling and param validation
28+
- [#200](https://github.com/RtlZeroMemory/Rezi/pull/200) fix(core): add max chord length and duplicate keybinding warnings
29+
930
## [0.1.0-alpha.39] - 2026-02-24
1031

1132
### Bug Fixes
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7ec5c0d5e8ecc3e4bb8261685aeab039fa02816b
1+
8d8b5f8687b04ee3aaed6b133948724a595a9886

packages/native/vendor/zireael/include/zr/zr_debug.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818

1919
#include <stdint.h>
2020

21+
#define ZR_DEBUG_SOURCE_FILE_LEN 32u
22+
#define ZR_DEBUG_MESSAGE_LEN 64u
23+
2124
/*
2225
Debug record categories.
2326
@@ -111,11 +114,11 @@ typedef struct zr_debug_error_record_t {
111114
source_file: 32-byte fixed buffer for source file name (truncated).
112115
Why: Avoids pointer indirection while providing actionable context.
113116
*/
114-
char source_file[32];
117+
char source_file[ZR_DEBUG_SOURCE_FILE_LEN];
115118
/*
116119
message: 64-byte fixed buffer for error message (truncated).
117120
*/
118-
char message[64];
121+
char message[ZR_DEBUG_MESSAGE_LEN];
119122
} zr_debug_error_record_t;
120123

121124
/*

packages/native/vendor/zireael/include/zr/zr_drawlist.h

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ typedef enum zr_dl_opcode_t {
6767
ZR_DL_OP_DRAW_IMAGE = 9
6868
} zr_dl_opcode_t;
6969

70+
/*
71+
Sub-cell blitter selector for DRAW_CANVAS / image fallback paths.
72+
73+
A "blitter" maps RGBA pixels onto terminal cell glyph/style combinations.
74+
*/
7075
typedef enum zr_blitter_t {
7176
ZR_BLIT_AUTO = 0, /* engine selects based on capability policy */
7277
ZR_BLIT_PIXEL = 1, /* reserved for graphics protocol path */
@@ -77,6 +82,36 @@ typedef enum zr_blitter_t {
7782
ZR_BLIT_ASCII = 6 /* 1x1 space+background fallback */
7883
} zr_blitter_t;
7984

85+
typedef enum zr_dl_cursor_shape_t {
86+
ZR_DL_CURSOR_BLOCK = 0,
87+
ZR_DL_CURSOR_UNDERLINE = 1,
88+
ZR_DL_CURSOR_BAR = 2
89+
} zr_dl_cursor_shape_t;
90+
91+
typedef enum zr_dl_draw_image_format_t {
92+
ZR_DL_DRAW_IMAGE_FORMAT_RGBA = 0,
93+
ZR_DL_DRAW_IMAGE_FORMAT_PNG = 1
94+
} zr_dl_draw_image_format_t;
95+
96+
typedef enum zr_dl_draw_image_protocol_t {
97+
ZR_DL_DRAW_IMAGE_PROTOCOL_AUTO = 0,
98+
ZR_DL_DRAW_IMAGE_PROTOCOL_KITTY = 1,
99+
ZR_DL_DRAW_IMAGE_PROTOCOL_SIXEL = 2,
100+
ZR_DL_DRAW_IMAGE_PROTOCOL_ITERM2 = 3
101+
} zr_dl_draw_image_protocol_t;
102+
103+
typedef enum zr_dl_draw_image_z_layer_t {
104+
ZR_DL_DRAW_IMAGE_Z_BACK = -1,
105+
ZR_DL_DRAW_IMAGE_Z_NORMAL = 0,
106+
ZR_DL_DRAW_IMAGE_Z_FRONT = 1
107+
} zr_dl_draw_image_z_layer_t;
108+
109+
typedef enum zr_dl_draw_image_fit_mode_t {
110+
ZR_DL_DRAW_IMAGE_FIT_FILL = 0,
111+
ZR_DL_DRAW_IMAGE_FIT_CONTAIN = 1,
112+
ZR_DL_DRAW_IMAGE_FIT_COVER = 2
113+
} zr_dl_draw_image_fit_mode_t;
114+
80115
typedef struct zr_dl_style_t {
81116
uint32_t fg;
82117
uint32_t bg;
@@ -161,7 +196,7 @@ typedef struct zr_dl_text_run_segment_v3_t {
161196
typedef struct zr_dl_cmd_set_cursor_t {
162197
int32_t x; /* 0-based cell; -1 means "leave unchanged" */
163198
int32_t y; /* 0-based cell; -1 means "leave unchanged" */
164-
uint8_t shape; /* 0=block, 1=underline, 2=bar */
199+
uint8_t shape; /* zr_dl_cursor_shape_t */
165200
uint8_t visible; /* 0/1 */
166201
uint8_t blink; /* 0/1 */
167202
uint8_t reserved0; /* must be 0 */
@@ -191,10 +226,10 @@ typedef struct zr_dl_cmd_draw_image_t {
191226
uint32_t blob_offset; /* byte offset inside drawlist blob-bytes section */
192227
uint32_t blob_len; /* payload bytes */
193228
uint32_t image_id; /* stable image key for protocol cache reuse */
194-
uint8_t format; /* 0=RGBA, 1=PNG */
195-
uint8_t protocol; /* 0=auto, 1=kitty, 2=sixel, 3=iterm2 */
196-
int8_t z_layer; /* -1, 0, 1 */
197-
uint8_t fit_mode; /* 0=fill, 1=contain, 2=cover */
229+
uint8_t format; /* zr_dl_draw_image_format_t */
230+
uint8_t protocol; /* zr_dl_draw_image_protocol_t */
231+
int8_t z_layer; /* zr_dl_draw_image_z_layer_t */
232+
uint8_t fit_mode; /* zr_dl_draw_image_fit_mode_t */
198233
uint8_t flags; /* reserved; must be 0 */
199234
uint8_t reserved0; /* reserved; must be 0 */
200235
uint16_t reserved1; /* reserved; must be 0 */

packages/native/vendor/zireael/include/zr/zr_event.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,17 @@ typedef enum zr_event_type_t {
6060
#define ZR_MOD_ALT (1u << 2u)
6161
#define ZR_MOD_META (1u << 3u)
6262

63+
/*
64+
Stable key-code allocation map (ABI contract):
65+
- 1..4 : basic editing/navigation keys
66+
- 10..15 : insert/delete/home/end/page navigation
67+
- 20..23 : arrow keys
68+
- 30..31 : focus in/out pseudo-keys
69+
- 100+ : function keys (F1..)
70+
71+
Why: Values are intentionally sparse to preserve room for future additions
72+
without renumbering existing keys.
73+
*/
6374
typedef enum zr_key_t {
6475
ZR_KEY_UNKNOWN = 0,
6576

packages/native/vendor/zireael/include/zr/zr_terminal_caps.h

Lines changed: 45 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
#include <stdint.h>
1515

16+
#define ZR_TERMINAL_VERSION_LEN 64u
17+
1618
typedef enum zr_terminal_id_t {
1719
ZR_TERM_UNKNOWN = 0,
1820
ZR_TERM_KITTY,
@@ -34,27 +36,51 @@ typedef enum zr_terminal_id_t {
3436

3537
typedef uint32_t zr_terminal_cap_flags_t;
3638

39+
/*
40+
Capability bit layout (zr_terminal_cap_flags_t):
41+
bits 0..9 : extended profile capabilities
42+
bits 10..17 : legacy/backend caps also reflected by engine_get_caps()
43+
*/
44+
#define ZR_TERM_CAP_BIT_SIXEL 0u
45+
#define ZR_TERM_CAP_BIT_KITTY_GRAPHICS 1u
46+
#define ZR_TERM_CAP_BIT_ITERM2_IMAGES 2u
47+
#define ZR_TERM_CAP_BIT_UNDERLINE_STYLES 3u
48+
#define ZR_TERM_CAP_BIT_COLORED_UNDERLINES 4u
49+
#define ZR_TERM_CAP_BIT_HYPERLINKS 5u
50+
#define ZR_TERM_CAP_BIT_GRAPHEME_CLUSTERS 6u
51+
#define ZR_TERM_CAP_BIT_OVERLINE 7u
52+
#define ZR_TERM_CAP_BIT_PIXEL_MOUSE 8u
53+
#define ZR_TERM_CAP_BIT_KITTY_KEYBOARD 9u
54+
#define ZR_TERM_CAP_BIT_MOUSE 10u
55+
#define ZR_TERM_CAP_BIT_BRACKETED_PASTE 11u
56+
#define ZR_TERM_CAP_BIT_FOCUS_EVENTS 12u
57+
#define ZR_TERM_CAP_BIT_OSC52 13u
58+
#define ZR_TERM_CAP_BIT_SYNC_UPDATE 14u
59+
#define ZR_TERM_CAP_BIT_SCROLL_REGION 15u
60+
#define ZR_TERM_CAP_BIT_CURSOR_SHAPE 16u
61+
#define ZR_TERM_CAP_BIT_OUTPUT_WAIT_WRITABLE 17u
62+
3763
/* --- Extended terminal capability flags (for profile + force/suppress overrides) --- */
38-
#define ZR_TERM_CAP_SIXEL ((zr_terminal_cap_flags_t)(1u << 0u))
39-
#define ZR_TERM_CAP_KITTY_GRAPHICS ((zr_terminal_cap_flags_t)(1u << 1u))
40-
#define ZR_TERM_CAP_ITERM2_IMAGES ((zr_terminal_cap_flags_t)(1u << 2u))
41-
#define ZR_TERM_CAP_UNDERLINE_STYLES ((zr_terminal_cap_flags_t)(1u << 3u))
42-
#define ZR_TERM_CAP_COLORED_UNDERLINES ((zr_terminal_cap_flags_t)(1u << 4u))
43-
#define ZR_TERM_CAP_HYPERLINKS ((zr_terminal_cap_flags_t)(1u << 5u))
44-
#define ZR_TERM_CAP_GRAPHEME_CLUSTERS ((zr_terminal_cap_flags_t)(1u << 6u))
45-
#define ZR_TERM_CAP_OVERLINE ((zr_terminal_cap_flags_t)(1u << 7u))
46-
#define ZR_TERM_CAP_PIXEL_MOUSE ((zr_terminal_cap_flags_t)(1u << 8u))
47-
#define ZR_TERM_CAP_KITTY_KEYBOARD ((zr_terminal_cap_flags_t)(1u << 9u))
64+
#define ZR_TERM_CAP_SIXEL ((zr_terminal_cap_flags_t)(1u << ZR_TERM_CAP_BIT_SIXEL))
65+
#define ZR_TERM_CAP_KITTY_GRAPHICS ((zr_terminal_cap_flags_t)(1u << ZR_TERM_CAP_BIT_KITTY_GRAPHICS))
66+
#define ZR_TERM_CAP_ITERM2_IMAGES ((zr_terminal_cap_flags_t)(1u << ZR_TERM_CAP_BIT_ITERM2_IMAGES))
67+
#define ZR_TERM_CAP_UNDERLINE_STYLES ((zr_terminal_cap_flags_t)(1u << ZR_TERM_CAP_BIT_UNDERLINE_STYLES))
68+
#define ZR_TERM_CAP_COLORED_UNDERLINES ((zr_terminal_cap_flags_t)(1u << ZR_TERM_CAP_BIT_COLORED_UNDERLINES))
69+
#define ZR_TERM_CAP_HYPERLINKS ((zr_terminal_cap_flags_t)(1u << ZR_TERM_CAP_BIT_HYPERLINKS))
70+
#define ZR_TERM_CAP_GRAPHEME_CLUSTERS ((zr_terminal_cap_flags_t)(1u << ZR_TERM_CAP_BIT_GRAPHEME_CLUSTERS))
71+
#define ZR_TERM_CAP_OVERLINE ((zr_terminal_cap_flags_t)(1u << ZR_TERM_CAP_BIT_OVERLINE))
72+
#define ZR_TERM_CAP_PIXEL_MOUSE ((zr_terminal_cap_flags_t)(1u << ZR_TERM_CAP_BIT_PIXEL_MOUSE))
73+
#define ZR_TERM_CAP_KITTY_KEYBOARD ((zr_terminal_cap_flags_t)(1u << ZR_TERM_CAP_BIT_KITTY_KEYBOARD))
4874

4975
/* --- Legacy/backend caps exposed through engine_get_caps() --- */
50-
#define ZR_TERM_CAP_MOUSE ((zr_terminal_cap_flags_t)(1u << 10u))
51-
#define ZR_TERM_CAP_BRACKETED_PASTE ((zr_terminal_cap_flags_t)(1u << 11u))
52-
#define ZR_TERM_CAP_FOCUS_EVENTS ((zr_terminal_cap_flags_t)(1u << 12u))
53-
#define ZR_TERM_CAP_OSC52 ((zr_terminal_cap_flags_t)(1u << 13u))
54-
#define ZR_TERM_CAP_SYNC_UPDATE ((zr_terminal_cap_flags_t)(1u << 14u))
55-
#define ZR_TERM_CAP_SCROLL_REGION ((zr_terminal_cap_flags_t)(1u << 15u))
56-
#define ZR_TERM_CAP_CURSOR_SHAPE ((zr_terminal_cap_flags_t)(1u << 16u))
57-
#define ZR_TERM_CAP_OUTPUT_WAIT_WRITABLE ((zr_terminal_cap_flags_t)(1u << 17u))
76+
#define ZR_TERM_CAP_MOUSE ((zr_terminal_cap_flags_t)(1u << ZR_TERM_CAP_BIT_MOUSE))
77+
#define ZR_TERM_CAP_BRACKETED_PASTE ((zr_terminal_cap_flags_t)(1u << ZR_TERM_CAP_BIT_BRACKETED_PASTE))
78+
#define ZR_TERM_CAP_FOCUS_EVENTS ((zr_terminal_cap_flags_t)(1u << ZR_TERM_CAP_BIT_FOCUS_EVENTS))
79+
#define ZR_TERM_CAP_OSC52 ((zr_terminal_cap_flags_t)(1u << ZR_TERM_CAP_BIT_OSC52))
80+
#define ZR_TERM_CAP_SYNC_UPDATE ((zr_terminal_cap_flags_t)(1u << ZR_TERM_CAP_BIT_SYNC_UPDATE))
81+
#define ZR_TERM_CAP_SCROLL_REGION ((zr_terminal_cap_flags_t)(1u << ZR_TERM_CAP_BIT_SCROLL_REGION))
82+
#define ZR_TERM_CAP_CURSOR_SHAPE ((zr_terminal_cap_flags_t)(1u << ZR_TERM_CAP_BIT_CURSOR_SHAPE))
83+
#define ZR_TERM_CAP_OUTPUT_WAIT_WRITABLE ((zr_terminal_cap_flags_t)(1u << ZR_TERM_CAP_BIT_OUTPUT_WAIT_WRITABLE))
5884

5985
#define ZR_TERM_CAP_ALL_MASK \
6086
((zr_terminal_cap_flags_t)(ZR_TERM_CAP_SIXEL | ZR_TERM_CAP_KITTY_GRAPHICS | ZR_TERM_CAP_ITERM2_IMAGES | \
@@ -76,7 +102,7 @@ typedef struct zr_terminal_profile_t {
76102
zr_terminal_id_t id;
77103
uint8_t _pad0[3];
78104

79-
char version_string[64];
105+
char version_string[ZR_TERMINAL_VERSION_LEN];
80106

81107
uint8_t supports_sixel;
82108
uint8_t supports_kitty_graphics;

packages/native/vendor/zireael/src/core/zr_base64.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,17 @@ size_t zr_base64_encoded_size(size_t in_len, uint8_t* out_overflow) {
4646
}
4747

4848
static void zr_base64_encode_triplet(const uint8_t src[3], uint8_t out[4]) {
49-
out[0] = ZR_BASE64_ALPHABET[(uint8_t)(src[0] >> 2u)];
50-
out[1] = ZR_BASE64_ALPHABET[(uint8_t)(((src[0] & 0x03u) << 4u) | (src[1] >> 4u))];
51-
out[2] = ZR_BASE64_ALPHABET[(uint8_t)(((src[1] & 0x0Fu) << 2u) | (src[2] >> 6u))];
52-
out[3] = ZR_BASE64_ALPHABET[(uint8_t)(src[2] & 0x3Fu)];
49+
const uint8_t idx0 = (uint8_t)(src[0] >> 2u);
50+
const uint8_t idx1_hi = (uint8_t)((src[0] & 0x03u) << 4u);
51+
const uint8_t idx1_lo = (uint8_t)(src[1] >> 4u);
52+
const uint8_t idx2_hi = (uint8_t)((src[1] & 0x0Fu) << 2u);
53+
const uint8_t idx2_lo = (uint8_t)(src[2] >> 6u);
54+
const uint8_t idx3 = (uint8_t)(src[2] & 0x3Fu);
55+
56+
out[0] = ZR_BASE64_ALPHABET[idx0];
57+
out[1] = ZR_BASE64_ALPHABET[(uint8_t)(idx1_hi | idx1_lo)];
58+
out[2] = ZR_BASE64_ALPHABET[(uint8_t)(idx2_hi | idx2_lo)];
59+
out[3] = ZR_BASE64_ALPHABET[idx3];
5360
}
5461

5562
/* Encode input bytes with deterministic padding behavior. */

packages/native/vendor/zireael/src/core/zr_blit.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,10 @@ uint8_t zr_blit_alpha_is_opaque(uint8_t alpha) {
115115
}
116116

117117
uint32_t zr_blit_pack_rgb(uint8_t r, uint8_t g, uint8_t b) {
118-
return ((uint32_t)r << 16u) | ((uint32_t)g << 8u) | (uint32_t)b;
118+
const uint32_t rr = ((uint32_t)r << 16u);
119+
const uint32_t gg = ((uint32_t)g << 8u);
120+
const uint32_t bb = (uint32_t)b;
121+
return rr | gg | bb;
119122
}
120123

121124
static uint8_t zr_blit_rgb_r(uint32_t rgb) {

packages/native/vendor/zireael/src/core/zr_blit_braille.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@
99

1010
static const uint8_t ZR_BRAILLE_BIT_MAP[4][2] = {{0u, 3u}, {1u, 4u}, {2u, 5u}, {6u, 7u}};
1111

12+
enum {
13+
ZR_UTF8_3BYTE_LEAD = 0xE0u,
14+
ZR_UTF8_CONT_BYTE = 0x80u,
15+
ZR_UTF8_3BYTE_MASK = 0x0Fu,
16+
ZR_UTF8_CONT_MASK = 0x3Fu,
17+
};
18+
1219
static uint32_t zr_blit_braille_cell_bg(const zr_fb_painter_t* painter, int32_t x, int32_t y) {
1320
const zr_cell_t* c = zr_fb_cell_const(painter->fb, (uint32_t)x, (uint32_t)y);
1421
if (!c) {
@@ -19,10 +26,13 @@ static uint32_t zr_blit_braille_cell_bg(const zr_fb_painter_t* painter, int32_t
1926

2027
static zr_blit_glyph_t zr_blit_braille_glyph(uint8_t pattern) {
2128
const uint32_t cp = 0x2800u + (uint32_t)pattern;
29+
const uint8_t top = (uint8_t)((cp >> 12u) & ZR_UTF8_3BYTE_MASK);
30+
const uint8_t mid = (uint8_t)((cp >> 6u) & ZR_UTF8_CONT_MASK);
31+
const uint8_t low = (uint8_t)(cp & ZR_UTF8_CONT_MASK);
2232
zr_blit_glyph_t g;
23-
g.bytes[0] = (uint8_t)(0xE0u | ((cp >> 12u) & 0x0Fu));
24-
g.bytes[1] = (uint8_t)(0x80u | ((cp >> 6u) & 0x3Fu));
25-
g.bytes[2] = (uint8_t)(0x80u | (cp & 0x3Fu));
33+
g.bytes[0] = (uint8_t)(ZR_UTF8_3BYTE_LEAD | top);
34+
g.bytes[1] = (uint8_t)(ZR_UTF8_CONT_BYTE | mid);
35+
g.bytes[2] = (uint8_t)(ZR_UTF8_CONT_BYTE | low);
2636
g.bytes[3] = 0u;
2737
g.len = 3u;
2838
g._pad0[0] = 0u;

packages/native/vendor/zireael/src/core/zr_diff.c

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "core/zr_diff.h"
99

1010
#include "util/zr_checked.h"
11+
#include "util/zr_macros.h"
1112
#include "util/zr_string_builder.h"
1213

1314
#include <stdbool.h>
@@ -93,6 +94,15 @@ static const uint8_t ZR_ANSI16_PALETTE[16][3] = {
9394
#define ZR_ASCII_ST_FINAL ((uint8_t)'\\')
9495
#define ZR_ASCII_DEL 0x7Fu
9596

97+
/*
98+
VT CSI introducer (ESC '[').
99+
100+
Reference: ECMA-48 / ISO-6429 control sequence syntax used by VT100/xterm.
101+
*/
102+
static bool zr_diff_write_csi(zr_sb_t* sb) {
103+
return zr_sb_write_u8(sb, ZR_ASCII_ESC) && zr_sb_write_u8(sb, (uint8_t)'[');
104+
}
105+
96106
/* Adaptive sweep threshold tuning (dirty-row density, percent). */
97107
#define ZR_DIFF_SWEEP_DIRTY_LINE_PCT_BASE 35u
98108
#define ZR_DIFF_SWEEP_DIRTY_LINE_PCT_WIDE_FRAME 30u
@@ -584,8 +594,7 @@ static bool zr_emit_cup(zr_sb_t* sb, zr_term_state_t* ts, uint32_t x, uint32_t y
584594
if (zr_term_cursor_pos_is_valid(ts) && ts->cursor_x == x && ts->cursor_y == y) {
585595
return true;
586596
}
587-
const uint8_t esc = 0x1Bu;
588-
if (!zr_sb_write_u8(sb, esc) || !zr_sb_write_u8(sb, (uint8_t)'[')) {
597+
if (!zr_diff_write_csi(sb)) {
589598
return false;
590599
}
591600
if (!zr_sb_write_u32_dec(sb, y + 1u) || !zr_sb_write_u8(sb, (uint8_t)';') || !zr_sb_write_u32_dec(sb, x + 1u) ||
@@ -648,8 +657,8 @@ static bool zr_emit_cursor_shape(zr_sb_t* sb, zr_term_state_t* ts, uint8_t shape
648657
}
649658

650659
const uint32_t ps = zr_cursor_shape_ps(shape, blink);
651-
if (!zr_sb_write_u8(sb, 0x1Bu) || !zr_sb_write_u8(sb, (uint8_t)'[') || !zr_sb_write_u32_dec(sb, ps) ||
652-
!zr_sb_write_u8(sb, (uint8_t)' ') || !zr_sb_write_u8(sb, (uint8_t)'q')) {
660+
if (!zr_diff_write_csi(sb) || !zr_sb_write_u32_dec(sb, ps) || !zr_sb_write_u8(sb, (uint8_t)' ') ||
661+
!zr_sb_write_u8(sb, (uint8_t)'q')) {
653662
return false;
654663
}
655664

@@ -831,20 +840,20 @@ static bool zr_emit_sgr_absolute(zr_sb_t* sb, zr_term_state_t* ts, zr_style_t de
831840
return true;
832841
}
833842

834-
if (!zr_sb_write_u8(sb, 0x1Bu) || !zr_sb_write_u8(sb, (uint8_t)'[') || !zr_sb_write_u32_dec(sb, ZR_SGR_RESET)) {
843+
if (!zr_diff_write_csi(sb) || !zr_sb_write_u32_dec(sb, ZR_SGR_RESET)) {
835844
return false;
836845
}
837846

838847
if (!zr_emit_sgr_attr_params(sb, desired.attrs, ZR_SGR_ATTRS_PRE_UNDERLINE,
839-
sizeof(ZR_SGR_ATTRS_PRE_UNDERLINE) / sizeof(ZR_SGR_ATTRS_PRE_UNDERLINE[0]))) {
848+
ZR_ARRAYLEN(ZR_SGR_ATTRS_PRE_UNDERLINE))) {
840849
return false;
841850
}
842851
if ((desired.attrs & ZR_STYLE_ATTR_UNDERLINE) != 0u &&
843852
(!zr_sb_write_u8(sb, (uint8_t)';') || !zr_emit_sgr_underline_style_param(sb, desired, caps))) {
844853
return false;
845854
}
846855
if (!zr_emit_sgr_attr_params(sb, desired.attrs, ZR_SGR_ATTRS_POST_UNDERLINE,
847-
sizeof(ZR_SGR_ATTRS_POST_UNDERLINE) / sizeof(ZR_SGR_ATTRS_POST_UNDERLINE[0]))) {
856+
ZR_ARRAYLEN(ZR_SGR_ATTRS_POST_UNDERLINE))) {
848857
return false;
849858
}
850859
if (desired_has_underline_color &&
@@ -1320,7 +1329,7 @@ static bool zr_emit_decstbm(zr_sb_t* sb, zr_term_state_t* ts, uint32_t top, uint
13201329
if (!sb || !ts) {
13211330
return false;
13221331
}
1323-
if (!zr_sb_write_u8(sb, 0x1Bu) || !zr_sb_write_u8(sb, (uint8_t)'[')) {
1332+
if (!zr_diff_write_csi(sb)) {
13241333
return false;
13251334
}
13261335
if (!zr_sb_write_u32_dec(sb, top + 1u) || !zr_sb_write_u8(sb, (uint8_t)';') ||
@@ -1341,7 +1350,7 @@ static bool zr_emit_scroll_op(zr_sb_t* sb, zr_term_state_t* ts, bool up, uint32_
13411350
if (lines == 0u) {
13421351
return true;
13431352
}
1344-
if (!zr_sb_write_u8(sb, 0x1Bu) || !zr_sb_write_u8(sb, (uint8_t)'[')) {
1353+
if (!zr_diff_write_csi(sb)) {
13451354
return false;
13461355
}
13471356
if (!zr_sb_write_u32_dec(sb, lines) || !zr_sb_write_u8(sb, up ? (uint8_t)'S' : (uint8_t)'T')) {
@@ -1354,7 +1363,7 @@ static bool zr_emit_decstbm_reset(zr_sb_t* sb, zr_term_state_t* ts) {
13541363
if (!sb || !ts) {
13551364
return false;
13561365
}
1357-
if (!zr_sb_write_u8(sb, 0x1Bu) || !zr_sb_write_u8(sb, (uint8_t)'[') || !zr_sb_write_u8(sb, (uint8_t)'r')) {
1366+
if (!zr_diff_write_csi(sb) || !zr_sb_write_u8(sb, (uint8_t)'r')) {
13581367
return false;
13591368
}
13601369
ts->cursor_x = 0u;

0 commit comments

Comments
 (0)