From 2e31cbeb70d93bb0f5512064f181990db189d1f6 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Sun, 4 Oct 2026 20:02:15 +0200 Subject: Initial commit --- termbox2/egc.ha | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 termbox2/egc.ha (limited to 'termbox2/egc.ha') diff --git a/termbox2/egc.ha b/termbox2/egc.ha new file mode 100644 index 0000000..a14e7ef --- /dev/null +++ b/termbox2/egc.ha @@ -0,0 +1,31 @@ +// If set, enable extended grapheme cluster support (see +// [[termbox2::extend_cell]] and [[termbox2::set_cell_ex]]). Consumes more +// memory. Defaults on. +export def OPT_EGC: bool = true; + +// A cell in a 2d grid representing the terminal screen. +// +// The terminal screen is represented as a 2d array of cells. The structure is +// optimized for dealing with single-width (wcwidth==1) Unicode codepoints, +// however some support for grapheme clusters (e.g., combining diacritical +// marks) and wide codepoints (e.g., Hiragana) is provided through ech via +// [[termbox2::set_cell_ex]]. ech is only valid if it is non-empty, otherwise +// ch is used. +// +// For non-single-width codepoints, given W=wcwidth(ch || ech): +// +// - when W<=0: termbox forces a single-width cell. Callers should avoid this +// if aiming to render text accurately. Callers may use +// [[termbox2::set_cell_ex]] or [[termbox2::print]] or similar to render +// W==0 combining characters. +// - when W>=2: termbox zeroes out the following W-1 cells and skips +// sending them to the tty. So, e.g., if the caller sets x=0,y=0 to a +// W==2 codepoint, the caller's next set should be at x=2,y=0. Anything +// set at x=1,y=0 will be ignored. If there are not enough columns +// remaining on th eline to render W cells, spaces are sent instead. +export type cell = struct { + ch: u32, // a Unicode codepoint + fg: uattr, // bitwise foreground attributes + bg: uattr, // bitwise background attributes + ech: []rune, // a grapheme cluster of Unicode codepoints +}; -- cgit v1.3