20inline constexpr const char*
kEllipsis =
"\xe2\x80\xa6";
26 while (count > 0 &&
i <
text.size()) {
27 unsigned char c =
static_cast<unsigned char>(
text[
i]);
33 else if (
c < 0xE0)
i += 2;
34 else if (
c < 0xF0)
i += 3;
46 for (std::size_t
i = 0;
i <
text.size();) {
47 unsigned char c =
static_cast<unsigned char>(
text[
i]);
53 else if (
c < 0xE0)
i += 2;
54 else if (
c < 0xF0)
i += 3;
76 std::string_view
text,
77 float available_width,
78 bool force_ellipsis =
false) {
79 if (available_width <= 0.0f)
return std::string(
kEllipsis);
80 if (!force_ellipsis &&
81 canvas.measure_text(std::string(
text)) <= available_width)
82 return std::string(
text);
85 if (total == 0)
return std::string(
text);
97 std::size_t hi = total;
99 std::size_t mid = (lo + hi) / 2;
Definition canvas.hpp:240
Definition affine_transform.hpp:24
Hover-cursor tracking for platform window hosts.
Definition fwd.hpp:27
std::size_t utf8_codepoint_count(std::string_view text)
Count the number of UTF-8 leading-byte codepoints in text.
Definition text_overflow.hpp:44
std::string truncate_to_width(canvas::Canvas &canvas, std::string_view text, float available_width, bool force_ellipsis=false)
If text already fits within available_width, return it as-is unless force_ellipsis is true.
Definition text_overflow.hpp:75
@ text
Plain text (default color).
Definition code_editor_tokenizer.hpp:37
constexpr const char * kEllipsis
UTF-8 horizontal ellipsis character (U+2026, "…").
Definition text_overflow.hpp:20
@ c
Definition input_events.hpp:39
@ n
Definition input_events.hpp:40
@ i
Definition input_events.hpp:40
@ candidate
Definition waveform_editor_primitives.hpp:193
std::size_t utf8_advance(std::string_view text, std::size_t count)
Walk forward over UTF-8 leading bytes.
Definition text_overflow.hpp:24