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