FTXUI 6.1.9
C++ functional terminal UI.
Loading...
Searching...
No Matches
html_like.cpp
Go to the documentation of this file.
1// 版權所有 2020 Arthur Sonzogni. 保留所有權利。
2// 本原始碼受 MIT 授權條款約束,詳情請參閱
3// LICENSE 檔案。
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("哈囉世界!這是一張圖片:"), img1(),
27 paragraph(" 這是一段文字 "), text("加底線的 ") | underlined,
28 paragraph(" 這是一段文字 "), text("粗體的 ") | bold,
29 paragraph("哈囉世界!這是一張圖片:"), img2(),
30 paragraph(
31 "Lorem Ipsum 僅是排版和印刷前的假文。Lorem Ipsum 自 15 世紀以來一直是印刷業的標準假文,當時一位匿名印刷商將不同的文字片段組合成一本字體樣本。它不僅存活了五個世紀,還適應了電子排版,內容卻未曾改變。它在 1960 年代因 Letraset 公司發售含有 Lorem Ipsum 段落的字體樣本而廣受歡迎,最近則因其被包含在 Aldus PageMaker 等桌面出版應用程式中而再次普及。"),
32 paragraph(" 這是一段文字 "), text("暗淡的 ") | dim,
33 paragraph("哈囉世界!這是一張圖片:"), img1(),
34 paragraph(" 這是一段文字 "), text("紅色的 ") | color(Color::Red),
35 paragraph(" 一個旋轉器 "), spinner(6, i / 10)) |
36 border;
37
38 auto screen = Screen::Create(Dimension::Fit(document));
39 Render(screen, document);
40 std::cout << reset_position;
41 screen.Print();
42 reset_position = screen.ResetPosition();
43
44 std::this_thread::sleep_for(0.01s);
45 }
46
47 return 0;
48}
void Render(Screen &screen, const Element &element)
在 ftxui::Screen 上顯示元素。
Definition node.cpp:82
int main()
Definition html_like.cpp:15
FTXUI 的 ftxui:: 命名空間
Definition animation.hpp:10