FTXUI 6.1.9
C++ functional terminal UI.
Loading...
Searching...
No Matches
examples/dom/paragraph.cpp
Go to the documentation of this file.
1// 版權所有 2020 Arthur Sonzogni. 保留所有權利。
2// 本原始碼的使用受 MIT 授權條款約束,詳情請參閱 `LICENSE` 檔案。
3#include <chrono> // for operator""s, chrono_literals
4#include <ftxui/screen/screen.hpp> // for Full, Screen
5#include <iostream> // for cout, ostream
6#include <memory> // for allocator, shared_ptr
7#include <string> // for string, operator<<
8#include <thread> // for sleep_for
9
10#include "ftxui/dom/elements.hpp" // for hflow, paragraph, separator, hbox, vbox, filler, operator|, border, Element
11#include "ftxui/dom/node.hpp" // for Render
12#include "ftxui/screen/box.hpp" // for ftxui
13
14using namespace std::chrono_literals;
15int main() {
16 using namespace ftxui;
17 std::string p =
18 R"(在機率論與統計學中,貝氏定理(或稱貝氏法則、貝氏規律)描述了一個事件的機率,其基礎是與該事件可能相關的條件的先驗知識。例如,如果癌症與年齡相關,那麼使用貝氏定理,一個人的年齡可以用來更準確地評估他們患癌症的機率,而不是在不知道該人年齡的情況下評估患癌症的機率。貝氏定理的眾多應用之一是貝氏推論,這是一種特殊的統計推論方法。當應用時,貝氏定理中涉及的機率可能具有不同的機率解釋。在貝氏機率解釋中,該定理表達了主觀的信念程度應如何理性地改變,以考慮相關證據的可用性。貝氏推論是貝氏統計學的基礎。)";
19
20 std::string reset_position;
21 while (true) {
22 auto document = vbox({
23 hflow(paragraph(p)),
24 separator(),
25 hflow(paragraph(p)),
26 separator(),
27 hbox({
28 hflow(paragraph(p)),
29 separator(),
30 hflow(paragraph(p)),
31 }),
32 }) |
33 border;
34
35 document = vbox(filler(), document);
36
37 // auto screen = Screen::Create(Dimension::Fit(document));
38 // Render(screen, document);
39 // screen.Print();
40 // getchar();
41
42 auto screen = Screen::Create(Dimension::Full());
43 Render(screen, document);
44 std::cout << reset_position;
45 screen.Print();
46 reset_position = screen.ResetPosition();
47
48 std::this_thread::sleep_for(0.01s);
49 }
50
51 return 0;
52}
void Render(Screen &screen, const Element &element)
在 ftxui::Screen 上顯示元素。
Definition node.cpp:82
FTXUI 的 ftxui:: 命名空間
Definition animation.hpp:10