FTXUI 7.0.0
C++ functional terminal UI.
Loading...
Searching...
No Matches
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#include <string>
9#include <vector>
10
11#include "ftxui/util/export.hpp"
12
13namespace ftxui {
14
15// Internal functions exported for the 'component' library.
16FTXUI_EXPORT(SCREEN)
17bool EatCodePoint(std::string_view input,
18 size_t start,
19 size_t* end,
20 uint32_t* ucs);
21FTXUI_EXPORT(SCREEN)
22bool EatCodePoint(std::wstring_view input,
23 size_t start,
24 size_t* end,
25 uint32_t* ucs);
26
27FTXUI_EXPORT(SCREEN) bool IsCombining(uint32_t ucs);
28FTXUI_EXPORT(SCREEN) bool IsFullWidth(uint32_t ucs);
29FTXUI_EXPORT(SCREEN) bool IsControl(uint32_t ucs);
30
31FTXUI_EXPORT(SCREEN) size_t GlyphPrevious(std::string_view input, size_t start);
32FTXUI_EXPORT(SCREEN) size_t GlyphNext(std::string_view input, size_t start);
33
34// Return the index in the |input| string of the glyph at |glyph_offset|,
35// starting at |start|
36FTXUI_EXPORT(SCREEN)
37size_t GlyphIterate(std::string_view input, int glyph_offset, size_t start = 0);
38
39// Returns the number of glyphs in |input|.
40FTXUI_EXPORT(SCREEN) int GlyphCount(std::string_view input);
41
42// Properties from:
43// https://www.unicode.org/Public/UCD/latest/ucd/auxiliary/WordBreakProperty.txt
44enum class WordBreakProperty : int8_t {
45 ALetter,
46 CR,
48 Extend,
50 Format,
53 LF,
55 MidNum,
57 Newline,
58 Numeric,
62 ZWJ,
63};
64FTXUI_EXPORT(SCREEN)
66FTXUI_EXPORT(SCREEN)
67std::vector<WordBreakProperty> Utf8ToWordBreakProperty(std::string_view input);
68
69FTXUI_EXPORT(SCREEN)
70bool IsWordBreakingCharacter(std::string_view input, size_t glyph_index);
71} // namespace ftxui
72
73#endif /* end of include guard: FTXUI_SCREEN_STRING_INTERNAL_HPP */
#define FTXUI_EXPORT(component)
Definition export.hpp:24
The FTXUI ftxui:: namespace.
Definition animation.hpp:11
bool IsControl(uint32_t ucs)
Definition string.cpp:1295
WordBreakProperty CodepointToWordBreakProperty(uint32_t codepoint)
Definition string.cpp:1309
size_t GlyphPrevious(std::string_view input, size_t start)
Definition string.cpp:1429
bool IsCombining(uint32_t ucs)
Definition string.cpp:1283
bool IsWordBreakingCharacter(std::string_view input, size_t glyph_index)
bool EatCodePoint(std::string_view input, size_t start, size_t *end, uint32_t *ucs)
Definition string.cpp:1175
int GlyphCount(std::string_view input)
Definition string.cpp:1535
std::vector< WordBreakProperty > Utf8ToWordBreakProperty(std::string_view input)
Definition string.cpp:1563
size_t GlyphIterate(std::string_view input, int glyph_offset, size_t start)
Definition string.cpp:1480
bool IsFullWidth(uint32_t ucs)
Definition string.cpp:1287
size_t GlyphNext(std::string_view input, size_t start)
Definition string.cpp:1454