diff options
author | Raúl Benencia <rul@kalgan.cc> | 2013-09-09 16:13:53 -0300 |
---|---|---|
committer | Raúl Benencia <rul@kalgan.cc> | 2013-09-09 16:13:53 -0300 |
commit | d5c39015fb75662f5ae572aa04cdf20d5b8baac7 (patch) | |
tree | 1e4db9af341a1565c241fb380467bdfd00b6c775 /src/Lazymail/Print.hs | |
parent | 41b16df2db3920b59d1c13a468e848e68111058b (diff) |
Compose mode
Diffstat (limited to 'src/Lazymail/Print.hs')
-rw-r--r-- | src/Lazymail/Print.hs | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/src/Lazymail/Print.hs b/src/Lazymail/Print.hs index 15e9df1..a6a38d1 100644 --- a/src/Lazymail/Print.hs +++ b/src/Lazymail/Print.hs @@ -13,7 +13,7 @@ import Data.List (intercalate) import Lazymail.Email import Codec.Text.Rfc1342 -import Lazymail.Types(Flag(..), Flags) +import Lazymail.Types(Flag(..), Flags, ComposeFields(..), ComposeState(..)) unquote xs= if (head xs == '"' && last xs == '"') then (tail . init) xs else xs @@ -43,18 +43,29 @@ ppFlag FORWARDED = 'P' ppFlag DELETED = 'T' ppFlag (OTHERFLAG [c]) = c +ppComposeState cs = ppComposeFields False (composeFields cs) ++ + [("Body file name: " ++) $ maybe "-" id $ bodyFileName cs] + +ppComposeFields removeEmpty cf | removeEmpty == False = l + | otherwise = filter (\str -> (last str) /= '-') l + where l = [ ("From: " ++) $ maybe "-" id $ fromField cf + , ("To: " ++) $ maybe "-" id $ toField cf + , ("Cc: " ++) $ maybe "-" id $ ccField cf + , ("Bcc: " ++) $ maybe "-" id $ bccField cf + , ("Reply-To: " ++) $ maybe "-" id $ replyToField cf + , ("Subject: " ++) $ maybe "-" id $ subjectField cf + ] + ppSep = " " -normalizeLen len cs = if (length cs > len) - then shorten len cs - else if (length cs < len) - then fillWithSpace len cs - else cs +normalizeLen len cs | (length cs > len) = shorten len cs + | otherwise = if (length cs < len) + then fillWithSpace len cs + else cs fillWithSpace len cs = cs ++ (take (len - length cs) . repeat $ ' ') -- The following functions are from DynamicLog xmonad-contrib source - -- | Wrap a string in delimiters, unless it is empty. wrap :: String -- ^ left delimiter -> String -- ^ right delimiter |