mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-12-16 01:48:56 +08:00
Some checks failed
Build / Bazel, cl, windows-latest (push) Has been cancelled
Build / Bazel, clang++, macos-latest (push) Has been cancelled
Build / Bazel, clang++, ubuntu-latest (push) Has been cancelled
Build / Bazel, g++, macos-latest (push) Has been cancelled
Build / Bazel, g++, ubuntu-latest (push) Has been cancelled
Build / CMake, cl, windows-latest (push) Has been cancelled
Build / CMake, gcc, ubuntu-latest (push) Has been cancelled
Build / CMake, llvm, ubuntu-latest (push) Has been cancelled
Build / CMake, llvm, macos-latest (push) Has been cancelled
Build / Test modules (llvm, ubuntu-latest) (push) Has been cancelled
Documentation / documentation (push) Has been cancelled
This is better ergonomic, as `std::string_view` is lightweight and accept more conversion than `const std::string&`. Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
37 lines
1.1 KiB
C++
37 lines
1.1 KiB
C++
// Copyright 2020 Arthur Sonzogni. All rights reserved.
|
|
// Use of this source code is governed by the MIT license that can be found in
|
|
// the LICENSE file.
|
|
#ifndef FTXUI_SCREEN_STRING_HPP
|
|
#define FTXUI_SCREEN_STRING_HPP
|
|
|
|
#include <string> // for string, wstring, to_string
|
|
#include <string_view> // for string_view
|
|
#include <vector> // for vector
|
|
|
|
namespace ftxui {
|
|
std::string to_string(std::wstring_view s);
|
|
std::wstring to_wstring(std::string_view s);
|
|
|
|
template <typename T>
|
|
std::wstring to_wstring(T s) {
|
|
return to_wstring(std::string_view(std::to_string(s)));
|
|
}
|
|
template <>
|
|
inline std::wstring to_wstring(const char* s) {
|
|
return to_wstring(std::string_view(s));
|
|
}
|
|
|
|
int string_width(std::string_view);
|
|
|
|
// Split the string into a its glyphs. An empty one is inserted ater fullwidth
|
|
// ones.
|
|
std::vector<std::string> Utf8ToGlyphs(std::string_view input);
|
|
|
|
// Map every cells drawn by |input| to their corresponding Glyphs. Half-size
|
|
// Glyphs takes one cell, full-size Glyphs take two cells.
|
|
std::vector<int> CellToGlyphIndex(std::string_view input);
|
|
|
|
} // namespace ftxui
|
|
|
|
#endif /* end of include guard: FTXUI_SCREEN_STRING_HPP */
|