mirror of
https://github.com/jtdaugherty/brick.git
synced 2024-11-26 09:06:56 +03:00
MouseDemo: move Vty handle operations into appStartEvent
This commit is contained in:
parent
2838263c22
commit
b0273b0109
@ -307,7 +307,8 @@ executable brick-mouse-demo
|
||||
microlens >= 0.3.0.0,
|
||||
microlens-th,
|
||||
microlens-mtl,
|
||||
text-zipper
|
||||
text-zipper,
|
||||
mtl
|
||||
|
||||
executable brick-layer-demo
|
||||
if !flag(demos)
|
||||
|
@ -7,6 +7,7 @@ import Lens.Micro ((^.))
|
||||
import Lens.Micro.TH (makeLenses)
|
||||
import Lens.Micro.Mtl
|
||||
import Control.Monad (void)
|
||||
import Control.Monad.Trans (liftIO)
|
||||
#if !(MIN_VERSION_base(4,11,0))
|
||||
import Data.Monoid ((<>))
|
||||
#endif
|
||||
@ -113,7 +114,9 @@ aMap = attrMap V.defAttr
|
||||
app :: M.App St e Name
|
||||
app =
|
||||
M.App { M.appDraw = drawUi
|
||||
, M.appStartEvent = return ()
|
||||
, M.appStartEvent = do
|
||||
vty <- M.getVtyHandle
|
||||
liftIO $ V.setMode (V.outputIface vty) V.Mouse True
|
||||
, M.appHandleEvent = appEvent
|
||||
, M.appAttrMap = const aMap
|
||||
, M.appChooseCursor = M.showFirstCursor
|
||||
@ -121,13 +124,7 @@ app =
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
let buildVty = do
|
||||
v <- V.mkVty =<< V.standardIOConfig
|
||||
V.setMode (V.outputIface v) V.Mouse True
|
||||
return v
|
||||
|
||||
initialVty <- buildVty
|
||||
void $ M.customMain initialVty buildVty Nothing app $ St [] Nothing
|
||||
void $ M.defaultMain app $ St [] Nothing
|
||||
(unlines [ "Try clicking on various UI elements."
|
||||
, "Observe that the click coordinates identify the"
|
||||
, "underlying widget coordinates."
|
||||
|
Loading…
Reference in New Issue
Block a user