Tabbed: added more configuration options

It is now possible to configure active and inactive border colors, and
active and inactive text colors (i.e. tabs are now very similar to Ion3
tabs: former Ion users may appreciate).
This commit is contained in:
Andrea Rossato
2007-07-06 13:08:45 +00:00
parent 7ce8ed2f8b
commit 5f827b68e7

View File

@@ -54,8 +54,10 @@ import XMonadContrib.LayoutHelpers ( idModify )
data TConf = data TConf =
TConf { activeColor :: String TConf { activeColor :: String
, inactiveColor :: String , inactiveColor :: String
, bgColor :: String , activeBorderColor :: String
, textColor :: String , inactiveTextColor :: String
, inactiveBorderColor :: String
, activeTextColor :: String
, fontName :: String , fontName :: String
, tabSize :: Int , tabSize :: Int
} deriving (Show, Read) } deriving (Show, Read)
@@ -64,8 +66,10 @@ defaultTConf :: TConf
defaultTConf = defaultTConf =
TConf { activeColor ="#BBBBBB" TConf { activeColor ="#BBBBBB"
, inactiveColor = "#888888" , inactiveColor = "#888888"
, bgColor = "#000000" , activeBorderColor = "#FFFFFF"
, textColor = "#000000" , inactiveBorderColor = "#BFBFBF"
, activeTextColor = "#FFFFFF"
, inactiveTextColor = "#BFBFBF"
, fontName = "-misc-fixed-*-*-*-*-10-*-*-*-*-*-*-*" , fontName = "-misc-fixed-*-*-*-*-10-*-*-*-*-*-*-*"
, tabSize = 20 , tabSize = 20
} }
@@ -80,27 +84,30 @@ dolay :: Shrinker -> TConf
-> Rectangle -> W.Stack Window -> X ([(Window, Rectangle)], Maybe (Layout Window)) -> Rectangle -> W.Stack Window -> X ([(Window, Rectangle)], Maybe (Layout Window))
dolay _ _ sc (W.Stack w [] []) = return ([(w,sc)], Nothing) dolay _ _ sc (W.Stack w [] []) = return ([(w,sc)], Nothing)
dolay shr conf sc@(Rectangle x y wid _) s = withDisplay $ \dpy -> dolay shr conf sc@(Rectangle x y wid _) s = withDisplay $ \dpy ->
do activecolor <- io $ initColor dpy $ activeColor conf do ac <- io $ initColor dpy $ activeColor conf
inactivecolor <- io $ initColor dpy $ inactiveColor conf ic <- io $ initColor dpy $ inactiveColor conf
textcolor <- io $ initColor dpy $ textColor conf abc <- io $ initColor dpy $ activeBorderColor conf
bgcolor <- io $ initColor dpy $ bgColor conf ibc <- io $ initColor dpy $ inactiveBorderColor conf
atc <- io $ initColor dpy $ activeTextColor conf
itc <- io $ initColor dpy $ inactiveTextColor conf
let ws = W.integrate s let ws = W.integrate s
ts = gentabs conf x y wid (length ws) ts = gentabs conf x y wid (length ws)
tws = zip ts ws tws = zip ts ws
focusColor w incol actcol = (maybe incol (\focusw -> if focusw == w
then actcol else incol) . W.peek)
`fmap` gets windowset
make_tabs [] l = return l make_tabs [] l = return l
make_tabs (tw':tws') l = do l' <- maketab tw' l make_tabs (tw':tws') l = do bc <- focusColor (snd tw') ibc abc
l' <- maketab tw' bc l
make_tabs tws' l' make_tabs tws' l'
maketab (t,ow) = newDecoration ow t 1 bgcolor activecolor maketab (t,ow) bg = newDecoration ow t 1 bg ac
(fontName conf) (drawtab t ow) (focus ow) (fontName conf) (drawtab t ow) (focus ow)
drawtab r@(Rectangle _ _ wt ht) ow d w' gc fn = drawtab r@(Rectangle _ _ wt ht) ow d w' gc fn =
do nw <- getName ow do nw <- getName ow
tabcolor <- (maybe inactivecolor (\focusw -> if focusw == ow (fc,tc) <- focusColor ow (ic,itc) (ac,atc)
then activecolor io $ setForeground d gc fc
else inactivecolor) . W.peek)
`fmap` gets windowset
io $ setForeground d gc tabcolor
io $ fillRectangles d w' gc [Rectangle 0 0 wt ht] io $ fillRectangles d w' gc [Rectangle 0 0 wt ht]
io $ setForeground d gc textcolor io $ setForeground d gc tc
centerText d w' gc fn r (show nw) centerText d w' gc fn r (show nw)
centerText d w' gc fontst (Rectangle _ _ wt ht) name = centerText d w' gc fontst (Rectangle _ _ wt ht) name =
do let (_,asc,_,_) = textExtents fontst name do let (_,asc,_,_) = textExtents fontst name