Merge simple demo

This commit is contained in:
Jonathan Daugherty 2015-05-19 10:25:12 -07:00
commit 0c7914175a
3 changed files with 28 additions and 0 deletions

View File

@ -46,6 +46,17 @@ executable brick
data-default,
lens
executable brick-minimal
hs-source-dirs: programs
ghc-options: -threaded -Wall -fno-warn-unused-do-bind
default-language: Haskell2010
main-is: Minimal.hs
build-depends: base,
brick,
vty >= 5.2.9,
data-default,
lens
executable brick-rogue
buildable: False
hs-source-dirs: programs

7
programs/Minimal.hs Normal file
View File

@ -0,0 +1,7 @@
module Main where
import Brick.Main
import Brick.Prim
main :: IO ()
main = simpleMain [Txt "Hello, world!"]

View File

@ -4,6 +4,8 @@ module Brick.Main
, defaultMain
, defaultMainWithVty
, simpleMain
, supplyVtyEvents
, withVty
, runVty
@ -30,6 +32,7 @@ import Graphics.Vty
, nextEvent
, mkVty
)
import System.Exit (exitSuccess)
import Brick.Prim (Prim)
import Brick.Prim.Internal (renderFinal)
@ -50,6 +53,13 @@ instance Default (App a e) where
defaultMain :: App a Event -> a -> IO ()
defaultMain = defaultMainWithVty (mkVty def)
simpleMain :: [Prim ()] -> IO ()
simpleMain ls =
let app = def { appDraw = const ls
, appHandleEvent = const $ const exitSuccess
}
in defaultMain app ()
defaultMainWithVty :: IO Vty -> App a Event -> a -> IO ()
defaultMainWithVty buildVty app initialState = do
chan <- newChan