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

Support OS language switch #210

Closed
habamax opened this issue Mar 24, 2020 · 10 comments
Closed

Support OS language switch #210

habamax opened this issue Mar 24, 2020 · 10 comments
Labels
bug Something isn't working keyboard Input Catch all category for keyboard issues

Comments

@habamax
Copy link

habamax commented Mar 24, 2020

Currently when I try to switch language and input some russian text I get something different.
And then If I switch back to english it continues "weirdness":

neovide-non-english

@habamax
Copy link
Author

habamax commented Mar 24, 2020

Probably related to #125

@Kethku
Copy link
Member

Kethku commented Mar 24, 2020

I would love some advice for how best to solve this. I'm incredibly frustrated with my options at the moment.

The full backstory is long and tired, but the basic gist is that sdl2 (the cross platform windowing library I am using) has two modes for getting keyboard inputs:

Keydown/KeyUp which gets non keyboard mapped keycodes. This event lets allows me to tell which key is pressed and which modifiers are held down, but does not transform the key to the correct keyboard layout mapped value. As an example: ctrl-shift-6 on a qwerty keyboard would be reported as ctrl-shift-6 using this method instead of ctrl-^.

TextInput which transforms the key properly, but does not allow for modifiers that don't produce a unique value. As an example: shift-6 on qwerty would properly produce ^, but ctrl-shift-6 would produce no TextInput event.

Given these two primitives, today neovide does the following here https://github.com/Kethku/neovide/blob/master/src/bridge/layouts/mod.rs#L102

If TextInput produced a text value, then shift is ignored (it is assumed that the textinput used it up), and modifiers are applied.
If not, we look up the keyboard layout configured by the neovide_keyboard_layout global variable (currently there is one qwerty option, but as demand requires more will be added) and we manually modify the keyboard character to produce the correct value. This may consume shift, ctrl, and or alt modifiers in the process.

This strategy is very unfortunate because it requires the user to set the correct keyboard layout in a global variable and it requires us to list every possible key combination in a giant file for every supported layout which is decidedly not crossplatform or layout compatible. If a user has a novel layout, they have to contribute it to the repo or they are out of luck.

Unfortunately I don't currently see a way out of this. I would LOVE any hint or advice for how to fix this. At this point I'm out of ideas.

@Kethku
Copy link
Member

Kethku commented Mar 24, 2020

As for the exact issue here, the D- means that the windows key is held down. I believe this is fixed in the current master, but not the released version of the app. Please build from source

@Kethku Kethku added the bug Something isn't working label Mar 24, 2020
@habamax
Copy link
Author

habamax commented Mar 25, 2020

Looks like you use kind of "scan codes" instead of characters and I am not sure if there is a simple/easy way to get real chars out of scan codes.

So I can see the following routes:

  • do nothing (then users with non-latin layouts wouldn't use neovide that much)
  • implement neovide specific keyboard layout manager and database of layouts -- I am not sure about efforts, but looks like huge.
  • refactor keyboard input routines to use chars instead of scancodes (I believe (g)vim and neovim(-qt) use characters) -- the efforts..., well :)

Not sure if SDL has char input you can use: https://forums.libsdl.org/viewtopic.php?p=51153

@Kethku
Copy link
Member

Kethku commented Mar 25, 2020

The character input is handled by the TextInput events I described. These can't be used for everything because they are not raised if modifiers outside of those necessary for producing the initial character are held down. So shift-6 produces ^ but ctrl-shift-6 does not.

@habamax
Copy link
Author

habamax commented Mar 26, 2020

Sorry not an expert :(, and don't know rust

But if I press C-S-6 shouldn't it go here:

https://github.com/Kethku/neovide/blob/e9808f185ff103e7e3dc2361bc5238541ccbc3e7/src/bridge/layouts/mod.rs#L103

Like, ^ was generated by S-6 and then you apply CTRL modifier?

@Kethku
Copy link
Member

Kethku commented Mar 27, 2020

It doesn't. No textinput event is raised because of a limitation in sdl2. I brought up the issue with the sdl2 team and they ignored my concerns even with repeated attempts to describe the problem. So at this point I'm out of luck

@Kethku
Copy link
Member

Kethku commented Mar 27, 2020

For background this is the conversation I had: https://bugzilla.libsdl.org/show_bug.cgi?id=5029

@ewhac
Copy link

ewhac commented Mar 31, 2020

This issue also breaks using C-^ to switch to the "alternate" file, something I use a lot.

@Kethku Kethku added the keyboard Input Catch all category for keyboard issues label Apr 3, 2020
@Kethku
Copy link
Member

Kethku commented Jan 11, 2021

closing in favor of #445

@Kethku Kethku closed this as completed Jan 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working keyboard Input Catch all category for keyboard issues
Projects
None yet
Development

No branches or pull requests

3 participants