diff options
-rw-r--r-- | Handlers.hs | 8 | ||||
-rw-r--r-- | Print.hs | 7 | ||||
-rw-r--r-- | Rfc1342.hs | 2 | ||||
-rw-r--r-- | Screen.hs | 1 | ||||
-rw-r--r-- | State.hs | 2 |
5 files changed, 11 insertions, 9 deletions
diff --git a/Handlers.hs b/Handlers.hs index 4a0ba88..3e27b79 100644 --- a/Handlers.hs +++ b/Handlers.hs @@ -86,6 +86,7 @@ incSelectedRow MaildirMode = do else -- Move the selected row put $ incrementSelectedRow st +{- Down-scrolling in Email mode -} incSelectedRow EmailMode = do st <- get let est = emailState st @@ -94,7 +95,7 @@ incSelectedRow EmailMode = do let totalRows = length $ emailLines est let est' = est { scrollRowEm = (cur + 1) } - when ((totalRows - scrRows) > (scrollRowEm est)) $ + when ((totalRows - scrRows + (bodyStartRow est) - 1) > (scrollRowEm est)) $ put $ st { emailState = est' } incSelectedRow _ = (=<<) put $ get >>= \st -> return $ incrementSelectedRow st @@ -138,7 +139,7 @@ decSelectedRow EmailMode = do let totalRows = length $ emailLines est let est' = est { scrollRowEm = (cur - 1) } - when ((totalRows - (scrRows + cur)) > 0) $ + when (cur > 0) $ put $ st { emailState = est' } decSelectedRow _ = (=<<) put $ get >>= \st -> return $ decrementSelectedRow st @@ -170,6 +171,3 @@ formatMaildirModeRows st = mapM formatRow where pad = " " numPads = (length $ filter (== '/') str) + (length $ filter (`elem` imapSep) str) imapSep = ['.'] -- IMAP usually separates its directories with dots - --- TODO: Improve this rancidness -mailHeaderLength = 4
\ No newline at end of file @@ -20,14 +20,15 @@ nameLen = 20 ppNameAddr nas = intercalate ", " $ map ppNameAddr' nas where ppNameAddr' na = case nameAddr_name na of Nothing -> nameAddr_addr na - Just n -> (decodeField n) ++ " <" ++ nameAddr_addr na ++ ">" + Just n -> unquote (decodeField n) ++ " <" ++ nameAddr_addr na ++ ">" ppIndexNameAddr nas = normalizeLen nameLen $ concat $ map ppNameAddr' nas where ppNameAddr' na = case nameAddr_name na of Nothing -> nameAddr_addr na - Just n -> (decodeField n) + Just n -> unquote (decodeField n) + +unquote xs= if (head xs == '"' && last xs == '"') then (tail . init) xs else xs -subjectLen = 90 ppSubject = flat . decodeField flat xs = intercalate " " $ map (dropWhile isSpace) $ map (filter (/= '\r')) $ lines xs @@ -44,7 +44,7 @@ decodeWithCharset dec ('?':c:'?':cs) | toLower c == 'b' = dataDecodeWith B64.dec rest = if "?=" `isPrefixOf` rest' then drop 2 rest' else rest' - dataDecodeWith datadec = (_2spc . dec . unwrap . datadec $ encoded) ++ (decodeField $ dropWhile isSpace rest) + dataDecodeWith datadec = (_2spc . dec . unwrap . datadec $ encoded) ++ decodeField rest -- ++ (decodeField $ dropWhile isSpace rest) unwrap :: Maybe [Word8] -> String unwrap Nothing = [] @@ -136,6 +136,7 @@ drawEmailHelper = do st <- get let est = emailState st + put $ st { emailState = est { bodyStartRow = (currentRow st ) } } let body = getBody $ currentEmail . emailState $ st let maxRows = if statusBar st then (scrRowsAsInteger st) - 1 else scrRowsAsInteger st liftUpdate $ @@ -54,6 +54,7 @@ data ComposeState = ComposeState { data EmailState = EmailState { scrollRowEm :: Int + , bodyStartRow :: Int , emailLines :: [String] , currentEmail :: Message } @@ -100,6 +101,7 @@ initialIndexState = IndexState { initialEmailState = EmailState { scrollRowEm = 0 + , bodyStartRow = 0 , emailLines = [] , currentEmail = Message [] "Dummy email" } |