diff --git a/.idea/vcs.xml b/.idea/vcs.xml index 94a25f7..0a7ad43 100644 --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -2,5 +2,6 @@ + \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 40e0148..86f8e7c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,7 @@ cmake_minimum_required(VERSION 3.28) -project(floc VERSION 0.0.2) +project(floc VERSION 0.0.3) + +include(FetchContent) option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF) option(ENABLE_UBSAN "Enable the ub sanitizer" OFF) @@ -7,14 +9,29 @@ option(ENABLE_TSAN "Enable the thread data race sanitizer" OFF) set(CMAKE_CXX_STANDARD 17) -add_subdirectory(lib/blt) - include_directories(include/) file(GLOB_RECURSE PROJECT_BUILD_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp") add_executable(floc ${PROJECT_BUILD_FILES}) +add_subdirectory(lib/blt) +FetchContent_Declare(ftxui + GIT_REPOSITORY https://github.com/ArthurSonzogni/ftxui + GIT_TAG v5.0.0 +) + +FetchContent_GetProperties(ftxui) +if(NOT ftxui_POPULATED) + FetchContent_Populate(ftxui) + add_subdirectory(${ftxui_SOURCE_DIR} ${ftxui_BINARY_DIR} EXCLUDE_FROM_ALL) +endif() + target_link_libraries(floc ${BLT_TARGET}) +target_link_libraries(floc + PRIVATE ftxui::screen + PRIVATE ftxui::dom + PRIVATE ftxui::component +) target_compile_options(floc PRIVATE -Wall -Werror -Wpedantic -Wno-comment) target_link_options(floc PRIVATE -Wall -Werror -Wpedantic -Wno-comment) @@ -32,4 +49,4 @@ endif () if (${ENABLE_TSAN} MATCHES ON) target_compile_options(floc PRIVATE -fsanitize=thread) target_link_options(floc PRIVATE -fsanitize=thread) -endif () \ No newline at end of file +endif () diff --git a/src/main.cpp b/src/main.cpp index 4f9de56..44f4e7a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,7 +1,40 @@ #include +#include "ftxui/dom/elements.hpp" +#include "ftxui/screen/screen.hpp" +#include "ftxui/screen/string.hpp" + int main() { - std::cout << "Hello, World!" << std::endl; - return 0; + 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; }