Removed fromIMaybe from Tabbed ad added it to Invisible

This commit is contained in:
Andrea Rossato
2007-09-30 18:19:12 +00:00
parent d758a8b412
commit 3ed5f5cde0
2 changed files with 7 additions and 6 deletions

View File

@@ -17,6 +17,7 @@ module XMonadContrib.Invisible (
-- $usage -- $usage
Invisible (..) Invisible (..)
, whenIJust , whenIJust
, fromIMaybe
) where ) where
-- $usage -- $usage
@@ -41,3 +42,7 @@ instance (Functor m, Monad m) => Functor (Invisible m) where
whenIJust :: (Monad m) => Invisible Maybe a -> (a -> m ()) -> m () whenIJust :: (Monad m) => Invisible Maybe a -> (a -> m ()) -> m ()
whenIJust (I (Just x)) f = f x whenIJust (I (Just x)) f = f x
whenIJust (I Nothing) _ = return () whenIJust (I Nothing) _ = return ()
fromIMaybe :: a -> Invisible Maybe a -> a
fromIMaybe _ (I (Just x)) = x
fromIMaybe a (I Nothing) = a

View File

@@ -137,7 +137,7 @@ handleMess _ _ = return Nothing
handleEvent :: Invisible Maybe Shrinker -> TConf -> TabState -> Event -> X () handleEvent :: Invisible Maybe Shrinker -> TConf -> TabState -> Event -> X ()
-- button press -- button press
handleEvent ishr conf (TabState {tabsWindows = tws, scr = screen, fontS = fs }) handleEvent ishr conf (TabState {tabsWindows = tws, scr = screen, fontS = fs })
(ButtonEvent {ev_window = thisw, ev_subwindow = thisbw, ev_event_type = t }) (ButtonEvent {ev_window = thisw, ev_subwindow = thisbw, ev_event_type = t })
| t == buttonPress, tl <- map fst tws, thisw `elem` tl || thisbw `elem` tl = do | t == buttonPress, tl <- map fst tws, thisw `elem` tl || thisbw `elem` tl = do
focus (fromJust $ lookup thisw tws) focus (fromJust $ lookup thisw tws)
updateTab ishr conf fs width (thisw, fromJust $ lookup thisw tws) updateTab ishr conf fs width (thisw, fromJust $ lookup thisw tws)
@@ -145,7 +145,7 @@ handleEvent ishr conf (TabState {tabsWindows = tws, scr = screen,
width = rect_width screen`div` fromIntegral (length tws) width = rect_width screen`div` fromIntegral (length tws)
handleEvent ishr conf (TabState {tabsWindows = tws, scr = screen, fontS = fs }) handleEvent ishr conf (TabState {tabsWindows = tws, scr = screen, fontS = fs })
(AnyEvent {ev_window = thisw, ev_event_type = t }) (AnyEvent {ev_window = thisw, ev_event_type = t })
-- expose -- expose
| thisw `elem` (map fst tws) && t == expose = do | thisw `elem` (map fst tws) && t == expose = do
updateTab ishr conf fs width (thisw, fromJust $ lookup thisw tws) updateTab ishr conf fs width (thisw, fromJust $ lookup thisw tws)
@@ -206,7 +206,3 @@ shrinkWhile sh p x = sw $ sh x
shrinkText :: Shrinker shrinkText :: Shrinker
shrinkText "" = [""] shrinkText "" = [""]
shrinkText cs = cs : shrinkText (init cs) shrinkText cs = cs : shrinkText (init cs)
fromIMaybe :: a -> Invisible Maybe a -> a
fromIMaybe _ (I (Just x)) = x
fromIMaybe a (I Nothing) = a