allow drawing functions to set cursor visibility

This commit is contained in:
Jonathan Lamothe 2019-08-22 16:53:31 -04:00
parent def2af7e64
commit 7e93b329b2
2 changed files with 8 additions and 3 deletions

View File

@ -38,8 +38,10 @@ import Mtlstats.Types
import Mtlstats.Types.Menu
-- | The draw function for a 'Menu'
drawMenu :: Menu a -> C.Update ()
drawMenu = C.drawString . show
drawMenu :: Menu a -> C.Update C.CursorMode
drawMenu m = do
C.drawString $ show m
return C.CursorInvisible
-- | The event handler for a 'Menu'
menuHandler :: Menu a -> C.Event -> Action a

View File

@ -21,6 +21,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
module Mtlstats.UI (draw) where
import Control.Monad (void)
import Lens.Micro ((^.))
import qualified UI.NCurses as C
@ -30,8 +31,9 @@ import Mtlstats.Types
-- | Drawing function
draw :: ProgState -> C.Curses ()
draw s = do
void $ C.setCursorMode C.CursorInvisible
w <- C.defaultWindow
C.updateWindow w $ do
cm <- C.updateWindow w $ do
C.clear
case s ^. progMode of
MainMenu -> drawMenu mainMenu
@ -40,3 +42,4 @@ draw s = do
| null $ gs ^. gameType -> drawMenu gameTypeMenu
| otherwise ->undefined
C.render
void $ C.setCursorMode cm