From 430b8d21493092690a3c27c8c285202312f776bd Mon Sep 17 00:00:00 2001 From: Jose Antonio Ortega Ruiz Date: Sun, 26 May 2013 13:49:48 +0200 Subject: Refactoring and slight generalisation of the new Battery feature --- src/Plugins/Monitors/Common.hs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/Plugins/Monitors/Common.hs') diff --git a/src/Plugins/Monitors/Common.hs b/src/Plugins/Monitors/Common.hs index 0547311..881d679 100644 --- a/src/Plugins/Monitors/Common.hs +++ b/src/Plugins/Monitors/Common.hs @@ -1,7 +1,7 @@ ----------------------------------------------------------------------------- -- | -- Module : Plugins.Monitors.Common --- Copyright : (c) 2010, 2011 Jose Antonio Ortega Ruiz +-- Copyright : (c) 2010, 2011, 2013 Jose Antonio Ortega Ruiz -- (c) 2007-2010 Andrea Rossato -- License : BSD-style (see LICENSE) -- @@ -35,6 +35,7 @@ module Plugins.Monitors.Common ( , getAfterString , skipTillString , parseTemplate + , parseTemplate' -- ** String Manipulation -- $strings , padString @@ -306,6 +307,15 @@ parseTemplate l = let m = Map.fromList . zip e $ l return $ combine m s +-- | Works like parseTemplate, but using the given template string. +parseTemplate' :: String -> [String] -> Monitor String +parseTemplate' t l = do + t' <- getConfigValue template + setConfigValue t template + r <- parseTemplate l + setConfigValue t' template + return r + -- | Given a finite "Map" and a parsed templatet produces the -- | resulting output string. combine :: Map.Map String String -> [(String, String, String)] -> String -- cgit v1.2.3