Finish alignment.

This commit is contained in:
Dominik Pantůček 2023-03-29 09:00:12 +02:00
parent 3f50d85412
commit 965b0432fa
4 changed files with 19 additions and 5 deletions

View file

@ -127,7 +127,10 @@
;; 1 - seen escape ;; 1 - seen escape
;; 2 - CSI started ;; 2 - CSI started
(define (ansi-string-length str) (define (ansi-string-length str)
(let loop ((lst (irregex-extract (irregex "." 'u) str)) (let loop ((lst (irregex-extract (irregex "." 'u)
(irregex-replace (irregex "\t$" 'u)
(irregex-replace (irregex "^\t" 'u)
str))))
(state 0) (state 0)
(len 0)) (len 0))
(if (null? lst) (if (null? lst)

View file

@ -26,6 +26,7 @@ CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
") ")
(import testing (import testing
(chicken format)
listing listing
dictionary dictionary
month month
@ -136,7 +137,9 @@ CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
(let* ((mc (member-calendar mr)) (let* ((mc (member-calendar mr))
(fees (member-calendar->fees mc))) (fees (member-calendar->fees mc)))
(print-member-table mr) (print-member-table mr)
(print (table->string (cons (list "" 1 2 3 4 5 6 7 8 9 10 11 12) (print (table->string (cons (map (lambda (c)
(sprintf "\t~A\t" c))
(list "" 1 2 3 4 5 6 7 8 9 10 11 12))
(member-calendar->years-table mc)) (member-calendar->years-table mc))
#:table-border #t #:table-border #t
#:row-border #t #:row-border #t

View file

@ -332,7 +332,7 @@
;; Helper function for pretty-formatting the filtered members lists ;; Helper function for pretty-formatting the filtered members lists
;; in a table. ;; in a table.
(define (members-table-row a:? label mrs fmt) (define (members-table-row a:? label mrs fmt)
(list (string-append a:? label) (list (string-append "\t" a:? label)
(length mrs) (length mrs)
(ansi-paragraph-format (ansi-paragraph-format
(member-records->string (member-records->string

View file

@ -150,8 +150,16 @@
(if (< len w) (if (< len w)
(let* ((miss (- w len)) (let* ((miss (- w len))
(do-left-pad first-tab) (do-left-pad first-tab)
(do-right-pad (or (not first-tab) last-tab))) (do-right-pad (or (not first-tab) last-tab))
(string-append line1 (string-repeat " " miss))) (left-pad-len (if do-left-pad
(if do-right-pad
(- miss (quotient miss 2))
miss)
0))
(right-pad-len (- miss left-pad-len))
(left-pad (make-string left-pad-len #\space))
(right-pad (make-string right-pad-len #\space)))
(string-append left-pad line1 right-pad))
line1))) line1)))
;; Pads all lines of this cell to required width ;; Pads all lines of this cell to required width