feat: add IME cursor positioning support (#2) #833
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There is a bug in pull request #803, so I redesigned and developed a new solution related to the terminal cursor.
(Some of the source code from #803 was referenced.)
Problem
The terminal cursor is actually located at the bottom.
For languages such as Korean, Japanese, and Chinese, characters must be combined to form complete characters or words.
Until the character or word is completed, this is managed by the IME candidate windows buffer and output there.
The problem is that because the terminal cursor exists at the bottom, the IME Candidate Windows buffer is also being output at the bottom.
Purpose
When inputting text in
{input}, synchronize the terminal cursor to position the "IME candidate windows" at the actual input location.There may be developers or users who do not need this logic. (English-speaking users, etc.)
Therefore, the logic below is implemented to operate only when the
enableImeCursoroption in the render function is set totrue.Even if
terminalCursorFocusandterminalCursorPositionprops are used, they will not work unless theenableImeCursoroption is set totrue.Changes
terminalCursorFocusprop to the text component.terminalCursorPositionprop to the text component.The location of the example that applies this logic is
examples/multi-input/multi-input.tsx.Below is an example of how to use the terminal cursor in
example/chat/chat.tsx.You can specify which Text component receives terminal focus by setting
terminalCursorFocus.How to test?
Install Korean IME ("two-set keyboard").
and input this.
d k s s u d g k t p d y . -> print "안녕하세요."
Install Japanese IME ("Romaji").
and input this.
k o n n n i c h i w a。 -> print "こんにちわ。"
Test Checklist
mp4 test
terminalcursor.mp4
I partially developed and verified using Claude Code.