allow drawing functions to set cursor visibility
This commit is contained in:
parent
def2af7e64
commit
7e93b329b2
|
@ -38,8 +38,10 @@ import Mtlstats.Types
|
||||||
import Mtlstats.Types.Menu
|
import Mtlstats.Types.Menu
|
||||||
|
|
||||||
-- | The draw function for a 'Menu'
|
-- | The draw function for a 'Menu'
|
||||||
drawMenu :: Menu a -> C.Update ()
|
drawMenu :: Menu a -> C.Update C.CursorMode
|
||||||
drawMenu = C.drawString . show
|
drawMenu m = do
|
||||||
|
C.drawString $ show m
|
||||||
|
return C.CursorInvisible
|
||||||
|
|
||||||
-- | The event handler for a 'Menu'
|
-- | The event handler for a 'Menu'
|
||||||
menuHandler :: Menu a -> C.Event -> Action a
|
menuHandler :: Menu a -> C.Event -> Action a
|
||||||
|
|
|
@ -21,6 +21,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
module Mtlstats.UI (draw) where
|
module Mtlstats.UI (draw) where
|
||||||
|
|
||||||
|
import Control.Monad (void)
|
||||||
import Lens.Micro ((^.))
|
import Lens.Micro ((^.))
|
||||||
import qualified UI.NCurses as C
|
import qualified UI.NCurses as C
|
||||||
|
|
||||||
|
@ -30,8 +31,9 @@ import Mtlstats.Types
|
||||||
-- | Drawing function
|
-- | Drawing function
|
||||||
draw :: ProgState -> C.Curses ()
|
draw :: ProgState -> C.Curses ()
|
||||||
draw s = do
|
draw s = do
|
||||||
|
void $ C.setCursorMode C.CursorInvisible
|
||||||
w <- C.defaultWindow
|
w <- C.defaultWindow
|
||||||
C.updateWindow w $ do
|
cm <- C.updateWindow w $ do
|
||||||
C.clear
|
C.clear
|
||||||
case s ^. progMode of
|
case s ^. progMode of
|
||||||
MainMenu -> drawMenu mainMenu
|
MainMenu -> drawMenu mainMenu
|
||||||
|
@ -40,3 +42,4 @@ draw s = do
|
||||||
| null $ gs ^. gameType -> drawMenu gameTypeMenu
|
| null $ gs ^. gameType -> drawMenu gameTypeMenu
|
||||||
| otherwise ->undefined
|
| otherwise ->undefined
|
||||||
C.render
|
C.render
|
||||||
|
void $ C.setCursorMode cm
|
||||||
|
|
Loading…
Reference in New Issue
Block a user