Use non-breaking spaces for alignment.

This commit is contained in:
Dominik Pantůček 2023-06-15 22:42:39 +02:00
parent cc9e5bad7d
commit f1c3ec70a3
6 changed files with 36 additions and 25 deletions

View file

@ -410,7 +410,8 @@ sgr-list.o: sgr-list.import.scm
sgr-list.import.scm: $(SGR-LIST-SOURCES) sgr-list.import.scm: $(SGR-LIST-SOURCES)
SGR-BLOCK-SOURCES=sgr-block.scm racket-kwargs.import.scm \ SGR-BLOCK-SOURCES=sgr-block.scm racket-kwargs.import.scm \
sgr-state.import.scm sgr-list.import.scm testing.import.scm sgr-state.import.scm sgr-list.import.scm testing.import.scm \
util-utf8.import.scm
sgr-block.o: sgr-block.import.scm sgr-block.o: sgr-block.import.scm
sgr-block.import.scm: $(SGR-BLOCK-SOURCES) sgr-block.import.scm: $(SGR-BLOCK-SOURCES)

View file

@ -109,20 +109,23 @@
(brmember-credit mr)) (brmember-credit mr))
#:border '(((#:right light) ... none) ...)))) #:border '(((#:right light) ... none) ...))))
((suspend student member council chair revision grant) ((suspend student member council chair revision grant)
(list k (let* ((pdata (cons (list "Since" "Until")
(table->string (map
(cons (list "Since" "Until") (lambda (p)
(map (list
(lambda (p) (string-append (cal-day/month->string
(list (cal-period-since p)) " "
(string-append (cal-day/month->string (or (cal-period-scomment p) ""))
(cal-period-since p)) " " (string-append (cal-day/month->string
(or (cal-period-scomment p) "")) (cal-period-before p)) " "
(string-append (cal-day/month->string (or (cal-period-bcomment p) ""))))
(cal-period-before p)) " " v)))
(or (cal-period-bcomment p) "")))) (ptbl (table->string
v)) pdata
#:border '(((#:right light) ... none) ...)))) #:border '(((#:right light) ... none) ...))))
;;(print pdata)
;;(write ptbl)(newline)
(list k ptbl)))
(else (else
(if v (if v
(list k v) (list k v)
@ -132,10 +135,11 @@
(mailman (list (list "Mailing Lists" (mailman (list (list "Mailing Lists"
(string-intersperse (brmember-mailman mr) "\n")))) (string-intersperse (brmember-mailman mr) "\n"))))
(result (filter identity (append head body mailman)))) (result (filter identity (append head body mailman))))
;;(write result)(newline)
(table->string result (table->string result
#:border '(((#:bottom #:right light) ... (#:bottom light)) #:border '(((#:bottom #:right light) ... (#:bottom light))
((#:right light) ... none) ...
...) ((#:right light) ... none))
#:ansi-reset? #t))) #:ansi-reset? #t)))
;; Prints nicely formatted table ;; Prints nicely formatted table

View file

@ -49,7 +49,8 @@
racket-kwargs racket-kwargs
sgr-state sgr-state
sgr-list sgr-list
testing) testing
util-utf8)
;; Converts sgr-list (possibly containing multiple lines) into a ;; Converts sgr-list (possibly containing multiple lines) into a
;; sgr-block ;; sgr-block
@ -101,7 +102,7 @@
;; Creates filler for justification of SGR lines ;; Creates filler for justification of SGR lines
(define (make-sgr-list-filler n) (define (make-sgr-list-filler n)
(cons (make-string n #\space) n)) (cons (make-utf8-string n #\xA0) n))
;; If first or last non-sgr-state token is space, removes it, ;; If first or last non-sgr-state token is space, removes it,
;; converts all spaces to glues. Removes unglue. ;; converts all spaces to glues. Removes unglue.
@ -172,14 +173,14 @@
(if (sgr-token-glue? tk) (if (sgr-token-glue? tk)
(loop (cdr gluelens) (loop (cdr gluelens)
(cdr sl) (cdr sl)
(cons (cons (make-string (car gluelens)) (cons (cons (make-utf8-string (car gluelens) #\xA0)
(car gluelens)) (car gluelens))
res)) res))
(loop gluelens (loop gluelens
(cdr sl) (cdr sl)
(cons (car sl) res)))))) (cons (car sl) res))))))
;; Nothing to expand, fill-in remainder with spaces ;; Nothing to expand, fill-in remainder with spaces
(reverse (cons (cons (make-string rem0) rem0) (reverse (cons (cons (make-utf8-string rem0 #\xA0) rem0)
(reverse sl))))) (reverse sl)))))
;; Nowhere to expand ;; Nowhere to expand
sl))) sl)))
@ -361,8 +362,9 @@
(list '()) (list '())
slw)) slw))
state))) state)))
(let-values (((sln) (sgr-list-neutralize sl))) (let ((sln (sgr-list-neutralize sl)))
(values sln initial-state)))) ;;(write sln)(newline)
(values (list sln) initial-state))))
;; Renders all the lines and appends the resulting blocks ;; Renders all the lines and appends the resulting blocks
(define* (sgr-block-render sb (define* (sgr-block-render sb
@ -419,7 +421,7 @@
0 0
(sgr-list-last-state (car rsb)))) (sgr-list-last-state (car rsb))))
(filler (list state (filler (list state
(cons (make-string sbw) (cons (make-utf8-string sbw #\xA0)
sbw)))) sbw))))
(let loop ((rsb rsb) (let loop ((rsb rsb)
(rh (- h sbh))) (rh (- h sbh)))

View file

@ -345,7 +345,8 @@
(when (eq? ch #\tab) (when (eq? ch #\tab)
(string-set! str idx #\space)) (string-set! str idx #\space))
(loop (add1 idx))))) (loop (add1 idx)))))
t)))) t))
t))
;; Neutralizes whole SGR list ;; Neutralizes whole SGR list
(define (sgr-list-neutralize sl) (define (sgr-list-neutralize sl)

View file

@ -204,6 +204,8 @@
(tbl1 (render-cells-widths ptbl col-widths)) (tbl1 (render-cells-widths ptbl col-widths))
;;(_ (print tbl1)) ;;(_ (print tbl1))
(tbl2 (map expand-row-height tbl1))) (tbl2 (map expand-row-height tbl1)))
;;(write tbl1)(newline)
;;(write tbl2)(newline)
;; Just return the result - both the table and cached column widths ;; Just return the result - both the table and cached column widths
(values tbl2 (values tbl2
col-widths)))) col-widths))))

View file

@ -88,6 +88,7 @@
(borders (expand-table-style border-spec num-columns num-rows)) (borders (expand-table-style border-spec num-columns num-rows))
(col-separators (table-col-separators? borders)) (col-separators (table-col-separators? borders))
(rows (merge-rows ptbl borders col-separators unicode?))) (rows (merge-rows ptbl borders col-separators unicode?)))
;;(write rows)(newline)
(let loop ((rows rows) (let loop ((rows rows)
(borders borders) (borders borders)
(res '()) (res '())