mirror of
https://github.com/jtdaugherty/brick.git
synced 2024-11-26 09:06:56 +03:00
Add resizeOrQuit for easy simple event handling
This commit is contained in:
parent
52bf9ec288
commit
2e3bef7f8e
@ -26,7 +26,7 @@ theMap = attrMap defAttr
|
||||
app :: App () Event
|
||||
app =
|
||||
App { appDraw = const [ui]
|
||||
, appHandleEvent = const halt
|
||||
, appHandleEvent = resizeOrQuit
|
||||
, appAttrMap = const theMap
|
||||
, appChooseCursor = neverShowCursor
|
||||
, appMakeVtyEvent = id
|
||||
|
@ -3,6 +3,7 @@ module Brick.Main
|
||||
, defaultMain
|
||||
, customMain
|
||||
, simpleMain
|
||||
, resizeOrQuit
|
||||
|
||||
, EventM
|
||||
, Next
|
||||
@ -71,15 +72,19 @@ defaultMain app st = do
|
||||
simpleMain :: Widget -> IO ()
|
||||
simpleMain w =
|
||||
let app = App { appDraw = const [w]
|
||||
, appHandleEvent = \e st -> case e of
|
||||
EvResize _ _ -> continue st
|
||||
_ -> halt st
|
||||
, appAttrMap = const $ attrMap def []
|
||||
, appHandleEvent = resizeOrQuit
|
||||
, appAttrMap = def
|
||||
, appMakeVtyEvent = id
|
||||
, appChooseCursor = neverShowCursor
|
||||
}
|
||||
in defaultMain app ()
|
||||
|
||||
resizeOrQuit :: Event -> a -> EventM (Next a)
|
||||
resizeOrQuit e a =
|
||||
case e of
|
||||
EvResize _ _ -> continue a
|
||||
_ -> halt a
|
||||
|
||||
data InternalNext a = InternalSuspendAndResume RenderState (IO a)
|
||||
| InternalHalt a
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user