tboox / ltui

🍖 A cross-platform terminal ui library based on Lua
https://tboox.org
Apache License 2.0
817 stars 49 forks source link

is there utf8 support? #12

Open mendisobal opened 4 years ago

mendisobal commented 4 years ago

Do you plan utf8 support?

waruqi commented 4 years ago

I don't have time to support it now.

laelnasan commented 3 years ago

In linux I managed to have utf8 running by simply linking to ncursesw. There are some issues with drawing on short views, but it may be simple to solve it with Lua 5.4 or with a library such as https://github.com/starwing/luautf8

image

I will investigate it further when I have the time

waruqi commented 3 years ago

In linux I managed to have utf8 running by simply linking to ncursesw.

We also need to consider pdcurse with wchar.

There are some issues with drawing on short views, but it may be simple to solve it with Lua 5.4 or with a library such as https://github.com/starwing/luautf8

I also need to consider the compatibility with xmake, because xmake also uses ltui, https://github.com/xmake-io/xmake/tree/master/xmake/core/ui

But xmake's ltui does not need luautf8, because its runtime rewrites built-in lua modules such as io/string, and has added support for utf8.

I will investigate it further when I have the time

Thanks

laelnasan commented 3 years ago

I also need to consider the compatibility with xmake, because xmake also uses ltui, https://github.com/xmake-io/xmake/tree/master/xmake/core/ui

But xmake's ltui does not need luautf8, because its runtime rewrites built-in lua modules such as io/string, and has added support for utf8.

this pr #27 solves the splitting of utf8 strings and also permits utf8 input in textedit views. Both ncurses and pdcurses use codes greater then 0xFF for special key codes, hence the limitation for codes < 0x7f is not strictly needed AFAIK

We also need to consider pdcurse with wchar.

I've submitted a pr #28 with the required flag for pdcurses, but I didn't test it, I got access to a windows machine but didn't set up the environment yet. I tried to use ltui over ssh (putty), though. If the utf8 support comes to be, it would be nice to permit the user to choose utf8 glyphs instead of ACS characters:

image

the utf8 characters and mouse events work fine over ssh. Great for embedded applications!

waruqi commented 3 years ago

Thank you very much, as long as you can ensure compatibility with xmake's ui module, only modify curses/pdcurses, or replace some native io interfaces, I welcome pr.

But I don't want to add new c modules and interface calls to ltui. Because when these patches are merged into xmake, these c libraries will also be added.