mike-fabian / ibus-typing-booster

ibus-typing-booster is a completion input method for faster typing
https://mike-fabian.github.io/ibus-typing-booster/
Other
232 stars 16 forks source link

[Question] Automatic layout change #359

Closed 000exploit closed 2 years ago

000exploit commented 2 years ago

I didn't find it in the documentation, maybe I missed it, but does it support automatic layout change? For example, I write in Cyrillic layout(ofc with hunspell support) and want to write a few words in English language and vise versa, will it change layout automatically (and replace wrong characters with correct), or should I change it manually?

mike-fabian commented 2 years ago

I think Typing Booster can do what you want, but I’ll try to explain in detail:

Currently, ibus-typing-booster does not change the “real” keyboard layout in any way, it just uses the keyboard layout which was active when switching to ibus-typing-booster.

Some input methods enforce a certain keyboard layout when switching to them, for example some Chinese input methods like Cangjie do that. Because they work well only with the “English US” layout or very similar layouts and would not work well with very different layouts like French AZERTY or Dvorak layouts, they enforce the “English US” layout when switching to them. ibus-m17n also has the option to switch to “English US” layout when switching to ibus-m17n. I think there are currently no ibus input methods which switch to any other layout except “English US” if they enforce any layout change at all.

Most input methods do not enforce a specific keyboard layout, for example phonetic input methods like most Japanese input methods or Chinese input methods using something like Pinyin work well with any keyboard layout which is able to produce the Latin letters for the phonetics, i.e. they work well with almost all layouts except those which don’t produce Latin letters but for example Cyrillic.

Typing Booster does not enforce a specific keyboard layout either, it can work with almost any keyboard layout, which one is best depends very much on what the user wants.

Maybe, in future I might add a feature to make it possible to switch to a certain keyboard layout when switching to typing booster. But if I do that, the keyboard layout to be switched to has to be selectable by the user, it cannot just be “English US” as it is in the otther ibus input methods which currently enforce a layout. But I am not sure yet how useful such a feature would be, I think it can be useful in some corner cases, but I think for what you actually want it is not needed.

I’ll try to explain with some screenshots in the next comment.

mike-fabian commented 2 years ago

In this screenshot you can see that I have configured

ru-kbd is an emulation of the standard Russian keyboard layout when the input is really coming from an English US (or similar) layout.

NoIME means just use the current keyboard layout as it is.

In the screenshot I have typed these keys on the English US layout (i.e. the “real” keyboard layout): xt,ehf But what I actually see in the preedit is чебура.

This is because the ru-kbd input method is at the top priority and it “translates” the keys xt,ehf to what is at the same position on a Russian layout like https://en.wikipedia.org/wiki/JCUKEN#/media/File:KB_Russian.svg

Therefore one sees чебура in the preedit.

And the completion suggestions are all Russian because both xt,ehf and чебура are searched in both the English and the Russian dictionaries, but of course xt,ehf does not match anything but чебура finds some matches in the Russian dictionary:

Screenshot

mike-fabian commented 2 years ago

Now if I don’t change anything but type cheese, I get what this screenshot shows:

Screenshot2

mike-fabian commented 2 years ago

As the input method with highest priority is still ru-kbd, I don’t see cheese in the preedit but the respective letters on the Russian layout produced by ru-kbd, i.e. I see срууыу in the preedit.

But in the list of suggestions I see only English words starting with cheese because again both cheese and срууыу are looked up in both dictionaries but срууыу matches nothing in either dictionary (no valid Russian word starts like that). But cheese finds some matches in the English dictionary.

mike-fabian commented 2 years ago

So if you mostly type Russian but from time to time type a few English words, you could just have ru-kbd a the top priority and type the English word, most likely it will match nothing in the Russian dictionary but it will match something in the English dictionary and you can select it from the candidate list then.

I.e. in many cases, if you want to type some English word, you just type the start of that word as you would on an English US keyboard layout and you can then select the completed word from the candidate list, probably even save some keystrokes because of the completion and also save some keystrokes by not having to switch layouts.

mike-fabian commented 2 years ago

You can switch input methods manually though. The default key bindings for that are:

next_input_method          ['Control+Down', 'Control+KP_Down']
previous_input_method   ['Control+UP', 'Control+KP_Up']

This changes the priority order of ru-kbd and NoIME and therefore also changes what is displayed in the preedit.

But it does not change the list of candidates displayed as these are calculated with both interpretations of the input anyway.

If you want to remember this input method priority to what was last used, use the option:

☑️ Remember last used preedit input method

mike-fabian commented 2 years ago

Video showing how the preedit changes between cheese and срууыу when I type Control+Down to select the next input method:

https://user-images.githubusercontent.com/2330175/183847756-a47de2b2-0dde-4ea2-81aa-f5642beb6991.mp4

mike-fabian commented 2 years ago

In the video you can also see the priority of the input methods change in the setup tool while I type Control+Down. That is because I selected the option:

☑️ Remember last used preedit input method

Without that Control+Down would still switch from ru-kbd to NoIME but after a restart of the Gnome sessioņ ru-kbd would still be on top.

When I don’t select any candidate and just type space, then whatever is currently visisble in the preedit is committed.

When I typed “cheese” for the second time and switched the preedit to “срууыу” by typing Control+Down I then typed a space and therefore “срууыу” was committed.

Therefore, when I typed “cheese” for the 3rd time, “срууыу” shows among the candidates even though it is not contained in the Russian dictionary. But Typing Booster remembers that after typing “cheese”, “срууыу” was chosen and therefore when typing “cheese” next, “срууыу” will show up as a candidate.

mike-fabian commented 2 years ago

Does that help for you? Does that do what you want?

mike-fabian commented 2 years ago

Ping 🏓

000exploit commented 2 years ago

Ping :ping_pong:

Pong :ping_pong:

000exploit commented 2 years ago

Does that help for you? Does that do what you want?

Yes, that's helped me. Not exactly what I want (auto switch when it detects that something is wrong and there's, for example, a word in the dictionary), but at least I can correct the word after typing without typing it from scratch and see another candidates in the dictionary. Anyway, thanks for the answer.

mike-fabian commented 2 years ago

Yes, that's helped me.

Great!

Not exactly what I want (auto switch when it detects that something is wrong and there's, for example, a word in the dictionary)

That is an interesting idea to automatically switch the top priority input method used for the preedit in some cases.

Something like “If there are only matches in dictionary x, switch to input method y” or something like that might be useful.

I need to think about this ...