Skip to content

Instantly share code, notes, and snippets.

@retupmoca
Created June 9, 2021 17:27
Show Gist options
  • Save retupmoca/68a4852a28b7cf6d2c39a90d7670212f to your computer and use it in GitHub Desktop.
Save retupmoca/68a4852a28b7cf6d2c39a90d7670212f to your computer and use it in GitHub Desktop.
#include <iostream>
#include "ftxui/dom/elements.hpp"
#include "ftxui/screen/screen.hpp"
#include "ftxui/screen/string.hpp"
int main(void) {
using namespace ftxui;
// plain UTF-8 output of a random combining character:
// https://www.fileformat.info/info/unicode/char/0303/index.htm
std::cout << "done\xcc\x83:\n";
auto summary = [&] {
auto content = vbox({
// converted UTF-8
hbox({text(to_wstring(std::string("- done\xcc\x83: "))), text(L"3") | bold}) | color(Color::Green),
// UTF-16 / UCS-2
hbox({text(L"- active\x0303: "), text(L"2") | bold}) | color(Color::RedLight),
hbox({text(L"- queue: "), text(L"9") | bold}) | color(Color::Red),
});
return window(text(L" Summary "), content);
};
auto document = //
vbox({
hbox({
summary(),
summary(),
summary() | flex,
}),
summary(),
summary(),
});
// Limit the size of the document to 80 char.
document = document | size(WIDTH, LESS_THAN, 80);
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
Render(screen, document);
std::cout << screen.ToString() << std::endl;
return EXIT_SUCCESS;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment