{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses, PatternGuards, TypeSynonymInstances #-}------------------------------------------------------------------------------- |-- Module : XMonad.Layout.Tabbed-- Copyright : (c) 2007 David Roundy, Andrea Rossato-- License : BSD-style (see xmonad/LICENSE)---- Maintainer : droundy@darcs.net, andrea.rossato@unibz.it-- Stability : unstable-- Portability : unportable---- A tabbed layout for the Xmonad Window Manager-------------------------------------------------------------------------------moduleXMonad.Layout.Tabbed(-- * Usage:-- $usagesimpleTabbed,tabbed,addTabs,simpleTabbedAlways,tabbedAlways,addTabsAlways,simpleTabbedBottom,tabbedBottom,addTabsBottom,simpleTabbedBottomAlways,tabbedBottomAlways,addTabsBottomAlways,Theme(..),defaultTheme,TabbedDecoration(..),shrinkText,CustomShrink(CustomShrink),Shrinker(..))whereimportData.MaybeimportData.ListimportXMonadimportqualifiedXMonad.StackSetasSimportXMonad.Layout.DecorationimportXMonad.Layout.Simplest(Simplest(Simplest))-- $usage-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@:---- > import XMonad.Layout.Tabbed---- Then edit your @layoutHook@ by adding the Tabbed layout:---- > myLayouts = simpleTabbed ||| Full ||| etc..---- or, if you want a specific theme for you tabbed layout:---- > myLayouts = tabbed shrinkText defaultTheme ||| Full ||| etc..---- and then:---- > main = xmonad defaultConfig { layoutHook = myLayouts }---- The default Tabbar behaviour is to hide it when only one window is open-- on the workspace. To have it always shown, use one of the layouts or-- modifiers ending in "Always".---- For more detailed instructions on editing the layoutHook see:---- "XMonad.Doc.Extending#Editing_the_layout_hook"---- You can also edit the default configuration options.---- > myTabConfig = defaultTheme { inactiveBorderColor = "#FF0000"-- > , activeTextColor = "#00FF00"}---- and---- > mylayout = tabbed shrinkText myTabConfig ||| Full ||| etc..-- Layouts-- | A tabbed layout with the default xmonad Theme.---- This is a minimal working configuration:---- > import XMonad-- > import XMonad.Layout.DecorationMadness-- > main = xmonad defaultConfig { layoutHook = simpleTabbed }simpleTabbed::ModifiedLayout(DecorationTabbedDecorationDefaultShrinker)SimplestWindowsimpleTabbed=tabbedshrinkTextdefaultThemesimpleTabbedAlways::ModifiedLayout(DecorationTabbedDecorationDefaultShrinker)SimplestWindowsimpleTabbedAlways=tabbedAlwaysshrinkTextdefaultTheme-- | A bottom-tabbed layout with the default xmonad Theme.simpleTabbedBottom::ModifiedLayout(DecorationTabbedDecorationDefaultShrinker)SimplestWindowsimpleTabbedBottom=tabbedBottomshrinkTextdefaultTheme-- | A bottom-tabbed layout with the default xmonad Theme.simpleTabbedBottomAlways::ModifiedLayout(DecorationTabbedDecorationDefaultShrinker)SimplestWindowsimpleTabbedBottomAlways=tabbedBottomAlwaysshrinkTextdefaultTheme-- | A layout decorated with tabs and the possibility to set a custom-- shrinker and theme.tabbed::(Eqa,Shrinkers)=>s->Theme->ModifiedLayout(DecorationTabbedDecorations)Simplestatabbedsc=addTabsscSimplesttabbedAlways::(Eqa,Shrinkers)=>s->Theme->ModifiedLayout(DecorationTabbedDecorations)SimplestatabbedAlwayssc=addTabsAlwaysscSimplest-- | A layout decorated with tabs at the bottom and the possibility to set a custom-- shrinker and theme.tabbedBottom::(Eqa,Shrinkers)=>s->Theme->ModifiedLayout(DecorationTabbedDecorations)SimplestatabbedBottomsc=addTabsBottomscSimplesttabbedBottomAlways::(Eqa,Shrinkers)=>s->Theme->ModifiedLayout(DecorationTabbedDecorations)SimplestatabbedBottomAlwayssc=addTabsBottomAlwaysscSimplest-- Layout Modifiers-- | A layout modifier that uses the provided shrinker and theme to add tabs to any layout.addTabs::(Eqa,LayoutClassla,Shrinkers)=>s->Theme->la->ModifiedLayout(DecorationTabbedDecorations)laaddTabs=createTabsWhenPluralTopaddTabsAlways::(Eqa,LayoutClassla,Shrinkers)=>s->Theme->la->ModifiedLayout(DecorationTabbedDecorations)laaddTabsAlways=createTabsAlwaysTop-- | A layout modifier that uses the provided shrinker and theme to add tabs to the bottom of any layout.addTabsBottom::(Eqa,LayoutClassla,Shrinkers)=>s->Theme->la->ModifiedLayout(DecorationTabbedDecorations)laaddTabsBottom=createTabsWhenPluralBottomaddTabsBottomAlways::(Eqa,LayoutClassla,Shrinkers)=>s->Theme->la->ModifiedLayout(DecorationTabbedDecorations)laaddTabsBottomAlways=createTabsAlwaysBottom-- Tab creation abstractions. Internal use only.-- Create tabbar when required at the given location with the given-- shrinker and theme to the supplied layout.createTabs::(Eqa,LayoutClassla,Shrinkers)=>TabbarShown->TabbarLocation->s->Theme->la->ModifiedLayout(DecorationTabbedDecorations)lacreateTabsshloctxthl=decorationtxth(Tabbedlocsh)ldataTabbarLocation=Top|Bottomderiving(Read,Show)dataTabbarShown=Always|WhenPluralderiving(Read,Show,Eq)dataTabbedDecorationa=TabbedTabbarLocationTabbarShownderiving(Read,Show)instanceEqa=>DecorationStyleTabbedDecorationawheredescribeDeco(TabbedTop_)="Tabbed"describeDeco(TabbedBottom_)="Tabbed Bottom"decorationMouseDragHook___=return()pureDecoration(Tabbedlcsh)_ht_swrs(w,r@(Rectanglexywhhh))=if((sh==Always&&numWindows>0)||numWindows>1)thenJust$caselcofTop->upperTabBottom->lowerTabelseNothingwherews=filter(`elem`mapfst(filter((==r).snd)wrs))(S.integrates)loci=x+fi((wh*fii)`div`max1(fi$lengthws))wid=fi$maybex(\i->loc(i+1)-loci)$w`elemIndex`wsnx=maybexloc$w`elemIndex`wsupperTab=Rectanglenxywid(fiht)lowerTab=Rectanglenx(y+fi(hh-ht))wid(fiht)numWindows=lengthwsshrink(Tabbedloc_)(Rectangle___dh)(Rectanglexywh)=caselocofTop->Rectanglex(y+fidh)w(h-dh)Bottom->Rectanglexyw(h-dh)