xonecas.io
79113
Ma

mini-coding-agent / commit 384f652

fix(tui): big pass fixng terminal render issues

xonecas2026-10-07 384f652e6a6c4c498f04352dcc0b06dd53db11c5 parent de76c76

7 files changed

This diff is too big to show in full. The first 1000 lines are below, and every file is listed with its counts.

notes.md+55βˆ’1
@@ -27,7 +27,7 @@ I suggest the above structure, so we match the work we did for opencode. Basical
2727 Another note here is that again, I'm shocked at how cumbersome it is to read and validate JSON.
2828
2929 **resize, width measurements, line wrapping** - these still behave in suprising ways sometimes, breaking highligting, wrapping at weird limits, stange states after resize.
30-A definite research about the best approach to a clean rendering method is required.
30+A definite research about the best approach to a clean rendering method is required, instead of trial and error. This is not breakthrough, many TUIs have these issues and address them. Use github to learn. Once you've applied the fixes, do exhaustive testing with the stress script or the techniques described there.
3131
3232 **`src/main.zig` - has some headless concerns mixed into the entry point of the app. Worth considering extracting headless into `src/headless.zig`. Single concern files are easier to make a mental model around.
3333
@@ -36,3 +36,57 @@ A definite research about the best approach to a clean rendering method is requi
3636 `src/tui/tui.zig` - This file has a lot of responsibilities, making it very big. Token estimation and commands at least, could be extracted.
3737
3838 `src/tui/theme.zig` - will eventually grow too much, each theme we add will make that file worse. A refactor for later, since it's ok right now.
39+
40+## Rendering defects reproduced (real kitty, real provider)
41+
42+Measured against a real kitty window via `kitty @` remote control
43+(`get-text`, `resize-os-window`) and a real turn against the live provider.
44+
45+1. **Width model is per-codepoint.** `render.charWidth` sums codepoints; a
46+ grapheme cluster is not a codepoint. Kitty-measured vs app:
47+ `πŸ³οΈβ€πŸŒˆ` 2 vs 4, `πŸ‘¨β€πŸ‘©β€πŸ‘§β€πŸ‘¦` 2 vs 8, `πŸ‡©πŸ‡ͺ` 2 vs 4, `πŸ‘πŸ½` 2 vs 4,
48+ `βœ…` 2 vs 1, `β˜€οΈ`/`ℒ️`/`0️⃣` 2 vs 1, `πŸ‡ΊπŸ‡Έ` 2 vs 4, `πŸ”Ÿ` 2 vs 1.
49+ Wide chars (`ζ—₯ ν•œ a`) and ambiguous (`∡ ∴`) are right.
50+2. **Highlighting breaks across a soft wrap.** `wrapLine` splits bytes at a
51+ width boundary; a tree-sitter span that crosses the boundary loses its SGR
52+ on the continuation row (the opening sequence stays on the previous row).
53+ Narrowing a fenced python block to 50 shows the continuation rows in the
54+ normal fg.
55+3. **Reflow does not rejoin on widen.** `history` stores already-wrapped
56+ physical rows; `reflow` re-wraps them, so a paragraph wrapped at 100 stays
57+ broken at 100 after widening to 120. Confirmed: after 100β†’120 the rows still
58+ end at the old 100-col boundary.
59+4. **Reflow loses style.** `reflow` repaints every history row with
60+ `paintRow` (which prepends `SGR_PLAIN`), so styled rows come back unstyled.
61+ Confirmed: teal/comment rows repaint as `[197,201,197]`.
62+5. **`3J` on every resize drops native scrollback** (`\x1b[2J\x1b[3J\x1b[H`).
63+6. **Live-region accounting after resize** is a heuristic
64+ (`reanchor = live.rows >= height-1`), and `reflow` resets `live` without
65+ reconciling the cursor.
66+
67+Reference implementations studied: bubbletea `cursed_renderer.go` (inline
68+`Erase`+redraw on width change, cursor parked off the last column, cells owned
69+by the app), Ink/`wrap-ansi` and lipgloss SGR-balanced wrap, Ghostty/uucode
70+grapheme-cluster width, `unicode-display_width` precedence rules.
71+
72+### Resolved approach
73+
74+Validated against real kitty by driving the terminal over remote control and
75+reading back `get-text`/`get-cell-colors` and DSR replies (prototypes in
76+`/tmp/proto`), so the design comes from measured terminal behavior, not trial
77+and error.
78+
79+- **Committed transcript is written as logical lines once.** kitty soft-wraps
80+ logical lines, repeats the active SGR on every wrapped row, and *reflows and
81+ rejoins* them on resize; it neither rejoins nor restyles hard (CRLF) rows.
82+ So the app must not pre-wrap or re-emit committed content, and must not send
83+ `ED2`/`ED3` on resize.
84+- **The live region is pre-wrapped by the app** (status, queue, body, editor),
85+ because the editor needs to own its cursor. It is redrawn every frame.
86+- **Erase uses the caret.** The cursor is parked on the caret cell. To erase,
87+ move up by the caret's physical row offset *recomputed at the current width
88+ from the previous frame's live rows* (`sum ceil(cells_i/W) + col/W`), CR,
89+ SGR, `ED0`. The terminal keeps the cursor attached to its character across
90+ reflow, so that offset is exact.
91+- **Width** comes from generated UCD tables and a UAX#29 grapheme-cluster
92+ walk (`src/tui/width.zig`); it matches kitty cell-for-cell.
src/tui/editor.zig+53βˆ’37
@@ -4,6 +4,12 @@ const term = @import("term.zig");
44
55 const TAB = 4;
66
7+fn physicalRows(line: []const u8, width: usize) usize {
8+ const cells = render.displayWidth(line);
9+ if (cells == 0) return 1;
10+ return (cells + width - 1) / width;
11+}
12+
713 fn isSpace(cp: u21) bool {
814 return cp == ' ' or cp == '\t' or cp == '\n' or cp == '\r' or cp == 0x0b or cp == 0x0c or cp == 0xa0;
915 }
@@ -82,7 +88,6 @@ pub const Editor = struct {
8288 lines: std.ArrayList([]const u8) = .empty,
8389 row: usize = 0,
8490 col: usize = 0,
85- scroll: usize = 0,
8691 width: usize = 80,
8792 a: std.mem.Allocator,
8893 s: std.mem.Allocator = undefined,
@@ -107,7 +112,6 @@ pub const Editor = struct {
107112 self.lines.append(self.a, "") catch {};
108113 self.row = 0;
109114 self.col = 0;
110- self.scroll = 0;
111115 }
112116
113117 pub fn setText(self: *Editor, input: []const u8) void {
@@ -117,7 +121,6 @@ pub const Editor = struct {
117121 if (self.lines.items.len == 0) self.lines.append(self.a, "") catch {};
118122 self.row = self.lines.items.len - 1;
119123 self.col = cpLen(self.lines.items[self.row]);
120- self.scroll = 0;
121124 }
122125
123126 pub fn handle(self: *Editor, key: term.Key) Action {
@@ -194,14 +197,22 @@ pub const Editor = struct {
194197 out.append(self.s, 0) catch {};
195198 var col: usize = 0;
196199 var i: usize = 0;
197- while (i < line.len) {
198- const n = std.unicode.utf8ByteSequenceLength(line[i]) catch 1;
199- const len = @min(@as(usize, n), line.len - i);
200- const cp = std.unicode.utf8Decode(line[i .. i + len]) catch line[i];
201- col += if (cp == '\t') TAB - (col % TAB) else render.charWidth(cp);
202- out.append(self.s, col) catch {};
203- i += len;
200+ while (render.nextCluster(line, i)) |cluster| {
201+ const tab = cluster.text.len == 1 and cluster.text[0] == '\t';
202+ const advance = if (tab) TAB - (col % TAB) else cluster.width;
203+ var cps: usize = 0;
204+ var j: usize = 0;
205+ while (j < cluster.text.len) {
206+ const n = std.unicode.utf8ByteSequenceLength(cluster.text[j]) catch 1;
207+ j += @min(@as(usize, n), cluster.text.len - j);
208+ cps += 1;
209+ }
210+ var m: usize = 0;
211+ while (m < cps) : (m += 1) out.append(self.s, col) catch {};
212+ col += advance;
213+ i += cluster.text.len;
204214 }
215+ if (out.items.len == 0) out.append(self.s, 0) catch {};
205216 return out.items;
206217 }
207218
@@ -215,42 +226,47 @@ pub const Editor = struct {
215226 fn caret(self: *Editor) struct { row: usize, col: usize } {
216227 const width = @max(self.width, 1);
217228 const line = self.lines.items[self.row];
218- const expanded = render.expandTabs(self.s, line, TAB);
219- const chunks = render.wrapLine(self.s, expanded, width);
220229 const cell = self.cells(line)[self.col];
221- const row = cell / width;
222- if (row >= chunks.len) return .{ .row = chunks.len - 1, .col = render.displayWidth(chunks[chunks.len - 1]) };
223- return .{ .row = row, .col = cell - row * width };
230+ const rows = render.wrapLine(self.s, render.expandTabs(self.s, line, TAB), width);
231+ var used: usize = 0;
232+ for (rows, 0..) |r, i| {
233+ const w = render.displayWidth(r);
234+ if (cell < used + w) return .{ .row = i, .col = cell - used };
235+ used += w;
236+ }
237+ const last = render.displayWidth(rows[rows.len - 1]);
238+ return .{ .row = rows.len - 1, .col = @min(last, width - 1) };
224239 }
225240
226241 pub fn layout(self: *Editor, width: usize, max_rows: usize) Render {
227242 self.width = @max(1, width);
228- var rows: std.ArrayList([]const u8) = .empty;
229- var cursor_row: usize = 0;
230- var cursor_col: usize = 0;
231- for (self.lines.items, 0..) |line, li| {
232- const expanded = render.expandTabs(self.s, line, TAB);
233- const chunks = render.wrapLine(self.s, expanded, self.width);
234- if (li == self.row) {
235- const ct = self.caret();
236- cursor_row = rows.items.len + ct.row;
237- cursor_col = ct.col;
243+ const view = @max(1, max_rows);
244+ const n = self.lines.items.len;
245+ const heights = self.s.alloc(usize, n) catch return .{ .rows = &.{}, .cursor_row = 0, .cursor_col = 0 };
246+ var caret_line: usize = 0;
247+ var caret_cell: usize = 0;
248+ for (self.lines.items, 0..) |line, i| {
249+ heights[i] = physicalRows(render.expandTabs(self.s, line, TAB), self.width);
250+ if (i == self.row) {
251+ caret_line = i;
252+ caret_cell = self.cells(line)[self.col];
238253 }
239- for (chunks) |c| rows.append(self.s, c) catch {};
240254 }
241- const view = @max(1, max_rows);
242- if (cursor_row < self.scroll) {
243- self.scroll = cursor_row;
244- } else if (cursor_row >= self.scroll + view) {
245- self.scroll = cursor_row - view + 1;
255+ var start = caret_line;
256+ var used = heights[caret_line];
257+ while (start > 0 and used + heights[start - 1] <= view) {
258+ start -= 1;
259+ used += heights[start];
260+ }
261+ var end = caret_line + 1;
262+ while (end < n and used + heights[end] <= view) {
263+ used += heights[end];
264+ end += 1;
246265 }
247- const max_scroll = if (rows.items.len > view) rows.items.len - view else 0;
248- self.scroll = @min(self.scroll, max_scroll);
249- const end = @min(self.scroll + view, rows.items.len);
250266 return .{
251- .rows = rows.items[self.scroll..end],
252- .cursor_row = cursor_row - self.scroll,
253- .cursor_col = cursor_col,
267+ .rows = self.lines.items[start..end],
268+ .cursor_row = caret_line - start,
269+ .cursor_col = caret_cell,
254270 };
255271 }
256272
src/tui/render.zig+43βˆ’76
@@ -1,95 +1,57 @@
11 const std = @import("std");
2+const wcwidth = @import("width.zig");
23
3-pub fn charWidth(code: u21) u8 {
4- if (code < 32 or (code >= 0x7f and code < 0xa0)) return 0;
5- if (code == 0x200b or code == 0x200c or code == 0x200d or code == 0xfeff) return 0;
6- if (code >= 0xfe00 and code <= 0xfe0f) return 0;
7- if (code >= 0xe0100 and code <= 0xe01ef) return 0;
8- if (isCombining(code)) return 0;
9- if ((code >= 0x1100 and code <= 0x115f) or
10- (code >= 0x2e80 and code <= 0x303e) or
11- (code >= 0x3041 and code <= 0x33ff) or
12- (code >= 0x3400 and code <= 0x4dbf) or
13- (code >= 0x4e00 and code <= 0x9fff) or
14- (code >= 0xa000 and code <= 0xa4cf) or
15- (code >= 0xac00 and code <= 0xd7a3) or
16- (code >= 0xf900 and code <= 0xfaff) or
17- (code >= 0xfe10 and code <= 0xfe19) or
18- (code >= 0xfe30 and code <= 0xfe6f) or
19- (code >= 0xff00 and code <= 0xff60) or
20- (code >= 0xffe0 and code <= 0xffe6) or
21- (code >= 0x1f300 and code <= 0x1faff) or
22- (code >= 0x20000 and code <= 0x3fffd))
23- {
24- return 2;
25- }
26- return 1;
27-}
4+pub const charWidth = wcwidth.charWidth;
5+pub const nextCluster = wcwidth.nextCluster;
286
29-fn isCombining(code: u21) bool {
30- return (code >= 0x0300 and code <= 0x036f) or
31- (code >= 0x0483 and code <= 0x0489) or
32- (code >= 0x0591 and code <= 0x05bd) or
33- (code >= 0x0610 and code <= 0x061a) or
34- (code >= 0x064b and code <= 0x065f) or
35- (code >= 0x0670 and code <= 0x0670) or
36- (code >= 0x06d6 and code <= 0x06dc) or
37- (code >= 0x06df and code <= 0x06e4) or
38- (code >= 0x0730 and code <= 0x074a) or
39- (code >= 0x07a6 and code <= 0x07b0) or
40- (code >= 0x0900 and code <= 0x0903) or
41- (code >= 0x093a and code <= 0x094f) or
42- (code >= 0x0951 and code <= 0x0957) or
43- (code >= 0x0962 and code <= 0x0963) or
44- (code >= 0x0e31 and code <= 0x0e31) or
45- (code >= 0x0e34 and code <= 0x0e3a) or
46- (code >= 0x0e47 and code <= 0x0e4e) or
47- (code >= 0x1ab0 and code <= 0x1aff) or
48- (code >= 0x1dc0 and code <= 0x1dff) or
49- (code >= 0x20d0 and code <= 0x20ff) or
50- (code >= 0xfe20 and code <= 0xfe2f);
7+pub fn displayWidth(text: []const u8) usize {
8+ var width: usize = 0;
9+ var i: usize = 0;
10+ while (nextPiece(text, &i)) |piece| width += piece.width;
11+ return width;
5112 }
5213
53-const Piece = struct { text: []const u8, width: usize };
14+const Piece = struct { text: []const u8, width: usize, sgr: bool };
5415
55-const Decoded = struct { len: usize, cp: u21 };
16+fn decodeLen(text: []const u8, i: usize) usize {
17+ const n = std.unicode.utf8ByteSequenceLength(text[i]) catch return 1;
18+ return if (i + n > text.len) 1 else n;
19+}
5620
57-fn decodeAt(text: []const u8, i: usize) ?Decoded {
58- const n = std.unicode.utf8ByteSequenceLength(text[i]) catch return null;
59- if (i + n > text.len) return null;
60- const cp = std.unicode.utf8Decode(text[i .. i + n]) catch return null;
61- return .{ .len = n, .cp = cp };
21+fn decodeCp(text: []const u8, i: usize) u21 {
22+ const n = decodeLen(text, i);
23+ if (text[i] < 0x80) return text[i];
24+ return std.unicode.utf8Decode(text[i .. i + n]) catch text[i];
6225 }
6326
6427 fn nextPiece(text: []const u8, i: *usize) ?Piece {
6528 if (i.* >= text.len) return null;
6629 if (isSgrAt(text, i.*)) |n| {
67- const piece = Piece{ .text = text[i.* .. i.* + n], .width = 0 };
30+ const piece = Piece{ .text = text[i.* .. i.* + n], .width = 0, .sgr = true };
6831 i.* += n;
6932 return piece;
7033 }
71- if (decodeAt(text, i.*)) |d| {
72- const piece = Piece{ .text = text[i.* .. i.* + d.len], .width = if (d.cp == '\t') 0 else charWidth(d.cp) };
73- i.* += d.len;
34+ if (wcwidth.nextCluster(text, i.*)) |cluster| {
35+ const piece = Piece{ .text = cluster.text, .width = if (cluster.text[0] == '\t') 0 else cluster.width, .sgr = false };
36+ i.* += cluster.text.len;
7437 return piece;
7538 }
76- const piece = Piece{ .text = text[i.* .. i.* + 1], .width = charWidth(text[i.*]) };
77- i.* += 1;
39+ const len = decodeLen(text, i.*);
40+ const piece = Piece{ .text = text[i.* .. i.* + len], .width = 1, .sgr = false };
41+ i.* += len;
7842 return piece;
7943 }
8044
81-pub fn displayWidth(text: []const u8) usize {
82- var width: usize = 0;
83- var i: usize = 0;
84- while (nextPiece(text, &i)) |piece| width += piece.width;
85- return width;
86-}
87-
8845 fn isSgrAt(text: []const u8, i: usize) ?usize {
8946 if (i + 1 >= text.len or text[i] != 0x1b or text[i + 1] != '[') return null;
9047 var j = i + 2;
9148 while (j < text.len and (text[j] == ';' or (text[j] >= '0' and text[j] <= '9'))) j += 1;
9249 if (j < text.len and text[j] == 'm') return j - i + 1;
50+ if (j < text.len and text[j] == ':' ) {
51+ while (j < text.len and (text[j] == ':' or text[j] == ';' or (text[j] >= '0' and text[j] <= '9'))) j += 1;
52+ if (j < text.len and text[j] == 'm') return j - i + 1;
53+ }
54+ if (j == i + 2 and j < text.len and text[j] == 'm') return j - i + 1;
9355 return null;
9456 }
9557
@@ -133,16 +95,14 @@ pub fn sanitize(a: std.mem.Allocator, text: []const u8) []const u8 {
13395 i += 1;
13496 continue;
13597 }
136- const d = decodeAt(text, i) orelse {
137- i += 1;
138- continue;
139- };
140- if (d.cp >= 0x80 and d.cp <= 0x9f) {
141- i += d.len;
98+ const cp = decodeCp(text, i);
99+ if (cp >= 0x80 and cp <= 0x9f) {
100+ i += decodeLen(text, i);
142101 continue;
143102 }
144- out.appendSlice(a, text[i .. i + d.len]) catch {};
145- i += d.len;
103+ const len = decodeLen(text, i);
104+ out.appendSlice(a, text[i .. i + len]) catch {};
105+ i += len;
146106 }
147107 return out.items;
148108 }
@@ -174,11 +134,18 @@ pub fn wrapLine(a: std.mem.Allocator, text: []const u8, width: usize) []const []
174134 }
175135 var current: std.ArrayList(u8) = .empty;
176136 var used: usize = 0;
137+ var active: []const u8 = "";
177138 var i: usize = 0;
178139 while (nextPiece(text, &i)) |piece| {
179- if (used + piece.width > width and current.items.len != 0) {
140+ if (piece.sgr) {
141+ current.appendSlice(a, piece.text) catch {};
142+ active = piece.text;
143+ continue;
144+ }
145+ if (used + piece.width > width and used != 0) {
180146 rows.append(a, current.items) catch {};
181147 current = .empty;
148+ current.appendSlice(a, active) catch {};
182149 used = 0;
183150 }
184151 current.appendSlice(a, piece.text) catch {};
src/tui/tui.zig+128βˆ’113
@@ -22,59 +22,68 @@ const SPINNER_MS = 120;
2222 const BODY_PREFIX = " | ";
2323 const ERROR_PREFIX = " ! ";
2424
25-const HISTORY_LINES = 1000;
26-
2725 const MAX_BODY_ROWS = 12;
2826 const ELIDED_HEAD = 4;
2927 const ELIDED_TAIL = 4;
3028
29+fn physicalRows(line: []const u8, width: usize) usize {
30+ return rowsForCells(render.displayWidth(line), width);
31+}
32+
33+fn rowsForCells(cells: usize, width: usize) usize {
34+ if (cells == 0) return 1;
35+ return (cells + width - 1) / width;
36+}
37+
3138 const PendingCall = struct { name: []const u8, summary: []const u8 };
3239
3340 const STATE_WIDTH = "running".len;
3441 const STATE_PAD = std.fmt.comptimePrint("{{s: <{d}}}", .{STATE_WIDTH});
3542
36-fn paintRow(a: std.mem.Allocator, line: []const u8) []const u8 {
37- return std.fmt.allocPrint(a, "{s}{s}\x1b[K", .{ theme.SGR_PLAIN, line }) catch line;
38-}
39-
40-fn styleRow(a: std.mem.Allocator, line: stream.BodyLine, width: usize) []const []const u8 {
43+fn styleLine(a: std.mem.Allocator, line: stream.BodyLine) []const u8 {
4144 const safe = render.sanitize(a, line.text);
4245 const expanded = render.expandTabs(a, safe, 4);
43- const wrapped = render.wrapLine(a, expanded, width);
44- var out: std.ArrayList([]const u8) = .empty;
45- for (wrapped) |row| {
46- if (row.len == 0) {
47- out.append(a, "") catch {};
48- continue;
49- }
50- const row_bg = if (line.bg) |bg| theme.sgrBg(a, bg) else theme.SGR_NORMAL_BG;
51- const styled = if (line.style) |s| styles.styledWith(a, .{
52- .fg = s.fg,
53- .bg = line.bg orelse theme.current.bg,
54- .bold = s.bold,
55- .italic = s.italic,
56- .underline = s.underline,
57- }, row) else row;
58- out.append(a, std.fmt.allocPrint(a, "{s}{s}{s}", .{ row_bg, styled, row_bg }) catch row) catch {};
59- }
60- return out.items;
46+ if (expanded.len == 0) return "";
47+ const row_bg = if (line.bg) |bg| theme.sgrBg(a, bg) else theme.SGR_NORMAL_BG;
48+ const styled = if (line.style) |s| styles.styledWith(a, .{
49+ .fg = s.fg,
50+ .bg = line.bg orelse theme.current.bg,
51+ .bold = s.bold,
52+ .italic = s.italic,
53+ .underline = s.underline,
54+ }, expanded) else expanded;
55+ return std.fmt.allocPrint(a, "{s}{s}{s}", .{ row_bg, styled, row_bg }) catch expanded;
6156 }
6257
63-fn renderRows(a: std.mem.Allocator, lines: []const stream.BodyLine, width: usize) []const []const u8 {
58+fn plainRows(a: std.mem.Allocator, lines: []const stream.BodyLine) []const []const u8 {
6459 var out: std.ArrayList([]const u8) = .empty;
65- for (lines) |line| {
66- for (styleRow(a, line, width)) |row| out.append(a, row) catch {};
67- }
60+ for (lines) |line| out.append(a, styleLine(a, line)) catch {};
6861 return out.items;
6962 }
7063
7164 fn bodyRows(a: std.mem.Allocator, lines: []const stream.BodyLine, width: usize) []const []const u8 {
72- const rows = renderRows(a, lines, width);
73- if (rows.len <= MAX_BODY_ROWS) return rows;
65+ const rows = plainRows(a, lines);
66+ var height: usize = 0;
67+ for (rows) |r| height += physicalRows(r, width);
68+ if (height <= MAX_BODY_ROWS or rows.len <= ELIDED_HEAD + ELIDED_TAIL) return rows;
69+ const tail_at = rows.len - ELIDED_TAIL;
70+ var shown: usize = 0;
71+ var head: usize = 0;
72+ while (head < tail_at) : (head += 1) {
73+ const h = physicalRows(rows[head], width);
74+ if (shown + h + ELIDED_TAIL > MAX_BODY_ROWS - 1) break;
75+ shown += h;
76+ }
7477 var out: std.ArrayList([]const u8) = .empty;
75- for (rows[0..ELIDED_HEAD]) |r| out.append(a, r) catch {};
76- out.append(a, styles.dim(a, std.fmt.allocPrint(a, "... {d} lines not shown ...", .{rows.len - ELIDED_HEAD - ELIDED_TAIL}) catch "")) catch {};
77- for (rows[rows.len - ELIDED_TAIL ..]) |r| out.append(a, r) catch {};
78+ for (rows[0..head]) |r| out.append(a, r) catch {};
79+ const hidden_rows: usize = blk: {
80+ var n = height;
81+ for (rows[0..head]) |r| n -= physicalRows(r, width);
82+ for (rows[tail_at..]) |r| n -= physicalRows(r, width);
83+ break :blk n;
84+ };
85+ out.append(a, styles.dim(a, std.fmt.allocPrint(a, "... {d} lines not shown ...", .{hidden_rows}) catch "")) catch {};
86+ for (rows[tail_at..]) |r| out.append(a, r) catch {};
7887 return out.items;
7988 }
8089
@@ -82,12 +91,14 @@ fn callHead(a: std.mem.Allocator, name: []const u8) []const u8 {
8291 return styles.teal(a, std.fmt.allocPrint(a, "-> {s}", .{name}) catch "->");
8392 }
8493
85-fn callRows(a: std.mem.Allocator, width: usize, call: PendingCall, running: bool) []const []const u8 {
94+fn callRows(a: std.mem.Allocator, call: PendingCall, running: bool) []const []const u8 {
8695 const padded = std.fmt.allocPrint(a, STATE_PAD, .{if (running) "running" else "queued"}) catch "";
8796 const word = if (running) styles.teal(a, padded) else styles.dim(a, padded);
8897 const head = callHead(a, call.name);
8998 const text = render.expandTabs(a, render.sanitize(a, call.summary), 4);
90- return render.wrapLine(a, std.fmt.allocPrint(a, "{s} {s} {s}", .{ word, head, text }) catch text, width);
99+ var out: std.ArrayList([]const u8) = .empty;
100+ out.append(a, std.fmt.allocPrint(a, "{s} {s} {s}", .{ word, head, text }) catch text) catch {};
101+ return out.items;
91102 }
92103
93104 fn collapseWs(a: std.mem.Allocator, s: []const u8) []const u8 {
@@ -365,36 +376,59 @@ fn contextUsageLine(a: std.mem.Allocator, used: u64, model: *const types.Model)
365376 }
366377
367378 const LiveRegion = struct {
368- rows: usize = 0,
369- cursor_up: usize = 0,
379+ widths: std.ArrayList(usize) = .empty,
380+ caret_line: usize = 0,
381+ caret_cell: usize = 0,
382+ drawn: bool = false,
383+
384+ fn remember(self: *LiveRegion, lines: []const []const u8, caret_line: usize, caret_cell: usize) void {
385+ self.widths.clearRetainingCapacity();
386+ for (lines) |line| self.widths.append(platform.gpa, render.displayWidth(line)) catch {};
387+ self.caret_line = caret_line;
388+ self.caret_cell = caret_cell;
389+ self.drawn = true;
390+ }
391+
392+ fn caretRow(self: *LiveRegion, width: usize) usize {
393+ var row: usize = 0;
394+ const lines = @min(self.caret_line, self.widths.items.len);
395+ for (self.widths.items[0..lines]) |cells| row += rowsForCells(cells, width);
396+ return row + self.caret_cell / width;
397+ }
398+
399+ fn totalRows(self: *LiveRegion, width: usize) usize {
400+ var row: usize = 0;
401+ for (self.widths.items) |cells| row += rowsForCells(cells, width);
402+ return row;
403+ }
370404
371- fn clear(self: *LiveRegion, a: std.mem.Allocator) []const u8 {
372- if (self.rows == 0) return "";
405+ fn erase(self: *LiveRegion, a: std.mem.Allocator, width: usize) []const u8 {
406+ if (!self.drawn) return "";
407+ const up = self.caretRow(width);
373408 var out: std.ArrayList(u8) = .empty;
374- if (self.cursor_up > 0) out.appendSlice(a, std.fmt.allocPrint(a, "\x1b[{d}B", .{self.cursor_up}) catch "") catch {};
375- if (self.rows > 1) out.appendSlice(a, std.fmt.allocPrint(a, "\x1b[{d}A", .{self.rows - 1}) catch "") catch {};
409+ if (up > 0) out.appendSlice(a, std.fmt.allocPrint(a, "\x1b[{d}A", .{up}) catch "") catch {};
376410 out.appendSlice(a, "\r") catch {};
377411 out.appendSlice(a, theme.SGR_PLAIN) catch {};
378412 out.appendSlice(a, "\x1b[J") catch {};
379- self.rows = 0;
380- self.cursor_up = 0;
381413 return out.items;
382414 }
383415
384- fn draw(self: *LiveRegion, a: std.mem.Allocator, lines: []const []const u8, cursor_row: usize, cursor_col: usize, above: []const u8) []const u8 {
416+ fn draw(self: *LiveRegion, a: std.mem.Allocator, width: usize, lines: []const []const u8, caret_line: usize, caret_cell: usize, above: []const u8) []const u8 {
385417 var out: std.ArrayList(u8) = .empty;
386- out.appendSlice(a, self.clear(a)) catch {};
418+ out.appendSlice(a, self.erase(a, width)) catch {};
387419 out.appendSlice(a, above) catch {};
388420 for (lines, 0..) |line, i| {
389421 if (i > 0) out.appendSlice(a, "\r\n") catch {};
390422 out.appendSlice(a, line) catch {};
391423 }
392- const up = if (lines.len > 0 and lines.len - 1 > cursor_row) lines.len - 1 - cursor_row else 0;
424+ self.remember(lines, caret_line, caret_cell);
425+ const end_row = self.totalRows(width) - 1;
426+ const caret_row = self.caretRow(width);
427+ const up = if (end_row > caret_row) end_row - caret_row else 0;
393428 if (up > 0) out.appendSlice(a, std.fmt.allocPrint(a, "\x1b[{d}A", .{up}) catch "") catch {};
394429 out.appendSlice(a, "\r") catch {};
395- if (cursor_col > 0) out.appendSlice(a, std.fmt.allocPrint(a, "\x1b[{d}G", .{cursor_col + 1}) catch "") catch {};
396- self.rows = lines.len;
397- self.cursor_up = up;
430+ const col = caret_cell % width;
431+ if (col > 0) out.appendSlice(a, std.fmt.allocPrint(a, "\x1b[{d}C", .{col}) catch "") catch {};
398432 return out.items;
399433 }
400434 };
@@ -452,7 +486,6 @@ const Tui = struct {
452486 abort: std.atomic.Value(bool) = std.atomic.Value(bool).init(false),
453487
454488 scroll: std.ArrayList(u8) = .empty,
455- history: std.ArrayList([]const u8) = .empty,
456489 wrote: bool = false,
457490 last_blank: bool = false,
458491 separator: bool = false,
@@ -518,17 +551,13 @@ const Tui = struct {
518551 const blank = clean.len == 0 or (self.separator and self.wrote);
519552 self.separator = false;
520553 if (blank and self.wrote and !self.last_blank) {
521- self.history.append(platform.gpa, "") catch {};
522- self.capHistory();
523- self.scroll.appendSlice(self.a, paintRow(self.sa, "")) catch {};
554+ self.scroll.appendSlice(self.a, theme.SGR_PLAIN) catch {};
524555 self.scroll.appendSlice(self.a, "\r\n") catch {};
525556 self.last_blank = true;
526557 }
527558 if (clean.len != 0) {
528- if (platform.gpa.dupe(u8, clean)) |owned| {
529- if (self.history.append(platform.gpa, owned)) |_| self.capHistory() else |_| platform.gpa.free(owned);
530- } else |_| {}
531- self.scroll.appendSlice(self.a, paintRow(self.sa, clean)) catch {};
559+ self.scroll.appendSlice(self.a, clean) catch {};
560+ self.scroll.appendSlice(self.a, theme.SGR_PLAIN) catch {};
532561 self.scroll.appendSlice(self.a, "\r\n") catch {};
533562 self.wrote = true;
534563 self.last_blank = false;
@@ -536,32 +565,8 @@ const Tui = struct {
536565 self.dirty = true;
537566 }
538567
539- fn capHistory(self: *Tui) void {
540- while (self.history.items.len > HISTORY_LINES) {
541- const old = self.history.orderedRemove(0);
542- if (old.len > 0) platform.gpa.free(old);
543- }
544- }
545-
546- fn reflow(self: *Tui) void {
547- self.term.refreshSize();
548- self.live.rows = 0;
549- self.live.cursor_up = 0;
550- self.scroll.clearRetainingCapacity();
551- self.term.write("\x1b[2J\x1b[3J\x1b[H");
552- const width = @max(self.term.width(), 1);
553- for (self.history.items) |line| {
554- for (render.wrapLine(self.s, line, width)) |row| {
555- self.scroll.appendSlice(self.a, paintRow(self.sa, row)) catch {};
556- self.scroll.appendSlice(self.a, "\r\n") catch {};
557- }
558- }
559- self.dirty = true;
560- }
561-
562568 fn commitLines(self: *Tui, lines: []const stream.BodyLine) void {
563- const width = @max(self.term.width(), 1);
564- for (renderRows(self.s, lines, width)) |row| self.push(row);
569+ for (lines) |line| self.push(styleLine(self.sa, line));
565570 }
566571
567572 fn note(self: *Tui, line: []const u8) void {
@@ -638,14 +643,15 @@ const Tui = struct {
638643 fn queueRows(self: *Tui, width: usize, budget: usize) []const []const u8 {
639644 if (budget == 0) return &.{};
640645 var out: std.ArrayList([]const u8) = .empty;
646+ var used: usize = 0;
641647 for (self.pending_calls.items, 0..) |call, i| {
642- for (callRows(self.s, width, call, i == 0 and self.phase == .running_tool)) |row| out.append(self.s, row) catch {};
648+ for (callRows(self.s, call, i == 0 and self.phase == .running_tool)) |row| {
649+ const h = physicalRows(row, width);
650+ if (used + h > budget and out.items.len > 0) break;
651+ used += h;
652+ out.append(self.s, row) catch {};
653+ }
643654 }
644- if (out.items.len <= budget) return out.items;
645- const keep = budget - 1;
646- const hidden = out.items.len - keep;
647- out.shrinkRetainingCapacity(keep);
648- out.append(self.s, styles.dim(self.s, std.fmt.allocPrint(self.s, "... {d} more lines ...", .{hidden}) catch "...")) catch {};
649655 return out.items;
650656 }
651657
@@ -654,33 +660,38 @@ const Tui = struct {
654660 self.resetScratch();
655661 const width = @max(self.term.width(), 1);
656662 const height = @max(self.term.height() - 1, 1);
657- const status = render.wrapLine(self.s, self.statusLine(), width);
663+ const status = self.statusLine();
658664
659665 var inflight = self.reply.pending();
660666 if (inflight.len == 0) inflight = self.activity.pending();
661- const rows = renderRows(self.s, inflight, width);
667+ const rows = plainRows(self.s, inflight);
662668
663- const room = if (height > status.len + 1) height - status.len - 1 else 0;
669+ const status_rows = physicalRows(status, width);
670+ const room = if (height > status_rows + 1) height - status_rows - 1 else 0;
664671 const queue = self.queueRows(width, room);
665- const keep = @min(rows.len, room - queue.len);
666- const body = rows[rows.len - keep ..];
667- const ed = self.editor.layout(width, @max(height - status.len - queue.len - body.len, 1));
672+ var queue_height: usize = 0;
673+ for (queue) |r| queue_height += physicalRows(r, width);
674+ const body_budget = if (room > queue_height) room - queue_height else 0;
675+ var body_start = rows.len;
676+ var body_used: usize = 0;
677+ while (body_start > 0) {
678+ const h = physicalRows(rows[body_start - 1], width);
679+ if (body_used + h > body_budget) break;
680+ body_used += h;
681+ body_start -= 1;
682+ }
683+ const body = rows[body_start..];
684+ const editor_budget = height -| (status_rows + queue_height + body_used);
685+ const ed = self.editor.layout(width, @max(editor_budget, 1));
668686
669687 var lines: std.ArrayList([]const u8) = .empty;
670- for (body) |r| lines.append(self.s, paintRow(self.s, r)) catch {};
671- for (queue) |r| lines.append(self.s, paintRow(self.s, r)) catch {};
672- for (status) |r| lines.append(self.s, paintRow(self.s, r)) catch {};
673- for (ed.rows) |r| lines.append(self.s, paintRow(self.s, r)) catch {};
674- var cursor_row = body.len + queue.len + status.len + ed.cursor_row;
675- if (cursor_row >= lines.items.len and lines.items.len > 0) cursor_row = lines.items.len - 1;
676-
677- const scroll = self.scroll.items;
678- const reanchor = scroll.len > 0 and self.live.rows >= self.term.height() - 1;
679- const above = if (reanchor)
680- std.fmt.allocPrint(self.s, "{s}\r\n", .{scroll}) catch scroll
681- else
682- scroll;
683- const frame_text = self.live.draw(self.s, lines.items, cursor_row, ed.cursor_col, above);
688+ for (body) |r| lines.append(self.s, r) catch {};
689+ for (queue) |r| lines.append(self.s, r) catch {};
690+ lines.append(self.s, status) catch {};
691+ const caret_line = lines.items.len + ed.cursor_row;
692+ for (ed.rows) |r| lines.append(self.s, r) catch {};
693+
694+ const frame_text = self.live.draw(self.s, width, lines.items, caret_line, ed.cursor_col, self.scroll.items);
684695 self.term.write(frame_text);
685696 self.scroll.clearRetainingCapacity();
686697 _ = self.sarena.reset(.retain_capacity);
@@ -768,13 +779,13 @@ const Tui = struct {
768779 &.{.{ .text = body.? }}
769780 else
770781 resultLines(self.s, name, text, is_error);
771- const rows = if (std.mem.eql(u8, name, "edit")) renderRows(self.s, lines, width) else bodyRows(self.s, lines, width);
782+ const rows = if (std.mem.eql(u8, name, "edit")) plainRows(self.s, lines) else bodyRows(self.s, lines, width);
772783 for (rows, 0..) |row, i| {
773784 const prefix = if (is_error and i == rows.len - 1) styles.red(self.s, ERROR_PREFIX) else styles.dim(self.s, BODY_PREFIX);
774785 self.push(std.fmt.allocPrint(self.s, "{s}{s}", .{ prefix, row }) catch row);
775786 }
776787 if (diffs.len > 0) {
777- for (renderRows(self.s, diffRows(self.s, diffs), width)) |row| {
788+ for (plainRows(self.s, diffRows(self.s, diffs))) |row| {
778789 self.push(std.fmt.allocPrint(self.s, "{s}{s}", .{ styles.dim(self.s, BODY_PREFIX), row }) catch row);
779790 }
780791 }
@@ -1066,7 +1077,8 @@ const Tui = struct {
10661077 self.closed = true;
10671078 self.abort.store(true, .seq_cst);
10681079 self.steering_ready.store(true, .seq_cst);
1069- self.term.write(self.live.clear(self.a));
1080+ const width = @max(self.term.width(), 1);
1081+ self.term.write(self.live.erase(self.a, width));
10701082 self.term.write(self.scroll.items);
10711083 self.term.stop();
10721084 self.opts.session.close();
@@ -1288,7 +1300,10 @@ pub fn run(opts: agent.Options, cfg: *const config.Config, tool_names: []const c
12881300 self.dirty = true;
12891301 }
12901302
1291- if (resize_flag.swap(false, .seq_cst)) self.reflow();
1303+ if (resize_flag.swap(false, .seq_cst)) {
1304+ self.term.refreshSize();
1305+ self.dirty = true;
1306+ }
12921307 if (exit_flag.swap(false, .seq_cst)) self.exit();
12931308
12941309 const now = util.nowMs();
src/tui/width.zig+157βˆ’0
@@ -0,0 +1,157 @@
1+const std = @import("std");
2+const tables = @import("width_tables.zig");
3+
4+pub const Cluster = struct { text: []const u8, width: u8 };
5+
6+fn inRanges(comptime ranges: []const tables.Range, cp: u21) bool {
7+ var lo: usize = 0;
8+ var hi: usize = ranges.len;
9+ while (lo < hi) {
10+ const mid = (lo + hi) / 2;
11+ if (cp < ranges[mid].lo) hi = mid else if (cp > ranges[mid].hi) lo = mid + 1 else return true;
12+ }
13+ return false;
14+}
15+
16+fn classOf(cp: u21) ?tables.Class {
17+ var lo: usize = 0;
18+ var hi: usize = tables.grapheme.len;
19+ while (lo < hi) {
20+ const mid = (lo + hi) / 2;
21+ if (cp < tables.grapheme[mid].lo) {
22+ hi = mid;
23+ } else if (cp > tables.grapheme[mid].hi) {
24+ lo = mid + 1;
25+ } else {
26+ return tables.grapheme[mid].class;
27+ }
28+ }
29+ return null;
30+}
31+
32+fn isZero(cp: u21) bool {
33+ return inRanges(&tables.zero, cp);
34+}
35+
36+pub fn charWidth(cp: u21) u8 {
37+ if (cp < 0x20 or (cp >= 0x7f and cp < 0xa0)) return 0;
38+ if (isZero(cp)) return 0;
39+ if (inRanges(&tables.wide, cp)) return 2;
40+ return 1;
41+}
42+
43+fn decodeAt(text: []const u8, i: usize) ?struct { cp: u21, len: usize } {
44+ if (i >= text.len) return null;
45+ const n = std.unicode.utf8ByteSequenceLength(text[i]) catch return .{ .cp = text[i], .len = 1 };
46+ if (i + n > text.len) return .{ .cp = text[i], .len = 1 };
47+ const cp = std.unicode.utf8Decode(text[i .. i + n]) catch return .{ .cp = text[i], .len = 1 };
48+ return .{ .cp = cp, .len = n };
49+}
50+
51+fn isExtPict(cp: u21) bool {
52+ return inRanges(&tables.extended_pictographic, cp);
53+}
54+fn isEmoji(cp: u21) bool {
55+ return inRanges(&tables.emoji, cp);
56+}
57+fn isConsonant(cp: u21) bool {
58+ return inRanges(&tables.consonant, cp);
59+}
60+fn isLinker(cp: u21) bool {
61+ return inRanges(&tables.linker, cp);
62+}
63+
64+const State = struct {
65+ ri: u32 = 0,
66+ ext_pict: bool = false,
67+ zwj_ext_pict: bool = false,
68+ indic: u2 = 0,
69+};
70+
71+fn startsWith(state: *State, cp: u21) void {
72+ state.* = .{
73+ .ri = if (classOf(cp) == .regional_indicator) 1 else 0,
74+ .ext_pict = isExtPict(cp),
75+ .indic = if (isConsonant(cp)) 1 else 0,
76+ };
77+}
78+
79+fn extends(state: *State, cur: u21) void {
80+ const cur_class = classOf(cur);
81+ state.ri = if (cur_class == .regional_indicator) state.ri + 1 else 0;
82+ if (cur_class == .zwj) {
83+ state.zwj_ext_pict = state.ext_pict;
84+ } else if (cur_class != .extend and cur_class != .spacingmark) {
85+ state.ext_pict = isExtPict(cur);
86+ state.zwj_ext_pict = false;
87+ }
88+ if (isConsonant(cur)) {
89+ state.indic = 1;
90+ } else if (isLinker(cur) and state.indic >= 1) {
91+ state.indic = 2;
92+ }
93+}
94+
95+fn noBreak(state: State, prev: u21, cur: u21) bool {
96+ const a = classOf(prev);
97+ const b = classOf(cur);
98+ if (a == .cr and b == .lf) return true;
99+ if (a == .cr or a == .lf or a == .control) return false;
100+ if (b == .cr or b == .lf or b == .control) return false;
101+ if (a == .l and (b == .l or b == .v or b == .lv or b == .lvt)) return true;
102+ if ((a == .lv or a == .v) and (b == .v or b == .t)) return true;
103+ if ((a == .lvt or a == .t) and b == .t) return true;
104+ if (b == .extend or b == .zwj) return true;
105+ if (b == .spacingmark) return true;
106+ if (a == .prepend) return true;
107+ if (a != null and a.? == .zwj and state.zwj_ext_pict and isExtPict(cur)) return true;
108+ if (a == .regional_indicator and b == .regional_indicator and state.ri % 2 == 1) return true;
109+ if (state.indic == 2 and isConsonant(cur)) return true;
110+ return false;
111+}
112+
113+fn clusterWidth(text: []const u8) u8 {
114+ var width: u8 = 0;
115+ var has_vs16 = false;
116+ var base: u21 = 0;
117+ var i: usize = 0;
118+ var first = true;
119+ while (i < text.len) {
120+ const d = decodeAt(text, i) orelse break;
121+ if (d.cp == 0xfe0f) has_vs16 = true;
122+ if (first) {
123+ base = d.cp;
124+ first = false;
125+ }
126+ width = @max(width, charWidth(d.cp));
127+ i += d.len;
128+ }
129+ if (has_vs16 and isEmoji(base)) width = @max(width, 2);
130+ return width;
131+}
132+
133+pub fn nextCluster(text: []const u8, i: usize) ?Cluster {
134+ const d = decodeAt(text, i) orelse return null;
135+ var state = State{};
136+ startsWith(&state, d.cp);
137+ var end = i + d.len;
138+ var prev = d.cp;
139+ while (end < text.len) {
140+ const n = decodeAt(text, end) orelse break;
141+ if (!noBreak(state, prev, n.cp)) break;
142+ extends(&state, n.cp);
143+ prev = n.cp;
144+ end += n.len;
145+ }
146+ return .{ .text = text[i..end], .width = clusterWidth(text[i..end]) };
147+}
148+
149+pub fn displayWidth(text: []const u8) usize {
150+ var width: usize = 0;
151+ var i: usize = 0;
152+ while (nextCluster(text, i)) |cluster| {
153+ width += cluster.width;
154+ i += cluster.text.len;
155+ }
156+ return width;
157+}
src/tui/width_tables.zig+2333βˆ’0
@@ -0,0 +1,2333 @@
1+// Generated by tools/gen_width.py from the Unicode Character Database.
2+// EastAsianWidth version 18.0.0. Do not edit by hand.
3+
4+pub const Range = struct { lo: u21, hi: u21 };
5+pub const Class = enum { cr, lf, control, extend, zwj, regional_indicator, prepend, spacingmark, l, v, t, lv, lvt };
6+pub const ClassRange = struct { lo: u21, hi: u21, class: Class };
7+
8+pub const wide = [_]Range{
9+ .{ .lo = 0x1100, .hi = 0x115F },
10+ .{ .lo = 0x231A, .hi = 0x231B },
11+ .{ .lo = 0x2329, .hi = 0x232A },
12+ .{ .lo = 0x23E9, .hi = 0x23EC },
13+ .{ .lo = 0x23F0, .hi = 0x23F0 },
14+ .{ .lo = 0x23F3, .hi = 0x23F3 },
15+ .{ .lo = 0x25FD, .hi = 0x25FE },
16+ .{ .lo = 0x2614, .hi = 0x2615 },
17+ .{ .lo = 0x261D, .hi = 0x261D },
18+ .{ .lo = 0x2630, .hi = 0x2637 },
19+ .{ .lo = 0x2648, .hi = 0x2653 },
20+ .{ .lo = 0x267F, .hi = 0x267F },
21+ .{ .lo = 0x268A, .hi = 0x268F },
22+ .{ .lo = 0x2693, .hi = 0x2693 },
23+ .{ .lo = 0x26A1, .hi = 0x26A1 },
24+ .{ .lo = 0x26AA, .hi = 0x26AB },
25+ .{ .lo = 0x26BD, .hi = 0x26BE },
26+ .{ .lo = 0x26C4, .hi = 0x26C5 },
27+ .{ .lo = 0x26CE, .hi = 0x26CE },
28+ .{ .lo = 0x26D4, .hi = 0x26D4 },
29+ .{ .lo = 0x26EA, .hi = 0x26EA },
30+ .{ .lo = 0x26F2, .hi = 0x26F3 },
31+ .{ .lo = 0x26F5, .hi = 0x26F5 },
32+ .{ .lo = 0x26F9, .hi = 0x26FA },
33+ .{ .lo = 0x26FD, .hi = 0x26FD },
34+ .{ .lo = 0x2705, .hi = 0x2705 },
35+ .{ .lo = 0x270A, .hi = 0x270D },
36+ .{ .lo = 0x2728, .hi = 0x2728 },
37+ .{ .lo = 0x274C, .hi = 0x274C },
38+ .{ .lo = 0x274E, .hi = 0x274E },
39+ .{ .lo = 0x2753, .hi = 0x2755 },
40+ .{ .lo = 0x2757, .hi = 0x2757 },
41+ .{ .lo = 0x2795, .hi = 0x2797 },
42+ .{ .lo = 0x27B0, .hi = 0x27B0 },
43+ .{ .lo = 0x27BF, .hi = 0x27BF },
44+ .{ .lo = 0x2B1B, .hi = 0x2B1C },
45+ .{ .lo = 0x2B50, .hi = 0x2B50 },
46+ .{ .lo = 0x2B55, .hi = 0x2B55 },
47+ .{ .lo = 0x2E80, .hi = 0x2E99 },
48+ .{ .lo = 0x2E9B, .hi = 0x2EF3 },
49+ .{ .lo = 0x2F00, .hi = 0x2FD5 },
50+ .{ .lo = 0x2FF0, .hi = 0x303E },
51+ .{ .lo = 0x3041, .hi = 0x3096 },
52+ .{ .lo = 0x3099, .hi = 0x30FF },
53+ .{ .lo = 0x3105, .hi = 0x312F },
54+ .{ .lo = 0x3131, .hi = 0x318E },
55+ .{ .lo = 0x3190, .hi = 0x31E5 },
56+ .{ .lo = 0x31EF, .hi = 0x321E },
57+ .{ .lo = 0x3220, .hi = 0x3247 },
58+ .{ .lo = 0x3250, .hi = 0xA48C },
59+ .{ .lo = 0xA490, .hi = 0xA4C6 },
60+ .{ .lo = 0xA960, .hi = 0xA97C },
61+ .{ .lo = 0xAC00, .hi = 0xD7A3 },
62+ .{ .lo = 0xF900, .hi = 0xFAFF },
63+ .{ .lo = 0xFE10, .hi = 0xFE19 },
64+ .{ .lo = 0xFE30, .hi = 0xFE52 },
65+ .{ .lo = 0xFE54, .hi = 0xFE66 },
66+ .{ .lo = 0xFE68, .hi = 0xFE6B },
67+ .{ .lo = 0xFF01, .hi = 0xFF60 },
68+ .{ .lo = 0xFFE0, .hi = 0xFFE6 },
69+ .{ .lo = 0x16FE0, .hi = 0x16FE4 },
70+ .{ .lo = 0x16FF0, .hi = 0x16FF6 },
71+ .{ .lo = 0x17000, .hi = 0x18CDA },
72+ .{ .lo = 0x18CFF, .hi = 0x18D20 },
73+ .{ .lo = 0x18D80, .hi = 0x18DF2 },
74+ .{ .lo = 0x18E00, .hi = 0x19191 },
75+ .{ .lo = 0x191A0, .hi = 0x191D2 },
76+ .{ .lo = 0x1AFF0, .hi = 0x1AFF3 },
77+ .{ .lo = 0x1AFF5, .hi = 0x1AFFB },
78+ .{ .lo = 0x1AFFD, .hi = 0x1AFFE },
79+ .{ .lo = 0x1B000, .hi = 0x1B128 },
80+ .{ .lo = 0x1B132, .hi = 0x1B132 },
81+ .{ .lo = 0x1B150, .hi = 0x1B152 },
82+ .{ .lo = 0x1B155, .hi = 0x1B155 },
83+ .{ .lo = 0x1B164, .hi = 0x1B168 },
84+ .{ .lo = 0x1B170, .hi = 0x1B2FB },
85+ .{ .lo = 0x1D300, .hi = 0x1D356 },
86+ .{ .lo = 0x1D360, .hi = 0x1D376 },
87+ .{ .lo = 0x1F004, .hi = 0x1F004 },
88+ .{ .lo = 0x1F0CF, .hi = 0x1F0CF },
Cut short: this commit's diff is over 1000 lines.
tools/gen_width.py+159βˆ’0
Cut short: this commit's diff is over 1000 lines.