-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: IME mode after pressing Escape or Enter key in CJK input #1304
Comments
@qqkookie is this for the Windows Terminal, or conhost.exe (which is the window for cmd.exe, powershell, wsl.exe, etc.)? |
For Window Terminal. I have implemented similar feature for Cygwin / mintty. You can see my implementation in qqkookie/mintty@c7fb70e Many CJK terminal emulators (SSH/Telnet clients) on MS Windows have similar feature. For example, Korean iPuTTY (open source), XShell (commercial SSH client) and many X window Korean/Hanguel terminal emulator like hanterm. It is such universally requested feature for Korean terminal users. |
I examined current source myself. It seems that CJK IME is handled by console host. ConHost/Host/{ input.c and conimeinfo.c_. I guess that the HandleKeyEvent() routine in $(ROOT)/src/interactivity/win32/windowio.cpp is suitable place to handle this feature. Insert code like below in the HandleKeyEvent() function. if ((key == VK_RETURN || key == VK_ESCAPE) && !mods) { HIMC hImc = ImmGetContext(wnd); if (ImmGetOpenStatus(hImc)) { ImmSetConversionStatus(hImc, IME_CMODE_ALPHANUMERIC, IME_SMODE_NONE); ImmReleaseContext(wnd, hImc); }; }; |
@qqkookie great work finding that in the code. However, what you've found there is the code that is responsible for Unfortunately, with #2213, the IME in the Windows Terminal doesn't currently work. There's a PR in progress for it in #1919. Once that's in, then it might be more appropriate to investigate this feature for the Windows Terminal 😊 |
From @eromoe:
|
I've looked high and low at CoreTextEditContext, and I just can't find the equivalent API for ImmSetConversionStatus. Have to ask our input folks. |
It not limit to particular IME . The key problem is :
This make other IME shows on input area at default . Usually I don't expect that , I manully add an English IME to overcome currently . This happened on terminal is very annoy . |
@eromoe By saying "creating a default English IME" do you mean creating one after deleting the default Microsoft Pinyin? I think that people inside the Windows OS team may have more knowledge about this. Personally I'm happy with the performance and reliability of the stock Microsoft Pinyin, especially after 2004 release. Overall the IME experience does not cause me serious problems. |
@skyline75489 Below setting doesn't work with English input(in Chinese Language) : I use |
Ah. I see. So the issue for Sogou can be separated into two parts:
As for the IME configuration, personally I have this: I'm using the en-US version of Windows so naturally I have en-US at first, then I installed the zh-CH language pack and got the Microsoft Pinyin. I guess this is why I'm not experience the IME difficulty. |
Above is a little diverge , previous The key points of this issue I had expressed by the gif, these are definitely bugs :
|
I believe that changing this line (/src/cascadia/TerminalControl/TSFInputControl.cpp#L41) _editContext.InputScope(CoreTextInputScope::Text); to _editContext.InputScope(CoreTextInputScope::AlphanumericHalfWidth); should make CJK IME open in English input mode by default. But the problem is that after switching to composition mode(eg, Chinese Pinyin), it will be difficult to switch back dynamically through code. In fact I found a workaround but it raises other problems: // c# sample code
case VirtualKey.Enter:
_editContext.InputScope = CoreTextInputScope.Password;
_editContext.NotifyFocusLeave();
_editContext.NotifyFocusEnter();
_editContext.InputScope = CoreTextInputScope.AlphanumericHalfWidth;
break; When inputting through the physical keyboard, the next time you switch to composition mode you will need to press shift twice (normally only once). A more serious problem occurs when using the soft keyboard for input. If speculate from the code it may cause the soft keyboard to flash once or twice, which already affects the user experience, but the reality is worse, soft keyboard will be fixed to the password mode and cannot be switched. The soft keyboard behaves very strangely, If you adjust where // c# sample code
case VirtualKey.Space:
_editContext.NotifyFocusLeave();
_editContext.InputScope = CoreTextInputScope.Password;
_editContext.NotifyFocusEnter();
_editContext.NotifyFocusLeave();
_editContext.InputScope = CoreTextInputScope.AlphanumericHalfWidth;
_editContext.NotifyFocusEnter();
break; I didn't find an API that really fits, maybe it just doesn't exist. For me it was enough to have windows terminal support English input by default when it was opened |
Problem of CJK IME on terminal start up is related but different matter, I guess. So we should call I tried to insert such code into I also tried
Any help or idea? |
I made good progress. Now it works on my PC, at least. I need more testing, I guess. |
Hmm.. I added terminal Setting/Interaction UI and it works. |
Next in the popular series of minor refactorings: Out with the old, in with the new! This PR removes all of the existing TSF code, both for conhost and Windows Terminal. conhost's TSF implementation was awful: It allocated an entire text buffer _per line_ of input. Additionally, its implementation spanned a whopping 40 files and almost 5000 lines of code. Windows Terminal's implementation was absolutely fine in comparison, but it was user unfriendly due to two reasons: Its usage of the `CoreTextServices` WinRT API indirectly meant that it used a non-transitory TSF document, which is not the right choice for a terminal. A `TF_SS_TRANSITORY` document (-context) indicates to TSF that it cannot undo a previously completed composition which is exactly what we need: Once composition has completed we send the result to the shell and we cannot undo this later on. The WinRT API does not allow us to use `TF_SS_TRANSITORY` and so it's unsuitable for our application. Additionally, the implementation used XAML to render the composition instead of being part of our text renderer, which resulted in the text looking weird and hard to read. The new implementation spans just 8 files and is ~1000 lines which should make it significantly easier to maintain. The architecture is not particularly great, but it's certainly better than what we had. The implementation is almost entirely identical between both conhost and Windows Terminal and thus they both also behave identical. It fixes an uncountable number of subtle bugs in the conhost TSF implementation, as it failed to check for status codes after calls. It also adds several new features, like support for wavy underlines (as used by the Japanese IME), dashed underlines (the default for various languages now, like Vietnamese), colored underlines, colored foreground/background controlled by the IME, and more! I have tried to replicate the following issues and have a high confidence that they're resolved now: Closes #1304 Closes #3730 Closes #4052 Closes #5007 (as it is not applicable anymore) Closes #5110 Closes #6186 Closes #6192 Closes #13805 Closes #14349 Closes #14407 Closes #16180 For the following issues I'm not entirely sure if it'll fix it, but I suspect it's somewhat likely: #13681 #16305 #16817 Lastly, there's one remaining bug that I don't know how to resolve. However, that issue also plagues conhost and Windows Terminal right now, so it's at least not a regression: * Press Win+. (emoji picker) and close it * Move the window around * Press Win+. This will open the emoji picker at the old window location. It also occurs when the cursor moves within the window. While this is super annoying, I could not find a way to fix it. ## Validation Steps Performed * See the above closed issues * Use Vietnamese Telex and type "xin choaf" Results in "xin chào" ✅ * Use the MS Japanese IME and press Alt+` Toggles between the last 2 modes ✅ * Use the MS Japanese IME, type "kyouhaishaheiku", and press Space * The text is converted, underlined and the first part is doubly underlined ✅ * Left/Right moves between the 3 segments ✅ * Home/End moves between start/end ✅ * Esc puts a wavy line under the current segment ✅ * Use the Korean IME, type "gksgks" This results in "한한" ✅ * Use the Korean IME, type "gks", and press Right Ctrl Opens a popup which allows you to navigate with Arrow/Tab keys ✅
We just published a major update to our IME implementation in the nightly Canary branch. It was rewritten from the ground up and has tons of improvements! If you're interested in trying it out, you can get it here: https://aka.ms/terminal-canary-installer If you encounter any issues or have any suggestions, or if you simply like/dislike the changes, please let us know! Thank you for bearing with us. 😊 |
When CJK input method (IME) is used, pressing Escape key or Enter key will restore IME mode to ALPHA input mode. Keeping CJK mode in command line input after these keys causes mostly erroneous input. This behavior may be per-user configurable option.
The text was updated successfully, but these errors were encountered: