FTXUI 6.1.9
C++ functional terminal UI.
Loading...
Searching...
No Matches
html_like.cpp
Go to the documentation of this file.
1// Copyright 2020 Arthur Sonzogni. All rights reserved.
2// Use of this source code is governed by the MIT license that can be found in
3// the LICENSE file.
4#include <chrono> // for operator""s, chrono_literals
5#include <ftxui/screen/screen.hpp> // for Screen
6#include <iostream> // for cout, ostream
7#include <string> // for allocator, operator<<, string
8#include <thread> // for sleep_for
9
10#include "ftxui/dom/elements.hpp" // for paragraph, text, operator|, Element, border, Fit, color, hflow, spinner, vbox, bold, dim, underlined
11#include "ftxui/dom/node.hpp" // for Render
12#include "ftxui/screen/box.hpp" // for ftxui
13#include "ftxui/screen/color.hpp" // for Color, Color::Red
14
15int main() {
16 using namespace ftxui;
17 using namespace std::chrono_literals;
18
19 auto img1 = []() { return text("img") | border; };
20 auto img2 = []() { return vbox({text("big"), text("image")}) | border; };
21
22 std::string reset_position;
23 for (int i = 0;; ++i) {
24 auto document = //
25 hflow(
26 paragraph("Hello world! Here is an image:"), img1(),
27 paragraph(" Here is a text "), text("underlined ") | underlined,
28 paragraph(" Here is a text "), text("bold ") | bold,
29 paragraph("Hello world! Here is an image:"), img2(),
30 paragraph(
31 "Le Lorem Ipsum est simplement du faux texte employé dans la "
32 "composition et la mise en page avant impression. Le Lorem "
33 "Ipsum est le faux texte standard de l'imprimerie depuis les "
34 "années 1500, quand un imprimeur anonyme assembla ensemble "
35 "des morceaux de texte pour réaliser un livre spécimen de "
36 "polices de texte. Il n'a pas fait que survivre cinq siècles, "
37 "mais s'est aussi adapté à la bureautique informatique, sans "
38 "que son contenu n'en soit modifié. Il a été popularisé dans "
39 "les années 1960 grâce à la vente de feuilles Letraset "
40 "contenant des passages du Lorem Ipsum, et, plus récemment, "
41 "par son inclusion dans des applications de mise en page de "
42 "texte, comme Aldus PageMaker."),
43 paragraph(" Here is a text "), text("dim ") | dim,
44 paragraph("Hello world! Here is an image:"), img1(),
45 paragraph(" Here is a text "), text("red ") | color(Color::Red),
46 paragraph(" A spinner "), spinner(6, i / 10)) |
47 border;
48
49 auto screen = Screen::Create(Dimension::Fit(document));
50 Render(screen, document);
51 std::cout << reset_position;
52 screen.Print();
53 reset_position = screen.ResetPosition();
54
55 std::this_thread::sleep_for(0.01s);
56 }
57
58 return 0;
59}
int main()
Definition html_like.cpp:15
The FTXUI ftxui:: namespace.
Definition animation.hpp:10