-
Notifications
You must be signed in to change notification settings - Fork 164
/
Copy pathCroppingDemo.hs
61 lines (55 loc) · 1.59 KB
/
CroppingDemo.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Brick.Main (App(..), neverShowCursor, resizeOrQuit, defaultMain)
import Brick.Types
( Widget
)
import Brick.Widgets.Core
( vBox
, hBox
, txt
, (<=>)
, padRight
, cropLeftBy
, cropRightBy
, cropTopBy
, cropBottomBy
, cropLeftTo
, cropRightTo
, cropTopTo
, cropBottomTo
, Padding(..)
)
import Brick.Widgets.Border (border)
import Brick.AttrMap (attrMap)
import qualified Graphics.Vty as V
example :: Widget n
example =
border
(txt "Example" <=> txt "Widget")
mkExample :: Widget n -> Widget n
mkExample = padRight (Pad 2)
ui :: Widget ()
ui =
vBox [ txt "Uncropped" <=> example
, hBox [ mkExample $ txt "cropLeftBy 2" <=> cropLeftBy 2 example
, mkExample $ txt "cropRightBy 2" <=> cropRightBy 2 example
, mkExample $ txt "cropTopBy 2" <=> cropTopBy 2 example
, mkExample $ txt "cropBottomBy 2" <=> cropBottomBy 2 example
]
, hBox [ mkExample $ txt "cropLeftTo 4" <=> cropLeftTo 4 example
, mkExample $ txt "cropRightTo 4" <=> cropRightTo 4 example
, mkExample $ txt "cropTopTo 1" <=> cropTopTo 1 example
, mkExample $ txt "cropBottomTo 1" <=> cropBottomTo 1 example
]
]
app :: App () e ()
app =
App { appDraw = const [ui]
, appHandleEvent = resizeOrQuit
, appStartEvent = return ()
, appAttrMap = const $ attrMap V.defAttr []
, appChooseCursor = neverShowCursor
}
main :: IO ()
main = defaultMain app ()