Add tables and spinners

This commit is contained in:
Dimitri Lozeve 2021-11-22 18:29:40 +01:00
parent 51f5e862a3
commit ac81aeaddc
5 changed files with 77 additions and 3 deletions

22
table.scm Normal file
View file

@ -0,0 +1,22 @@
(define-record table names widths)
(define (column-text text width)
(string-append
" "
(parse-markup text)
(make-string (- width (string-length (remove-markup text)) 1) #\ )))
(define (table-header tab)
(string-append
"┌" (string-join (map (lambda (w) (make-string (+ 2 w) #\─)) (table-widths tab)) "┬") "┐\n"
"│" (string-join (map (lambda (name width) (column-text name (+ 2 width))) (table-names tab) (table-widths tab)) "│") "│\n"
"├" (string-join (map (lambda (w) (make-string (+ 2 w) #\─)) (table-widths tab)) "┼") "┤\n"))
(define (table-row tab . args)
(string-append
"│"
(string-join (map (lambda (text width) (column-text text (+ 2 width))) args (table-widths tab)) "│")
"│\n"))
(define (table-footer tab)
(string-append "└" (string-join (map (lambda (w) (make-string (+ 2 w) #\─)) (table-widths tab)) "┴") "┘\n"))