In the Land of Columns and Characters


A few more details about the TUI version of Lagrange, and thoughts about the bigger picture of cross-platform UI programming.

@jk the width of emoji and other Unicode characters have certainly been a nuisance when working on my own #TUI tools...

@FiXato Do you have any guidelines or best practices to share regarding this? Seems to me the program has no way to detect how the terminal will behave, so it’s ultimately the user’s problem…

I’m currently using libunistring to query the character widths.

@jk I considered a couple of approaches, such as using libraries to query character width, or manually offsetting widths when a string contains certain unicode ranges, but as you already noted: the widths don't always match the actual width in the various terminals and it also depends on how the font draws it, and if it actually supports for example a zero-width-joiner glyph. Country or rainbows flags and some skin tone emoji combinations were especially troublesome. I ended up just giving up because I could see no way of detecting all variations, aside from building an entire detection suite that requires user input to indicate which kind of characters cause offsets or not...

Sign in to participate in the conversation

skyjake's personal Mastodon instance