mirror of
https://github.com/jtdaugherty/brick.git
synced 2024-11-29 10:54:48 +03:00
README: add simple demo UI and corresponding program
This commit is contained in:
parent
2792b309e1
commit
14871549a1
24
README.md
24
README.md
@ -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
|
||||||
---------------
|
---------------
|
||||||
|
|
||||||
|
12
brick.cabal
12
brick.cabal
@ -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
15
programs/ReadmeDemo.hs
Normal 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
|
Loading…
Reference in New Issue
Block a user