fix(console): count a virama conjunct as one cell

A Hindi conjunct such as न्द in हिन्दी drew the --list border one cell short.
This commit is contained in:
imSp4rky
2026-10-24 12:46:53 -06:00
parent bcef9ff87a
commit 0de069f35a
2 changed files with 21 additions and 0 deletions
+16
View File
@@ -426,7 +426,23 @@ def _cell_size(character: str, *args: str) -> int:
return 1 if unicodedata.category(character) == "Mc" else _rich_cell_size(character, *args)
# the viramas that join the next consonant into one cluster (Unicode InCB=Linker); Tamil and Kannada do not
_JOINING_VIRAMAS = frozenset("्্્୍్്")
_rich_cell_len = rich.cells._cell_len
def _cell_len(text: str, *args: str) -> int:
"""Count a consonant joined by a virama (the न्द in हिन्दी) as no cell: terminals draw the conjunct in one."""
width = _rich_cell_len(text, *args)
if _JOINING_VIRAMAS.isdisjoint(text):
return width
return width - sum(
prev in _JOINING_VIRAMAS and unicodedata.category(char) == "Lo" for prev, char in zip(text, text[1:])
)
rich.cells.get_character_cell_size = _cell_size
rich.cells._cell_len = _cell_len
rich.cells.cached_cell_len.cache_clear()
console = ComfyConsole(