From 91a01542dfd6ba4658909fd6dfb4ec4d1bbd1731 Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Tue, 21 May 2024 22:05:29 -0400 Subject: [PATCH] some basic files for structure. floc is part of BLT --- CMakeLists.txt | 4 +- include/blt/floc/analyzer.h | 29 +++++++++ src/blt/floc/analyzer.cpp | 18 ++++++ src/main.cpp | 126 ++++++++++++++++++------------------ 4 files changed, 113 insertions(+), 64 deletions(-) create mode 100644 include/blt/floc/analyzer.h create mode 100644 src/blt/floc/analyzer.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index e45ad74..8d7ef64 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ -cmake_minimum_required(VERSION 3.28) -project(floc VERSION 0.0.7) +cmake_minimum_required(VERSION 3.25) +project(floc VERSION 0.0.8) include(FetchContent) diff --git a/include/blt/floc/analyzer.h b/include/blt/floc/analyzer.h new file mode 100644 index 0000000..7240363 --- /dev/null +++ b/include/blt/floc/analyzer.h @@ -0,0 +1,29 @@ +#pragma once +/* + * Copyright (C) 2024 Brett Terpstra + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef BLT_FLOC_ANALYZER_H +#define BLT_FLOC_ANALYZER_H + +/* + * This file provides an analyzer class for counting lines of code in a file along with a recursive parser for finding files + * it also provides a utility class to build a structure which mimics the file system directories alongside relevant code + * + * maybe split this into a few header files? + */ + +#endif // BLT_FLOC_ANALYZER_H diff --git a/src/blt/floc/analyzer.cpp b/src/blt/floc/analyzer.cpp new file mode 100644 index 0000000..cd662c7 --- /dev/null +++ b/src/blt/floc/analyzer.cpp @@ -0,0 +1,18 @@ +/* + * + * Copyright (C) 2024 Brett Terpstra + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#include \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index df4b57b..fe512c7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -10,69 +10,71 @@ #include "ftxui/component/screen_interactive.hpp" // for Component, ScreenInteractive #include "ftxui/dom/elements.hpp" // for text, separator, bold, hcenter, vbox, hbox, gauge, Element, operator|, border +#include +#include int main() { - using namespace ftxui; - auto screen = ScreenInteractive::TerminalOutput(); - - std::vector left_menu_entries = { - "0%", "10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", - }; - std::vector right_menu_entries = { - "0%", "1%", "2%", "3%", "4%", "5%", "6%", "7%", "8%", "9%", "10%", - }; - - auto menu_option = MenuOption(); - menu_option.on_enter = screen.ExitLoopClosure(); - - int left_menu_selected = 0; - int right_menu_selected = 0; - Component left_menu_ = - Menu(&left_menu_entries, &left_menu_selected, menu_option); - Component right_menu_ = - Menu(&right_menu_entries, &right_menu_selected, menu_option); - - Component container = Container::Horizontal({ - left_menu_, - right_menu_, - }); - - auto renderer = Renderer(container, [&] { - int sum = left_menu_selected * 10 + right_menu_selected; - return vbox({ - // -------- Top panel -------------- - hbox({ - // -------- Left Menu -------------- - vbox({ - hcenter(bold(text("Percentage by 10%"))), - separator(), - left_menu_->Render(), - }), - separator(), - // -------- Right Menu -------------- - vbox({ - hcenter(bold(text("Percentage by 1%"))), - separator(), - right_menu_->Render(), - }), - separator(), - }), - separator(), - // -------- Bottom panel -------------- - vbox({ - hbox({ - text(" gauge : "), - gauge(sum / 100.0), - }), - hbox({ - text(" text : "), - text(std::to_string(sum) + " %"), - }), - }), - }) | - border; - }); - - screen.Loop(renderer); +// using namespace ftxui; +// auto screen = ScreenInteractive::TerminalOutput(); +// +// std::vector left_menu_entries = { +// "0%", "10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", +// }; +// std::vector right_menu_entries = { +// "0%", "1%", "2%", "3%", "4%", "5%", "6%", "7%", "8%", "9%", "10%", +// }; +// +// auto menu_option = MenuOption(); +// menu_option.on_enter = screen.ExitLoopClosure(); +// +// int left_menu_selected = 0; +// int right_menu_selected = 0; +// Component left_menu_ = +// Menu(&left_menu_entries, &left_menu_selected, menu_option); +// Component right_menu_ = +// Menu(&right_menu_entries, &right_menu_selected, menu_option); +// +// Component container = Container::Horizontal({ +// left_menu_, +// right_menu_, +// }); +// +// auto renderer = Renderer(container, [&] { +// int sum = left_menu_selected * 10 + right_menu_selected; +// return vbox({ +// // -------- Top panel -------------- +// hbox({ +// // -------- Left Menu -------------- +// vbox({ +// hcenter(bold(text("Percentage by 10%"))), +// separator(), +// left_menu_->Render(), +// }), +// separator(), +// // -------- Right Menu -------------- +// vbox({ +// hcenter(bold(text("Percentage by 1%"))), +// separator(), +// right_menu_->Render(), +// }), +// separator(), +// }), +// separator(), +// // -------- Bottom panel -------------- +// vbox({ +// hbox({ +// text(" gauge : "), +// gauge(sum / 100.0), +// }), +// hbox({ +// text(" text : "), +// text(std::to_string(sum) + " %"), +// }), +// }), +// }) | +// border; +// }); +// +// screen.Loop(renderer); }