diff options
| -rw-r--r-- | news.md | 2 | ||||
| -rw-r--r-- | samples/xmobar.config | 3 | ||||
| -rw-r--r-- | src/Parsers.hs | 21 | 
3 files changed, 16 insertions, 10 deletions
| @@ -10,6 +10,8 @@ _New features_    - `Weather` now offers `dewPointC` and `dewPointF` instead of      `dewPoint`, and the new `windCardinal`, `windAzimuth`, `windMph`      and `windKnots` variables, by Tony Morris. +  - Strings in the configuration file can now span multiple lines +    using Haskell-style multiline script, thanks to dunric  ## Version 0.21 (Jul 1, 2014) diff --git a/samples/xmobar.config b/samples/xmobar.config index 9c359e3..5f4c224 100644 --- a/samples/xmobar.config +++ b/samples/xmobar.config @@ -19,5 +19,6 @@ Config { font = "-misc-fixed-*-*-*-*-10-*-*-*-*-*-*-*"                      ]         , sepChar = "%"         , alignSep = "}{" -       , template = "%cpu% | %memory% * %swap% | %eth0% - %eth1% }{ <fc=#ee9a00>%date%</fc>| %EGPF% | %uname%" +       , template = "%cpu% | %memory% * %swap% | %eth0% - %eth1% }\ +                    \{ <fc=#ee9a00>%date%</fc>| %EGPF% | %uname%"         } diff --git a/src/Parsers.hs b/src/Parsers.hs index 69c5f21..f7be1e3 100644 --- a/src/Parsers.hs +++ b/src/Parsers.hs @@ -25,7 +25,7 @@ import Runnable  import Commands  import Actions -import Control.Monad (guard, mzero) +import Control.Monad (guard, mzero, liftM)  import qualified Data.Map as Map  import Text.ParserCombinators.Parsec  import Text.ParserCombinators.Parsec.Perm @@ -180,9 +180,6 @@ stripComments :: String -> String  stripComments =    unlines . map (drop 5 . strip False . (replicate 5 ' '++)) . lines      where strip m ('-':'-':xs) = if m then "--" ++ strip m xs else "" -          strip m ('\\':xss) = case xss of -                                '\\':xs -> '\\' : strip m xs -                                _ -> strip m $ drop 1 xss            strip m ('"':xs) = '"': strip (not m) xs            strip m (x:xs) = x : strip m xs            strip _ [] = [] @@ -249,11 +246,17 @@ parseConfig = runParser parseConf fields "Config" . stripComments        readCommands = manyTill anyChar (try commandsEnd) >>=                          read' commandsErr . flip (++) "]" -      strField e n = field e n . between (strDel "start" n) (strDel "end" n) . -                     many $ noneOf "\"\n\r" -      strDel t n = char '"' <?> strErr t n -      strErr t n = "the " ++ t ++ " of the string field " ++ n ++ -                       " - a double quote (\")." +      strField e n = field e n strMulti + +      strMulti = scan '"' +          where +            scan lead = do +                spaces +                char lead +                s <- manyTill anyChar (rowCont <|> unescQuote) +                (char '"' >> return s) <|> liftM (s ++) (scan '\\') +            rowCont    = try $ char '\\' >> string "\n" +            unescQuote = lookAhead (noneOf "\\") >> lookAhead (string "\"")        wrapSkip   x = many space >> x >>= \r -> many space >> return r        sepEndSpc    = mapM_ (wrapSkip . try . string) | 
