rxi / lite

A lightweight text editor written in Lua
MIT License
7.41k stars 352 forks source link

Support for software text compositing #5

Open lemon32767 opened 4 years ago

lemon32767 commented 4 years ago

See https://wiki.libsdl.org/Tutorials/TextInput Chinese and Japanese users (mostly) use IMEs (input method editors) to input characters, and these require some help from the applications to work properly. Thankfully, SDL exposes functionality to do this.

I have implemented some basic support for it here, the patch is not large (about 40 lines total).

Here's a demonstration of me inputting some text in Japanese without this patch (you can't see the characters as I type them and the candidate box shows up in the top left corner of the window): LITE0 and with the patch: LITE1 I changed the code font in those demos since the default one does not have glyphs for CJK characters.

The reason I'm making an issue for this is because it's requires adding stuff to the core (albeit it's not a lot) and it can technically be considered new functionality. It does not affect users who don't use an IME in any way. I haven't tested it on windows since I don't have a windows computer but I assume it would work since the SDL APIs that the patch uses are supposed to work there too.

I will also add that this is not an ideal implementation, as the compositing text shows up in a box hovering in front of the rest of the text (similar to an over the spot implementation), however in my opinion it's better to have at least some basic support than none at all.

p410n3 commented 4 years ago

I recommend making a Pull Request :)