diff options
author | Adam Vogt <vogt.adam@gmail.com> | 2010-11-16 00:22:22 +0100 |
---|---|---|
committer | Adam Vogt <vogt.adam@gmail.com> | 2010-11-16 00:22:22 +0100 |
commit | f0088e4fa88da36624e3b8fd11b8e95eebfc9fe3 (patch) | |
tree | f33572c63f3dfbde8e1b4492d020c7fd740d3f58 /XMonad/Actions | |
parent | f4f3ce9117167055503cc24c10d9e37f6416d0f8 (diff) | |
download | XMonadContrib-f0088e4fa88da36624e3b8fd11b8e95eebfc9fe3.tar.gz XMonadContrib-f0088e4fa88da36624e3b8fd11b8e95eebfc9fe3.tar.xz XMonadContrib-f0088e4fa88da36624e3b8fd11b8e95eebfc9fe3.zip |
Rename state in A.Gridselect to avoid name shadowing (mtl-2)
Ignore-this: cd81e11ae9f5372ddd71f0c2b60675d5
darcs-hash:20101115232222-1499c-679e09cc62a0e689dd8025e9c996db2fef0b4b0d.gz
Diffstat (limited to 'XMonad/Actions')
-rw-r--r-- | XMonad/Actions/GridSelect.hs | 45 |
1 files changed, 22 insertions, 23 deletions
diff --git a/XMonad/Actions/GridSelect.hs b/XMonad/Actions/GridSelect.hs index 3f3d4bc..2cbf134 100644 --- a/XMonad/Actions/GridSelect.hs +++ b/XMonad/Actions/GridSelect.hs @@ -296,20 +296,20 @@ drawWinBox win font (fg,bg) ch cw text x y cp = updateAllElements :: TwoD a () updateAllElements = do - state <- get - updateElements (td_elementmap state) + s <- get + updateElements (td_elementmap s) grayoutAllElements :: TwoD a () grayoutAllElements = do - state <- get - updateElementsWithColorizer grayOnly (td_elementmap state) + s <- get + updateElementsWithColorizer grayOnly (td_elementmap s) where grayOnly _ _ = return ("#808080", "#808080") updateElements :: TwoDElementMap a -> TwoD a () updateElements elementmap = do - state <- get - updateElementsWithColorizer (gs_colorizer (td_gsconfig state)) elementmap + s <- get + updateElementsWithColorizer (gs_colorizer (td_gsconfig s)) elementmap updateElementsWithColorizer :: (a -> Bool -> X (String, String)) -> TwoDElementMap a -> TwoD a () updateElementsWithColorizer colorizer elementmap = do @@ -338,12 +338,11 @@ updateElementsWithColorizer colorizer elementmap = do stdHandle :: Event -> TwoD a (Maybe a) -> TwoD a (Maybe a) stdHandle (ButtonEvent { ev_event_type = t, ev_x = x, ev_y = y }) contEventloop | t == buttonRelease = do - state <- get - let (TwoDState { td_paneX = px, td_paneY = py, - td_gsconfig = (GSConfig ch cw _ _ _ _ _ _) }) = state - gridX = (fi x - (px - cw) `div` 2) `div` cw + s @ TwoDState { td_paneX = px, td_paneY = py, + td_gsconfig = (GSConfig ch cw _ _ _ _ _ _) } <- get + let gridX = (fi x - (px - cw) `div` 2) `div` cw gridY = (fi y - (py - ch) `div` 2) `div` ch - case lookup (gridX,gridY) (td_elementmap state) of + case lookup (gridX,gridY) (td_elementmap s) of Just (_,el) -> return (Just el) Nothing -> contEventloop | otherwise = contEventloop @@ -379,8 +378,8 @@ shadowWithKeymap keymap dflt keyEvent@(ks,_,m') = fromMaybe (dflt keyEvent) (M.l -- | Closes gridselect returning the element under the cursor select :: TwoD a (Maybe a) select = do - state <- get - return $ fmap (snd . snd) $ findInElementMap (td_curpos state) (td_elementmap state) + s <- get + return $ fmap (snd . snd) $ findInElementMap (td_curpos s) (td_elementmap s) -- | Closes gridselect returning no element. cancel :: TwoD a (Maybe a) @@ -389,34 +388,34 @@ cancel = return Nothing -- | Sets the absolute position of the cursor. setPos :: (Integer, Integer) -> TwoD a () setPos newPos = do - state <- get - let elmap = td_elementmap state - newSelectedEl = findInElementMap newPos (td_elementmap state) - oldPos = td_curpos state + s <- get + let elmap = td_elementmap s + newSelectedEl = findInElementMap newPos (td_elementmap s) + oldPos = td_curpos s when (isJust newSelectedEl && newPos /= oldPos) $ do - put state { td_curpos = newPos } + put s { td_curpos = newPos } updateElements (catMaybes [(findInElementMap oldPos elmap), newSelectedEl]) -- | Moves the cursor by the offsets specified move :: (Integer, Integer) -> TwoD a () move (dx,dy) = do - state <- get - let (x,y) = td_curpos state + s <- get + let (x,y) = td_curpos s newPos = (x+dx,y+dy) setPos newPos -- | Apply a transformation function the current search string transformSearchString :: (String -> String) -> TwoD a () transformSearchString f = do - state <- get - let oldSearchString = td_searchString state + s <- get + let oldSearchString = td_searchString s newSearchString = f oldSearchString when (newSearchString /= oldSearchString) $ do -- FIXME: grayoutAllElements + updateAllElements paint some fields twice causing flickering -- we would need a much smarter update strategy to fix that when (length newSearchString > length oldSearchString) grayoutAllElements -- FIXME curpos might end up outside new bounds - put state { td_searchString = newSearchString } + put s { td_searchString = newSearchString } updateAllElements -- | By default gridselect used the defaultNavigation action, which |