aboutsummaryrefslogtreecommitdiff
path: root/Screen.hs
diff options
context:
space:
mode:
authorRaúl Benencia <rul@kalgan.cc>2013-08-24 17:12:14 -0300
committerRaúl Benencia <rul@kalgan.cc>2013-08-24 17:12:14 -0300
commit4728bb04b2f5daff7a2ed8c30dd0fd8a8ee9539b (patch)
treee1470ff4f60e64c52927ff590ceaeef8461bd886 /Screen.hs
parentfc1231ca6e008582fb6a669cb9d0607059e82cdd (diff)
Advancing with monad transformers
Diffstat (limited to 'Screen.hs')
-rw-r--r--Screen.hs53
1 files changed, 35 insertions, 18 deletions
diff --git a/Screen.hs b/Screen.hs
index df6ed92..22587cb 100644
--- a/Screen.hs
+++ b/Screen.hs
@@ -1,35 +1,50 @@
--- This module is part of Lazymail, a Haskell email client.
---
--- Copyright (C) 2013 Raúl Benencia <rul@kalgan.cc>
---
--- This program is free software: you can redistribute it and/or modify
--- it under the terms of the GNU General Public License as published by
--- the Free Software Foundation, either version 3 of the License, or
--- (at your option) any later version.
---
--- This program is distributed in the hope that it will be useful,
--- but WITHOUT ANY WARRANTY; without even the implied warranty of
--- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
--- GNU General Public License for more details.
---
--- You should have received a copy of the GNU General Public License
--- along with this program. If not, see <http://www.gnu.org/licenses/>.
+{- Lazymail interaction with curses.
+ -
+ - Copyright 2013 Raúl Benencia <rul@kalgan.cc>
+ -
+ - Licensed under the GNU GPL version 3 or higher
+ -
+ -}
module Screen where
import Control.Monad.Trans(liftIO)
+import Control.Monad.Reader
+import Control.Monad.State
import Data.List(isPrefixOf)
-import UI.NCurses
+import UI.NCurses as UI
import Text.ParserCombinators.Parsec.Rfc2822(Message(..))
-- Local imports
+import Config
+import Lazymail
import Maildir
import Email
import Print
import Rfc1342
import State
--- | Main entry point
+type LazymailCurses = ReaderT LazymailConfig (StateT LazymailState Curses)
+liftCurses = lift . lift
+
+entryPoint :: Lazymail ()
+entryPoint = do
+ st <- get
+ cfg <- ask
+ maildirs <- liftIO $ getMaildirsRecursively $ basePath st
+ liftIO $ runCurses $ runStateT (runReaderT startCurses cfg) st
+ return ()
+
+startCurses :: LazymailCurses ()
+startCurses = do
+ st <- get
+ (rows, columns) <- liftCurses $ do
+ UI.setEcho False
+ UI.screenSize
+
+ return ()
+
+{-- | Main entry point
entryPoint :: MState -> IO ()
entryPoint st' = do
maildirs <- getMaildirsRecursively (initPath st')
@@ -203,3 +218,5 @@ handleEvent st = loop where
return $ st { mode = IndexMode, selectedEmails = selEmails }
_ -> loop
+
+-} \ No newline at end of file
nihil fit ex nihilo