aboutsummaryrefslogtreecommitdiff
path: root/State.hs
diff options
context:
space:
mode:
Diffstat (limited to 'State.hs')
-rw-r--r--State.hs84
1 files changed, 31 insertions, 53 deletions
diff --git a/State.hs b/State.hs
index f4ac3d8..7ff8359 100644
--- a/State.hs
+++ b/State.hs
@@ -95,64 +95,42 @@ curRowAsInteger st = toInteger $ currentRow st
colPadAsInteger st = toInteger $ columnPadding st
-
-{- data MState = MState {
- selectedRowMD :: Integer -- Selected row in MaildirMode
- , selectedRowIn :: Integer -- Selected row in IndexMode
- , mode :: Mode
- , initPath :: String
- , scrRows :: Integer
- , scrColumns :: Integer
- , curRow :: Integer
- , colPadding :: Integer
- , selectedColorID :: ColorID
- , statusColorID :: ColorID
- , selectedEmail :: Message
- , selectedEmails :: [(String, [Flag], String)]
- , selectedMD :: String
- , detectedMDs :: [String]
- , exitRequested :: Bool
- , showStatus :: Bool
-}
-
-initState = MState {
- selectedRowMD = 0
- , selectedRowIn = 0
- , mode = MaildirMode
- , initPath = ""
- , scrRows = (-1)
- , scrColumns = (-1)
- , curRow = 0
- , colPadding = 0
- , selectedColorID = defaultColorID
- , statusColorID = defaultColorID
- , selectedEmail = Message [] "Dummy email"
- , selectedEmails = []
- , selectedMD = ""
- , detectedMDs = []
- , exitRequested = False
- , showStatus = True
-}
-
-incCurRow st = st { curRow = (curRow st) + 1 }
-
-incSelectedRow st | (selectedRow st) < limit = case (mode st) of
- MaildirMode -> st { selectedRowMD = (selectedRowMD st) + 1 }
- IndexMode -> st { selectedRowIn = (selectedRowIn st) + 1 }
- | otherwise = st
+incrementSelectedRow st | (selectedRow st) < limit = case (mode st) of
+ MaildirMode ->
+ let
+ sr = (selectedRowMD . maildirState) st
+ maildirState' = (maildirState st) { selectedRowMD = sr + 1 }
+ in
+ st { maildirState = maildirState' }
+ IndexMode ->
+ let
+ sr = (selectedRowIn . indexState) st
+ indexState' = (indexState st) { selectedRowIn = sr + 1 }
+ in
+ st { indexState = indexState' }
+ | otherwise = st
where
limit' = case (mode st) of
- MaildirMode -> (length $ detectedMDs st ) - 1
- IndexMode -> (length $ selectedEmails st) - 1
- limit = if (showStatus st) && (limit' == scrRowsAsInt st)
+ MaildirMode -> (length $ detectedMDs . maildirState $ st ) - 1
+ IndexMode -> (length $ selectedEmails . indexState $ st) - 1
+ limit = if (statusBar st) && (limit' == screenRows st)
then fromIntegral $ limit' - 2
else fromIntegral limit'
-decSelectedRow st | (selectedRow st) > 0 = case (mode st) of
- MaildirMode -> st { selectedRowMD = (selectedRowMD st) - 1 }
- IndexMode -> st { selectedRowIn = (selectedRowIn st) - 1 }
- | otherwise = st
--}
+decrementSelectedRow st | (selectedRow st) > 0 = case (mode st) of
+ MaildirMode ->
+ let
+ sr = (selectedRowMD . maildirState) st
+ maildirState' = (maildirState st) { selectedRowMD = sr - 1 }
+ in
+ st { maildirState = maildirState' }
+ IndexMode ->
+ let
+ sr = (selectedRowIn . indexState) st
+ indexState' = (indexState st) { selectedRowIn = sr - 1 }
+ in
+ st { indexState = indexState' }
+ | otherwise = st
selectedRow st = case (mode st) of
MaildirMode -> selectedRowMD . maildirState $ st
nihil fit ex nihilo