diff options
| author | Raúl Benencia <rul@kalgan.cc> | 2013-09-05 19:57:02 -0300 | 
|---|---|---|
| committer | Raúl Benencia <rul@kalgan.cc> | 2013-09-05 19:57:02 -0300 | 
| commit | 3bd3fd2c6eae2f36f69f247403421e8cf8226394 (patch) | |
| tree | 0d92cd91d69cf52b9168c403af317643e88c2587 /Lazymail/Print.hs | |
| parent | 41b53ca04b6d52457f331930e8fea68416498882 (diff) | |
Moved all code to src/
Diffstat (limited to 'Lazymail/Print.hs')
| -rw-r--r-- | Lazymail/Print.hs | 80 | 
1 files changed, 0 insertions, 80 deletions
| diff --git a/Lazymail/Print.hs b/Lazymail/Print.hs deleted file mode 100644 index 15e9df1..0000000 --- a/Lazymail/Print.hs +++ /dev/null @@ -1,80 +0,0 @@ -{- Printing utilities. - - - - Copyright 2013 Raúl Benencia <rul@kalgan.cc> - - - - Licensed under the GNU GPL version 3 or higher - - - -} - -module Lazymail.Print where - -import Data.Char (isSpace) -import Data.List (intercalate) - -import Lazymail.Email -import Codec.Text.Rfc1342 -import Lazymail.Types(Flag(..), Flags) - -unquote xs= if (head xs == '"' && last xs == '"') then (tail . init) xs else xs - -ppField = flat . decodeField - -{- Pretty print a RFC822 date format -} - - -fromLen :: Int -fromLen = 20 - -maxFlags :: Int -maxFlags = 4 - -flat xs = intercalate " " $ map (dropWhile isSpace) $ map (filter (/= '\r')) $ lines xs - -ppFlags :: Flags -> String -ppFlags = map ppFlag - -ppFlag :: Flag -> Char -ppFlag NEW       = 'N' -ppFlag SEEN      = 'S' -ppFlag ANSWERED  = 'A' -ppFlag FLAGGED   = 'F' -ppFlag DRAFT     = 'D' -ppFlag FORWARDED = 'P' -ppFlag DELETED   = 'T' -ppFlag (OTHERFLAG [c]) = c - -ppSep = "  " - -normalizeLen len cs = if (length cs > len) -                      then shorten len cs -                      else 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 -     -> String  -- ^ output string -     -> String -wrap _ _ "" = "" -wrap l r m  = l ++ m ++ r - --- | Pad a string with a leading and trailing space. -pad :: String -> String -pad = wrap " " " " - --- | Trim leading and trailing whitespace from a string. -trim :: String -> String -trim = f . f -    where f = reverse . dropWhile isSpace - --- | Limit a string to a certain length, adding "..." if truncated. -shorten :: Int -> String -> String -shorten n xs | length xs < n = xs -             | otherwise     = take (n - length end) xs ++ end -  where -    end = "..." | 
