skip to content
==> include/tui/unicode_width.h <==
1/* @ajax/tui-unicode-width: how many terminal columns text takes, exactly as Rust's unicode-width
2 * crate 0.2.2 computes it (UAX #11, ambiguous characters narrow, emoji presentation sequences,
3 * ZWJ sequences, the ligatures it knows). ratatui measures every span with it, so a port that
4 * must lay out the same frame needs the same answers. */
5#ifndef TUI_UNICODE_WIDTH_H
6#define TUI_UNICODE_WIDTH_H
7
8#include <stddef.h>
9#include <stdint.h>
10
11/* One character's width (0, 1 or 2), or -1 for a control character (Rust: None). */
12int tui_char_width(uint32_t cp);
13/* A string's width (Rust: UnicodeWidthStr::width). Control characters count 1, "\r\n" counts 1.
14 * The string is UTF-8; an invalid byte counts as U+FFFD. */
15size_t tui_str_width(const char *s, size_t len);
16size_t tui_cstr_width(const char *s);
17
18#endif