summaryrefslogtreecommitdiff
path: root/src/commands.h
diff options
context:
space:
mode:
authorBossCode45 <human.cyborg42@gmail.com>2025-01-04 15:14:05 +1300
committerBossCode45 <human.cyborg42@gmail.com>2025-01-04 15:14:05 +1300
commitaa1500fea32db04c9e4fe72786ebd7e3479b6a8a (patch)
treedf2bcb0182704dac9e1813f269fb46bb67e65c61 /src/commands.h
parentd1d4a63d4473cd4910b678cf5b385f622186fbd3 (diff)
downloadYATwm-aa1500fea32db04c9e4fe72786ebd7e3479b6a8a.tar.gz
YATwm-aa1500fea32db04c9e4fe72786ebd7e3479b6a8a.zip
feat: Commands restructure + home manager module now makes config
Commands module is now a separate libraray that the flake includes. The home manager module will now auto generate the config and has options for different things such as keybinds, gaps, workspaces, etc.
Diffstat (limited to 'src/commands.h')
-rw-r--r--src/commands.h89
1 files changed, 0 insertions, 89 deletions
diff --git a/src/commands.h b/src/commands.h
deleted file mode 100644
index af4a4a0..0000000
--- a/src/commands.h
+++ /dev/null
@@ -1,89 +0,0 @@
-#pragma once
-
-#include "error.h"
-
-#include <vector>
-#include <string>
-#include <any>
-#include <functional>
-
-enum MoveDir
- {
- UP,
- RIGHT,
- DOWN,
- LEFT
- };
-enum CommandArgType
- {
- STR,
- NUM,
- MOVDIR,
- STR_REST,
- NUM_ARR_REST
- };
-
-struct NumArr
-{
- int* arr;
- int size;
-};
-typedef union
-{
- char* str;
- int num;
- NumArr numArr;
- MoveDir dir;
-} CommandArg;
-
-struct Command
-{
- const std::string name;
- const std::function<void(std::any&, const CommandArg* argv)> func;
- const std::function<void(const CommandArg* argv)> staticFunc;
- const int argc;
- CommandArgType* argTypes;
- std::any* module;
-};
-class CommandsModule
-{
-private:
- std::vector<Command> commandList;
- std::vector<std::string> splitCommand(std::string command);
- CommandArg* getCommandArgs(std::vector<std::string>& args, const CommandArgType* argTypes, const int argc);
- const void echo(const CommandArg* argv);
-public:
- CommandsModule();
- ~CommandsModule();
- template <class T>
- void addCommand(std::string name, const void(T::*func)(const CommandArg*), const int argc, CommandArgType* argTypes, T* module);
- void addCommand(std::string name, const void(*func)(const CommandArg*), const int argc, CommandArgType* argTypes);
- template <class T>
- void addCommand(std::string name, const void(T::*func)(const CommandArg*), const int argc, std::vector<CommandArgType> argTypes, T* module);
- void addCommand(std::string name, const void(*func)(const CommandArg*), const int argc, std::vector<CommandArgType> argTypes);
- void addCommand(Command c);
- Command* lookupCommand(std::string name);
- void runCommand(std::string command);
- void runCommand(std::vector<std::string> split);
- std::vector<Err> checkCommand(std::string command);
- Err checkCommand(std::vector<std::string> split);
-};
-
-// YES I KNOW THIS IS BAD
-// but it needs to be done this way
-template <class T>
-void CommandsModule::addCommand(std::string name, const void(T::*func)(const CommandArg*), const int argc, CommandArgType* argTypes, T* module)
-{
- Command c = {name, (const void*(std::any::*)(const CommandArg* argv)) func, nullptr, argc, argTypes, (std::any*)module};
- addCommand(c);
-}
-template <class T>
-void CommandsModule::addCommand(std::string name, const void(T::*func)(const CommandArg*), const int argc, std::vector<CommandArgType> argTypes, T* module)
-{
- CommandArgType* argTypesArr = new CommandArgType[argc];
- for(int i = 0; i < argc; i++)
- {
- argTypesArr[i] = argTypes[i];
- }
- addCommand(name, func, argc, argTypesArr, module);
-}