From 49f103cfdf558e469774b0a5e668823fdf11a91c Mon Sep 17 00:00:00 2001
From: Braden Shepherdson <Braden.Shepherdson@gmail.com>
Date: Sat, 14 Mar 2009 04:28:18 +0100
Subject: X.H.DynamicLog: Add dzenStrip to remove formatting, for use in
 dzenPP's ppUrgent.

Ignore-this: fd96a1a4b112d0f71589b639b83ec3e
This function was written by Wirt Wolff. This change should allow UrgencyHook
to work out of the box with dzen and dzenPP, rather than the colours being
overridden so even though UrgencyHook is working, it doesn't change colours.

darcs-hash:20090314032818-d53a8-7af4c3e0cb04eca34d7d95cdd28a3e727a1abd83.gz
---
 XMonad/Hooks/DynamicLog.hs | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

(limited to 'XMonad')

diff --git a/XMonad/Hooks/DynamicLog.hs b/XMonad/Hooks/DynamicLog.hs
index b599783..b4bbe48 100644
--- a/XMonad/Hooks/DynamicLog.hs
+++ b/XMonad/Hooks/DynamicLog.hs
@@ -39,7 +39,7 @@ module XMonad.Hooks.DynamicLog (
 
     -- * Formatting utilities
     wrap, pad, shorten,
-    xmobarColor, dzenColor, dzenEscape,
+    xmobarColor, dzenColor, dzenEscape, dzenStrip,
 
     -- * Internal formatting functions
     pprWindowSet,
@@ -332,6 +332,17 @@ dzenColor fg bg = wrap (fg1++bg1) (fg2++bg2)
 dzenEscape :: String -> String
 dzenEscape = concatMap (\x -> if x == '^' then "^^" else [x])
 
+-- | Strip dzen formatting (used in ppUrgent)
+dzenStrip :: String -> String
+dzenStrip = strip [] where
+    strip keep [] = keep
+    strip keep ('^':'^':x) = strip (keep ++ "^") x
+    strip keep ('^':x) = strip keep (drop 1 . dropWhile (')' /=) $ x)
+    strip keep x = let (good,x') = span ('^' /=) x
+        in strip (keep ++ good) x'
+
+
+
 -- | Use xmobar escape codes to output a string with given foreground
 --   and background colors.
 xmobarColor :: String  -- ^ foreground color: a color name, or #rrggbb format
@@ -421,7 +432,7 @@ dzenPP = defaultPP { ppCurrent  = dzenColor "white" "#2b4f98" . pad
                      , ppVisible  = dzenColor "black" "#999999" . pad
                      , ppHidden   = dzenColor "black" "#cccccc" . pad
                      , ppHiddenNoWindows = const ""
-                     , ppUrgent   = dzenColor "red" "yellow"
+                     , ppUrgent   = dzenColor "red" "yellow" . dzenStrip
                      , ppWsSep    = ""
                      , ppSep      = ""
                      , ppLayout   = dzenColor "black" "#cccccc" .
-- 
cgit v1.2.3