raart/t/draw.rkt

55 lines
1.4 KiB
Racket
Raw Normal View History

2018-01-02 00:22:00 +00:00
#lang racket/base
2018-01-02 16:18:09 +00:00
(require racket/format
raart)
2018-01-03 03:05:06 +00:00
(module+ test
(define here (make-output-buffer)))
2018-01-02 00:22:00 +00:00
(module+ test
2018-01-03 03:05:06 +00:00
(draw
here
(crop 1 80 1 20
;;70 80 10 20
(matte 80 20
#:halign 'right
(fg 'blue
(frame #:fg 'red
(inset
4 5
(happend (style 'underline (text "Left"))
(blank 4)
(style 'bold (text "Right")))))))))
2018-01-02 00:22:00 +00:00
(newline))
(module+ test
2018-01-03 03:05:06 +00:00
(draw
here
(translate
2 10
(table
#:frames? #t
#:inset-dw 2
#:valign 'center
#:halign '(right left left left)
(text-rows
`([ "ID" "First Name" "Last Name" "Grade"]
[70022 "John" "Smith" "A+"]
[ 22 "Macumber" "Stark" "B"]
[ 1223 "Sarah" ,(vappend (text "Top")
(text "Mid")
(text "Bot")) "C"])))))
2018-01-02 00:22:00 +00:00
(newline))
2018-01-02 16:18:09 +00:00
(module+ test
(define seen? (list))
2018-01-03 03:05:06 +00:00
(draw
here
2018-01-02 16:18:09 +00:00
(crop 0 80 70 10
(vappend*
#:halign 'left
(for/list ([i (in-range 80)])
(if-drawn
2018-01-09 18:20:08 +00:00
(λ (r c w h) (set! seen? (cons i seen?)))
2018-01-02 16:18:09 +00:00
(text (~a "Row " i)))))))
(newline)
(printf "Drawn: ~v\n" (reverse seen?)))