FUEL: Shorten very long words in tables to keep delims aligned.
parent
03455ab770
commit
3ee5772c88
|
@ -15,24 +15,26 @@
|
||||||
|
|
||||||
(defun fuel-table--col-widths (rows)
|
(defun fuel-table--col-widths (rows)
|
||||||
(let* ((col-no (length (car rows)))
|
(let* ((col-no (length (car rows)))
|
||||||
(available (- (window-width) 10 (* 2 col-no)))
|
(available (- (window-width) 2 (* 2 col-no)))
|
||||||
(widths)
|
(widths)
|
||||||
(c 0))
|
(c 0))
|
||||||
(while (< c col-no)
|
(while (< c col-no)
|
||||||
(let ((width 0)
|
(let ((width 0)
|
||||||
(av-width (/ available (- col-no c))))
|
(av-width (- available (* 5 (- col-no c)))))
|
||||||
(dolist (row rows)
|
(dolist (row rows)
|
||||||
(setq width (min av-width
|
(setq width
|
||||||
(max width (length (nth c row))))))
|
(min av-width
|
||||||
|
(max width (length (nth c row))))))
|
||||||
(push width widths)
|
(push width widths)
|
||||||
(setq available (- available width)))
|
(setq available (- available width)))
|
||||||
(setq c (1+ c)))
|
(setq c (1+ c)))
|
||||||
(reverse widths)))
|
(reverse widths)))
|
||||||
|
|
||||||
(defsubst fuel-table--pad-str (str width)
|
(defun fuel-table--pad-str (str width)
|
||||||
(if (>= (length str) width)
|
(let ((len (length str)))
|
||||||
str
|
(cond ((= len width) str)
|
||||||
(concat str (make-string (- width (length str)) ?\ ))))
|
((> len width) (concat (substring str 0 (- width 3)) "..."))
|
||||||
|
(t (concat str (make-string (- width (length str)) ?\ ))))))
|
||||||
|
|
||||||
(defun fuel-table--str-lines (str width)
|
(defun fuel-table--str-lines (str width)
|
||||||
(if (<= (length str) width)
|
(if (<= (length str) width)
|
||||||
|
|
Loading…
Reference in New Issue