cpjreynolds / rustty

A terminal UI library
https://docs.rs/rustty
MIT License
153 stars 14 forks source link

wide character support #10

Open mathstuf opened 9 years ago

mathstuf commented 9 years ago

Found this through TWiR :) . It looks like the API assumes each character is one cell wide, but this isn't true of Kanji and other ideographic languages. IIRC, some codepoints even change width based on the locale too (so punctuation is the same width as the rest of the characters, but I can't remember exactly). Any plan to support wide characters or did I skim the API too quickly? Thanks.

cpjreynolds commented 9 years ago

Thank you for reporting this! At the moment we do not have wide character support, however I plan on implementing this soon.

cpjreynolds commented 8 years ago

Going off the code written in termbox, I don't believe this will be too hard to implement. This should make in into rustty very soon.

ghost commented 8 years ago

Hello, I'm quite interested in this as well. If this is something you're still planning on doing, do you mind giving a ballpark estimate of when? Otherwise I might want to look into this myself, in which case it would be nice to hear any thoughts you've already had about it.

cpjreynolds commented 8 years ago

So I've taken a hard look at the issue of supporting wide characters and have encountered a fairly fundamental problem. rustty's abstraction over the underlying terminal relies on the assumption that each Cell occupies only the space which it represents; thus if one cell was to draw a wide character, it would end up drawing into the adjacent cell's space, which would in turn be overwritten when that adjacent cell is drawn.

I'm open to any and all suggestions as to how to handle this, but at the moment I'm drawing a blank.

mathstuf commented 8 years ago

Another thing is that there are zero-width characters (for things like ZWJ and friends, but also potentially some escape codes as well).

Might be worthwhile to look into how tmux represents these things (since it does support wide characters).