diff --git a/ansi.scm b/ansi.scm index 6c28ac3..4a11b12 100644 --- a/ansi.scm +++ b/ansi.scm @@ -127,7 +127,10 @@ ;; 1 - seen escape ;; 2 - CSI started (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) (len 0)) (if (null? lst) diff --git a/bbstool.scm b/bbstool.scm index 4962eb7..69348ac 100644 --- a/bbstool.scm +++ b/bbstool.scm @@ -26,6 +26,7 @@ CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ") (import testing + (chicken format) listing dictionary month @@ -136,7 +137,9 @@ CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. (let* ((mc (member-calendar mr)) (fees (member-calendar->fees mc))) (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)) #:table-border #t #:row-border #t diff --git a/members-base.scm b/members-base.scm index da6c41a..94a4a19 100644 --- a/members-base.scm +++ b/members-base.scm @@ -332,7 +332,7 @@ ;; Helper function for pretty-formatting the filtered members lists ;; in a table. (define (members-table-row a:? label mrs fmt) - (list (string-append a:? label) + (list (string-append "\t" a:? label) (length mrs) (ansi-paragraph-format (member-records->string diff --git a/table.scm b/table.scm index cfbd559..ef4c38a 100644 --- a/table.scm +++ b/table.scm @@ -150,8 +150,16 @@ (if (< len w) (let* ((miss (- w len)) (do-left-pad first-tab) - (do-right-pad (or (not first-tab) last-tab))) - (string-append line1 (string-repeat " " miss))) + (do-right-pad (or (not first-tab) last-tab)) + (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))) ;; Pads all lines of this cell to required width