From da3b5b2131d2b4ff5cb127e92090fca568376835 Mon Sep 17 00:00:00 2001 From: BossCode45 Date: Wed, 24 May 2023 10:28:49 +1200 Subject: in-progress: Config refactor started, changed all existing keybind command args and added in the new files, still many errors --- old.config.h | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 old.config.h (limited to 'old.config.h') diff --git a/old.config.h b/old.config.h new file mode 100644 index 0000000..31005e7 --- /dev/null +++ b/old.config.h @@ -0,0 +1,93 @@ +#pragma once + +#include "error.h" + +#include + +#include +#include + +#include + +enum MoveDir +{ + Up, + Right, + Down, + Left +}; + +typedef union +{ + char* str; + int num; + MoveDir dir; +} KeyArg; + +struct KeyBind +{ + unsigned int modifiers; + KeySym keysym; + void(* func) (const KeyArg arg); + KeyArg args; +}; + +//Keybind commands +#define KEYCOM(X) \ + void X (const KeyArg arg) +KEYCOM(exit); +KEYCOM(spawn); +KEYCOM(toggle); +KEYCOM(kill); +KEYCOM(changeWS); +KEYCOM(wToWS); +KEYCOM(focChange); +KEYCOM(wMove); +KEYCOM(bashSpawn); +KEYCOM(reload); +KEYCOM(wsDump); +KEYCOM(nextMonitor); + +class Config +{ + public: + Config(); + ~Config(); + void free(); + + Err loadFromFile(std::string path); + Err reload(); + + // Startup + std::string* startupBash; + int startupBashc; + + // Main + int gaps; + int outerGaps; + std::string logFile; + + // Workspaces + int numWS; + std::string* workspaceNames; + int workspaceNamesc; + int maxMonitors; + int** screenPreferences; + int screenPreferencesc; + + // Keybinds + KeyBind* binds; + int bindsc; + private: + template + T getValue(std::string path, Err* err); + + void loadWorkspaceArrays(toml::table tbl, toml::table defaults, Err* err); + void loadStartupBash(toml::table tbl, toml::table defaults, Err* err); + + toml::table tbl; + toml::table defaults; + + bool loaded = false; + std::string path; +}; -- cgit v1.2.3