summaryrefslogtreecommitdiff
path: root/src/util.cpp
diff options
context:
space:
mode:
authorBossCode45 <human.cyborg42@gmail.com>2024-12-01 19:24:09 +1300
committerBossCode45 <human.cyborg42@gmail.com>2024-12-01 19:24:09 +1300
commit8dca89a1be23f0de2dd1676b95feb6b46cbdd5f2 (patch)
tree7ebc1a5161bbe70d6ab6a0e5353a1a622240c915 /src/util.cpp
parente162dff48c251e262f475de9261f0ecfa0f39dc4 (diff)
parent434ec6542d0d79190c6aa7003aac91b03cad4398 (diff)
downloadYATwm-8dca89a1be23f0de2dd1676b95feb6b46cbdd5f2.tar.gz
YATwm-8dca89a1be23f0de2dd1676b95feb6b46cbdd5f2.zip
Merge branch 'IPC'
Diffstat (limited to 'src/util.cpp')
-rw-r--r--src/util.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/util.cpp b/src/util.cpp
new file mode 100644
index 0000000..58116d0
--- /dev/null
+++ b/src/util.cpp
@@ -0,0 +1,32 @@
+#include "util.h"
+
+#include <sstream>
+#include <algorithm>
+
+using std::string;
+
+std::vector<string> split (const string &s, char delim) {
+ std::vector<string> result;
+ std::stringstream ss (s);
+ string item;
+
+ while (getline (ss, item, delim)) {
+ result.push_back (item);
+ }
+
+ return result;
+}
+
+const string evNames[] = {"", "", "KeyPress", "KeyRelease", "ButtonPress", "ButtonRelease", "MotionNotify", "EnterNotify", "LeaveNotify", "FocusIn", "FocusOut", "KeymapNotify", "Expose", "GraphicsExpose", "NoExpose", "VisibilityNotify", "CreateNotify", "DestroyNotify", "UnmapNotify", "MapNotify", "MapRequest", "ReparentNotify", "ConfigureNotify", "ConfigureRequest", "GravityNotify", "ResizeRequest", "CirculateNotify", "CirculateRequest", "PropertyNotify", "SelectionClear", "SelectionRequest", "SelectionNotify", "ColormapNotify", "ClientMessage", "MappingNotify", "GenericEvent", "LASTEvent"};
+
+string getEventName(int e)
+{
+ return evNames[e];
+}
+
+string lowercase(string s)
+{
+ string s2 = s;
+ std::transform(s2.begin(), s2.end(), s2.begin(), [](unsigned char c){ return std::tolower(c); });
+ return s2;
+}