mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-15 18:40:39 -08:00
Make the sorting indicator prettier in vtable
* lisp/emacs-lisp/vtable.el (vtable--insert-header-line): Place the sorting indicator flush right in the heading.
This commit is contained in:
parent
09ac2c73ee
commit
c4768cda7f
1 changed files with 37 additions and 14 deletions
|
|
@ -635,20 +635,43 @@ This also updates the displayed table."
|
||||||
(indicator-width (string-pixel-width indicator))
|
(indicator-width (string-pixel-width indicator))
|
||||||
(last (= index (1- (length (vtable-columns table)))))
|
(last (= index (1- (length (vtable-columns table)))))
|
||||||
displayed)
|
displayed)
|
||||||
(insert
|
(setq displayed
|
||||||
(setq displayed
|
(if (> (string-pixel-width name)
|
||||||
(concat
|
(- (elt widths index) indicator-width))
|
||||||
(if (> (string-pixel-width name)
|
(vtable--limit-string
|
||||||
(- (elt widths index) indicator-width))
|
name (- (elt widths index) indicator-width))
|
||||||
(vtable--limit-string
|
name))
|
||||||
name (- (elt widths index) indicator-width))
|
(let ((fill-width
|
||||||
name)
|
(+ (- (elt widths index)
|
||||||
indicator))
|
(string-pixel-width displayed)
|
||||||
(propertize " " 'display
|
indicator-width
|
||||||
(list 'space :width
|
(vtable-separator-width table))
|
||||||
(list (+ (- (elt widths index)
|
(if last 0 spacer))))
|
||||||
(string-pixel-width displayed))
|
(if (or (not last)
|
||||||
(if last 0 spacer))))))
|
(zerop indicator-width)
|
||||||
|
(< (seq-reduce #'+ widths 0) (window-width nil t)))
|
||||||
|
;; Normal case.
|
||||||
|
(insert
|
||||||
|
displayed
|
||||||
|
(propertize " " 'display
|
||||||
|
(list 'space :width (list fill-width)))
|
||||||
|
indicator)
|
||||||
|
;; This is the final column, and we have a sorting
|
||||||
|
;; indicator, and the table is too wide for the window.
|
||||||
|
(let* ((pre-indicator (string-pixel-width
|
||||||
|
(buffer-substring (point-min) (point))))
|
||||||
|
(pre-fill
|
||||||
|
(- (window-width nil t)
|
||||||
|
pre-indicator
|
||||||
|
(string-pixel-width displayed))))
|
||||||
|
(insert
|
||||||
|
displayed
|
||||||
|
(propertize " " 'display
|
||||||
|
(list 'space :width (list pre-fill)))
|
||||||
|
indicator
|
||||||
|
(propertize " " 'display
|
||||||
|
(list 'space :width
|
||||||
|
(list (- fill-width pre-fill))))))))
|
||||||
(when (and divider (not last))
|
(when (and divider (not last))
|
||||||
(insert (propertize divider 'keymap dmap)))
|
(insert (propertize divider 'keymap dmap)))
|
||||||
(put-text-property start (point) 'vtable-column index)))
|
(put-text-property start (point) 'vtable-column index)))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue