diff --git a/programs/MarkupDemo.hs b/programs/MarkupDemo.hs index 3159575..b487a88 100644 --- a/programs/MarkupDemo.hs +++ b/programs/MarkupDemo.hs @@ -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 diff --git a/src/Brick/Main.hs b/src/Brick/Main.hs index 0f522f0..5a9f2b4 100644 --- a/src/Brick/Main.hs +++ b/src/Brick/Main.hs @@ -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