aboutsummaryrefslogtreecommitdiff
path: root/src/Rahm/Desktop/Keys.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Rahm/Desktop/Keys.hs')
-rw-r--r--src/Rahm/Desktop/Keys.hs79
1 files changed, 55 insertions, 24 deletions
diff --git a/src/Rahm/Desktop/Keys.hs b/src/Rahm/Desktop/Keys.hs
index e55c636..d8b7f20 100644
--- a/src/Rahm/Desktop/Keys.hs
+++ b/src/Rahm/Desktop/Keys.hs
@@ -13,7 +13,7 @@ import Data.List hiding ((!!))
import Data.List.Safe ((!!))
import Data.Map (Map)
import qualified Data.Map as Map
-import Data.Maybe (fromMaybe, isJust, mapMaybe, isNothing)
+import Data.Maybe (fromMaybe, isJust, isNothing, mapMaybe)
import Data.Monoid (Endo (..))
import Data.Proxy
import Debug.Trace
@@ -139,11 +139,28 @@ keyBindingToKeymap bindings config = Map.mapWithKey bindingToX (bindings config)
case b of
Documented _ (Action x) -> x
Documented _ (Submap mapping) ->
- submap (Map.mapWithKey bindingToX mapping)
+ withPendingBuffer $ do
+ -- This is a submap, add it to the pending buffer.
+ --
+ -- This could potentially use the current event in the XState and
+ -- lookupString to potentially recover the real string typed, but
+ -- for now, this will do.
+ addStringToPendingBuffer (keysymToString $ snd key)
+ submap (Map.mapWithKey bindingToX mapping)
Documented _ (Repeat mapping) -> do
- mapM_ (bindingToX key) (Map.lookup key mapping)
- fix $ \recur ->
- submap (Map.mapWithKey (\k b -> bindingToX k b >> recur) mapping)
+ withPendingBuffer $ do
+ addStringToPendingBuffer (keysymToString $ snd key)
+ mapM_ (bindingToX key) (Map.lookup key mapping)
+ fix $ \recur -> do
+ submap
+ ( Map.mapWithKey
+ ( \k b -> do
+ withPendingBuffer $ do
+ addStringToPendingBuffer (keysymToString $ snd k)
+ bindingToX k b >> recur
+ )
+ mapping
+ )
keymap :: XConfig l -> KeyBindings
keymap = runKeys $ do
@@ -156,7 +173,7 @@ keymap = runKeys $ do
justMod $
doc "Jumps between marks." $
withPendingBuffer $ do
- setPendingBuffer "Jump To "
+ setPendingBuffer "w "
runMaybeT_ $ do
l <- readNextLocationSet
case l of
@@ -279,7 +296,7 @@ keymap = runKeys $ do
justMod $
doc
"Goto/Send/Etc To a workspace\n\n\t\
- \Workspaces are alphanumeric characters. So if the next key typed is an\n\t\
+ \Workspacs are alphanumeric characters. So if the next key typed is an\n\t\
\alphanumeric character, that's the workspace to operate on\n\n\
\\tThe following special characters can also reference workspaces:\n\t\t\
\]: The next workspace, skipping those already visible.\n\t\t\
@@ -297,13 +314,13 @@ keymap = runKeys $ do
\Other keybindings starting with H-g\n\t\t\
\F1: display this help.\n\n\t"
$ withPendingBuffer $ do
- setPendingBuffer "Goto "
+ setPendingBuffer "g "
runMaybeT_ $ (lift . gotoWorkspaceFn) =<< readNextWorkspace
controlMod $
doc "Restore the desktop marked with the next typed character." $
withPendingBuffer $ do
- setPendingBuffer "Restore "
+ setPendingBuffer "C-g "
runMaybeT_ $ do
mapNextString $ \_ str -> lift $
case str of
@@ -319,7 +336,7 @@ keymap = runKeys $ do
shiftMod $
doc "Restore a theater state" $
withPendingBuffer $ do
- setPendingBuffer "Goto Theater"
+ setPendingBuffer "G "
runMaybeT_ $ do
mapNextString $ \_ str -> lift $
case str of
@@ -368,12 +385,16 @@ keymap = runKeys $ do
bind xK_w $
noMod $
doc "Record a windowset macro" $
- runMaybeT_ readWindowsetMacro
+ withPendingBuffer $ do
+ setPendingBuffer "Win Macro "
+ runMaybeT_ readWindowsetMacro
bind xK_t $
noMod $
doc "Record a workspace macro" $
- runMaybeT_ readWorkspaceMacro
+ withPendingBuffer $ do
+ setPendingBuffer "Wksp Macro "
+ runMaybeT_ readWorkspaceMacro
bind xK_h $ do
justMod $
@@ -436,7 +457,7 @@ keymap = runKeys $ do
justMod $
doc "Mark the current window with the next typed character." $ do
withPendingBuffer $ do
- addStringToPendingBuffer "Mark "
+ addStringToPendingBuffer "m "
locs <- fromMaybe [] <$> runMaybeT readNextLocationSet
let wins = mapMaybe locationWindow locs
unless (null wins) $ do
@@ -449,19 +470,23 @@ keymap = runKeys $ do
shiftMod $
doc "Mark the current desktop with the next typed character." $
- runMaybeT_ $ do
- mapNextString $ \_ str -> lift $
- case str of
- [ch] | isAlpha ch -> saveCurrentDesktop str
- _ -> return ()
+ withPendingBuffer $ do
+ addStringToPendingBuffer "M "
+ runMaybeT_ $ do
+ mapNextString $ \_ str -> lift $
+ case str of
+ [ch] | isAlpha ch -> saveCurrentDesktop str
+ _ -> return ()
controlMod $
doc "Mark the current theater with the next typed character." $
- runMaybeT_ $ do
- mapNextString $ \_ str -> lift $
- case str of
- [ch] | isAlpha ch -> saveCurrentTheater (Just str)
- _ -> return ()
+ withPendingBuffer $ do
+ addStringToPendingBuffer "C-M "
+ runMaybeT_ $ do
+ mapNextString $ \_ str -> lift $
+ case str of
+ [ch] | isAlpha ch -> saveCurrentTheater (Just str)
+ _ -> return ()
bind xK_plus $ do
justMod $
@@ -500,7 +525,7 @@ keymap = runKeys $ do
else "Shift a windowset to a workspace"
)
$ withPendingBuffer $ do
- setPendingBuffer $ if doSwap then "Swap " else "Shift "
+ setPendingBuffer $ if doSwap then "S " else "s "
maybeLocs <- runMaybeT readNextLocationSet
forM_ maybeLocs $ \locations -> do
@@ -653,6 +678,12 @@ keymap = runKeys $ do
"Kill all other copies of a window."
CopyWindow.killAllOtherCopies
+ bind xK_q $
+ justMod $ do
+ subkeys $ do
+ bind xK_q $
+ justMod $ spawnX "echo hi"
+
bind xK_e $ do
(justMod -|- noMod) $
doc "Select an emoji" $