def cluster
import bend-kit-tty@0.1.0.1/text.bend as Textimport Base
import bend-kit-tty@0.1.0.1/width.bend as W
21# A grapheme cluster takes its first code point's columns (W.w); VS16 makes a narrow base an emoji, 2 wide.
22def cluster(g: String) -> U32:
23 match g:
24 case SNil{}:
25 0
26 case SCon{Chr{+c}, t}:
27 +w = W.w(c)
28 Bool.pick(U32, U32.is_eq(w, 1) && vs16(t), 2, w)