mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 11:30:22 -07:00
Rename state in A.Gridselect to avoid name shadowing (mtl-2)
This commit is contained in:
parent
cbb20fb3a8
commit
52d3aa1500
@ -296,20 +296,20 @@ drawWinBox win font (fg,bg) ch cw text x y cp =
|
|||||||
updateAllElements :: TwoD a ()
|
updateAllElements :: TwoD a ()
|
||||||
updateAllElements =
|
updateAllElements =
|
||||||
do
|
do
|
||||||
state <- get
|
s <- get
|
||||||
updateElements (td_elementmap state)
|
updateElements (td_elementmap s)
|
||||||
|
|
||||||
grayoutAllElements :: TwoD a ()
|
grayoutAllElements :: TwoD a ()
|
||||||
grayoutAllElements =
|
grayoutAllElements =
|
||||||
do
|
do
|
||||||
state <- get
|
s <- get
|
||||||
updateElementsWithColorizer grayOnly (td_elementmap state)
|
updateElementsWithColorizer grayOnly (td_elementmap s)
|
||||||
where grayOnly _ _ = return ("#808080", "#808080")
|
where grayOnly _ _ = return ("#808080", "#808080")
|
||||||
|
|
||||||
updateElements :: TwoDElementMap a -> TwoD a ()
|
updateElements :: TwoDElementMap a -> TwoD a ()
|
||||||
updateElements elementmap = do
|
updateElements elementmap = do
|
||||||
state <- get
|
s <- get
|
||||||
updateElementsWithColorizer (gs_colorizer (td_gsconfig state)) elementmap
|
updateElementsWithColorizer (gs_colorizer (td_gsconfig s)) elementmap
|
||||||
|
|
||||||
updateElementsWithColorizer :: (a -> Bool -> X (String, String)) -> TwoDElementMap a -> TwoD a ()
|
updateElementsWithColorizer :: (a -> Bool -> X (String, String)) -> TwoDElementMap a -> TwoD a ()
|
||||||
updateElementsWithColorizer colorizer elementmap = do
|
updateElementsWithColorizer colorizer elementmap = do
|
||||||
@ -338,12 +338,11 @@ updateElementsWithColorizer colorizer elementmap = do
|
|||||||
stdHandle :: Event -> TwoD a (Maybe a) -> TwoD a (Maybe a)
|
stdHandle :: Event -> TwoD a (Maybe a) -> TwoD a (Maybe a)
|
||||||
stdHandle (ButtonEvent { ev_event_type = t, ev_x = x, ev_y = y }) contEventloop
|
stdHandle (ButtonEvent { ev_event_type = t, ev_x = x, ev_y = y }) contEventloop
|
||||||
| t == buttonRelease = do
|
| t == buttonRelease = do
|
||||||
state <- get
|
s @ TwoDState { td_paneX = px, td_paneY = py,
|
||||||
let (TwoDState { td_paneX = px, td_paneY = py,
|
td_gsconfig = (GSConfig ch cw _ _ _ _ _ _) } <- get
|
||||||
td_gsconfig = (GSConfig ch cw _ _ _ _ _ _) }) = state
|
let gridX = (fi x - (px - cw) `div` 2) `div` cw
|
||||||
gridX = (fi x - (px - cw) `div` 2) `div` cw
|
|
||||||
gridY = (fi y - (py - ch) `div` 2) `div` ch
|
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)
|
Just (_,el) -> return (Just el)
|
||||||
Nothing -> contEventloop
|
Nothing -> contEventloop
|
||||||
| otherwise = 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
|
-- | Closes gridselect returning the element under the cursor
|
||||||
select :: TwoD a (Maybe a)
|
select :: TwoD a (Maybe a)
|
||||||
select = do
|
select = do
|
||||||
state <- get
|
s <- get
|
||||||
return $ fmap (snd . snd) $ findInElementMap (td_curpos state) (td_elementmap state)
|
return $ fmap (snd . snd) $ findInElementMap (td_curpos s) (td_elementmap s)
|
||||||
|
|
||||||
-- | Closes gridselect returning no element.
|
-- | Closes gridselect returning no element.
|
||||||
cancel :: TwoD a (Maybe a)
|
cancel :: TwoD a (Maybe a)
|
||||||
@ -389,34 +388,34 @@ cancel = return Nothing
|
|||||||
-- | Sets the absolute position of the cursor.
|
-- | Sets the absolute position of the cursor.
|
||||||
setPos :: (Integer, Integer) -> TwoD a ()
|
setPos :: (Integer, Integer) -> TwoD a ()
|
||||||
setPos newPos = do
|
setPos newPos = do
|
||||||
state <- get
|
s <- get
|
||||||
let elmap = td_elementmap state
|
let elmap = td_elementmap s
|
||||||
newSelectedEl = findInElementMap newPos (td_elementmap state)
|
newSelectedEl = findInElementMap newPos (td_elementmap s)
|
||||||
oldPos = td_curpos state
|
oldPos = td_curpos s
|
||||||
when (isJust newSelectedEl && newPos /= oldPos) $ do
|
when (isJust newSelectedEl && newPos /= oldPos) $ do
|
||||||
put state { td_curpos = newPos }
|
put s { td_curpos = newPos }
|
||||||
updateElements (catMaybes [(findInElementMap oldPos elmap), newSelectedEl])
|
updateElements (catMaybes [(findInElementMap oldPos elmap), newSelectedEl])
|
||||||
|
|
||||||
-- | Moves the cursor by the offsets specified
|
-- | Moves the cursor by the offsets specified
|
||||||
move :: (Integer, Integer) -> TwoD a ()
|
move :: (Integer, Integer) -> TwoD a ()
|
||||||
move (dx,dy) = do
|
move (dx,dy) = do
|
||||||
state <- get
|
s <- get
|
||||||
let (x,y) = td_curpos state
|
let (x,y) = td_curpos s
|
||||||
newPos = (x+dx,y+dy)
|
newPos = (x+dx,y+dy)
|
||||||
setPos newPos
|
setPos newPos
|
||||||
|
|
||||||
-- | Apply a transformation function the current search string
|
-- | Apply a transformation function the current search string
|
||||||
transformSearchString :: (String -> String) -> TwoD a ()
|
transformSearchString :: (String -> String) -> TwoD a ()
|
||||||
transformSearchString f = do
|
transformSearchString f = do
|
||||||
state <- get
|
s <- get
|
||||||
let oldSearchString = td_searchString state
|
let oldSearchString = td_searchString s
|
||||||
newSearchString = f oldSearchString
|
newSearchString = f oldSearchString
|
||||||
when (newSearchString /= oldSearchString) $ do
|
when (newSearchString /= oldSearchString) $ do
|
||||||
-- FIXME: grayoutAllElements + updateAllElements paint some fields twice causing flickering
|
-- FIXME: grayoutAllElements + updateAllElements paint some fields twice causing flickering
|
||||||
-- we would need a much smarter update strategy to fix that
|
-- we would need a much smarter update strategy to fix that
|
||||||
when (length newSearchString > length oldSearchString) grayoutAllElements
|
when (length newSearchString > length oldSearchString) grayoutAllElements
|
||||||
-- FIXME curpos might end up outside new bounds
|
-- FIXME curpos might end up outside new bounds
|
||||||
put state { td_searchString = newSearchString }
|
put s { td_searchString = newSearchString }
|
||||||
updateAllElements
|
updateAllElements
|
||||||
|
|
||||||
-- | By default gridselect used the defaultNavigation action, which
|
-- | By default gridselect used the defaultNavigation action, which
|
||||||
|
Loading…
x
Reference in New Issue
Block a user