Skip to content

Fix cursor position for CJK/wide characters in TUI input - #25

Merged
Doorman11991 merged 1 commit into
Doorman11991:masterfrom
nashixiong926:fix/cjk-cursor-position
May 21, 2026
Merged

Fix cursor position for CJK/wide characters in TUI input#25
Doorman11991 merged 1 commit into
Doorman11991:masterfrom
nashixiong926:fix/cjk-cursor-position

Conversation

@nashixiong926

Copy link
Copy Markdown

Both cursor positioning and text wrapping in FullScreenTUI used string.length (JS character count), but CJK/Hangul/fullwidth characters occupy 2 terminal columns, causing the blinking cursor to appear mid-text when input contained such characters.

Added visualWidth(), visualLength(), visualWrap(), and visualCursorPosition() helpers accounting for double-width characters, and updated _renderInput(), render(), and _computeLayout() to use them.

Both cursor positioning and text wrapping in FullScreenTUI used
string.length (JS character count), but CJK/Hangul/fullwidth
characters occupy 2 terminal columns, causing the blinking cursor
to appear mid-text when input contained such characters.

Added visualWidth(), visualLength(), visualWrap(), and
visualCursorPosition() helpers accounting for double-width
characters, and updated _renderInput(), render(), and
_computeLayout() to use them.
@Doorman11991
Doorman11991 merged commit 301c524 into Doorman11991:master May 21, 2026
5 checks passed
@nashixiong926
nashixiong926 deleted the fix/cjk-cursor-position branch May 21, 2026 10:50
Kothulhu94 pushed a commit to Kothulhu94/smallcode that referenced this pull request May 29, 2026
…position

Fix cursor position for CJK/wide characters in TUI input
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.

3 participants