diff --git a/table.scm b/table.scm index 5f2d31b..83c6684 100644 --- a/table.scm +++ b/table.scm @@ -136,6 +136,14 @@ rcws)) rcws))))) + ;; Normalizes cell line to required width and handles leading and + ;; trailing tabs to allow for right and center alignment. + (define (table-normalize-cell-line cs w) + (let ((csl (ansi-string-length cs))) + (if (< csl w) + (string-append cs (string-repeat " " (- w csl))) + cs))) + ;; Pads all lines of this cell to required width (define (table-normalize-cell c w) (let loop ((c c) @@ -143,11 +151,7 @@ (if (null? c) (reverse r) (loop (cdr c) - (cons (let* ((cs (car c)) - (csl (ansi-string-length cs))) - (if (< csl w) - (string-append cs (string-repeat " " (- w csl))) - cs)) + (cons (table-normalize-cell-line (car c) w) r))))) ;; Returns a row (list) of cells (list of strings) with all strings