Skip to content
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: Set IME input mode to English when a Windows Terminal window is opened #12731

Closed
gexgd0419 opened this issue Mar 21, 2022 · 7 comments · Fixed by #13028
Closed
Labels
Area-i18n Internationalization issues (e.g.: non-US input handling doesn't work) Area-Input Related to input processing (key presses, mouse, etc.) Issue-Task It's a feature request, but it doesn't really need a major design. Product-Terminal The new Windows Terminal. Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release.
Milestone

Comments

@gexgd0419
Copy link

Description of the new feature/enhancement

I'm using the Microsoft Chinese IMEs, and when I open a Windows Terminal window, the input mode will be set to Chinese.

I know that's because the IME's "default mode" is set to Chinese (which is also the system default setting). If I change its "default mode" to English then the input mode will be English when I open Windows Terminal.

But I also noticed that even with the "default mode" set to Chinese, if you open Command Prompt (or other programs hosted by conhost.exe), the IME mode will still be switched to English, because users are more likely to input English texts.

So setting the input mode to English when Windows Terminal is launched would be helpful, as most command line texts are in English.

For Sougou Pinyin IME users: seems that Sougou Pinyin does not respect the "default input mode" set by those programs, because opening a Command Prompt window won't change its input mode to English.

I actually found a similar issue #1304 that further requested to restore input mode to English each time users hit Enter or Esc. That may be even better, although changing input mode so often might confuse some users. Personally I just want Windows Terminal to have English input mode on startup like what conhost does, so I can type in commands immediately.

@gexgd0419 gexgd0419 added the Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. label Mar 21, 2022
@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Mar 21, 2022
@zadjii-msft
Copy link
Member

If this is something that conhost already does, then this should be fairly trivial to implement for the Terminal, and it'd be all the precedent needed to do it. I'm worried that this is something that the IME does on behalf of conhost - detecting that conhost is the foreground window and then switching automatically.

If that's the case, this might be quite a bit harder to fix, requiring a fix in the OS itself.

@zadjii-msft zadjii-msft added Area-Input Related to input processing (key presses, mouse, etc.) Product-Terminal The new Windows Terminal. Issue-Task It's a feature request, but it doesn't really need a major design. Area-i18n Internationalization issues (e.g.: non-US input handling doesn't work) and removed Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. labels Mar 21, 2022
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label Mar 21, 2022
@YanceyChiew
Copy link
Contributor

YanceyChiew commented Apr 14, 2022

I didn't go deep, but have done a little testing to try and solve the same problem.

In terms of test results, there should be at least two_(edited: maybe only one)_ factors affecting the default input mode for window programs:

  • When the window class is ConsoleWindowClass, the input mode will be set to english regardless of the default value.(edited: There was an error in the previous test, because specifying WindowClass alone was far from enough to create an interactive console window, therefore, the above conclusions are only inferences based on limited indirect tests, which are in fact wrong. Finally, it was found that the real impact was the process name of conhost.exe, If it was renamed, any shells hosted on it will no longer automatically switch to the English input mode.)

  • When the process name is cmd.exe, powershell.exe, bash.exe or conhost.exe, the input mode will be set to english regardless of the default value. (edited: supplement known process name)

Looks more like it's determined by the Microsoft Pinyin itself, especially the second. When I rename other programs like notepad.exe to cmd.exe, it will accept English input by default.

For the first item, because there is no language related field in WNDCLASS or WNDCLASSEX structure, so I can only think that this ConsoleWindowClass has an extra contract with the system or Microsoft Pinyin. (edited: It doesn't matter because the first item above does not actually affect.)

The input area window class of windows terminal is Windows.UI.Input.InputSite.WindowClass,
I also didn't find the relevant settings, so I gave up.

The example in this link might be useful, but I didn't test it.

@zadjii-msft
Copy link
Member

Well, that's certainly great research! It's maybe a little troubling that this is something that seems to be outside our codebase. If this is something that's truly just a heuristic by Microsoft Pinyin, that just means it's gonna be less likely we can just patch that on our side.

@zadjii-msft zadjii-msft removed the Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting label Apr 14, 2022
@zadjii-msft zadjii-msft added this to the 22H2 milestone Apr 14, 2022
@YanceyChiew
Copy link
Contributor

Well, that's certainly great research! It's maybe a little troubling that this is something that seems to be outside our codebase. If this is something that's truly just a heuristic by Microsoft Pinyin, that just means it's gonna be less likely we can just patch that on our side.

I think I found a way:

in src\cascadia\TerminalControl\TSFInputControl.cpp:41:

        _editContext.InputScope(CoreTextInputScope::Text);

Just simply change the CoreTextInputScope::Text to CoreTextInputScope::AlphanumericHalfWidth should work.

  • CoreTextInputScope::AlphanumericHalfWidth makes the input box accept English by default, and can be manually changed to Chinese Pinyin with the shift key, which is exactly the effect we want.
    Although its name limits the characters to half-width, the input method can still enter full-width characters.
  • CoreTextInputScope::Password can also make the input box accept English input by default, but it will prevent the input method from being manually switched to Chinese Pinyin.

NOTICE: I have not actually tested the above code in this project, but completed the feasibility verification in another simple project which is just for testing, then I searched the entire microsoft/terminal project and found the only place InputScope appears and wrote this comment.

@YanceyChiew
Copy link
Contributor

YanceyChiew commented Apr 21, 2022

I have actually verified in this project that _editContext.InputScope(CoreTextInputScope::AlphanumericHalfWidth) works as expected, the remaining question is whether this change will cause dissatisfaction among some other users?

Or to be on the safe side, make the inputScope customizable through the configuration file maybe a better choice, I can handle it if necessary.

@ghost ghost added the In-PR This issue has a related PR label May 3, 2022
@DHowett
Copy link
Member

DHowett commented May 3, 2022

We can wait to see how users react. We only have to add a setting if they complain. 😄 Thanks!

@ghost ghost closed this as completed in #13028 May 3, 2022
@ghost ghost added Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release. and removed In-PR This issue has a related PR labels May 3, 2022
ghost pushed a commit that referenced this issue May 3, 2022
Modified the scope of input control, it used to be `Text`, now it is
`AlphanumericHalfWidth`.  This input scope actually accepts any
characters, but English characters are preferred, and the soft keyboard
also displays English by default.

This should improve user friendliness for users using composition mode
input methods.

As a user who uses the composition mode input method, in applications
like windows terminal that should usually be input in English, it is
always required to manually switch to English mode by pressing Shift
before entering commands.

One keystroke is not a problem, but often for some reason there is no or
no successful switching, and additional more keystrokes are required to
clear the wrong input.

The input method that comes with windows will automatically switch to
English mode for a few programs such as conhost, but windows terminal is
not in this list.

This change should have no negative impact. Even if someone does tend to
use a shell oriented towards composition characters or non-alpha
letters, there should also were more users who in the same language are
more inclined to English characters shells, for example, cmd,
powershell, bash that comes with windows.

If there's any reason to have to keep the Text inputScope, maybe making
this setting customizable via `settings.json` would be a good idea, but
I don't see the need to do this, `AlphanumericHalfWidth` is perfect.

Closes #12731
@ghost
Copy link

ghost commented May 24, 2022

🎉This issue was addressed in #13028, which has now been successfully released as Windows Terminal Preview v1.14.143.:tada:

Handy links:

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-i18n Internationalization issues (e.g.: non-US input handling doesn't work) Area-Input Related to input processing (key presses, mouse, etc.) Issue-Task It's a feature request, but it doesn't really need a major design. Product-Terminal The new Windows Terminal. Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants