summaryrefslogtreecommitdiffhomepage
path: root/Plugins/Monitors/Common.hs
diff options
context:
space:
mode:
authorJose A Ortega Ruiz <jao@gnu.org>2010-02-22 15:42:26 +0100
committerJose A Ortega Ruiz <jao@gnu.org>2010-02-22 15:42:26 +0100
commit32dc866c396c262d3781e03bdfd1acd2b4a151ee (patch)
treebc6edd435e0e93d94c76c5849b50e56575bb6bb7 /Plugins/Monitors/Common.hs
parentfd7de94c92b5d094bd244a06f8b330237ed7e99d (diff)
downloadxmobar-32dc866c396c262d3781e03bdfd1acd2b4a151ee.tar.gz
xmobar-32dc866c396c262d3781e03bdfd1acd2b4a151ee.tar.bz2
Wireless monitor: better boundary checks
Ignore-this: cfb69e10b2eaff6924a2df32b1e51bf0 darcs-hash:20100222144226-748be-f28cbe827c89238074448b23da7ba606f930ceb9.gz
Diffstat (limited to 'Plugins/Monitors/Common.hs')
-rw-r--r--Plugins/Monitors/Common.hs16
1 files changed, 11 insertions, 5 deletions
diff --git a/Plugins/Monitors/Common.hs b/Plugins/Monitors/Common.hs
index c99a40f..101907b 100644
--- a/Plugins/Monitors/Common.hs
+++ b/Plugins/Monitors/Common.hs
@@ -36,6 +36,7 @@ module Plugins.Monitors.Common (
-- ** String Manipulation
-- $strings
, padString
+ , showWithPadding
, showWithColors
, showWithColors'
, showPercentsWithColors
@@ -339,15 +340,20 @@ setColor str s =
Just c -> return $
"<fc=" ++ c ++ ">" ++ str ++ "</fc>"
+showWithPadding :: String -> Monitor String
+showWithPadding s =
+ do mn <- getConfigValue minWidth
+ mx <- getConfigValue maxWidth
+ p <- getConfigValue padChars
+ pr <- getConfigValue padRight
+ return $ padString mn mx p pr s
+
showWithColors :: (Num a, Ord a) => (a -> String) -> a -> Monitor String
showWithColors f x =
do h <- getConfigValue high
l <- getConfigValue low
- mn <- getConfigValue minWidth
- mx <- getConfigValue maxWidth
- p <- getConfigValue padChars
- pr <- getConfigValue padRight
- let col = setColor $ padString mn mx p pr $ f x
+ s <- showWithPadding $ f x
+ let col = setColor s
[ll,hh] = map fromIntegral $ sort [l, h] -- consider high < low
head $ [col highColor | x > hh ] ++
[col normalColor | x > ll ] ++