mirror of
https://github.com/jtdaugherty/brick.git
synced 2024-11-29 21:46:11 +03:00
Merge simple demo
This commit is contained in:
commit
0c7914175a
11
brick.cabal
11
brick.cabal
@ -46,6 +46,17 @@ executable brick
|
|||||||
data-default,
|
data-default,
|
||||||
lens
|
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
|
executable brick-rogue
|
||||||
buildable: False
|
buildable: False
|
||||||
hs-source-dirs: programs
|
hs-source-dirs: programs
|
||||||
|
7
programs/Minimal.hs
Normal file
7
programs/Minimal.hs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
module Main where
|
||||||
|
|
||||||
|
import Brick.Main
|
||||||
|
import Brick.Prim
|
||||||
|
|
||||||
|
main :: IO ()
|
||||||
|
main = simpleMain [Txt "Hello, world!"]
|
@ -4,6 +4,8 @@ module Brick.Main
|
|||||||
, defaultMain
|
, defaultMain
|
||||||
, defaultMainWithVty
|
, defaultMainWithVty
|
||||||
|
|
||||||
|
, simpleMain
|
||||||
|
|
||||||
, supplyVtyEvents
|
, supplyVtyEvents
|
||||||
, withVty
|
, withVty
|
||||||
, runVty
|
, runVty
|
||||||
@ -30,6 +32,7 @@ import Graphics.Vty
|
|||||||
, nextEvent
|
, nextEvent
|
||||||
, mkVty
|
, mkVty
|
||||||
)
|
)
|
||||||
|
import System.Exit (exitSuccess)
|
||||||
|
|
||||||
import Brick.Prim (Prim)
|
import Brick.Prim (Prim)
|
||||||
import Brick.Prim.Internal (renderFinal)
|
import Brick.Prim.Internal (renderFinal)
|
||||||
@ -50,6 +53,13 @@ instance Default (App a e) where
|
|||||||
defaultMain :: App a Event -> a -> IO ()
|
defaultMain :: App a Event -> a -> IO ()
|
||||||
defaultMain = defaultMainWithVty (mkVty def)
|
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 :: IO Vty -> App a Event -> a -> IO ()
|
||||||
defaultMainWithVty buildVty app initialState = do
|
defaultMainWithVty buildVty app initialState = do
|
||||||
chan <- newChan
|
chan <- newChan
|
||||||
|
Loading…
Reference in New Issue
Block a user