diff options
| author | eunhhu <[email protected]> | 2026-09-30 13:19:01 +0100 |
|---|---|---|
| committer | eunhhu <[email protected]> | 2026-09-30 13:19:01 +0100 |
| commit | 611b54fefc8a02f67cd59041c1795a083ac0bb4c (patch) | |
| tree | 6eaf8bab3ec7d8cb9b2d7d8b5d432df42988cf5c /surfaces/width.c | |
| parent | b3c01b3a26a7b5fe60b70739a6fc7b5967e0d9c8 (diff) | |
| download | vega-611b54fefc8a02f67cd59041c1795a083ac0bb4c.tar.gz vega-611b54fefc8a02f67cd59041c1795a083ac0bb4c.zip | |
Show what would act on a screen as a picture on every surface, and keep a value's bidi within it
Speech wrote a value's C1 controls (U+009B is a CSI to some terminals),
DEL, line separators and bidi overrides as they were; the CLI and the
TUI wrote line separators (a pipe's reader may break its line there) and
the controls that turn text around (a terminal then reverses the rest of
its line, other values' cells too); the web page showed controls as they
were and let a label's override reverse its badge. Now every surface
shows controls, DEL, C1 and line and paragraph separators as pictures
(vega_visible); a terminal's cells show embeddings, overrides and
isolates as U+FFFD too (vega_cell); speech says a space for the one and
nothing for the other; the page shows the pictures and isolates each
value, while /screen's JSON keeps values as they are. screen_meaning
checks the CLI, the TUI, speech and the JSON against that rule, and that
nothing a value holds reaches any output as a control; the browser check
sees the page show it.
Diffstat (limited to 'surfaces/width.c')
| -rw-r--r-- | surfaces/width.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/surfaces/width.c b/surfaces/width.c index 1e893f6..645e309 100644 --- a/surfaces/width.c +++ b/surfaces/width.c @@ -46,9 +46,15 @@ uint32_t vega_visible(uint32_t codepoint) { if (codepoint < 0x20) return 0x2400 + codepoint; if (codepoint == 0x7F) return 0x2421; if (codepoint >= 0x80 && codepoint < 0xA0) return 0xFFFD; + if (codepoint == 0x2028 || codepoint == 0x2029) return 0x2424; return codepoint; } +uint32_t vega_cell(uint32_t codepoint) { + if ((codepoint >= 0x202A && codepoint <= 0x202E) || (codepoint >= 0x2066 && codepoint <= 0x2069)) return 0xFFFD; + return vega_visible(codepoint); +} + size_t vega_decode(const char *text, size_t length, size_t at, uint32_t *codepoint) { const unsigned char *p = (const unsigned char *)text + at; size_t left = length - at, need = p[0] < 0x80 ? 1 : p[0] < 0xE0 ? 2 : p[0] < 0xF0 ? 3 : 4; @@ -64,7 +70,7 @@ unsigned vega_text_width(const char *text, size_t length) { for (size_t at = 0; at < length;) { uint32_t codepoint; at += vega_decode(text, length, at, &codepoint); - width += vega_width(vega_visible(codepoint)); + width += vega_width(vega_cell(codepoint)); } return width; } |
