Skip to content

Misc cleanups: clear_region note, Hangul jamo width, ESC-digit cursor…#9

Merged
alganet merged 1 commit into
mainfrom
misc
Jun 13, 2026
Merged

Misc cleanups: clear_region note, Hangul jamo width, ESC-digit cursor…#9
alganet merged 1 commit into
mainfrom
misc

Conversation

@alganet

@alganet alganet commented Jun 13, 2026

Copy link
Copy Markdown
Owner

… seq

Three low-severity items.

  • tuish_clear_region re-implements _tuish_str_repeat's O(log n) doubling. It can't be deduplicated: that helper lives in str.sh, but term.sh depends only on tui.sh and is sourced without str.sh in minimal setups (README quick-start, examples/slow_menu.sh). Add a comment documenting the deliberate duplication so it isn't re-flagged.

  • Conjoining Hangul Jamo (U+1160-U+11FF, medial vowels and final consonants) were classified width 1; like other wcwidth implementations they are zero width (they combine onto the leading consonant, which stays width 2). Add a 0-width branch for that range. New width test: a decomposed syllable (U+1100 + U+1161 + U+11A8) is 2 columns, not 4.

  • More than cosmetic: tuish_save_cursor used '\x1b7', which ksh93's printf reads as hex 0x1b7 — so DECSC was emitted as the bytes c6 b7 instead of ESC 7. No single backslash escape works everywhere (the octal '\0337' becomes byte 337 on mksh). Emit a literal ESC byte (_tuish_chr_27 from the ord table) for both save and restore so the trailing digit can't be swallowed. Verified ESC 7 / ESC 8 on bash, zsh, ksh93, mksh, busybox (buffered and unbuffered). New tests/unit/test_term.sh guards it per shell.

All unit suites pass on bash/zsh/ksh93/mksh/busybox; boxes/keyboard/editor integration pass under ksh93 and mksh.

… seq

Three low-severity items.

 - tuish_clear_region re-implements _tuish_str_repeat's O(log n) doubling.
It can't be deduplicated: that helper lives in str.sh, but term.sh depends
only on tui.sh and is sourced without str.sh in minimal setups (README
quick-start, examples/slow_menu.sh). Add a comment documenting the
deliberate duplication so it isn't re-flagged.

 - Conjoining Hangul Jamo (U+1160-U+11FF, medial vowels and final
consonants) were classified width 1; like other wcwidth implementations
they are zero width (they combine onto the leading consonant, which stays
width 2). Add a 0-width branch for that range. New width test: a
decomposed syllable (U+1100 + U+1161 + U+11A8) is 2 columns, not 4.

 - More than cosmetic: tuish_save_cursor used '\x1b7', which ksh93's
printf reads as hex 0x1b7 — so DECSC was emitted as the bytes c6 b7
instead of ESC 7. No single backslash escape works everywhere (the octal
'\0337' becomes byte 337 on mksh). Emit a literal ESC byte (_tuish_chr_27
from the ord table) for both save and restore so the trailing digit can't
be swallowed. Verified ESC 7 / ESC 8 on bash, zsh, ksh93, mksh, busybox
(buffered and unbuffered). New tests/unit/test_term.sh guards it per shell.

All unit suites pass on bash/zsh/ksh93/mksh/busybox; boxes/keyboard/editor
integration pass under ksh93 and mksh.
@alganet
alganet merged commit 19edd70 into main Jun 13, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant