diff options
| author | Josh Rahm <rahm@google.com> | 2022-11-23 12:30:41 -0700 |
|---|---|---|
| committer | Josh Rahm <rahm@google.com> | 2022-11-23 12:30:41 -0700 |
| commit | 438f50cda56d2170931a6b45ce084c6deffeb86b (patch) | |
| tree | 1d59780f2976fb91bb612b7e90a7c5f73a74cfd5 /src/Rahm/Desktop/Keys | |
| parent | e91951d76a25de8335edc26afd3f1905e2f05733 (diff) | |
| download | rde-438f50cda56d2170931a6b45ce084c6deffeb86b.tar.gz rde-438f50cda56d2170931a6b45ce084c6deffeb86b.tar.bz2 rde-438f50cda56d2170931a6b45ce084c6deffeb86b.zip | |
Change WML to give precedence to macros over everything else.
This makes it so one can record a macro to M- keys where the
lookupString might be alphanumeric, but has another modifier.
This allows one to write a macro for double tapping <M-g><M-g>, for
example.
Diffstat (limited to 'src/Rahm/Desktop/Keys')
| -rw-r--r-- | src/Rahm/Desktop/Keys/Wml.hs | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/Rahm/Desktop/Keys/Wml.hs b/src/Rahm/Desktop/Keys/Wml.hs index a46bbac..4e63575 100644 --- a/src/Rahm/Desktop/Keys/Wml.hs +++ b/src/Rahm/Desktop/Keys/Wml.hs @@ -113,7 +113,7 @@ import Rahm.Desktop.XMobarLog.PendingBuffer ( addStringToPendingBuffer, setPendingBuffer, ) -import System.Exit (ExitCode (..), exitWith, exitSuccess) +import System.Exit (ExitCode (..), exitSuccess, exitWith) import Text.Printf (printf) import XMonad ( Default (def), @@ -336,7 +336,11 @@ readNextWorkspaceName = joinMaybe $ workspaceName <$> readNextWorkspace readNextWorkspace :: (KeyFeeder m) => MaybeT m Workspace readNextWorkspace = readNextKey $ \mask sym str -> do + macros <- (lift . fromX) $ workspaceMacros <$> XS.get + case (mask, sym, str) of + (mask, keysym, _) | (Just macro) <- Map.lookup (mask, keysym) macros -> do + fromMaybeTX $ workspaceForKeysT macro (_, e, _) | e == xK_Escape -> MaybeT $ return Nothing (_, _, [ch]) | isAlphaNum ch || ch == '*' -> return $ justWorkspace [ch] (_, _, "[") -> @@ -351,16 +355,23 @@ readNextWorkspace = ) (_, _, "(") -> justWorkspace - <$> (lift1 (adjacentWorkspace prev) =<< readNextWorkspaceName) + <$> ( lift1 (adjacentWorkspace prev) + =<< readNextWorkspaceName + ) (_, _, ")") -> justWorkspace - <$> (lift1 (adjacentWorkspace next) =<< readNextWorkspaceName) + <$> ( lift1 (adjacentWorkspace next) + =<< readNextWorkspaceName + ) (_, _, "^") -> mapMaybeT fromX $ MaybeT $ withWindowSet $ \ws -> return $ - (fmap (justWorkspace . W.tag . W.workspace . snd) . head) - (getHorizontallyOrderedScreens ws) + ( fmap + ( justWorkspace . W.tag . W.workspace . snd + ) + . head + ) (getHorizontallyOrderedScreens ws) (_, _, "'") -> fromMaybeTX $ justWorkspace . locationWorkspace <$> MaybeT lastLocation (_, _, ".") -> mt $ justWorkspace <$> getCurrentWorkspace (_, _, "$") -> MaybeT $ @@ -430,9 +441,6 @@ readNextWorkspace = if null l1 then ws2 else ws1 - (mask, keysym, _) -> do - macro <- (MaybeT . fromX) (Map.lookup (mask, keysym) . workspaceMacros <$> XS.get) - fromMaybeTX $ workspaceForKeysT macro where mt :: (KeyFeeder m) => X a -> MaybeT m a mt = lift . fromX |