aboutsummaryrefslogtreecommitdiff
path: root/src/Rahm/Desktop/Lang.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Rahm/Desktop/Lang.hs')
-rw-r--r--src/Rahm/Desktop/Lang.hs127
1 files changed, 0 insertions, 127 deletions
diff --git a/src/Rahm/Desktop/Lang.hs b/src/Rahm/Desktop/Lang.hs
deleted file mode 100644
index 374500d..0000000
--- a/src/Rahm/Desktop/Lang.hs
+++ /dev/null
@@ -1,127 +0,0 @@
-module Rahm.Desktop.Lang where
-
-import Control.Monad.Trans.Maybe
-import Control.Monad.Trans.Class
-
-import Data.Char (isAlphaNum, isAlpha, isDigit, ord)
-import XMonad.Actions.CopyWindow as CopyWindow
-import XMonad.Util.Run (safeSpawn)
-import qualified XMonad.StackSet as W
-
-import Rahm.Desktop.Common
-import Rahm.Desktop.Keys.Dsl
-import Rahm.Desktop.History
-import Rahm.Desktop.Marking
-import Rahm.Desktop.Workspaces
-import Rahm.Desktop.Submap
-import Rahm.Desktop.Logger
-
-import Text.Printf
-
-import XMonad
-
-data Workspace =
- Workspace {
- moveLocationToWorkspaceFn :: Location -> X ()
- , gotoWorkspaceFn :: X ()
- , workspaceName :: String
- }
-
-justWorkspace :: String -> Workspace
-justWorkspace s =
- Workspace {
- moveLocationToWorkspaceFn = flip moveLocationToWorkspace s
- , gotoWorkspaceFn = gotoWorkspace s
- , workspaceName = s
- }
-
-blackHoleWorkspace :: Workspace
-blackHoleWorkspace =
- Workspace {
- moveLocationToWorkspaceFn = mapM_ killWindow . locationWindow
- , gotoWorkspaceFn = return () -- can't navigate to black hole
- , workspaceName = "blackhole"
- }
-
-alternateWorkspace :: Workspace
-alternateWorkspace =
- Workspace {
- moveLocationToWorkspaceFn = \l@(Location _ maybeWin) -> do
- logs $ "Moving Location: " ++ show l
- case maybeWin of
- Nothing -> return ()
- Just win -> do
- alter <- getAlternateWorkspace win
- logs $ printf "Moving %s to %s" (show win) (show alter)
- mapM_ (moveLocationToWorkspace l) alter
-
- , gotoWorkspaceFn = do
- (Location _ maybeWin) <- getCurrentLocation
- case maybeWin of
- Nothing -> return ()
- Just win -> do
- mapM_ gotoWorkspace =<< getAlternateWorkspace win
-
- , workspaceName = "@"
- }
-
-readNextWorkspace :: MaybeT X Workspace
-readNextWorkspace =
- mapNextStringWithKeysym $ \mask sym str ->
- case (mask, sym, str) of
- (_, _, [ch]) | isAlphaNum ch || ch == '*' -> return $ justWorkspace [ch]
- (_, _, "[") -> lift $
- justWorkspace <$>
- (adjacentWorkspaceNotVisible prev =<< getCurrentWorkspace)
- (_, _, "]") -> lift $
- justWorkspace <$>
- (adjacentWorkspaceNotVisible next =<< getCurrentWorkspace)
- (_, _, "(") -> lift $
- justWorkspace <$>
- (adjacentWorkspace prev =<< getCurrentWorkspace)
- (_, _, ")") -> lift $
- justWorkspace <$>
- (adjacentWorkspace next =<< getCurrentWorkspace)
- (_, _, "}") -> lift $ justWorkspace <$> adjacentScreen next
- (_, _, "{") -> lift $ justWorkspace <$> adjacentScreen prev
- (_, _, "^") -> lift $ justWorkspace <$> firstWorkspaceId
- (_, _, "'") -> justWorkspace . locationWorkspace <$> MaybeT lastLocation
- (_, _, ".") -> lift $ justWorkspace <$> getCurrentWorkspace
- (_, _, "$") -> lift $ justWorkspace <$> lastWorkspaceId
- (_, _, "/") -> do
- justWorkspace <$> ((MaybeT . workspaceWithWindow) =<< MaybeT askWindowId)
- (_, _, " ") -> lift $
- justWorkspace . accompaningWorkspace <$> getCurrentWorkspace
- (_, _, "_") -> return blackHoleWorkspace
- (_, _, "-") -> return alternateWorkspace
- _ -> MaybeT (return Nothing)
-
-readNextLocationSet :: MaybeT X [Location]
-readNextLocationSet =
- mapNextStringWithKeysym $ \mask sym str ->
- case (mask, sym, str) of
- (_, _, [ch]) | isAlpha ch -> lift $ getMarkedLocations [ch]
- (_, _, "0") -> (:[]) <$> MaybeT getMostRecentLocationInHistory
- (_, _, [ch]) | isDigit ch ->
- (:[]) <$> MaybeT (pastHistory (ord ch - 0x30))
- (_, _, ".") -> (:[]) <$> lift getCurrentLocation
- (_, _, "^") -> (:[]) <$> farLeftWindow
- (_, _, "$") -> (:[]) <$> farRightWindow
- (_, _, "\"") -> (:[]) <$> MaybeT nextLocation
- (_, _, "'") -> (:[]) <$> MaybeT lastLocation
- (_, _, "*") -> (:[]) <$> (windowLocation =<< masterWindow)
- (_, _, "-") -> mapM windowLocation =<< lift getAlternateWindows
- (_, _, "/") -> (:[]) <$> (windowLocation =<< MaybeT askWindowId)
- (_, _, "%") ->
- mapM windowLocation =<< lift (withWindowSet (return . W.allWindows))
- (_, _, "@") -> (lift . windowsInWorkspace . workspaceName) =<< readNextWorkspace
- (_, _, "&") -> do
- l1 <- readNextLocationSet
- l2 <- readNextLocationSet
- return (l1 ++ l2)
- (_, _, "\\") -> do
- l1 <- readNextLocationSet
- l2 <- readNextLocationSet
- return $ filter (not . flip elem l2) l1
-
- _ -> MaybeT (return Nothing)