diff options
author | Raúl Benencia <rul@kalgan.cc> | 2013-09-03 00:00:50 -0300 |
---|---|---|
committer | Raúl Benencia <rul@kalgan.cc> | 2013-09-03 00:00:50 -0300 |
commit | e41dd5091f597e2252deb9ecbde900eda7c15614 (patch) | |
tree | b60a532b67aa9932dd0af9a00daf5735e496812b /Types.hs | |
parent | 56b4aef769386e9fbe3b074698451e8b74489d61 (diff) |
Sorted index mode
Diffstat (limited to 'Types.hs')
-rw-r--r-- | Types.hs | 95 |
1 files changed, 86 insertions, 9 deletions
@@ -5,18 +5,95 @@ - Licensed under the GNU GPL version 3 or higher -} -module Types - ( - LazymailUpdate - , LazymailCurses - ) where +module Types where +import Codec.MIME.Type(MIMEValue(..)) import Control.Monad.Reader(ReaderT) import Control.Monad.State(StateT) -import UI.NCurses(Curses, Update) - -import Config (LazymailConfig) -import State (LazymailState) +import Data.DateTime(DateTime) +import System.FilePath(FilePath) +import UI.NCurses(Curses, Update, Color(..), ColorID) type LazymailUpdate = ReaderT LazymailConfig (StateT LazymailState Update) type LazymailCurses = ReaderT LazymailConfig (StateT LazymailState Curses) + +{- Lazymail monad is a ReaderT around a StateT with IO at the bottom of the + - stack. + -} +type Lazymail = ReaderT LazymailConfig (StateT LazymailState IO) + +data LazymailConfig = LazymailConfig { + baseColor :: (Color, Color) -- (foreground, background) + , selectionColor :: (Color, Color) + , statusBarColor :: (Color, Color) + , headerColor :: (Color, Color) + , showStatusBar :: Bool + , initialPath :: FilePath + , filterMaildirsHook :: [FilePath] -> IO [FilePath] + , indexDateFormat :: String +} + +data Email = Email { + emailValue :: MIMEValue + , emailDate :: DateTime + , emailPath :: FilePath +} + +instance Eq Email where + (Email _ _ fp1) == (Email _ _ fp2) = fp1 == fp2 + +instance Ord Email where + (Email _ d1 _) `compare` (Email _ d2 _) = d1 `compare` d2 + +data Mode = MaildirMode | IndexMode | EmailMode | ComposeMode + +data LazymailState = LazymailState { + mode :: Mode + , basePath :: FilePath + , screenRows :: Int + , screenColumns :: Int + , currentRow :: Int + , columnPadding :: Int + , exitRequested :: Bool + , statusBar :: Bool + , maildirState :: MaildirState + , indexState :: IndexState + , emailState :: EmailState + , composeState :: ComposeState + , colorStyle :: ColorStyle +} + +data MaildirState = MaildirState { + selectedRowMD :: Int + , selectedMD :: String + , detectedMDs :: [(FilePath, String)] + , scrollRowMD :: Int + , scrollBufferMD :: [(FilePath, String)] +} + +data IndexState = IndexState { + selectedRowIn :: Int + , selectedEmailPath :: FilePath + , selectedEmails :: [Email] + , scrollRowIn :: Int + , currentInLen :: Int + , scrollBufferIn :: [(FilePath, String)] +} + +data ComposeState = ComposeState { + composition :: Maybe String +} + +data EmailState = EmailState { + scrollRowEm :: Int + , bodyStartRow :: Int + , emailLines :: [String] + , currentEmail :: MIMEValue +} + +data ColorStyle = ColorStyle { + baseColorID :: ColorID + , selectionColorID :: ColorID + , statusBarColorID :: ColorID + , headerColorID :: ColorID +} |