FTXUI  3.0.0
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// Map every cells drawn by |input| to their corresponding Glyphs. Half-size
30// Glyphs takes one cell, full-size Glyphs take two cells.
31std::vector<int> CellToGlyphIndex(const std::string& input);
32
33} // namespace ftxui
34
36
37#endif /* end of include guard: FTXUI_SCREEN_STRING_HPP */
38
39// Copyright 2020 Arthur Sonzogni. All rights reserved.
40// Use of this source code is governed by the MIT license that can be found in
41// the LICENSE file.
std::vector< std::string > Utf8ToGlyphs(const std::string &input)
Definition string.cpp:291
int string_width(const std::string &)
Definition string.cpp:264
std::wstring to_wstring(const std::string &s)
Convert a std::wstring into a UTF8 std::string.
Definition string.cpp:443
std::string to_string(const std::wstring &s)
Convert a UTF8 std::string into a std::wstring.
Definition string.cpp:437
int GlyphPosition(const std::string &input, size_t glyph_index, size_t start=0)
Definition string.cpp:334
std::vector< int > CellToGlyphIndex(const std::string &input)
Definition string.cpp:362
int GlyphCount(const std::string &input)
Definition string.cpp:403