mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-09-16 08:04:21 +08:00
Add Blink. Refactor examples.
This commit is contained in:
3
examples/dom/CMakeLists.txt
Normal file
3
examples/dom/CMakeLists.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
example(frame)
|
||||
example(separator)
|
||||
example(vbox_hbox)
|
49
examples/dom/frame.cpp
Normal file
49
examples/dom/frame.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
|
||||
#include "ftxui/screen.hpp"
|
||||
#include "ftxui/dom/elements.hpp"
|
||||
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
using namespace ftxui::dom;
|
||||
auto document =
|
||||
hbox(
|
||||
frame(hcenter(text(L" main frame ")),
|
||||
vbox(
|
||||
text(L"Line 1"),
|
||||
text(L"Line 2"),
|
||||
text(L"Line 3"),
|
||||
frame(
|
||||
vbox(
|
||||
text(L"Line 4"),
|
||||
text(L"Line 5"),
|
||||
text(L"Line 6")
|
||||
)
|
||||
),
|
||||
hbox(
|
||||
frame(text(L"frame 2"),
|
||||
vbox(
|
||||
text(L"Line 4"),
|
||||
text(L"Line 5"),
|
||||
text(L"Line 6")
|
||||
)
|
||||
),
|
||||
frame(text(L"frame 3"),
|
||||
vbox(
|
||||
text(L"Line 7"),
|
||||
text(L"Line 8"),
|
||||
text(L"Line 9")
|
||||
)
|
||||
)
|
||||
),
|
||||
text(L"footer footer footer footer footer")
|
||||
)
|
||||
),
|
||||
flex()
|
||||
);
|
||||
auto screen = ftxui::Screen::TerminalOutput(document);
|
||||
Render(screen, document.get());
|
||||
std::cout << screen.ToString() << std::endl;
|
||||
}
|
25
examples/dom/separator.cpp
Normal file
25
examples/dom/separator.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
#include "ftxui/screen.hpp"
|
||||
#include "ftxui/dom/elements.hpp"
|
||||
#include <iostream>
|
||||
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
using namespace ftxui::dom;
|
||||
auto document =
|
||||
hbox(
|
||||
text(L"left-column"),
|
||||
separator(),
|
||||
flex(vbox(
|
||||
flex(center(text(L"right-column"))),
|
||||
separator(),
|
||||
center(text(L"bottom-column"))
|
||||
))
|
||||
);
|
||||
auto screen = ftxui::Screen::TerminalFullscreen();
|
||||
Render(screen, document.get());
|
||||
|
||||
std::cout << screen.ToString();
|
||||
getchar();
|
||||
|
||||
return 0;
|
||||
}
|
36
examples/dom/vbox_hbox.cpp
Normal file
36
examples/dom/vbox_hbox.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
#include "ftxui/screen.hpp"
|
||||
#include "ftxui/dom/elements.hpp"
|
||||
#include <iostream>
|
||||
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
using namespace ftxui::dom;
|
||||
auto document =
|
||||
vbox(
|
||||
hbox(
|
||||
text(L"north-west"),
|
||||
flex(),
|
||||
text(L"north-east")
|
||||
),
|
||||
flex(),
|
||||
hbox(
|
||||
hbox(
|
||||
flex(),
|
||||
text(L"center"),
|
||||
flex()
|
||||
)
|
||||
),
|
||||
flex(),
|
||||
hbox(
|
||||
text(L"south-west"),
|
||||
flex(),
|
||||
text(L"south-east")
|
||||
)
|
||||
);
|
||||
auto screen = ftxui::Screen::TerminalFullscreen();
|
||||
Render(screen, document.get());
|
||||
|
||||
std::cout << screen.ToString();
|
||||
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user