on master help sign in
add a demo program to vty distribution
e010924Corey O'Connor
Demo.hsnew file+41
@@ -0,0 +1,41 @@
1+module Main where
2+
3+import Graphics.Vty
4+
5+import Control.Applicative
6+import Control.Arrow
7+import Control.Monad.RWS
8+
9+import Data.Default (def)
10+import Data.Sequence (Seq, (<|) )
11+import qualified Data.Sequence as Seq
12+import Data.Foldable
13+
14+eventBufferSize = 1000
15+
16+type App = RWST Vty () (Seq String) IO
17+
18+main = do
19+ vty <- mkVty def
20+ _ <- execRWST (vtyInteract False) vty Seq.empty
21+ shutdown vty
22+
23+vtyInteract :: Bool -> App ()
24+vtyInteract shouldExit = do
25+ updateDisplay
26+ unless shouldExit $ handleNextEvent >>= vtyInteract
27+
28+updateDisplay :: App ()
29+updateDisplay = do
30+ let info = string defAttr "Press ESC to exit."
31+ eventLog <- foldMap (string defAttr) <$> get
32+ let pic = picForImage $ info <-> eventLog
33+ vty <- ask
34+ liftIO $ update vty pic
35+
36+handleNextEvent = ask >>= liftIO . nextEvent >>= handleEvent
37+ where
38+ handleEvent e = do
39+ modify $ (<|) (show e) >>> Seq.take eventBufferSize
40+ return $ e == EvKey KEsc []
41+
vty.cabal+31−17
@@ -31,7 +31,7 @@ description:
31 &#169; 2006-2007 Stefan O'Rear; BSD3 license.
31 &#169; 2006-2007 Stefan O'Rear; BSD3 license.
32 .
32 .
33 &#169; Corey O'Connor; BSD3 license.
33 &#169; Corey O'Connor; BSD3 license.
34−cabal-version: >= 1.18.0
34+cabal-version: >= 1.20.0
35build-type: Simple
35build-type: Simple
36data-files: README.md,
36data-files: README.md,
37 TODO,
37 TODO,
@@ -116,6 +116,20 @@ library
116
116
117 cc-options: -O2 -fpic
117 cc-options: -O2 -fpic
118
118
119+executable vty-demo
120+ main-is: Demo.hs
121+
122+ default-language: Haskell2010
123+ default-extensions: ScopedTypeVariables
124+ ghc-options: -threaded
125+
126+ build-depends: vty,
127+ base >= 4 && < 5,
128+ containers,
129+ data-default >= 0.5.3,
130+ lens,
131+ mtl >= 1.1.1.0 && < 2.2
132+
119test-suite verify-attribute-ops
133test-suite verify-attribute-ops
120 default-language: Haskell2010
134 default-language: Haskell2010
121 default-extensions: ScopedTypeVariables
135 default-extensions: ScopedTypeVariables
@@ -123,7 +137,7 @@ test-suite verify-attribute-ops
123 hs-source-dirs: test
137 hs-source-dirs: test
124 test-module: VerifyAttributeOps
138 test-module: VerifyAttributeOps
125 build-depends: vty,
139 build-depends: vty,
126− Cabal == 1.18.*,
140+ Cabal == 1.20.*,
127 QuickCheck >= 2.4,
141 QuickCheck >= 2.4,
128 random == 1.0.*,
142 random == 1.0.*,
129 base >= 4 && < 5,
143 base >= 4 && < 5,
@@ -155,7 +169,7 @@ test-suite verify-using-mock-terminal
155 Verify.Graphics.Vty.Output
169 Verify.Graphics.Vty.Output
156
170
157 build-depends: vty,
171 build-depends: vty,
158− Cabal == 1.18.*,
172+ Cabal == 1.20.*,
159 QuickCheck >= 2.4,
173 QuickCheck >= 2.4,
160 random == 1.0.*,
174 random == 1.0.*,
161 base >= 4 && < 5,
175 base >= 4 && < 5,
@@ -188,7 +202,7 @@ test-suite verify-terminal
188 Verify.Graphics.Vty.Output
202 Verify.Graphics.Vty.Output
189
203
190 build-depends: vty,
204 build-depends: vty,
191− Cabal == 1.18.*,
205+ Cabal == 1.20.*,
192 QuickCheck >= 2.4,
206 QuickCheck >= 2.4,
193 random == 1.0.*,
207 random == 1.0.*,
194 base >= 4 && < 5,
208 base >= 4 && < 5,
@@ -220,7 +234,7 @@ test-suite verify-display-attributes
220 Verify.Graphics.Vty.Span
234 Verify.Graphics.Vty.Span
221
235
222 build-depends: vty,
236 build-depends: vty,
223− Cabal == 1.18.*,
237+ Cabal == 1.20.*,
224 QuickCheck >= 2.4,
238 QuickCheck >= 2.4,
225 random == 1.0.*,
239 random == 1.0.*,
226 base >= 4 && < 5,
240 base >= 4 && < 5,
@@ -246,7 +260,7 @@ test-suite verify-empty-image-props
246 other-modules: Verify
260 other-modules: Verify
247
261
248 build-depends: vty,
262 build-depends: vty,
249− Cabal == 1.18.*,
263+ Cabal == 1.20.*,
250 QuickCheck >= 2.4,
264 QuickCheck >= 2.4,
251 random == 1.0.*,
265 random == 1.0.*,
252 base >= 4 && < 5,
266 base >= 4 && < 5,
@@ -273,7 +287,7 @@ test-suite verify-eval-terminfo-caps
273 Verify.Graphics.Vty.Output
287 Verify.Graphics.Vty.Output
274
288
275 build-depends: vty,
289 build-depends: vty,
276− Cabal == 1.18.*,
290+ Cabal == 1.20.*,
277 QuickCheck >= 2.4,
291 QuickCheck >= 2.4,
278 random == 1.0.*,
292 random == 1.0.*,
279 base >= 4 && < 5,
293 base >= 4 && < 5,
@@ -303,7 +317,7 @@ test-suite verify-image-ops
303 Verify.Graphics.Vty.Image
317 Verify.Graphics.Vty.Image
304
318
305 build-depends: vty,
319 build-depends: vty,
306− Cabal == 1.18.*,
320+ Cabal == 1.20.*,
307 QuickCheck >= 2.4,
321 QuickCheck >= 2.4,
308 random == 1.0.*,
322 random == 1.0.*,
309 base >= 4 && < 5,
323 base >= 4 && < 5,
@@ -331,7 +345,7 @@ test-suite verify-image-trans
331 Verify.Graphics.Vty.Image
345 Verify.Graphics.Vty.Image
332
346
333 build-depends: vty,
347 build-depends: vty,
334− Cabal == 1.18.*,
348+ Cabal == 1.20.*,
335 QuickCheck >= 2.4,
349 QuickCheck >= 2.4,
336 random == 1.0.*,
350 random == 1.0.*,
337 base >= 4 && < 5,
351 base >= 4 && < 5,
@@ -358,7 +372,7 @@ test-suite verify-inline
358 Verify.Graphics.Vty.Output
372 Verify.Graphics.Vty.Output
359
373
360 build-depends: vty,
374 build-depends: vty,
361− Cabal == 1.18.*,
375+ Cabal == 1.20.*,
362 QuickCheck >= 2.4,
376 QuickCheck >= 2.4,
363 random == 1.0.*,
377 random == 1.0.*,
364 base >= 4 && < 5,
378 base >= 4 && < 5,
@@ -386,7 +400,7 @@ test-suite verify-parse-terminfo-caps
386 Verify.Graphics.Vty.Output
400 Verify.Graphics.Vty.Output
387
401
388 build-depends: vty,
402 build-depends: vty,
389− Cabal == 1.18.*,
403+ Cabal == 1.20.*,
390 QuickCheck >= 2.4,
404 QuickCheck >= 2.4,
391 random == 1.0.*,
405 random == 1.0.*,
392 base >= 4 && < 5,
406 base >= 4 && < 5,
@@ -418,7 +432,7 @@ test-suite verify-simple-span-generation
418 Verify.Graphics.Vty.Span
432 Verify.Graphics.Vty.Span
419
433
420 build-depends: vty,
434 build-depends: vty,
421− Cabal == 1.18.*,
435+ Cabal == 1.20.*,
422 QuickCheck >= 2.4,
436 QuickCheck >= 2.4,
423 random == 1.0.*,
437 random == 1.0.*,
424 base >= 4 && < 5,
438 base >= 4 && < 5,
@@ -450,7 +464,7 @@ test-suite verify-crop-span-generation
450 Verify.Graphics.Vty.Span
464 Verify.Graphics.Vty.Span
451
465
452 build-depends: vty,
466 build-depends: vty,
453− Cabal == 1.18.*,
467+ Cabal == 1.20.*,
454 QuickCheck >= 2.4,
468 QuickCheck >= 2.4,
455 random == 1.0.*,
469 random == 1.0.*,
456 base >= 4 && < 5,
470 base >= 4 && < 5,
@@ -482,7 +496,7 @@ test-suite verify-layers-span-generation
482 Verify.Graphics.Vty.Span
496 Verify.Graphics.Vty.Span
483
497
484 build-depends: vty,
498 build-depends: vty,
485− Cabal == 1.18.*,
499+ Cabal == 1.20.*,
486 QuickCheck >= 2.4,
500 QuickCheck >= 2.4,
487 random == 1.0.*,
501 random == 1.0.*,
488 base >= 4 && < 5,
502 base >= 4 && < 5,
@@ -508,7 +522,7 @@ test-suite verify-utf8-width
508 other-modules: Verify
522 other-modules: Verify
509
523
510 build-depends: vty,
524 build-depends: vty,
511− Cabal == 1.18.*,
525+ Cabal == 1.20.*,
512 QuickCheck >= 2.4,
526 QuickCheck >= 2.4,
513 random == 1.0.*,
527 random == 1.0.*,
514 base >= 4 && < 5,
528 base >= 4 && < 5,
@@ -532,7 +546,7 @@ test-suite verify-using-mock-input
532 main-is: VerifyUsingMockInput.hs
546 main-is: VerifyUsingMockInput.hs
533
547
534 build-depends: vty,
548 build-depends: vty,
535− Cabal == 1.18.*,
549+ Cabal == 1.20.*,
536 data-default >= 0.5.3,
550 data-default >= 0.5.3,
537 QuickCheck >= 2.4,
551 QuickCheck >= 2.4,
538 smallcheck == 1.*,
552 smallcheck == 1.*,
@@ -565,7 +579,7 @@ test-suite verify-config
565 main-is: VerifyConfig.hs
579 main-is: VerifyConfig.hs
566
580
567 build-depends: vty,
581 build-depends: vty,
568− Cabal == 1.18.*,
582+ Cabal == 1.20.*,
569 data-default >= 0.5.3,
583 data-default >= 0.5.3,
570 HUnit,
584 HUnit,
571 QuickCheck >= 2.4,
585 QuickCheck >= 2.4,