aboutsummaryrefslogtreecommitdiff
path: root/State.hs
diff options
context:
space:
mode:
authorRaúl Benencia <rul@kalgan.cc>2013-08-21 22:44:06 -0300
committerRaúl Benencia <rul@kalgan.cc>2013-08-21 22:44:06 -0300
commit92babe5d4ea236599f405380a8061ef21d69634e (patch)
tree976b77ded039539c6069d34cf801676e9abd46e3 /State.hs
parent0e6e62f317fc8a509eb127744620c6cb8e32f915 (diff)
Semi-functional core
Diffstat (limited to 'State.hs')
-rw-r--r--State.hs39
1 files changed, 29 insertions, 10 deletions
diff --git a/State.hs b/State.hs
index 3826bfc..76f200e 100644
--- a/State.hs
+++ b/State.hs
@@ -27,7 +27,8 @@ import Network.Email.Mailbox(Flag(..), Flags)
data Mode = MaildirMode | IndexMode | EmailMode
data MState = MState {
- selectedRow :: Integer
+ selectedRowMD :: Integer -- Selected row in MaildirMode
+ , selectedRowIn :: Integer -- Selected row in IndexMode
, mode :: Mode
, initPath :: String
, scrRows :: Integer
@@ -35,15 +36,18 @@ data MState = MState {
, curRow :: Integer
, colPadding :: Integer
, selectedColorID :: ColorID
+ , statusColorID :: ColorID
, selectedEmail :: Message
, selectedEmails :: [(String, [Flag], String)]
, selectedMD :: String
, detectedMDs :: [String]
- , exitRequested :: Bool
+ , exitRequested :: Bool
+ , showStatus :: Bool
}
initState = MState {
- selectedRow = 0
+ selectedRowMD = 0
+ , selectedRowIn = 0
, mode = MaildirMode
, initPath = ""
, scrRows = (-1)
@@ -51,22 +55,37 @@ initState = MState {
, curRow = 0
, colPadding = 0
, selectedColorID = defaultColorID
+ , statusColorID = defaultColorID
, selectedEmail = Message [] "Dummy email"
, selectedEmails = []
, selectedMD = ""
, detectedMDs = []
- , exitRequested = False
+ , exitRequested = False
+ , showStatus = True
}
incCurRow st = st { curRow = (curRow st) + 1 }
-incSelectedRow st | selectedRow st < fromIntegral limit = st { selectedRow = (selectedRow st) + 1 }
- | otherwise = st
+incSelectedRow st | (selectedRow st) < limit = case (mode st) of
+ MaildirMode -> st { selectedRowMD = (selectedRowMD st) + 1 }
+ IndexMode -> st { selectedRowIn = (selectedRowIn st) + 1 }
+ | otherwise = st
where
- limit = case (mode st) of
+ limit' = case (mode st) of
MaildirMode -> (length $ detectedMDs st ) - 1
IndexMode -> (length $ selectedEmails st) - 1
- _ -> fromIntegral $ scrRows st
+ limit = if (showStatus st) && (limit' == scrRowsAsInt st)
+ then fromIntegral $ limit' - 2
+ else fromIntegral limit'
-decSelectedRow st | selectedRow st > 0 = st { selectedRow = (selectedRow st) - 1 }
- | otherwise = st \ No newline at end of file
+decSelectedRow st | (selectedRow st) > 0 = case (mode st) of
+ MaildirMode -> st { selectedRowMD = (selectedRowMD st) - 1 }
+ IndexMode -> st { selectedRowIn = (selectedRowIn st) - 1 }
+ | otherwise = st
+
+selectedRow st = case (mode st) of
+ MaildirMode -> selectedRowMD st
+ IndexMode -> selectedRowIn st
+
+scrColsAsInt st = fromIntegral $ scrColumns st
+scrRowsAsInt st = fromIntegral $ scrRows st \ No newline at end of file
nihil fit ex nihilo