FTXUI 7.0.3
C++ functional terminal UI.
Loading...
Searching...
No Matches
string.hpp
Go to the documentation of this file.
1// Copyright 2020 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_HPP
5#define FTXUI_SCREEN_STRING_HPP
6
7#include <string> // for string, wstring, to_string
8#include <string_view> // for string_view
9#include <vector> // for vector
10
11#include "ftxui/util/export.hpp"
12
13namespace ftxui {
14FTXUI_EXPORT(SCREEN) std::string to_string(std::wstring_view s);
15FTXUI_EXPORT(SCREEN) std::wstring to_wstring(std::string_view s);
16
17template <typename T>
18std::wstring to_wstring(T s) {
19 return to_wstring(std::string_view(std::to_string(s)));
20}
21inline std::wstring to_wstring(const std::string& s) {
22 return to_wstring(std::string_view(s));
23}
24template <>
25inline std::wstring to_wstring(const char* s) {
26 return to_wstring(std::string_view(s));
27}
28
29FTXUI_EXPORT(SCREEN) int string_width(std::string_view);
30
31// 將字串拆分成其字位。在全形字位之後會插入一個空的
32// 字位。
33FTXUI_EXPORT(SCREEN)
34std::vector<std::string> Utf8ToGlyphs(std::string_view input);
35
36// 將 |input| 繪製的每個儲存格映射到其對應的字形。半形字形佔用一個儲存格,
37// 全形字形佔用兩個儲存格。
38FTXUI_EXPORT(SCREEN)
39std::vector<int> CellToGlyphIndex(std::string_view input);
40
41} // namespace ftxui
42
43#endif /* 包含守衛結束:FTXUI_SCREEN_STRING_HPP */
#define FTXUI_EXPORT(component)
Definition export.hpp:23
FTXUI ftxui:: 命名空間
Definition animation.hpp:11
FTXUI_EXPORT(SCREEN) int string_width(std std::vector< std::string > Utf8ToGlyphs(std::string_view input)
Definition string.cpp:348
int string_width(std::string_view input)
Definition string.cpp:298
std::string to_string(std::wstring_view s)
將 std::wstring 轉換為 UTF8 std::string。
Definition string.cpp:555
std::vector< int > CellToGlyphIndex(std::string_view input)
Definition string.cpp:455
FTXUI_EXPORT(SCREEN) std FTXUI_EXPORT(SCREEN) std std::wstring to_wstring(T s)
Definition string.hpp:18