From 6d6423a416f4a9372550a129e0cb7c5ee95b0112 Mon Sep 17 00:00:00 2001 From: IXtreme Date: Mon, 12 Oct 2026 04:54:12 -0400 Subject: [PATCH] meow --- .clangd | 2 ++ CMakeLists.txt | 41 ++++++++++++++++++++++++++++++++++ CMakePresets.json | 32 +++++++++++++++++++++++++++ Makefile | 50 ------------------------------------------ README.md | 11 ++++++++++ src/main.cpp | 24 +++++++++++++++++++- src/summarymanager.cpp | 30 +++++++++++++++++++++---- src/summarymanager.hpp | 2 ++ 8 files changed, 137 insertions(+), 55 deletions(-) create mode 100644 .clangd create mode 100644 CMakeLists.txt create mode 100644 CMakePresets.json delete mode 100644 Makefile diff --git a/.clangd b/.clangd new file mode 100644 index 0000000..2be4694 --- /dev/null +++ b/.clangd @@ -0,0 +1,2 @@ +CompileFlags: + CompilationDatabase: build/debug diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..bc41894 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,41 @@ +cmake_minimum_required(VERSION 3.28) + +project(MossMan LANGUAGES C CXX) # ← per-project edit: name drives the binary name + +# --- Language versions ------------------------------------------------------ +# Emits -std=c++26 (not gnu++26). STANDARD_REQUIRED = fail instead of +# silently falling back if the compiler doesn't support it. +set(CMAKE_CXX_STANDARD 26) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) +# set(CMAKE_C_STANDARD 23) # uncomment if you ever want to pin the C TU + +# --- Warnings ---------------------------------------------------------------- +# Applies to both C and C++ TUs, like your Makefile did. +add_compile_options(-Wall -Wextra -Wpedantic) +# add_compile_options("$<$:/W4>") # future Windows tinker + +# --- Dependencies ------------------------------------------------------------ +# CONFIG mode is deliberate: it picks up FLTK's own modern config +# (/usr/share/fltk/FLTKConfig.cmake) instead of CMake's crusty FindFLTK module. +find_package(FLTK CONFIG REQUIRED) +find_package(CURL REQUIRED) + +# If you ever need cairo directly (you currently don't — FLTK's imported +# targets already propagate its include paths): +# find_package(PkgConfig REQUIRED) +# pkg_check_modules(CAIRO IMPORTED_TARGET cairo) + +# --- Sources ------------------------------------------------------------------ +# CONFIGURE_DEPENDS = re-glob at build time and auto-reconfigure if the file +# set changed. This is what makes globbing honest. +file(GLOB_RECURSE sources CONFIGURE_DEPENDS + "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/src/*.c") + +# --- Target -------------------------------------------------------------------- +add_executable(${PROJECT_NAME} ${sources}) + +# fltk::fltk is probably pulled in transitively by fltk::images, but linking +# both explicitly costs nothing and documents intent. +target_link_libraries(${PROJECT_NAME} PRIVATE fltk::fltk fltk::images CURL::libcurl) diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 0000000..8bd8fc9 --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,32 @@ +{ + "version": 6, + "cmakeMinimumRequired": { "major": 3, "minor": 28, "patch": 0 }, + "configurePresets": [ + { + "name": "debug", + "displayName": "Debug", + "generator": "Ninja", + "binaryDir": "${sourceDir}/build/debug", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug", + "CMAKE_EXPORT_COMPILE_COMMANDS": "ON" + } + }, + { + "name": "release", + "displayName": "Release (-O3 -ffast-math)", + "generator": "Ninja", + "binaryDir": "${sourceDir}/build/release", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release", + "CMAKE_CXX_FLAGS_RELEASE": "-O3 -DNDEBUG -ffast-math", + "CMAKE_C_FLAGS_RELEASE": "-O3 -DNDEBUG -ffast-math", + "CMAKE_EXPORT_COMPILE_COMMANDS": "ON" + } + } + ], + "buildPresets": [ + { "name": "debug", "configurePreset": "debug" }, + { "name": "release", "configurePreset": "release" } + ] +} diff --git a/Makefile b/Makefile deleted file mode 100644 index 8fafb7f..0000000 --- a/Makefile +++ /dev/null @@ -1,50 +0,0 @@ -CC = gcc -CXX = g++ - -CPPFLAGS = -std=c++26 -g -Wall -Wextra -Wpedantic #-O3 -ffast-math -CFLAGS = -g -Wall -Wextra -Wpedantic #-O3 -ffast-math -LDFLAGS = -g -Wall -Wextra -Wpedantic #-O3 -ffast-math -LDLIBS = -lfltk -lcurl -lfltk_images - - -SRC_DIR = src -OBJ_DIR = obj -BIN_DIR = bin - - - -EXE = $(BIN_DIR)/main - -C_SRC := $(wildcard $(SRC_DIR)/*.c) #GET LIST OF ALL C FILES -CPP_SRC := $(wildcard $(SRC_DIR)/*.cpp) #GET LIST OF ALL CPP FILES - -#SRC := $(C_SRC) $(CPP_SCR) - - -C_OBJ := $(patsubst $(SRC_DIR)/%.c, $(OBJ_DIR)/%.o, $(C_SRC)) #MAKE LIST OF ALL C OBJECT FILES THAT NEED TO BE BUILT -CPP_OBJ := $(patsubst $(SRC_DIR)/%.cpp, $(OBJ_DIR)/%.o, $(CPP_SRC)) #MAKE LIST OF ALL CPP OBJECT FILES THAT NEED TO BE BUILT - -OBJ := $(C_OBJ) $(CPP_OBJ) - - -all: $(EXE) - -$(EXE): $(OBJ) | $(BIN_DIR) - $(CXX) $(LDFLAGS) $^ $(LDLIBS) -o $@ - -$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c | $(OBJ_DIR) - $(CC) $(CFLAGS) -c $< -o $@ - - -$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp | $(OBJ_DIR) - $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@ - -$(BIN_DIR) $(OBJ_DIR): - mkdir -p $@ - - -clean: - @$(RM) -rv $(BIN_DIR) $(OBJ_DIR) - -.PHONY: all clean - diff --git a/README.md b/README.md index 57b9be2..03835a4 100644 --- a/README.md +++ b/README.md @@ -5,5 +5,16 @@ MossMan is a tool designed to ease the filtering, viewing, and compilation of [S ![Screenshot](https://ajm.onl/moss.png) +## Building + +MossMan builds with CMake (sadly) + +Dependencies: a C++26-capable compiler (probably not needed, I just want to tinker w/ C++26 stuff when it comes out, CMake >= 3.28, Ninja, FLTK >= 1.4, and libcurl. + +```sh +cmake --preset debug && cmake --build --preset debug # debug build -> build/debug/MossMan +cmake --preset release && cmake --build --preset release # -O3 -ffast-math -> build/release/MossMan +``` + ## Adding images Because distributing an application (normally) would require the inclusion of multiple files that then must be grouped and installed (especially on Windows), we (read: I) chose to embed files into the executable itself for things like icons. Using xxd -i is recommended to generate the code needed. Note that modifications will be needed to fit naming conventions and to keep the actual data out of the header to ease compilation times. diff --git a/src/main.cpp b/src/main.cpp index 831ab3e..9bdd5d5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -34,6 +34,7 @@ struct Selected { }; void show_callback(Fl_Widget *w, void * data); +void add_callback(Fl_Widget *w, void * data); std::vector MakeEntires(std::string filename) { @@ -140,6 +141,7 @@ struct Topbar : Fl_Group { Fl_Box *titleText; Fl_Button *inspect; + Fl_Button *add; Topbar(int x, int y, int w, int h) : Fl_Group(x, y, w, h), @@ -150,11 +152,15 @@ struct Topbar : Fl_Group { titleText->labelfont(FL_TIMES | FL_BOLD); titleText->align(FL_ALIGN_INSIDE | FL_ALIGN_TOP_LEFT); inspect = new Fl_Button(950, 0, 50, 50); + add = new Fl_Button(900, 0, 50, 50); resizable(titleText); inspect->image(inspectIcon); inspect->tooltip("Inspect Entr(ies)"); + + add->tooltip("Add current entry to working set"); + end(); } }; @@ -173,6 +179,7 @@ struct MainGui : Fl_Window { list = new Fl_Multi_Browser(0, 50, 250, 700); summaryEditor = new SummaryManager(250, 50, 750, 700); topbar->inspect->callback(show_callback, this); + topbar->add->callback(add_callback, this); tilebox->end(); @@ -212,7 +219,19 @@ void show_callback(Fl_Widget *w, void *data) { } } +void add_callback(Fl_Widget *w, void *data) { + MainGui * rdata = (MainGui *) data; + auto activetab = (Summary *) rdata->summaryEditor->tabs.value(); + if (rdata->summaryEditor->tabs.child(0) == activetab) { + return; + } + + + + auto v = new ComplexEntry(activetab->entry); + rdata->summaryEditor->project_items->add(activetab->title.c_str(), v); +} int main(int argc, char **argv) { @@ -243,5 +262,8 @@ int main(int argc, char **argv) { x.updateList(argv[1]); x.show(); - return Fl::run(); + auto res = Fl::run(); + + return res; + } diff --git a/src/summarymanager.cpp b/src/summarymanager.cpp index 6f0bcf9..1e69577 100644 --- a/src/summarymanager.cpp +++ b/src/summarymanager.cpp @@ -8,7 +8,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -45,19 +47,38 @@ void SummaryCallback(Fl_Widget * w, void * data) { } } +void SelectionCallback(Fl_Widget * w, void * data) { + auto sumMan = (SummaryManager * ) data; + if (sumMan->project_items->value() == 0) return; + sumMan->win1->begin(); + Summary * ns = new Summary( *(ComplexEntry*) sumMan->project_items->data( sumMan->project_items->value()), 201,0, 400, sumMan->project_items->h()); + ns->show(); + sumMan->win1->end(); + if (sumMan->s != NULL) { + Fl::delete_widget(sumMan->s); + } + sumMan->s = ns; + sumMan->tabs.redraw(); + sumMan->win1->redraw(); + sumMan->redraw(); + + +} SummaryManager::SummaryManager(int x, int y, int w, int h) : Fl_Group(x, y, w, h), tabs(x, y, w, h) { Fl_Group *grp1 = new Fl_Group(x, y + 30, w, h - 30, "Current Project"); - grp1->when(FL_WHEN_CLOSED); + grp1->when(FL_WHEN_CLOSED); + { - Fl_Window *win1 = new Fl_Window(x, y + 30, w, h - 30, "Tab1W"); + win1 = new Fl_Window(x, y + 30, w, h - 30, "Tab1W"); std::cout << "here" << std::endl; { - project_items = new Fl_Multi_Browser(0,0,100,h-30); - auto butt = new Fl_Button(100, 0, 100, 200, "test"); + project_items = new Fl_Multi_Browser(0,0,200,h-160); + project_items->callback(SelectionCallback, this); + //auto butt = new Fl_Button(100, 0, 100, 200, "test"); } win1->end(); //auto butt = new Fl_Button(0, 30, 100, 200, "nyaaa"); @@ -221,6 +242,7 @@ Summary::Summary(ComplexEntry c, int x, int y, int w, int h) : Fl_Group(x, y, w, text_boxes->end(); win->end(); + win->show(); this->end(); this->resizable(win); win->resizable(text_boxes); diff --git a/src/summarymanager.hpp b/src/summarymanager.hpp index 64841f3..2df179a 100644 --- a/src/summarymanager.hpp +++ b/src/summarymanager.hpp @@ -35,6 +35,8 @@ struct SummaryManager : Fl_Group { SummaryManager(int x, int y, int w, int h); Fl_Tabs tabs; Fl_Multi_Browser * project_items; + Fl_Window * win1; + Fl_Widget * s; std::vector items;