From 39f53d2775f38514a537f03c7b72281ec31a3c0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Benencia?= Date: Sun, 1 Sep 2013 11:16:38 -0300 Subject: Further improving on body scrolling --- Handlers.hs | 8 +++----- Print.hs | 7 ++++--- Rfc1342.hs | 2 +- Screen.hs | 1 + 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 diff --git a/Print.hs b/Print.hs index 1e46c00..8916e55 100644 --- a/Print.hs +++ b/Print.hs @@ -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 diff --git a/Rfc1342.hs b/Rfc1342.hs index f4966fb..c2dad42 100644 --- a/Rfc1342.hs +++ b/Rfc1342.hs @@ -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 = [] diff --git a/Screen.hs b/Screen.hs index 4e16b22..eaa87cf 100644 --- a/Screen.hs +++ b/Screen.hs @@ -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 $ diff --git a/State.hs b/State.hs index d72bc1a..d04871f 100644 --- a/State.hs +++ b/State.hs @@ -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" } -- cgit v1.2.3