FTXUI  4.1.1
C++ functional terminal UI.
Loading...
Searching...
No Matches
string.hpp
Go to the documentation of this file.
1#ifndef FTXUI_SCREEN_STRING_HPP
2#define FTXUI_SCREEN_STRING_HPP
3
4#include <stddef.h> // for size_t
5#include <string> // for string, wstring, to_string
6#include <vector> // for vector
7
8namespace ftxui {
9std::string to_string(const std::wstring& s);
10std::wstring to_wstring(const std::string& s);
11
12template <typename T>
13std::wstring to_wstring(T s) {
14 return to_wstring(std::to_string(s));
15}
16
17int string_width(const std::string&);
18// Split the string into a its glyphs. An empty one is inserted ater fullwidth
19// ones.
20std::vector<std::string> Utf8ToGlyphs(const std::string& input);
21// If |input| was an array of glyphs, this returns the number of char to eat
22// before reaching the glyph at index |glyph_index|.
23int GlyphPosition(const std::string& input,
24 size_t glyph_index,
25 size_t start = 0);
26// Returns the number of glyphs in |input|.
27int GlyphCount(const std::string& input);
28
29// Properties from:
30// https://www.unicode.org/Public/UCD/latest/ucd/auxiliary/WordBreakProperty.txt
51std::vector<WordBreakProperty> Utf8ToWordBreakProperty(
52 const std::string& input);
53
54bool IsWordBreakingCharacter(const std::string& input, size_t glyph_index);
55
56// Map every cells drawn by |input| to their corresponding Glyphs. Half-size
57// Glyphs takes one cell, full-size Glyphs take two cells.
58std::vector<int> CellToGlyphIndex(const std::string& input);
59
60} // namespace ftxui
61
63
64#endif /* end of include guard: FTXUI_SCREEN_STRING_HPP */
65
66// Copyright 2020 Arthur Sonzogni. All rights reserved.
67// Use of this source code is governed by the MIT license that can be found in
68// the LICENSE file.
std::vector< std::string > Utf8ToGlyphs(const std::string &input)
Definition string.cpp:1727
int string_width(const std::string &)
Definition string.cpp:1700
std::wstring to_wstring(const std::string &s)
Convert a std::wstring into a UTF8 std::string.
Definition string.cpp:1971
bool IsWordBreakingCharacter(const std::string &input, size_t glyph_index)
std::string to_string(const std::wstring &s)
Convert a UTF8 std::string into a std::wstring.
Definition string.cpp:1899
int GlyphPosition(const std::string &input, size_t glyph_index, size_t start=0)
Definition string.cpp:1770
std::vector< int > CellToGlyphIndex(const std::string &input)
Definition string.cpp:1798
int GlyphCount(const std::string &input)
Definition string.cpp:1839
WordBreakProperty
Definition string.hpp:31
std::vector< WordBreakProperty > Utf8ToWordBreakProperty(const std::string &input)
Definition string.cpp:1867