README: add simple demo UI and corresponding program

This commit is contained in:
Jonathan Daugherty 2017-03-11 20:31:55 -08:00
parent 2792b309e1
commit 14871549a1
3 changed files with 51 additions and 0 deletions

View File

@ -22,6 +22,30 @@ will be helpful in using this library.
This library deprecates [vty-ui](https://github.com/jtdaugherty/vty-ui). This library deprecates [vty-ui](https://github.com/jtdaugherty/vty-ui).
Example
-------
Here's an example interface that resizes automatically when the terminal
size changes (see `programs/ReadmeDemo.hs`):
```
withBorderStyle unicode $
borderWithLabel (str "Hello!") $
(center (str "Left") <+> vBorder <+> center (str "Right"))
```
Result:
```
┌─────────Hello!─────────┐
│ │ │
│ │ │
│ Left │ Right │
│ │ │
│ │ │
└────────────────────────┘
```
Getting Started Getting Started
--------------- ---------------

View File

@ -94,6 +94,18 @@ library
template-haskell, template-haskell,
deepseq >= 1.3 && < 1.5 deepseq >= 1.3 && < 1.5
executable brick-readme-demo
if !flag(demos)
Buildable: False
hs-source-dirs: programs
ghc-options: -threaded -Wall -fno-warn-unused-do-bind -O3
default-language: Haskell2010
default-extensions: CPP
main-is: ReadmeDemo.hs
build-depends: base,
brick,
text
executable brick-cache-demo executable brick-cache-demo
if !flag(demos) if !flag(demos)
Buildable: False Buildable: False

15
programs/ReadmeDemo.hs Normal file
View File

@ -0,0 +1,15 @@
module Main where
import Brick
import Brick.Widgets.Center
import Brick.Widgets.Border
import Brick.Widgets.Border.Style
ui :: Widget ()
ui =
withBorderStyle unicode $
borderWithLabel (str "Hello!") $
(center (str "Left") <+> vBorder <+> center (str "Right"))
main :: IO ()
main = simpleMain ui