Text.cluster: def of bend-kit-tty@0.1.0.1 Import: import bend-kit-tty@0.1.0.1/text.bend as Text Lines 21-28 of bend-kit-tty@0.1.0.1/text.bend: https://jend.leeeet.dev/read.txt?path=bend-kit-tty@0.1.0.1/text.bend&start_line=21&end_line=28 import Base import bend-kit-tty@0.1.0.1/width.bend as W # A grapheme cluster takes its first code point's columns (W.w); VS16 makes a narrow base an emoji, 2 wide. def cluster(g: String) -> U32: match g: case SNil{}: 0 case SCon{Chr{+c}, t}: +w = W.w(c) Bool.pick(U32, U32.is_eq(w, 1) && vs16(t), 2, w) Uses (8): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool.and https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool.pick https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Char https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=String https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32 https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.is_eq https://jend.leeeet.dev/definition.txt?path=bend-kit-tty@0.1.0.1/text.bend&name=vs16 https://jend.leeeet.dev/definition.txt?path=bend-kit-tty@0.1.0.1/width.bend&name=w