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

If typing a keypad key makes a compose sequence invalid, try regular key instead #224

Closed mike-fabian closed 3 years ago

mike-fabian commented 3 years ago
$ grep Ø /usr/share/X11/locale/en_US.UTF-8/Compose
<dead_stroke> <O>                       : "Ø"   Oslash # LATIN CAPITAL LETTER O WITH STROKE
<Multi_key> <slash> <O>                 : "Ø"   Oslash # LATIN CAPITAL LETTER O WITH STROKE
<Multi_key> <O> <slash>                 : "Ø"   Oslash # LATIN CAPITAL LETTER O WITH STROKE
<Multi_key> <KP_Divide> <O>             : "Ø"   Oslash # LATIN CAPITAL LETTER O WITH STROKE

This is nonsense, why should the user care whether to use slash or KP_Divide and why should there be such subtle differences?

If <Multi_key> <slash> <O> and <Multi_key> <O> <slash> both work and produce the same result, then it makes no sense that when using KP_Divide instead of slash, only <Multi_key> <KP_Divide> <O> works but <Multi_key> <O> <KP_Divide> does not.

mike-fabian commented 3 years ago

I did submit a merge request for xorg to improve the Compose file to add the missing orders which should then result in the same behaviour for the keypad keys and the regular keys:

https://gitlab.freedesktop.org/xorg/lib/libx11/-/merge_requests/82

https://lists.x.org/archives/xorg-devel/2021-August/058743.html

mike-fabian commented 3 years ago

Only one response so far:

https://lists.x.org/archives/xorg-devel/2021-August/058744.html

Doesn’t seem to like my improvement ☹

mike-fabian commented 3 years ago

On top of that, my merge request missed a few sequences like these for example:

<Multi_key> <1> <4>                 : "¼"   onequarter # VULGAR FRACTION ONE QUARTER
<Multi_key> <1> <2>                 : "½"   onehalf # VULGAR FRACTION ONE HALF
<Multi_key> <3> <4>                 : "¾"   threequarters # VULGAR FRACTION THREE QUARTERS

I think these should also work with KP_1, KP_2, KP_3, and KP_4.

mike-fabian commented 3 years ago

I implemented:

This is certainly quite helpful and better than immediately stopping the compose sequence as invalid.

And it still observes what is written in the compose to the letter, so are still some minor differences in the behaviour of keypad keys and “normal” keys if the compose file makes a distinction.

For example:

[mfabian@fedora ~]$ grep '^<Multi_key> <KP_Divide>' /usr/share/X11/locale/en_US.UTF-8/Compose 
<Multi_key> <KP_Divide> <O>         : "Ø"   Oslash # LATIN CAPITAL LETTER O WITH STROKE
<Multi_key> <KP_Divide> <o>         : "ø"   oslash # LATIN SMALL LETTER O WITH STROKE
<Multi_key> <KP_Divide> <D>         : "Đ"   Dstroke # LATIN CAPITAL LETTER D WITH STROKE
<Multi_key> <KP_Divide> <d>         : "đ"   dstroke # LATIN SMALL LETTER D WITH STROKE
<Multi_key> <KP_Divide> <H>         : "Ħ"   U0126 # LATIN CAPITAL LETTER H WITH STROKE
<Multi_key> <KP_Divide> <h>         : "ħ"   U0127 # LATIN SMALL LETTER H WITH STROKE
<Multi_key> <KP_Divide> <L>         : "Ł"   U0141 # LATIN CAPITAL LETTER L WITH STROKE
<Multi_key> <KP_Divide> <l>         : "ł"   U0142 # LATIN SMALL LETTER L WITH STROKE
<Multi_key> <KP_Divide> <T>         : "Ŧ"   U0166 # LATIN CAPITAL LETTER T WITH STROKE
<Multi_key> <KP_Divide> <t>         : "ŧ"   U0167 # LATIN SMALL LETTER T WITH STROKE
<Multi_key> <KP_Divide> <b>         : "ƀ"   U0180 # LATIN SMALL LETTER B WITH STROKE
<Multi_key> <KP_Divide> <I>         : "Ɨ"   U0197 # LATIN CAPITAL LETTER I WITH STROKE
<Multi_key> <KP_Divide> <Z>         : "Ƶ"   U01B5 # LATIN CAPITAL LETTER Z WITH STROKE
<Multi_key> <KP_Divide> <z>         : "ƶ"   U01B6 # LATIN SMALL LETTER Z WITH STROKE
<Multi_key> <KP_Divide> <G>         : "Ǥ"   U01E4 # LATIN CAPITAL LETTER G WITH STROKE
<Multi_key> <KP_Divide> <g>         : "ǥ"   U01E5 # LATIN SMALL LETTER G WITH STROKE
<Multi_key> <KP_Divide> <i>         : "ɨ"   U0268 # LATIN SMALL LETTER I WITH STROKE
<Multi_key> <KP_Divide> <U0294>     : "ʡ"   U02A1 # LATIN LETTER GLOTTAL STOP WITH STROKE
<Multi_key> <KP_Divide> <Cyrillic_GHE>  : "Ғ"   U0492 # CYRILLIC CAPITAL LETTER GHE WITH STROKE
<Multi_key> <KP_Divide> <Cyrillic_ghe>  : "ғ"   U0493 # CYRILLIC SMALL LETTER GHE WITH STROKE
<Multi_key> <KP_Divide> <Cyrillic_KA>   : "Ҟ"   U049E # CYRILLIC CAPITAL LETTER KA WITH STROKE
<Multi_key> <KP_Divide> <Cyrillic_ka>   : "ҟ"   U049F # CYRILLIC SMALL LETTER KA WITH STROKE
<Multi_key> <KP_Divide> <U04AE>     : "Ұ"   U04B0 # CYRILLIC CAPITAL LETTER STRAIGHT U WITH STROKE
<Multi_key> <KP_Divide> <U04AF>     : "ұ"   U04B1 # CYRILLIC SMALL LETTER STRAIGHT U WITH STROKE
<Multi_key> <KP_Divide> <leftarrow>     : "↚"   U219A # LEFTWARDS ARROW WITH STROKE
<Multi_key> <KP_Divide> <rightarrow>    : "↛"   U219B # RIGHTWARDS ARROW WITH STROKE
<Multi_key> <KP_Divide> <U2194>     : "↮"   U21AE # LEFT RIGHT ARROW WITH STROKE
[mfabian@fedora ~]$ 

But:

[mfabian@fedora ~]$ grep '^<Multi_key> <slash>' /usr/share/X11/locale/en_US.UTF-8/Compose 
<Multi_key> <slash> <slash>         : "\\"   backslash # REVERSE SOLIDUS
<Multi_key> <slash> <less>          : "\\"   backslash # REVERSE SOLIDUS
<Multi_key> <slash> <asciicircum>   : "|"   bar # VERTICAL LINE
<Multi_key> <slash> <C>             : "₡"   U20a1 # COLON SIGN
<Multi_key> <slash> <m>             : "₥"   U20a5 # MILL SIGN
<Multi_key> <slash> <c>             : "¢"   cent # CENT SIGN
<Multi_key> <slash> <u>         : "µ"   mu # MICRO SIGN
<Multi_key> <slash> <O>             : "Ø"   Oslash # LATIN CAPITAL LETTER O WITH STROKE
<Multi_key> <slash> <o>             : "ø"   oslash # LATIN SMALL LETTER O WITH STROKE
<Multi_key> <slash> <D>             : "Đ"   Dstroke # LATIN CAPITAL LETTER D WITH STROKE
<Multi_key> <slash> <d>             : "đ"   dstroke # LATIN SMALL LETTER D WITH STROKE
<Multi_key> <slash> <H>             : "Ħ"   U0126 # LATIN CAPITAL LETTER H WITH STROKE
<Multi_key> <slash> <h>             : "ħ"   U0127 # LATIN SMALL LETTER H WITH STROKE
<Multi_key> <slash> <L>             : "Ł"   U0141 # LATIN CAPITAL LETTER L WITH STROKE
<Multi_key> <slash> <l>             : "ł"   U0142 # LATIN SMALL LETTER L WITH STROKE
<Multi_key> <slash> <T>             : "Ŧ"   U0166 # LATIN CAPITAL LETTER T WITH STROKE
<Multi_key> <slash> <t>             : "ŧ"   U0167 # LATIN SMALL LETTER T WITH STROKE
<Multi_key> <slash> <b>             : "ƀ"   U0180 # LATIN SMALL LETTER B WITH STROKE
<Multi_key> <slash> <I>             : "Ɨ"   U0197 # LATIN CAPITAL LETTER I WITH STROKE
<Multi_key> <slash> <Z>             : "Ƶ"   U01B5 # LATIN CAPITAL LETTER Z WITH STROKE
<Multi_key> <slash> <z>             : "ƶ"   U01B6 # LATIN SMALL LETTER Z WITH STROKE
<Multi_key> <slash> <G>             : "Ǥ"   U01E4 # LATIN CAPITAL LETTER G WITH STROKE
<Multi_key> <slash> <g>             : "ǥ"   U01E5 # LATIN SMALL LETTER G WITH STROKE
<Multi_key> <slash> <i>             : "ɨ"   U0268 # LATIN SMALL LETTER I WITH STROKE
<Multi_key> <slash> <U0294>     : "ʡ"   U02A1 # LATIN LETTER GLOTTAL STOP WITH STROKE
<Multi_key> <slash> <Cyrillic_GHE>  : "Ғ"   U0492 # CYRILLIC CAPITAL LETTER GHE WITH STROKE
<Multi_key> <slash> <Cyrillic_ghe>  : "ғ"   U0493 # CYRILLIC SMALL LETTER GHE WITH STROKE
<Multi_key> <slash> <Cyrillic_KA>   : "Ҟ"   U049E # CYRILLIC CAPITAL LETTER KA WITH STROKE
<Multi_key> <slash> <Cyrillic_ka>   : "ҟ"   U049F # CYRILLIC SMALL LETTER KA WITH STROKE
<Multi_key> <slash> <U04AE>     : "Ұ"   U04B0 # CYRILLIC CAPITAL LETTER STRAIGHT U WITH STROKE
<Multi_key> <slash> <U04AF>     : "ұ"   U04B1 # CYRILLIC SMALL LETTER STRAIGHT U WITH STROKE
<Multi_key> <slash> <leftarrow>     : "↚"   U219A # LEFTWARDS ARROW WITH STROKE
<Multi_key> <slash> <rightarrow>    : "↛"   U219B # RIGHTWARDS ARROW WITH STROKE
<Multi_key> <slash> <U2194>     : "↮"   U21AE # LEFT RIGHT ARROW WITH STROKE
<Multi_key> <slash> <equal>     : "≠"   U2260 # NOT EQUAL TO
<Multi_key> <slash> <v>                         : "√"   U221a   # / v SQUARE ROOT
<Multi_key> <slash> <minus>                     : "⌿"   U233f   # / - APL FUNCTIONAL SYMBOL SLASH BAR
<Multi_key> <slash> <U2395>                     : "⍁"   U2341   # / ⎕ APL FUNCTIONAL SYMBOL QUAD SLASH
[mfabian@fedora ~]$ 
mike-fabian commented 3 years ago

I.e. one starts typing <Multi_key> <KP_Divide>, this is still not invalid as this exists in the compose files. So <slash> is not tried as a replacement for <KP_Divide>. And the other way round, if <Multi_key> <slash> is typed, this is also valid so far so <KP_Divide> is not tried as a replacement for <slash>.

But the possible 3rd keysyms are not equal for the sequences starting with <Multi_key> <KP_Divide> and <Multi_key> <slash>!

That means that for example <Multi_key> <slash> <equal> is valid and works but <Multi_key> <KP_Divide> <equal> is invalid and does not work.

It also means that it is still possible to define <Multi_key> <KP_Divide> <equal> in a compose file to give a different result from <Multi_key> <slash> <equal> if one desires! (Why would one want to do something crazy like that?)

mike-fabian commented 3 years ago

I am considering treating the keypad keys and “normal” keys as if they were exactly the same thing.

If I do that, there would be no difference between <Multi_key> <slash> <equal> and <Multi_key> <KP_Divide> <equal> and it would not be possible to define different results for these sequences in Compose files, the last definition found would win in that case.

Therefore, I won’t do that at the moment, still thinking whether this is a good idea or not to treat these as exactly equal always.

My current improvement still prefers what is in the Compose file if the exact sequence is there but helpfully tries to continue with the replacement keysym if the exact sequence cannot be found.

I think that is quite helpful already, good enough maybe, still giving the contents of the Compose file the final authority.