aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Config.hs47
-rw-r--r--Lazymail.hs8
-rw-r--r--Main.hs2
-rw-r--r--State.hs93
4 files changed, 112 insertions, 38 deletions
diff --git a/Config.hs b/Config.hs
index b2d865b..39e227f 100644
--- a/Config.hs
+++ b/Config.hs
@@ -1,16 +1,35 @@
--- This module is part of Lazymail, a Haskell email client.
+{- Lazymail user configuration
+ -
+ - Copyright 2013 Raúl Benencia <rul@kalgan.cc>
+ -
+ - Licensed under the GNU GPL version 3 or higher
+ -
+ -}
+
+module Config(LazymailConfig(..), defaultConfig, customConfig) where
+
+import UI.NCurses(Color(..))
+import System.FilePath(FilePath)
+
+data LazymailConfig = LazymailConfig {
+ baseColor :: (Color, Color) -- (foreground, background)
+ , selectionColor :: (Color, Color)
+ , statusBarColor :: (Color, Color)
+ , showStatusBar :: Bool
+ , basePath :: Maybe FilePath
+}
+
+defaultConfig = LazymailConfig {
+ baseColor = (ColorWhite, ColorBlack)
+ , selectionColor = (ColorBlack, ColorWhite)
+ , statusBarColor = (ColorBlack, ColorWhite)
+ , showStatusBar = True
+ , basePath = Nothing
+}
+
--
--- Copyright (C) 2013 Raúl Benencia <rul@kalgan.cc>
+-- | Users should modify customConfig in order to set-up their
+-- preferences. In a possible future maybe I'll work in a not-so-crappy
+-- config system.
--
--- 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/>.
+customConfig = defaultConfig { basePath = "/home/rul/mail/kalgan" } \ No newline at end of file
diff --git a/Lazymail.hs b/Lazymail.hs
new file mode 100644
index 0000000..9347b2e
--- /dev/null
+++ b/Lazymail.hs
@@ -0,0 +1,8 @@
+{- Lazymail monad.
+ -
+ - Copyright 2013 Raúl Benencia <rul@kalgan.cc>
+ -
+ - Licensed under the GNU GPL version 3 or higher
+ -
+ -}
+
diff --git a/Main.hs b/Main.hs
index 1c79c07..5b3d6bc 100644
--- a/Main.hs
+++ b/Main.hs
@@ -15,7 +15,7 @@
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
-module Main where
+module Main (main) where
import System.Environment
import System.Exit
diff --git a/State.hs b/State.hs
index 76f200e..471ec1b 100644
--- a/State.hs
+++ b/State.hs
@@ -1,32 +1,78 @@
--- 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 state, and operations on it.
+ -
+ - Copyright 2013 Raúl Benencia <rul@kalgan.cc>
+ -
+ - Licensed under the GNU GPL version 3 or higher
+ -
+ -}
---
--- | The top level application state, and operations on that value.
---
module State where
import Text.ParserCombinators.Parsec.Rfc2822(Message, GenericMessage(..))
import UI.NCurses(ColorID(..), defaultColorID)
import Network.Email.Mailbox(Flag(..), Flags)
-data Mode = MaildirMode | IndexMode | EmailMode
+data Mode = MaildirMode | IndexMode | EmailMode | ComposeMode
-data MState = MState {
+data LazymailState = LazymailState {
+ mode :: Mode
+ , screenRows :: Int
+ , screenColumns :: Int
+ , currentRow :: Int
+ , columnPadding :: Int
+ , exitRequested :: Bool
+ , statusBar :: Bool
+ , maildirState :: MaildirState
+ , indexState :: IndexState
+ , composeState :: ComposeState
+}
+
+data MaildirState = MaildirState {
+ selectedRowMD :: Int
+ , selectedMD :: String
+ , detectedMDs :: [String]
+}
+
+data IndexState = IndexState {
+ selectedRowIn :: Int
+ , selectedEmail :: Message
+ , selectedEmails :: [(String, [Flag], String)]
+}
+
+data ComposeState = ComposeState {
+ composition :: Maybe String
+}
+
+initialState = LazymailState {
+ mode = MaildirMode
+ , screenRows = 0
+ , screenColumns = 0
+ , currentRow = 0
+ , columnPadding = 0
+ , exitRequested = False
+ , statusBar = True
+ , maildirState = initialMaildirState
+ , indexState = initialIndexState
+ , composeState = initialComposeState
+}
+
+initialMaildirState = MaildirState {
+ selectedRowMD = 0
+ , selectedMD = ""
+ , detectedMDs = []
+}
+
+initialIndexState = IndexState {
+ selectedRowIn = 0
+ , selectedEmail = Message [] "Dummy email"
+ , selectedEmails = []
+}
+
+initialComposeState = ComposeState {
+ composition = Nothing
+}
+
+{- data MState = MState {
selectedRowMD :: Integer -- Selected row in MaildirMode
, selectedRowIn :: Integer -- Selected row in IndexMode
, mode :: Mode
@@ -43,7 +89,7 @@ data MState = MState {
, detectedMDs :: [String]
, exitRequested :: Bool
, showStatus :: Bool
-}
+}
initState = MState {
selectedRowMD = 0
@@ -88,4 +134,5 @@ selectedRow st = case (mode st) of
IndexMode -> selectedRowIn st
scrColsAsInt st = fromIntegral $ scrColumns st
-scrRowsAsInt st = fromIntegral $ scrRows st \ No newline at end of file
+scrRowsAsInt st = fromIntegral $ scrRows st
+-} \ No newline at end of file
nihil fit ex nihilo