From 55bde227212ab6b932b620af7b67a862324184a9 Mon Sep 17 00:00:00 2001 From: daniel Date: Mon, 15 Feb 2010 01:07:31 +0100 Subject: documentation for marshallPP Ignore-this: efa38829b40dc1586f5f18c4bab21f7d darcs-hash:20100215000731-c98ca-8608df63586b6699bca3c52368e76c161b6b01b2.gz --- XMonad/Layout/IndependentScreens.hs | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) (limited to 'XMonad') diff --git a/XMonad/Layout/IndependentScreens.hs b/XMonad/Layout/IndependentScreens.hs index 4e8f095..0b5b996 100644 --- a/XMonad/Layout/IndependentScreens.hs +++ b/XMonad/Layout/IndependentScreens.hs @@ -19,8 +19,10 @@ module XMonad.Layout.IndependentScreens ( VirtualWorkspace, PhysicalWorkspace, workspaces', withScreens, onCurrentScreen, - countScreens, marshallPP, + countScreens, + -- * Converting between virtual and physical workspaces + -- $converting marshall, unmarshall, unmarshallS, unmarshallW, marshallWindowSpace, unmarshallWindowSpace ) where @@ -69,6 +71,14 @@ import XMonad.Hooks.DynamicLog type VirtualWorkspace = WorkspaceId type PhysicalWorkspace = WorkspaceId +-- $converting +-- You shouldn't need to use the functions below very much. They are used +-- internally. However, in some cases, they may be useful, and so are exported +-- just in case. In general, the \"marshall\" functions convert the convenient +-- form (like \"web\") you would like to use in your configuration file to the +-- inconvenient form (like \"2_web\") that xmonad uses internally. Similarly, +-- the \"unmarshall\" functions convert in the other direction. + marshall :: ScreenId -> VirtualWorkspace -> PhysicalWorkspace marshall (S sc) vws = show sc ++ '_':vws @@ -76,12 +86,6 @@ unmarshall :: PhysicalWorkspace -> (ScreenId, VirtualWorkspace) unmarshallS :: PhysicalWorkspace -> ScreenId unmarshallW :: PhysicalWorkspace -> VirtualWorkspace --- ^ You shouldn't need to use @marshall@ or the various @unmarshall@ functions --- very much. They simply convert between the physical and virtual worlds. --- For example, you might want to use them as part of a status bar --- configuration. The function @unmarshallW@ would discard the screen --- information from an otherwise unsightly workspace name. - unmarshall = ((S . read) *** drop 1) . break (=='_') unmarshallS = fst . unmarshall unmarshallW = snd . unmarshall @@ -110,10 +114,17 @@ onCurrentScreen f vws = screen . current >>= f . flip marshall vws countScreens :: (MonadIO m, Integral i) => m i countScreens = liftM genericLength . liftIO $ openDisplay "" >>= getScreenInfo --- TODO: documentation from here down --- TODO: note somewhere that "marshall" functions go from convenient --- to inconvenient, and "unmarshall" functions go from --- inconvenient to convenient +-- | This turns a naive pretty-printer into one that is aware of the +-- independent screens. That is, you can write your pretty printer to behave +-- the way you want on virtual workspaces; this function will convert that +-- pretty-printer into one that first filters out physical workspaces on other +-- screens, then converts all the physical workspaces on this screen to their +-- virtual names. +-- +-- For example, if you have handles @hLeft@ and @hRight@ for bars on the left and right screens, respectively, and @pp@ is a pretty-printer function that takes a handle, you could write +-- +-- > logHook = let log screen handle = dynamicLogWithPP . marshallPP screen . pp $ handle +-- > in log 0 hLeft >> log 1 hRight marshallPP :: ScreenId -> PP -> PP marshallPP s pp = pp { ppCurrent = ppCurrent pp . snd . unmarshall, @@ -130,7 +141,9 @@ marshallSort s vSort = pScreens . vSort . vScreens where vScreens = map unmarshallWindowSpace . filter onScreen pScreens = map (marshallWindowSpace s) +-- | Convert the tag of the 'WindowSpace' from a 'VirtualWorkspace' to a 'PhysicalWorkspace'. marshallWindowSpace :: ScreenId -> WindowSpace -> WindowSpace +-- | Convert the tag of the 'WindowSpace' from a 'PhysicalWorkspace' to a 'VirtualWorkspace'. unmarshallWindowSpace :: WindowSpace -> WindowSpace marshallWindowSpace s ws = ws { tag = marshall s (tag ws) } -- cgit v1.2.3