Initialize the project with basic code

This commit is contained in:
osamu-kj 2023-04-18 23:33:40 +02:00
parent a228617747
commit 3278c54743
3 changed files with 74 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
build/
compile_commands.json
.ccls-cache/

32
CMakeLists.txt Normal file
View File

@ -0,0 +1,32 @@
cmake_minimum_required(VERSION 3.26.3)
include(FetchContent)
set(FETCHCONTENT_UPDATES_DISCONNECTED TRUE)
FetchContent_Declare(ftxui
GIT_REPOSITORY https://github.com/ArthurSonzogni/ftxui
GIT_TAG v3.0.0
)
FetchContent_GetProperties(ftxui)
if(NOT ftxui_POPULATED)
FetchContent_Populate(ftxui)
add_subdirectory(${ftxui_SOURCE_DIR} ${ftxui_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()
# ------------------------------------------------------------------------------
project(vis
VERSION 1.0
DESCRIPTION "Vi Scheduler (vis) is a simple TUI program built for managing your schedules in a calendar-like grid."
LANGUAGES CXX)
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
add_executable(vis src/main.cpp)
target_include_directories(vis PRIVATE src)
target_link_libraries(vis
PRIVATE ftxui::screen
PRIVATE ftxui::dom
PRIVATE ftxui::component # Not needed for this example.
)

39
src/main.cpp Normal file
View File

@ -0,0 +1,39 @@
#include <stdio.h>
#include <iostream>
#include <ftxui/dom/elements.hpp>
#include <ftxui/component/screen_interactive.hpp>
#include <ftxui/component/component.hpp>
#include <ftxui/component/event.hpp>
using namespace std;
using namespace ftxui;
int main() {
auto screen = ScreenInteractive::FitComponent();
auto component = Renderer([&screen] {
auto make_box = [](int x, int y, int i) {
string title = to_string(i);
return window(text(""), text(title) | hcenter | size(WIDTH, EQUAL, x) | size(HEIGHT, EQUAL, y));
};
Element calendar = hflow({
make_box(12,7,0),
make_box(7,7,1),
make_box(7,7,2),
make_box(7,7,3),
make_box(7,7,4),
make_box(7,7,5),
make_box(7,7,6),
make_box(7,7,7)
});
return window(text("Vi Scheduler"), vbox(calendar));
});
screen.Loop(component);
return 0;
}