2019-01-23 09:16:00 +08:00
|
|
|
#include <chrono>
|
2020-05-25 07:34:13 +08:00
|
|
|
#include <ftxui/dom/elements.hpp>
|
|
|
|
#include <ftxui/screen/screen.hpp>
|
2019-01-23 09:16:00 +08:00
|
|
|
#include <iostream>
|
2021-05-02 02:40:35 +08:00
|
|
|
#include <string>
|
2019-01-23 09:16:00 +08:00
|
|
|
#include <thread>
|
2020-03-23 05:32:44 +08:00
|
|
|
|
2021-05-02 02:40:35 +08:00
|
|
|
#include "ftxui/dom/node.hpp"
|
|
|
|
#include "ftxui/screen/box.hpp"
|
|
|
|
#include "ftxui/screen/color.hpp"
|
|
|
|
|
2019-01-23 09:16:00 +08:00
|
|
|
int main(int argc, const char* argv[]) {
|
|
|
|
using namespace ftxui;
|
|
|
|
using namespace std::chrono_literals;
|
|
|
|
|
|
|
|
auto img1 = []() { return text(L"img") | border; };
|
2020-05-21 02:36:47 +08:00
|
|
|
auto img2 = []() { return vbox({text(L"big"), text(L"image")}) | border; };
|
2019-01-23 09:16:00 +08:00
|
|
|
|
|
|
|
std::string reset_position;
|
|
|
|
for (int i = 0;; ++i) {
|
2020-05-21 02:36:47 +08:00
|
|
|
auto document = //
|
2019-01-23 09:16:00 +08:00
|
|
|
hflow(
|
|
|
|
paragraph(L"Hello world! Here is an image:"), img1(),
|
|
|
|
paragraph(L" Here is a text "), text(L"underlined ") | underlined,
|
|
|
|
paragraph(L" Here is a text "), text(L"bold ") | bold,
|
|
|
|
paragraph(L"Hello world! Here is an image:"), img2(),
|
|
|
|
paragraph(
|
|
|
|
L"Le Lorem Ipsum est simplement du faux texte employé dans la "
|
|
|
|
L"composition et la mise en page avant impression. Le Lorem "
|
|
|
|
L"Ipsum est le faux texte standard de l'imprimerie depuis les "
|
|
|
|
L"années 1500, quand un imprimeur anonyme assembla ensemble "
|
|
|
|
L"des morceaux de texte pour réaliser un livre spécimen de "
|
|
|
|
L"polices de texte. Il n'a pas fait que survivre cinq siècles, "
|
|
|
|
L"mais s'est aussi adapté à la bureautique informatique, sans "
|
|
|
|
L"que son contenu n'en soit modifié. Il a été popularisé dans "
|
|
|
|
L"les années 1960 grâce à la vente de feuilles Letraset "
|
|
|
|
L"contenant des passages du Lorem Ipsum, et, plus récemment, "
|
|
|
|
L"par son inclusion dans des applications de mise en page de "
|
|
|
|
L"texte, comme Aldus PageMaker."),
|
|
|
|
paragraph(L" Here is a text "), text(L"dim ") | dim,
|
|
|
|
paragraph(L"Hello world! Here is an image:"), img1(),
|
|
|
|
paragraph(L" Here is a text "), text(L"red ") | color(Color::Red),
|
|
|
|
paragraph(L" A spinner "), spinner(6, i / 10)) |
|
|
|
|
border;
|
|
|
|
|
2019-01-27 04:52:55 +08:00
|
|
|
auto screen = Screen::Create(Dimension::Full());
|
2020-05-21 03:23:59 +08:00
|
|
|
Render(screen, document);
|
2021-03-22 05:54:39 +08:00
|
|
|
std::cout << reset_position;
|
|
|
|
screen.Print();
|
2019-01-23 09:16:00 +08:00
|
|
|
reset_position = screen.ResetPosition();
|
|
|
|
|
|
|
|
std::this_thread::sleep_for(0.01s);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2020-09-06 19:46:56 +08:00
|
|
|
|
|
|
|
// 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.
|