aboutsummaryrefslogtreecommitdiff
path: root/State.hs
diff options
context:
space:
mode:
authorRaúl Benencia <rul@kalgan.cc>2013-08-27 15:03:04 -0300
committerRaúl Benencia <rul@kalgan.cc>2013-08-27 15:03:04 -0300
commitfab15274bae93611f85dd4cc221ce07b1661a081 (patch)
tree1023af4c4b664ade52466babadf3dc95864aab1e /State.hs
parentf21a1f23ab53ab628ed2677c8d85869fa7e22b45 (diff)
Smoother scrolling in index mode
Diffstat (limited to 'State.hs')
-rw-r--r--State.hs33
1 files changed, 19 insertions, 14 deletions
diff --git a/State.hs b/State.hs
index 5b91d15..7613cf1 100644
--- a/State.hs
+++ b/State.hs
@@ -37,12 +37,13 @@ data MaildirState = MaildirState {
}
data IndexState = IndexState {
- selectedRowIn :: Int
- , selectedEmail :: Message
- , selectedEmails :: [FilePath]
- , scrollRowIn :: Int
- , currentInLen :: Int
- , scrollBufferIn :: [FilePath]
+ selectedRowIn :: Int
+ , selectedEmail :: Message
+ , selectedEmailPath :: FilePath
+ , selectedEmails :: [(FilePath, String)]
+ , scrollRowIn :: Int
+ , currentInLen :: Int
+ , scrollBufferIn :: [(FilePath, String)]
}
data ComposeState = ComposeState {
@@ -77,12 +78,13 @@ initialMaildirState = MaildirState {
}
initialIndexState = IndexState {
- selectedRowIn = 0
- , selectedEmail = Message [] "Dummy email"
- , selectedEmails = []
- , scrollRowIn = 0
- , currentInLen = 0
- , scrollBufferIn = []
+ selectedRowIn = 0
+ , selectedEmail = Message [] "Dummy email"
+ , selectedEmailPath = ""
+ , selectedEmails = []
+ , scrollRowIn = 0
+ , currentInLen = 0
+ , scrollBufferIn = []
}
initialComposeState = ComposeState {
@@ -118,10 +120,13 @@ incrementSelectedRow st | (selectedRow st) < limit =
_ -> st
| otherwise = st
where
+ scrRows = screenRows st
limit' = case (mode st) of
MaildirMode -> (length $ detectedMDs . maildirState $ st ) - 1
- IndexMode -> (length $ selectedEmails . indexState $ st) - 1
- limit = if (statusBar st) && (limit' == screenRows st)
+ IndexMode -> if (currentInLen . indexState $ st) < scrRows
+ then (currentInLen . indexState $ st) - 1
+ else scrRows
+ limit = if (statusBar st) && (limit' == scrRows)
then fromIntegral $ limit' - 2
else fromIntegral limit'
nihil fit ex nihilo