aboutsummaryrefslogtreecommitdiff
path: root/Screen.hs
diff options
context:
space:
mode:
authorRaúl Benencia <rul@kalgan.cc>2013-08-27 23:34:10 -0300
committerRaúl Benencia <rul@kalgan.cc>2013-08-27 23:34:10 -0300
commit77112dd4cd7657ebf16734d117d42283ee34c742 (patch)
treea180f9d9635ced5071d5e32557dfb13b5ad49541 /Screen.hs
parent496546229d1b5060c88266210f303a48280c885c (diff)
Scrolling working in Maildir mode
Diffstat (limited to 'Screen.hs')
-rw-r--r--Screen.hs18
1 files changed, 16 insertions, 2 deletions
diff --git a/Screen.hs b/Screen.hs
index ce98840..98dbfa0 100644
--- a/Screen.hs
+++ b/Screen.hs
@@ -54,6 +54,8 @@ startCurses = do
return $ st { screenRows = fromIntegral $ rows - 1
, screenColumns = fromIntegral $ cols
, colorStyle = style }
+
+ resetScrollBuffer
screenLoop
{- This function will loop til the user decides to leave -}
@@ -79,7 +81,7 @@ performUpdate = do
{- Pattern match on the received mode and draw it in the screen. -}
drawMode :: Mode -> LazymailUpdate ()
-drawMode MaildirMode = get >>= \st -> drawSelectionList $ detectedMDs . maildirState $ st
+drawMode MaildirMode = get >>= \st -> drawSelectionList $ scrollBufferMD . maildirState $ st
drawMode IndexMode = get >>= \st -> drawSelectionList $ scrollBufferIn . indexState $ st
drawMode EmailMode = drawEmailHelper
@@ -170,7 +172,7 @@ drawStatus = do
drawStatusHelper MaildirMode st =
["Maildir listing - "
- , "(", show ((+ 1) . selectedRow $ st), "/"
+ , "(", show ((selectedRow st) + (scrollRowMD . maildirState $ st) + 1), "/"
, show (length $ detectedMDs . maildirState $ st), ")"]
drawStatusHelper IndexMode st =
@@ -208,5 +210,17 @@ handleEvent = loop where
resetCurrentRow = (=<<) put $ get >>= \st -> return $ st { currentRow = 0 }
incrementCurrentRow = (=<<) put $ get >>= \st -> return $ st { currentRow = (currentRow st) + 1 }
+resetScrollBuffer = do
+ st <- get
+ case (mode st) of
+ MaildirMode -> do
+ let mst = (maildirState st) {
+ scrollBufferMD = EH.scrollCrop 0 (screenRows st) $ detectedMDs . maildirState $ st }
+ put st { maildirState = mst}
+ IndexMode -> do
+ let ist = (indexState st) {
+ scrollBufferIn = EH.scrollCrop 0 (screenRows st) $ selectedEmails . indexState $ st }
+ put st { indexState = ist }
+
liftCurses = lift . lift
liftUpdate = lift . lift
nihil fit ex nihilo