Use non-breaking spaces for alignment.
This commit is contained in:
		
							parent
							
								
									cc9e5bad7d
								
							
						
					
					
						commit
						f1c3ec70a3
					
				
					 6 changed files with 36 additions and 25 deletions
				
			
		|  | @ -410,7 +410,8 @@ sgr-list.o: sgr-list.import.scm | |||
| sgr-list.import.scm: $(SGR-LIST-SOURCES) | ||||
| 
 | ||||
| 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.import.scm: $(SGR-BLOCK-SOURCES) | ||||
|  |  | |||
|  | @ -109,20 +109,23 @@ | |||
| 					(brmember-credit mr)) | ||||
| 				   #:border '(((#:right light) ... none) ...)))) | ||||
| 			   ((suspend student member council chair revision grant) | ||||
| 			    (list k | ||||
| 				  (table->string | ||||
| 				   (cons (list "Since" "Until") | ||||
| 					 (map | ||||
| 					  (lambda (p) | ||||
| 					    (list | ||||
| 					     (string-append (cal-day/month->string | ||||
| 							     (cal-period-since p)) " " | ||||
| 							     (or (cal-period-scomment p) "")) | ||||
| 					     (string-append (cal-day/month->string | ||||
| 							     (cal-period-before p)) " " | ||||
| 							     (or (cal-period-bcomment p) "")))) | ||||
| 					  v)) | ||||
| 				   #:border '(((#:right light) ... none) ...)))) | ||||
| 			    (let* ((pdata (cons (list "Since" "Until") | ||||
| 						(map | ||||
| 						 (lambda (p) | ||||
| 						   (list | ||||
| 						    (string-append (cal-day/month->string | ||||
| 								    (cal-period-since p)) " " | ||||
| 								    (or (cal-period-scomment p) "")) | ||||
| 						    (string-append (cal-day/month->string | ||||
| 								    (cal-period-before p)) " " | ||||
| 								    (or (cal-period-bcomment p) "")))) | ||||
| 						 v))) | ||||
| 				   (ptbl (table->string | ||||
| 					  pdata | ||||
| 					  #:border '(((#:right light) ... none) ...)))) | ||||
| 			      ;;(print pdata) | ||||
| 			      ;;(write ptbl)(newline) | ||||
| 			      (list k ptbl))) | ||||
| 			   (else | ||||
| 			    (if v | ||||
| 				(list k v) | ||||
|  | @ -132,10 +135,11 @@ | |||
| 	  (mailman (list (list "Mailing Lists" | ||||
| 			       (string-intersperse (brmember-mailman mr) "\n")))) | ||||
| 	  (result (filter identity (append head body mailman)))) | ||||
|      ;;(write result)(newline) | ||||
|      (table->string result | ||||
| 		    #:border '(((#:bottom #:right light) ... (#:bottom light)) | ||||
| 			       ((#:right light) ... none) | ||||
| 			       ...) | ||||
| 			       ... | ||||
| 			       ((#:right light) ... none)) | ||||
| 		    #:ansi-reset? #t))) | ||||
| 
 | ||||
|  ;; Prints nicely formatted table | ||||
|  |  | |||
|  | @ -49,7 +49,8 @@ | |||
| 	 racket-kwargs | ||||
| 	 sgr-state | ||||
| 	 sgr-list | ||||
| 	 testing) | ||||
| 	 testing | ||||
| 	 util-utf8) | ||||
| 
 | ||||
|  ;; Converts sgr-list (possibly containing multiple lines) into a | ||||
|  ;; sgr-block | ||||
|  | @ -101,7 +102,7 @@ | |||
| 
 | ||||
|  ;; Creates filler for justification of SGR lines | ||||
|  (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, | ||||
|  ;; converts all spaces to glues. Removes unglue. | ||||
|  | @ -172,14 +173,14 @@ | |||
| 		       (if (sgr-token-glue? tk) | ||||
| 			   (loop (cdr gluelens) | ||||
| 				 (cdr sl) | ||||
| 				 (cons (cons (make-string (car gluelens)) | ||||
| 				 (cons (cons (make-utf8-string (car gluelens) #\xA0) | ||||
| 					     (car gluelens)) | ||||
| 				       res)) | ||||
| 			   (loop gluelens | ||||
| 				 (cdr sl) | ||||
| 				 (cons (car sl) res)))))) | ||||
| 	       ;; 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))))) | ||||
| 	 ;; Nowhere to expand | ||||
| 	 sl))) | ||||
|  | @ -361,8 +362,9 @@ | |||
| 			    (list '()) | ||||
| 			    slw)) | ||||
| 		   state))) | ||||
|        (let-values (((sln) (sgr-list-neutralize sl))) | ||||
| 	 (values sln initial-state)))) | ||||
|        (let ((sln (sgr-list-neutralize sl))) | ||||
| 	 ;;(write sln)(newline) | ||||
| 	 (values (list sln) initial-state)))) | ||||
| 
 | ||||
|  ;; Renders all the lines and appends the resulting blocks | ||||
|  (define* (sgr-block-render sb | ||||
|  | @ -419,7 +421,7 @@ | |||
| 			   0 | ||||
| 			   (sgr-list-last-state (car rsb)))) | ||||
| 		(filler (list state | ||||
| 			      (cons (make-string sbw) | ||||
| 			      (cons (make-utf8-string sbw #\xA0) | ||||
| 				    sbw)))) | ||||
| 	   (let loop ((rsb rsb) | ||||
| 		      (rh (- h sbh))) | ||||
|  |  | |||
|  | @ -345,7 +345,8 @@ | |||
| 		     (when (eq? ch #\tab) | ||||
| 		       (string-set! str idx #\space)) | ||||
| 		     (loop (add1 idx))))) | ||||
| 	     t)))) | ||||
| 	     t)) | ||||
|        t)) | ||||
| 
 | ||||
|  ;; Neutralizes whole SGR list | ||||
|  (define (sgr-list-neutralize sl) | ||||
|  |  | |||
|  | @ -204,6 +204,8 @@ | |||
| 	      (tbl1 (render-cells-widths ptbl col-widths)) | ||||
| 	      ;;(_ (print tbl1)) | ||||
| 	      (tbl2 (map expand-row-height tbl1))) | ||||
| 	 ;;(write tbl1)(newline) | ||||
| 	 ;;(write tbl2)(newline) | ||||
| 	 ;; Just return the result - both the table and cached column widths | ||||
| 	 (values tbl2 | ||||
| 		 col-widths)))) | ||||
|  |  | |||
|  | @ -88,6 +88,7 @@ | |||
| 	    (borders (expand-table-style border-spec num-columns num-rows)) | ||||
| 	    (col-separators (table-col-separators? borders)) | ||||
| 	    (rows (merge-rows ptbl borders col-separators unicode?))) | ||||
|        ;;(write rows)(newline) | ||||
|        (let loop ((rows rows) | ||||
| 		  (borders borders) | ||||
| 		  (res '()) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue