From 2af0357d460ac9bcf97c2a75173be5f93f529090 Mon Sep 17 00:00:00 2001 From: Jonathan Daugherty Date: Tue, 19 May 2015 10:23:58 -0700 Subject: [PATCH] Add ultra-minimal demo program --- brick.cabal | 11 +++++++++++ programs/Minimal.hs | 7 +++++++ src/Brick/Main.hs | 10 ++++++++++ 3 files changed, 28 insertions(+) create mode 100644 programs/Minimal.hs diff --git a/brick.cabal b/brick.cabal index 1f80bbe..5872e01 100644 --- a/brick.cabal +++ b/brick.cabal @@ -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 diff --git a/programs/Minimal.hs b/programs/Minimal.hs new file mode 100644 index 0000000..26a8b41 --- /dev/null +++ b/programs/Minimal.hs @@ -0,0 +1,7 @@ +module Main where + +import Brick.Main +import Brick.Prim + +main :: IO () +main = simpleMain [Txt "Hello, world!"] diff --git a/src/Brick/Main.hs b/src/Brick/Main.hs index 0f92682..13f784b 100644 --- a/src/Brick/Main.hs +++ b/src/Brick/Main.hs @@ -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