Kitty: kitten for IME input

Created on 19 Apr 2018  路  19Comments  路  Source: kovidgoyal/kitty

IME does not work with kitty thanks to limitations of GLFW (https://github.com/glfw/glfw/issues/41). Rather than trying to write code to interface with the IME platforms of every OS (not to mention the dozens of different IME systems in linux/windows), it might be nicer to create a kitten that implements a standard cross-platform IME interface optimized for usage with the keyboard.

Can use the data from the librime project, see https://github.com/rime/plum

Has a couple of pinyin datasets and also nice symbol definitions for entering commonly used unicode symbols. People can contribute other datasets as needed.

The other alternative is to interface with ibus via it's dbus interface, see for example: https://fossies.org/linux/SDL2/src/core/linux/SDL_ibus.c
https://github.com/qt/qtbase/tree/5.11/src/plugins/platforminputcontexts/ibus

This is what most toolkits do on linux, as evidenced by the links above.

enhancement kitten

Most helpful comment

Will fcitx be supported in kitty ? (not working for me, using ibus branch and GTK_IM_MODULE=fcitx python . --debug-keyboard) I prefer fcitx because it have better compatibility and performance.

All 19 comments

That doesn't help if you need multilingual input. Any timeline on a solution for this.?

Sure it does, it works with any language or combination of languages. As for a timeline, it will be done when it is done, if you want it to come faster, feel free to contribute.

I don't believe it will work for Chinese since there are several hundred characters that would need to be input in a normal document. Perhaps I am misunderstanding your proposal for a work around though. Also, my use case may be special since I write in the terminal with nvim and then convert to PDF. I wish I could contribute but I don't think my programming skill are there yet. Thanks for the extremely helpful reply though. Looks like a nice project, I will check back later.

@derrickcope: I don't believe it will work for Chinese since there are several hundred characters that would need to be input in a normal document.

Isn't that the whole plan? LibreIME has a pinyin dataset that can be used to map pinyin to characters.
Although I must say that the solution on GLFW's side seems to be awfully simple, unless I'm misunderstanding something.

The problem with GLFW's solution is that it does not actually work. It causes crashes/hangs and depends on the proper functioning of whatever IME system happens to be installed by the OS, which especially on linux is a total crapshoot.

Alright, then. I actually think providing the option to use the OS's IME system isn't necessarily a bad idea; many people like me already have IBus or something set up to their liking, and it would prevent the need for a separate keyboard shortcut. But if that would require code for integration with each IME then I suppose it's not worth it.
Perhaps kitty can provide its own IME overriding the normal system shortcut, like how ctrl+alt+u doesn't use the OS unicode input.
It's also probably worth noting that GLFW has set proper IME support for the 3.4 milestone, though they have been pushing it forward since 3.2....

On Sun, Jun 03, 2018 at 10:13:26PM -0700, Ian Huang wrote:

Perhaps kitty can provide its own IME overriding the normal system shortcut, like how ctrl+alt+u doesn't use the OS unicode input.

That is precisely what this issue is about.

Why is GLFW even used? SDL2 has had integration with the system IME for years.

I looked into this and it looks like on Linux, ibus has become the de-facto standard IME system. So it makes sense to add support for it to GLFW. I have done that in the ibus branch. Note that this required fairly major surgery on GLFW (essentially rewriting its event loop to integrate dbus into it), so it is possible that some things might be broken. Please test.

Also, currently while the IME system is working on matches, kitty will not display the typed text in the terminal, that is on my TODO list. Other than that everything works in my (rudimentary) testing. The IME popup widow shows up underthe cursor and you can press the numbers to choose matches or press esc to cancel IME. Tested under X11 (should work in wayland as well, but have not tested it, as I have no idea what the status of ibus under wayand is).

In order to test it, build the ibus branch and (with ibus running) start kitty as

GTK_IM_MODULE=ibus kitty --debug-keyboard

You should see debug output about conencting to the IBUS daemon and iME input via ibus should work.

And I also implemented display of the typed text while the IME is in progress.

Will fcitx be supported in kitty ? (not working for me, using ibus branch and GTK_IM_MODULE=fcitx python . --debug-keyboard) I prefer fcitx because it have better compatibility and performance.

No, I'm afraid I dont have the time/interest to support multiple IME systems. You are welcome to write a fcitx backed for glfw based on my ibus one, it should be easy now that I have done the hard work.

hope someone will write a patch for fcitx. I think it is more stable than ibus, at least for Chinese.

hope someone will write a patch for fcitx. I think it is more stable than ibus, at least for Chinese.

ibus-hangul broken - Cannot use space or backspace when in hangul mode.

Just a heads up: for the next kitty release 0.12.1 I am going to turn off IME by default. You need to set the environment variable:

GLFW_IM_MODULE=ibus

to re-enable it. This is because there have been lots of bug reports about ibus causing keyboard latency/dropped keys. Given that one of kitty's primary goals is reducing input latency, I have decided to turn IME off by default. Apologies for any inconvenience.

Just to provide some motivation for better IME support. I tried migrating from another terminal emulator and just noticed this issue - I cannot type Chinese with fcitx in a kitty window.

Just to provide some motivation for better IME support. I tried migrating from another terminal emulator and just noticed this issue - I cannot type Chinese with fcitx in a kitty window.\

Me too, I found that kitty's response is faster than others(sakura / alacritty).

Unfortunately, ibus does not work with sway yet. =(

Was this page helpful?
0 / 5 - 0 ratings

Related issues

RedBeard0531 picture RedBeard0531  路  4Comments

Ulrar picture Ulrar  路  3Comments

bewzaalex picture bewzaalex  路  3Comments

hdriqi picture hdriqi  路  3Comments

Jomik picture Jomik  路  4Comments