Setting up FTXUI with cmake.
Setting up FTXUI with cmake.
Root CMakeLists.txt file.
src dir CMakeLists.txt
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
add_executable(app main.cpp)
target_link_libraries(
app
PRIVATE
ftxui::screen
ftxui::dom
ftxui::component
)
vendors directory CMakeLists.txt
vendors ftx directory CMakeLists.txt
include(FetchContent)
FetchContent_Declare(
ftxui
GIT_REPOSITORY https://github.com/ArthurSonzogni/FTXUI.git
GIT_TAG main
)
FetchContent_MakeAvailable(ftxui)
main.cpp code
#include <iostream>
#include <ftxui/dom/elements.hpp>
#include <ftxui/screen/screen.hpp>
#include <ftxui/screen/string.hpp>
int main() {
using namespace ftxui;
auto summary = [&] {
auto content = vbox({
hbox({text(L"- done: "), text(L"3") | bold}) | color(Color::Green),
hbox({text(L"- active: "), text(L"2") | bold}) | color(Color::RedLight),
hbox({text(L"- queue: "), text(L"9") | bold}) | color(Color::Red),
});
return window(text(L" Summary "), content);
};
auto document = //
vbox({
hbox({
summary(),
summary(),
summary() | flex,
}),
summary(),
summary(),
});
// Limit the size of the document to 80 char.
document = document | size(WIDTH, LESS_THAN, 80);
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
Render(screen, document);
std::cout << screen.ToString() << '\0' << std::endl;
return EXIT_SUCCESS;
}