From 8b6c4a54f79b35ba153acf6dd6b6f1804237c545 Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Mon, 18 Apr 2022 10:11:05 -0600 Subject: Extend marking language to the mark command itself --- src/Rahm/Desktop/Keys.hs | 7 ++++--- src/Rahm/Desktop/Marking.hs | 8 ++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Rahm/Desktop/Keys.hs b/src/Rahm/Desktop/Keys.hs index 23927ef..da3b695 100644 --- a/src/Rahm/Desktop/Keys.hs +++ b/src/Rahm/Desktop/Keys.hs @@ -355,10 +355,11 @@ keymap = runKeys $ do bind xK_m $ do justMod $ doc "Mark the current window with the next typed character." $ - runMaybeT_ $ mapNextString $ \_ str -> lift $ + runMaybeT_ $ do + locs <- readNextLocationSet + mapNextString $ \_ str -> lift $ case str of - [ch] | isAlpha ch -> markCurrentWindow str - _ -> return () + [ch] | isAlpha ch -> markAllLocations str locs bind xK_plus $ do justMod $ diff --git a/src/Rahm/Desktop/Marking.hs b/src/Rahm/Desktop/Marking.hs index f4e0d9a..90808cf 100644 --- a/src/Rahm/Desktop/Marking.hs +++ b/src/Rahm/Desktop/Marking.hs @@ -7,6 +7,7 @@ module Rahm.Desktop.Marking ( setAlternateWorkspace, getAlternateWorkspace, getMarkedLocations, + markAllLocations, farLeftWindow, farRightWindow, windowLocation @@ -84,6 +85,13 @@ getAlternateWindows = alternateWindows <$> XS.get withMaybeFocused :: (Maybe Window -> X a) -> X a withMaybeFocused f = withWindowSet $ f . peek +markAllLocations :: Mark -> [Location] -> X () +markAllLocations mark locs = + XS.modify $ \m -> + m { + markStateMap = Map.insert mark locs (markStateMap m) + } + markCurrentWindow :: Mark -> X () markCurrentWindow mark = do ws <- getCurrentWorkspace -- cgit