mirror of
https://github.com/jtdaugherty/brick.git
synced 2024-11-29 21:46:11 +03:00
33 lines
729 B
Haskell
33 lines
729 B
Haskell
|
{-# LANGUAGE TypeApplications #-}
|
||
|
module Render
|
||
|
( main,
|
||
|
)
|
||
|
|
||
|
where
|
||
|
|
||
|
import Brick
|
||
|
import qualified Graphics.Vty as V
|
||
|
import Brick.Widgets.Border (hBorder)
|
||
|
|
||
|
region :: V.DisplayRegion
|
||
|
region = (30, 10)
|
||
|
|
||
|
renderToPicture :: Ord n => [Widget n] -> V.Picture
|
||
|
renderToPicture ws = let (p, _, _) = renderWidget (attrMap V.defAttr []) ws region (const Nothing) in p
|
||
|
|
||
|
renderDisplay :: Ord n => [Widget n] -> IO ()
|
||
|
renderDisplay ws = do
|
||
|
outp <- V.outputForConfig V.defaultConfig
|
||
|
ctx <- V.displayContext outp region
|
||
|
V.outputPicture ctx (renderToPicture ws)
|
||
|
|
||
|
ui :: Widget ()
|
||
|
ui = str "Hello, world!"
|
||
|
|
||
|
main :: IO Bool
|
||
|
main =
|
||
|
do
|
||
|
renderDisplay [ui]
|
||
|
renderDisplay @() [str "why" <=> hBorder <=> str "not"]
|
||
|
return True
|