diff options
-rw-r--r-- | Config.hs | 2 | ||||
-rw-r--r-- | Handlers.hs | 6 | ||||
-rw-r--r-- | Screen.hs | 8 | ||||
-rw-r--r-- | State.hs | 2 |
4 files changed, 13 insertions, 5 deletions
@@ -16,6 +16,7 @@ data LazymailConfig = LazymailConfig { baseColor :: (Color, Color) -- (foreground, background) , selectionColor :: (Color, Color) , statusBarColor :: (Color, Color) + , headerColor :: (Color, Color) , showStatusBar :: Bool , initialPath :: FilePath , filterMaildirsHook :: [FilePath] -> IO [FilePath] @@ -25,6 +26,7 @@ defaultConfig = LazymailConfig { baseColor = (ColorWhite, ColorBlack) , selectionColor = (ColorYellow, ColorBlack) , statusBarColor = (ColorYellow, ColorBlack) + , headerColor = (ColorYellow, ColorBlack) , showStatusBar = True , initialPath = "" , filterMaildirsHook = \mds -> return mds diff --git a/Handlers.hs b/Handlers.hs index 4605756..3d0b787 100644 --- a/Handlers.hs +++ b/Handlers.hs @@ -15,7 +15,7 @@ import Email(parseEmail, getFields, getSubject, getFrom) import Maildir import Print import State -import System.IO(IOMode(..), hGetContents, openFile) +import qualified System.IO.UTF8 as UTF8 import Types (LazymailCurses) previousMode :: Mode -> LazymailCurses () @@ -30,7 +30,7 @@ changeMode :: Mode -> LazymailCurses () changeMode EmailMode = return () changeMode IndexMode = do st <- get - msg <- liftIO $ readFile . selectedEmailPath . indexState $ st + msg <- liftIO $ UTF8.readFile . selectedEmailPath . indexState $ st let ist = (indexState st) { selectedEmail = (parseEmail msg) } put $ st { mode = EmailMode, indexState = ist } @@ -123,7 +123,7 @@ scrollCrop top rows xs = take rows $ drop top xs formatIndexModeRows st = mapM formatRow where formatRow fp = do - msg <- hGetContents =<< (openFile fp ReadMode) + msg <- UTF8.readFile fp let email = parseEmail msg let fs = getFields email let str = normalizeLen (screenColumns st) . concat $ @@ -50,7 +50,8 @@ startCurses = do basColID <- newColorID (fst . baseColor $ cfg) (snd . baseColor $ cfg) 1 selColID <- newColorID (fst . selectionColor $ cfg) (snd . selectionColor $ cfg) 2 staColID <- newColorID (fst . statusBarColor $ cfg) (snd . statusBarColor $ cfg) 3 - let style = ColorStyle defaultColorID selColID staColID + heaColID <- newColorID (fst . headerColor $ cfg) (snd . headerColor $ cfg) 3 + let style = ColorStyle defaultColorID selColID staColID heaColID return $ st { screenRows = fromIntegral $ rows - 1 , screenColumns = fromIntegral $ cols , colorStyle = style } @@ -135,15 +136,18 @@ drawEmailHelper = do let cropWith xs = normalizeLen $ (screenColumns st) - (length xs) let row = curRowAsInteger st liftUpdate $ do + setColor $ headerColorID . colorStyle $ st moveCursor row (colPadAsInteger st) drawString $ ("From: " ++) $ cropWith "From: " . ppNameAddr . getFrom $ fs moveCursor (row + 1) (colPadAsInteger st) drawString $ ("To: " ++) $ cropWith "To: " . ppNameAddr . getTo $ fs moveCursor (row + 2) (colPadAsInteger st) drawString $ ("Subject: " ++) $ cropWith "Subject: " . ppSubject . getSubject $ fs + setColor $ baseColorID . colorStyle $ st let body = getBody $ selectedEmail . indexState $ st - liftUpdate $ drawBody (row + 4) (colPadAsInteger st) (scrRowsAsInteger st) $ formatBody body (screenColumns st) + let maxRows = if statusBar st then (scrRowsAsInteger st) - 1 else scrRowsAsInteger st + liftUpdate $ drawBody (row + 4) (colPadAsInteger st) maxRows $ formatBody body (screenColumns st) where drawBody _ _ _ [] = return () drawBody row col maxRows (xs:xss) = do @@ -57,6 +57,7 @@ data ColorStyle = ColorStyle { baseColorID :: ColorID , selectionColorID :: ColorID , statusBarColorID :: ColorID + , headerColorID :: ColorID } initialState = LazymailState { @@ -100,6 +101,7 @@ initialColorStyle = ColorStyle { baseColorID = defaultColorID , selectionColorID = defaultColorID , statusBarColorID = defaultColorID + , headerColorID = defaultColorID } scrColsAsInteger st = toInteger $ screenColumns st |