FTXUI 6.1.9 C++ functional terminal UI.

Loading...
Searching...
No Matches
examples/dom/paragraph.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 Full, Screen
6#include <iostream> // for cout, ostream
7#include <memory> // for allocator, shared_ptr
8#include <string> // for string, operator<<
9#include <thread> // for sleep_for
10
11#include "ftxui/dom/elements.hpp" // for hflow, paragraph, separator, hbox, vbox, filler, operator|, border, Element
12#include "ftxui/dom/node.hpp" // for Render
13#include "ftxui/screen/box.hpp" // for ftxui
14
15 using namespace std::chrono_literals;
16 int main() {
17 using namespace ftxui;
18 std::string p =
19 R"(In probability theory and statistics, Bayes' theorem (alternatively Bayes' law or Bayes' rule) describes the probability of an event, based on prior knowledge of conditions that might be related to the event. For example, if cancer is related to age, then, using Bayes' theorem, a person's age can be used to more accurately assess the probability that they have cancer, compared to the assessment of the probability of cancer made without knowledge of the person's age. One of the many applications of Bayes' theorem is Bayesian inference, a particular approach to statistical inference. When applied, the probabilities involved in Bayes' theorem may have different probability interpretations. With the Bayesian probability interpretation the theorem expresses how a subjective degree of belief should rationally change to account for availability of related evidence. Bayesian inference is fundamental to Bayesian statistics.)";
20
21 std::string reset_position;
22 while (true) {
23 auto document = vbox({
24 hflow(paragraph(p)),
25 separator(),
26 hflow(paragraph(p)),
27 separator(),
28 hbox({
29 hflow(paragraph(p)),
30 separator(),
31 hflow(paragraph(p)),
32 }),
33 }) |
34 border;
35
36 document = vbox(filler(), document);
37
38 // auto screen = Screen::Create(Dimension::Fit(document));
39 // Render(screen, document);
40 // screen.Print();
41 // getchar();
42
43 auto screen = Screen::Create(Dimension::Full());
44 Render(screen, document);
45 std::cout << reset_position;
46 screen.Print();
47 reset_position = screen.ResetPosition();
48
49 std::this_thread::sleep_for(0.01s);
50 }
51
52 return 0;
53}
box.hpp
elements.hpp
main
int main()
Definition examples/dom/paragraph.cpp:16
ftxui
The FTXUI ftxui:: namespace.
Definition animation.hpp:10
node.hpp
screen.hpp