split mainLoop up into eventHandler and draw functions
This commit is contained in:
+11
-2
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user