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

kitten for IME input #469

Closed
kovidgoyal opened this issue Apr 19, 2018 · 39 comments
Closed

kitten for IME input #469

kovidgoyal opened this issue Apr 19, 2018 · 39 comments

Comments

@kovidgoyal
Copy link
Owner

kovidgoyal commented Apr 19, 2018

IME does not work with kitty thanks to limitations of GLFW (glfw/glfw#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.

@derrickcope
Copy link

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

@kovidgoyal
Copy link
Owner Author

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.

@derrickcope
Copy link

derrickcope commented May 1, 2018

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.

@imyxh
Copy link

imyxh commented Jun 4, 2018

@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.

@kovidgoyal
Copy link
Owner Author

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.

@imyxh
Copy link

imyxh commented Jun 4, 2018

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....

@kovidgoyal
Copy link
Owner Author

kovidgoyal commented Jun 4, 2018 via email

@Akaricchi
Copy link

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

@kovidgoyal
Copy link
Owner Author

kovidgoyal commented Jul 12, 2018

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.

@kovidgoyal
Copy link
Owner Author

kovidgoyal commented Jul 12, 2018

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

kovidgoyal added a commit that referenced this issue Jul 12, 2018
kovidgoyal added a commit that referenced this issue Jul 12, 2018
kovidgoyal added a commit that referenced this issue Jul 12, 2018
@Menchen
Copy link

Menchen commented Jul 19, 2018

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.

@kovidgoyal
Copy link
Owner Author

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.

@derrickcope
Copy link

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

1 similar comment
@derrickcope
Copy link

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

This was referenced Jul 31, 2018
metayan pushed a commit to metayan/kitty that referenced this issue Aug 1, 2018
@char
Copy link

char commented Sep 2, 2018

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

@kovidgoyal
Copy link
Owner Author

kovidgoyal commented Sep 7, 2018

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.

@MaskRay
Copy link

MaskRay commented Oct 14, 2019

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.

@chux0519
Copy link

chux0519 commented Oct 19, 2019

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).

@nicewarmcoffee
Copy link

nicewarmcoffee commented Dec 9, 2020

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

@qwIvan
Copy link

qwIvan commented Jan 20, 2021

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.

GLFW_IM_MODULE=ibus works for me with fcitx5.

@qwIvan
Copy link

qwIvan commented Jan 20, 2021

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.

GLFW_IM_MODULE=ibus works for me with fcitx5.

'GLFW_IM_MODULE=fcitx` works for me with fcitx5 too, thanks!

But running in GLFW_IM_MODULE=fcitx instead of ibus doesn't works for me.

@alan-w-255
Copy link

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.

GLFW_IM_MODULE=ibus works for me with fcitx5.

'GLFW_IM_MODULE=fcitx` works for me with fcitx5 too, thanks!

But running in GLFW_IM_MODULE=fcitx instead of ibus doesn't works for me.

Sorry about that. It doesn't work for me neither. I did not check the env carefully.

@wengxt
Copy link
Contributor

wengxt commented Feb 14, 2021

But running in GLFW_IM_MODULE=fcitx instead of ibus doesn't works for me.

GLFW_IM_MODULE=ibus + Fcitx 5 would work. Fcitx5 is able to simulate ibus api.

@Adnios
Copy link

Adnios commented Mar 12, 2021

GLFW_IM_MODULE=ibus kitty works for me.
image

@nicewarmcoffee
Copy link

nicewarmcoffee commented Aug 4, 2021

But running in GLFW_IM_MODULE=fcitx instead of ibus doesn't works for me.

GLFW_IM_MODULE=ibus + Fcitx 5 would work. Fcitx5 is able to simulate ibus api.

just tested with:
fcitx 5.0.8
sway 1.6.1
kitty 0.21.2
no xwayland

export IMSETTINGS_MODULE=fcitx5
export INPUT_METHOD=fcitx5
export GTK_IM_MODULE=fcitx5
export QT_IM_MODULE=fcitx5
export GLFW_IM_MODULE=ibus
export XMODIFIERS=@im=fcitx5
export GDK_BACKEND=wayland

Does not work with kitty =(

@kovidgoyal
Copy link
Owner Author

fcitx does not support the wayland text input method. kitty uses that,
not dbus, on wayland. If you want to use dbus run kitty with
linux_display_server x11

@ManInTheSuit
Copy link

I apologize for necroing this thread, but how to enable IME support? When run as in this screenshot: https://user-images.githubusercontent.com/41060790/110936258-91747580-836b-11eb-9dcd-88ca502ea875.png, it works, but putting export GLFW_IM_MODULE=ibus in .bashrc doesn't work. Am I missing something?

@Menchen
Copy link

Menchen commented Nov 8, 2021

@ManInTheSuit You need to pass the environment variable to kitty, exporting it in .bashrc only export it on interactive shell.
What you need to do is export it in your DE or the program that launch kitty, another option is run kitty as GLFW_IM_MODULE=ibus kitty. See more info in https://apple.stackexchange.com/questions/51036/what-is-the-difference-between-bash-profile-and-bashrc

@ManInTheSuit
Copy link

ManInTheSuit commented Nov 8, 2021

@ManInTheSuit You need to pass the environment variable to kitty, exporting it in .bashrc only export it on interactive shell. What you need to do is export it in your DE or the program that launch kitty, another option is run kitty as GLFW_IM_MODULE=ibus kitty. See more info in https://apple.stackexchange.com/questions/51036/what-is-the-difference-between-bash-profile-and-bashrc

Seeing env GLFW_IM_MODULE=ibus works for child processes, is there any way to set it for all kitty processes? Launching kitty with GLFW_IM_MODULE=ibus kitty doesn't work for some reason in Budgie (the shortcuts application)...

@ManInTheSuit
Copy link

Ok solved, I launch kitty like this now: sh -c "GLFW_IM_MODULE=ibus kitty"

@char
Copy link

char commented Nov 8, 2021

When you want to set an environment variable for a command, you can use env instead of sh à la env GLFW_IM_MODULE=ibus kitty

@ManInTheSuit
Copy link

When you want to set an environment variable for a command, you can use env instead of sh à la env GLFW_IM_MODULE=ibus kitty

Thanks, that works!

@LeisureLinux
Copy link

I did not find a way to pass the GLFW_IM_MODULE to gsetting default x-terminal-emulator .

tried to run

sudo update-alternatives --config x-terminal-emulator

and make it a shell script as:
env GLFW_IM_MODULE=ibus kitty
but this is not working when called from the default terminal when I press Ctr-Alt-T.

@ManInTheSuit
Copy link

I did not find a way to pass the GLFW_IM_MODULE to gsetting default x-terminal-emulator .

tried to run

sudo update-alternatives --config x-terminal-emulator

and make it a shell script as: env GLFW_IM_MODULE=ibus kitty but this is not working when called from the default terminal when I press Ctr-Alt-T.

I also have alias kitty='GLFW_IM_MODULE=ibus command kitty' in my .bashrc, for calling kitty within any other terminal.

Also, on the off chance that you are having troubles with gnome-terminal, I got my kitty to run system-wide with answer from Doron Behar here: https://askubuntu.com/questions/111592/how-do-i-set-the-default-gnome-terminal

@ctrlcctrlv
Copy link
Sponsor Contributor

I started bug #5033 to hopefully expand env to cover this case. That would prevent users from needing aliases, .desktop file hacks, etc.

@ctrlcctrlv
Copy link
Sponsor Contributor

Well, #5033 was closed, but I have a new workaround for the issues I explained above.

If you use KDE, run kmenuedit and edit Kitty like this:

image

I verified that even if you add Kitty's icon to your desktop, the change is preserved:

image

If you have an important .desktop file for Kitty already that is not a mere link to /home/fred/.local/share/applications/kitty.desktop (perhaps it's a link to the old system-wide kitty.desktop), that needs to be removed or recreated.

@ctrlcctrlv
Copy link
Sponsor Contributor

Related: Ubuntu bug №1970928.

@tin-pham
Copy link

tin-pham commented Aug 3, 2022

Well, #5033 was closed, but I have a new workaround for the issues I explained above.

If you use KDE, run kmenuedit and edit Kitty like this:

image

I verified that even if you add Kitty's icon to your desktop, the change is preserved:

image

If you have an important .desktop file for Kitty already that is not a mere link to /home/fred/.local/share/applications/kitty.desktop (perhaps it's a link to the old system-wide kitty.desktop), that needs to be removed or recreated.

Well this worked when i click to icon or launch kitty from terminal, if i open it with shortcut Super+T, it didn't

@wizardyhnr
Copy link

wizardyhnr commented Sep 22, 2022

You can edit kitty.desktop to instruct kitty to launch with GLFW_IM_MODULE=ibus.

Below are installation instuctions from kitty's website.
https://sw.kovidgoyal.net/kitty/binary/

After that, edit ~/.local/share/applications/kitty.desktop to add env variable in Exec line. It looks like following after that:
[Desktop Entry]
Version=1.0
Type=Application
Name=kitty
GenericName=Terminal emulator
Comment=Fast, feature-rich, GPU based terminal
TryExec=/location/of/kitty
Exec=env GLFW_IM_MODULE=ibus /location/of/kitty
Icon=/location/of/kitty/icon
Categories=System;TerminalEmulator;

Done.

BTW, you can also customize icon in this way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests