FTXUI  5.0.0
C++ functional terminal UI.
string_internal.hpp
Go to the documentation of this file.
1// Copyright 2023 Arthur Sonzogni. All rights reserved.
2// Use of this source code is governed by the MIT license that can be found in
3// the LICENSE file.
4#ifndef FTXUI_SCREEN_STRING_INTERNAL_HPP
5#define FTXUI_SCREEN_STRING_INTERNAL_HPP
6
7#include <cstdint>
8
9namespace ftxui {
10
11bool EatCodePoint(const std::string& input,
12 size_t start,
13 size_t* end,
14 uint32_t* ucs);
15bool EatCodePoint(const std::wstring& input,
16 size_t start,
17 size_t* end,
18 uint32_t* ucs);
19
20bool IsCombining(uint32_t ucs);
21bool IsFullWidth(uint32_t ucs);
22bool IsControl(uint32_t ucs);
23
24size_t GlyphPrevious(const std::string& input, size_t start);
25size_t GlyphNext(const std::string& input, size_t start);
26
27// Return the index in the |input| string of the glyph at |glyph_offset|,
28// starting at |start|
29size_t GlyphIterate(const std::string& input,
30 int glyph_offset,
31 size_t start = 0);
32
33// Returns the number of glyphs in |input|.
34int GlyphCount(const std::string& input);
35
36// Properties from:
37// https://www.unicode.org/Public/UCD/latest/ucd/auxiliary/WordBreakProperty.txt
38enum class WordBreakProperty : int8_t {
39 ALetter,
40 CR,
42 Extend,
44 Format,
47 LF,
49 MidNum,
51 Newline,
52 Numeric,
56 ZWJ,
57};
59std::vector<WordBreakProperty> Utf8ToWordBreakProperty(
60 const std::string& input);
61
62bool IsWordBreakingCharacter(const std::string& input, size_t glyph_index);
63} // namespace ftxui
64
65#endif /* end of include guard: FTXUI_SCREEN_STRING_INTERNAL_HPP */
size_t GlyphNext(const std::string &input, size_t start)
Definition: string.cpp:1424
bool IsControl(uint32_t ucs)
Definition: string.cpp:1292
WordBreakProperty CodepointToWordBreakProperty(uint32_t codepoint)
Definition: string.cpp:1306
bool IsCombining(uint32_t ucs)
Definition: string.cpp:1281
bool IsWordBreakingCharacter(const std::string &input, size_t glyph_index)
bool EatCodePoint(const std::string &input, size_t start, size_t *end, uint32_t *ucs)
Definition: string.cpp:1173
int GlyphCount(const std::string &input)
Definition: string.cpp:1505
bool IsFullWidth(uint32_t ucs)
Definition: string.cpp:1285
std::vector< WordBreakProperty > Utf8ToWordBreakProperty(const std::string &input)
Definition: string.cpp:1533
size_t GlyphIterate(const std::string &input, int glyph_offset, size_t start)
Definition: string.cpp:1450
size_t GlyphPrevious(const std::string &input, size_t start)
Definition: string.cpp:1399