mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-09-19 01:38:08 +08:00
Add webassembly support
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
|
||||
#include "ftxui/dom/node.hpp"
|
||||
#include "ftxui/screen/string.hpp"
|
||||
@@ -149,6 +150,7 @@ Screen::Screen(int dimx, int dimy)
|
||||
}
|
||||
|
||||
/// Produce a std::string that can be used to print the Screen on the terminal.
|
||||
/// Don't forget to flush stdout. Alternatively, you can use Screen::Print();
|
||||
std::string Screen::ToString() {
|
||||
std::wstringstream ss;
|
||||
|
||||
@@ -158,7 +160,7 @@ std::string Screen::ToString() {
|
||||
for (int y = 0; y < dimy_; ++y) {
|
||||
if (y != 0) {
|
||||
UpdatePixelStyle(ss, previous_pixel, final_pixel);
|
||||
ss << '\n';
|
||||
ss << L"\r\n";
|
||||
}
|
||||
for (int x = 0; x < dimx_;) {
|
||||
auto& pixel = pixels_[y][x];
|
||||
@@ -181,6 +183,10 @@ std::string Screen::ToString() {
|
||||
return to_string(ss.str());
|
||||
}
|
||||
|
||||
void Screen::Print() {
|
||||
std::cout << ToString() << std::flush << (char)0;
|
||||
}
|
||||
|
||||
/// @brief Access a character a given position.
|
||||
/// @param x The character position along the x-axis.
|
||||
/// @param y The character position along the y-axis.
|
||||
@@ -254,6 +260,7 @@ void Screen::ApplyShader() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// clang-format on
|
||||
|
||||
} // namespace ftxui
|
||||
|
@@ -19,7 +19,7 @@ namespace ftxui {
|
||||
|
||||
Terminal::Dimensions Terminal::Size() {
|
||||
#if defined(__EMSCRIPTEN__)
|
||||
return Dimensions{80, 43};
|
||||
return Dimensions{140, 43};
|
||||
#elif defined(_WIN32)
|
||||
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||
int columns, rows;
|
||||
@@ -48,6 +48,10 @@ bool Contains(const std::string& s, const char* key) {
|
||||
static bool cached = false;
|
||||
Terminal::Color cached_supported_color;
|
||||
Terminal::Color ComputeColorSupport() {
|
||||
#if defined(__EMSCRIPTEN__)
|
||||
return Terminal::Color::TrueColor;
|
||||
#endif
|
||||
|
||||
std::string COLORTERM = Safe(std::getenv("COLORTERM"));
|
||||
if (Contains(COLORTERM, "24bit") || Contains(COLORTERM, "truecolor"))
|
||||
return Terminal::Color::TrueColor;
|
||||
|
Reference in New Issue
Block a user