split mainLoop up into eventHandler and draw functions

This commit is contained in:
Jonathan Lamothe
2019-08-20 00:23:18 -04:00
parent 72f9d51977
commit 3fab328e17
4 changed files with 76 additions and 2 deletions
+11 -2
View File
@@ -21,10 +21,15 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
module Mtlstats (initState, mainLoop) where
import Control.Monad.Trans.State (StateT)
import Control.Monad.Extra (whenM)
import Control.Monad.Trans.Class (lift)
import Control.Monad.Trans.State (StateT, get)
import Data.Maybe (fromJust)
import qualified UI.NCurses as C
import Mtlstats.Events
import Mtlstats.Types
import Mtlstats.UI
-- | Initializes the progran
initState :: C.Curses ProgState
@@ -32,4 +37,8 @@ initState = return newProgState
-- | Main program loop
mainLoop :: StateT ProgState C.Curses ()
mainLoop = return ()
mainLoop = do
get >>= lift . draw
w <- lift C.defaultWindow
whenM (lift (fromJust <$> C.getEvent w Nothing) >>= handleEvent)
mainLoop