switch from ncurses to brick #1

Merged
jlamothe merged 21 commits from brick into dev 2023-06-02 15:28:41 -04:00
3 changed files with 6 additions and 6 deletions
Showing only changes of commit 886cf0b243 - Show all commits

View File

@ -26,14 +26,13 @@ import Brick.Main (App (..), halt, showFirstCursor)
import Brick.Types (BrickEvent (VtyEvent), Widget) import Brick.Types (BrickEvent (VtyEvent), Widget)
import Brick.Util (on) import Brick.Util (on)
import Brick.Widgets.Core (fill) import Brick.Widgets.Core (fill)
import Control.Monad.State.Class (gets)
import Graphics.Vty.Attributes.Color (blue, white) import Graphics.Vty.Attributes.Color (blue, white)
import Graphics.Vty.Input.Events import Graphics.Vty.Input.Events
( Event (EvKey) ( Event (EvKey)
, Modifier (MCtrl) , Modifier (MCtrl)
, Key (KChar) , Key (KChar)
) )
import Lens.Micro (to)
import Lens.Micro.Mtl (use)
import Mtlstats.Control import Mtlstats.Control
import Mtlstats.Types import Mtlstats.Types
@ -57,7 +56,7 @@ draw s =
handler :: Handler () handler :: Handler ()
handler (VtyEvent (EvKey (KChar 'c') [MCtrl])) = halt handler (VtyEvent (EvKey (KChar 'c') [MCtrl])) = halt
handler e = do handler e = do
c <- use (to dispatch) c <- gets dispatch
handleController c e handleController c e
myAttrMap :: AttrMap myAttrMap :: AttrMap

View File

@ -24,6 +24,7 @@ module Mtlstats.Control.CreateGoalie (createGoalieC) where
import Brick.Widgets.Core (str) import Brick.Widgets.Core (str)
import Control.Monad.State.Class (gets, modify) import Control.Monad.State.Class (gets, modify)
import Lens.Micro ((^.), (.~), (?~), (%~), to) import Lens.Micro ((^.), (.~), (?~), (%~), to)
import Lens.Micro.Mtl ((.=))
import Mtlstats.Actions import Mtlstats.Actions
import Mtlstats.Format import Mtlstats.Format
@ -63,7 +64,7 @@ getActiveFlagC :: Controller
getActiveFlagC = Controller getActiveFlagC = Controller
{ drawController = const $ str "Is this goalie active? (Y/N)" { drawController = const $ str "Is this goalie active? (Y/N)"
, handleController = \e -> , handleController = \e ->
modify $ progMode.createGoalieStateL.cgsActiveFlag .~ ynHandler e progMode.createGoalieStateL.cgsActiveFlag .= ynHandler e
} }
confirmCreateGoalieC :: Controller confirmCreateGoalieC :: Controller

View File

@ -24,7 +24,7 @@ module Mtlstats.Control.CreatePlayer (createPlayerC) where
import Brick.Widgets.Core (str) import Brick.Widgets.Core (str)
import Control.Monad.State.Class (gets, modify) import Control.Monad.State.Class (gets, modify)
import Lens.Micro ((^.), (.~), (?~), (%~), to) import Lens.Micro ((^.), (.~), (?~), (%~), to)
import Lens.Micro.Mtl ((.=)) import Lens.Micro.Mtl ((.=), use)
import Mtlstats.Actions import Mtlstats.Actions
import Mtlstats.Format import Mtlstats.Format
@ -85,7 +85,7 @@ confirmCreatePlayerC = Controller
, "Create player: are you sure? (Y/N)" , "Create player: are you sure? (Y/N)"
] ]
, handleController = \e -> do , handleController = \e -> do
cps <- gets (^.progMode.createPlayerStateL) cps <- use $ progMode.createPlayerStateL
let let
success = cps^.cpsSuccessCallback success = cps^.cpsSuccessCallback
failure = cps^.cpsFailureCallback failure = cps^.cpsFailureCallback