summaryrefslogtreecommitdiff
path: root/src/keybinds.cpp
diff options
context:
space:
mode:
authorBossCode45 <human.cyborg42@gmail.com>2025-03-06 21:26:04 +1300
committerBossCode45 <human.cyborg42@gmail.com>2025-03-06 21:30:38 +1300
commit74c58cdf74c4921071da93c4cbfaf22f672242a5 (patch)
tree3f53f51df1a6098b0d9600114b06fc6ae957a195 /src/keybinds.cpp
parent63005f5fc81e9b641f07eadb5f07bc7c532d40c7 (diff)
downloadYATwm-74c58cdf74c4921071da93c4cbfaf22f672242a5.tar.gz
YATwm-74c58cdf74c4921071da93c4cbfaf22f672242a5.zip
feat: Added the "S" modifier to the emacs bind mode
You can now use S as a modifier for shift when binding with emacs mode if you're unable to capatilise the key to be bound.
Diffstat (limited to 'src/keybinds.cpp')
-rw-r--r--src/keybinds.cpp55
1 files changed, 31 insertions, 24 deletions
diff --git a/src/keybinds.cpp b/src/keybinds.cpp
index 235f8c1..1f60a75 100644
--- a/src/keybinds.cpp
+++ b/src/keybinds.cpp
@@ -168,48 +168,55 @@ const Keybind KeybindsModule::emacsBindMode(string bindString)
Keybind bind;
bind.modifiers = 0;
- const std::regex keyRegex("^(?:([CMs])-)?(?:([CMs])-)?(?:([CMs])-)?([^\\s]|(SPC|ESC|RET|))$");
+ //cout << "Adding keybind: '" << bindString << "'" << endl;
+
+ const std::regex keyRegex("^((?:[CMSs]-)*)([^\\s]|(?:SPC|ESC|RET))$");
std::smatch keyMatch;
if(std::regex_match(bindString, keyMatch, keyRegex))
{
- for (int i = 1; i < 3; i++)
+ std::ssub_match modifierMatch = keyMatch[1];
+ for(std::string modifier : split(modifierMatch, '-'))
{
- std::ssub_match modifierMatch = keyMatch[i];
- if(modifierMatch.matched)
+ if(modifier == "s")
+ {
+ //cout << "\tModifier: s" << endl;
+ bind.modifiers |= cfg.swapSuperAlt?Mod1Mask:Mod4Mask;
+ }
+ else if(modifier == "M")
+ {
+ //cout << "\tModifier: M" << endl;
+ bind.modifiers |= cfg.swapSuperAlt?Mod4Mask:Mod1Mask;
+ }
+ else if(modifier == "C")
+ {
+ //cout << "\tModifier: C" << endl;
+ bind.modifiers |= ControlMask;
+ }
+ else if(modifier == "S")
{
- std::string modifier = modifierMatch.str();
- if(modifier == "s")
- {
- bind.modifiers |= Mod4Mask >> 3 * cfg.swapSuperAlt;
- }
- else if(modifier == "M")
- {
- bind.modifiers |= Mod1Mask << 3 * cfg.swapSuperAlt;
- }
- else if(modifier == "C")
- {
- bind.modifiers |= ControlMask;
- }
+ //cout << "\tModifier: S" << endl;
+ bind.modifiers |= ShiftMask;
}
}
}
- KeySym keySym = XStringToKeysym(keyMatch[4].str().c_str());
+ KeySym keySym = XStringToKeysym(keyMatch[2].str().c_str());
+ //cout << "\tKey: " << keyMatch[2].str() << endl;
- if(isUpper(keyMatch[4].str().c_str()) && keySym != NoSymbol)
+ if(isUpper(keyMatch[2].str().c_str()) && keySym != NoSymbol)
{
bind.modifiers |= ShiftMask;
}
if(keySym == NoSymbol)
{
- if(keyMatch[4].str() == "RET")
+ if(keyMatch[2].str() == "RET")
keySym = XK_Return;
- else if(keyMatch[4].str() == "ESC")
+ else if(keyMatch[2].str() == "ESC")
keySym = XK_Escape;
- else if(keyMatch[4].str() == "SPC")
+ else if(keyMatch[2].str() == "SPC")
keySym = XK_space;
- else if(keyMatch[4].str() == "-")
+ else if(keyMatch[2].str() == "-")
keySym = XK_minus;
- else if(keyMatch[4].str() == "+")
+ else if(keyMatch[2].str() == "+")
keySym = XK_plus;
else
throw Err(CFG_ERR_KEYBIND, "Keybind '" + bindString + "' is invalid");