diff options
Diffstat (limited to 'termbox2/egc.ha')
| -rw-r--r-- | termbox2/egc.ha | 31 |
1 files changed, 31 insertions, 0 deletions
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 @@ | |||
| 1 | // If set, enable extended grapheme cluster support (see | ||
| 2 | // [[termbox2::extend_cell]] and [[termbox2::set_cell_ex]]). Consumes more | ||
| 3 | // memory. Defaults on. | ||
| 4 | export def OPT_EGC: bool = true; | ||
| 5 | |||
| 6 | // A cell in a 2d grid representing the terminal screen. | ||
| 7 | // | ||
| 8 | // The terminal screen is represented as a 2d array of cells. The structure is | ||
| 9 | // optimized for dealing with single-width (wcwidth==1) Unicode codepoints, | ||
| 10 | // however some support for grapheme clusters (e.g., combining diacritical | ||
| 11 | // marks) and wide codepoints (e.g., Hiragana) is provided through ech via | ||
| 12 | // [[termbox2::set_cell_ex]]. ech is only valid if it is non-empty, otherwise | ||
| 13 | // ch is used. | ||
| 14 | // | ||
| 15 | // For non-single-width codepoints, given W=wcwidth(ch || ech): | ||
| 16 | // | ||
| 17 | // - when W<=0: termbox forces a single-width cell. Callers should avoid this | ||
| 18 | // if aiming to render text accurately. Callers may use | ||
| 19 | // [[termbox2::set_cell_ex]] or [[termbox2::print]] or similar to render | ||
| 20 | // W==0 combining characters. | ||
| 21 | // - when W>=2: termbox zeroes out the following W-1 cells and skips | ||
| 22 | // sending them to the tty. So, e.g., if the caller sets x=0,y=0 to a | ||
| 23 | // W==2 codepoint, the caller's next set should be at x=2,y=0. Anything | ||
| 24 | // set at x=1,y=0 will be ignored. If there are not enough columns | ||
| 25 | // remaining on th eline to render W cells, spaces are sent instead. | ||
| 26 | export type cell = struct { | ||
| 27 | ch: u32, // a Unicode codepoint | ||
| 28 | fg: uattr, // bitwise foreground attributes | ||
| 29 | bg: uattr, // bitwise background attributes | ||
| 30 | ech: []rune, // a grapheme cluster of Unicode codepoints | ||
| 31 | }; | ||
