kovidgoyal / kitty

Cross-platform, fast, feature-rich, GPU based terminal
https://sw.kovidgoyal.net/kitty/
GNU General Public License v3.0
24.06k stars 971 forks source link

Grapheme Clustering (mode 2027) #7799

Closed aymanbagabas closed 1 month ago

aymanbagabas commented 1 month ago

Is your feature request related to a problem? Please describe. Currently, Kitty always uses wcwidth to calculate the monospaced width of cell characters. The problem is that sometimes with certain characters, or what Unicode refer to as graphemes, such as emojis and multi-codepoint characters, wcwidth reports invalid width breaking the terminal display.

Describe the solution you'd like DECRQM 2027 or mode 2027. When mode 2027 is enabled, Kitty should use Unicode grapheme clustering to calculate the cell character widths instead of wcwidth.

Additional context A good write up explaining the issue in details and how mode 2027 proposes a reasonable solution https://mitchellh.com/writing/grapheme-clusters-in-terminals

Related: https://github.com/kovidgoyal/kitty/issues/3810

kovidgoyal commented 1 month ago

kitty doesn't use wcwidth. It uses the unicode standards to do grapheme clustering but it doesn't support ZWJ see the open issue about it. It's on my TODO list, but I probably wont support 2027 as I have something better in mind.