Open migueldeicaza opened 3 years ago
Have you find any solution on Chinese input? It doesn’t work and the insertText isn’t getting called. :( Having no idea where to follow up next…
Hello!
Can you describe what you are trying to do, and how it fails?
I would need to know what keyboard you are using, how you are activating it, and which keystrokes you are using, so I can reproduce locally.
It works as far as I can tell with the main branch
Let me answer the question first.
what you are trying to do
I am trying to fix an issue that the terminalView insertText won't get called when typing with Chinese keyboard.
how it fails?
No respond or future action created.
what keyboard you are using
The system one with Chinese Pinyin Input Method.
how you are activating it
.onAppear {
terminal.terminalView.becomeFirstResponder()
}
which keystrokes
I don't get it.......... :(
For some more detail, I can provide you a demo project that I am currently using. Let me explain a little bit more.
Changes:
Terminal Setup Block:
terminalView.backgroundColor = .clear
terminalView.isOpaque = true
terminalView.backgroundColor = UIColor.clear
terminalView.nativeBackgroundColor = UIColor.clear
curl https://www.baidu.com
, you will notice those Chinese clipped with only half left displayed.Interesting finding: this happens with the SwiftUI wrapper, but not with the view without SwiftUI.
If you open the SwiftTerm sample project for iOS (iOSTerminal), and configure the host in UIKitSshTerminal.View and add manually the password there, you can see that the Chinese text input works.
But when I tried it on my own app, that wraps the SwiftTerm into a SwiftUI, the auxiliary keyboard is not shown either.
This is what SwiftTerm shows:
Sadly, this is what SwiftTermApp (my SwiftUI-based app that uses the exact same code) shows. In this case, I have already entered a few keys, and the keyboard is never shown:
So at this point, I suspect something is going on with SwiftUI. Reveal shows that the keyboard is being activated on the regular version, and the size of the keyboard is larger:
While on the SwiftUI version, the keyboard starts up smaller, and does not get the region with the additional data:
(Ignore the yellow color, that is just a different style that I am using there).
I have implemented manual support for the cursor tracking, so this works, but it is not as good as it could be, because the data that I get is a proxy to the geometry for the caret that I get - which is not necessarily what we want on a terminal app. So a potential fix is to use a timer when we get close to the boundary to trigger a repeat operation - but I have not figured out how to get the boundary information
Currently, the UITextInput implementation is using an out-of-band Character buffer, plus positions and ranges that are based on indexes into this out-of-band buffer.
This works for dictation, and input methods and I finally got it to work.
That said, it has a few problems:
How other terminals work
Tracks+Funky
in SpaceMove means that the application does track the cursor with the space bar, and then attempts to send enough cursor key movements to the target to track the location. But also means that in the wrong context (say, "cat"), it just sends the sequences and just looks odd.