[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/transient 7f5520b 11/11: Add support for non-proportion
From: |
Jonas Bernoulli |
Subject: |
[elpa] externals/transient 7f5520b 11/11: Add support for non-proportional text |
Date: |
Thu, 4 Nov 2021 21:02:19 -0400 (EDT) |
branch: externals/transient
commit 7f5520b330d4d23e3241b731cb32f59a33aa251c
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Jonas Bernoulli <jonas@bernoul.li>
Add support for non-proportional text
Add a new `variable-pitch' prefix slot to enable support.
---
lisp/transient.el | 40 ++++++++++++++++++++++++++++++++--------
1 file changed, 32 insertions(+), 8 deletions(-)
diff --git a/lisp/transient.el b/lisp/transient.el
index c364c12..f80e6af 100644
--- a/lisp/transient.el
+++ b/lisp/transient.el
@@ -604,7 +604,8 @@ If `transient-save-history' is nil, then do nothing."
(transient-suffix :initarg :transient-suffix :initform nil)
(transient-non-suffix :initarg :transient-non-suffix :initform nil)
(incompatible :initarg :incompatible :initform nil)
- (suffix-description :initarg :suffix-description))
+ (suffix-description :initarg :suffix-description)
+ (variable-pitch :initarg :variable-pitch :initform nil))
"Transient prefix command.
Each transient prefix command consists of a command, which is
@@ -2994,11 +2995,17 @@ have a history of their own.")
(push desc rows))
rows))
(oref group suffixes)))
+ (vp (oref transient--prefix variable-pitch))
(rs (apply #'max (mapcar #'length columns)))
(cs (length columns))
- (cw (mapcar (lambda (col) (apply #'max (mapcar #'length col)))
+ (cw (mapcar (lambda (col)
+ (apply #'max
+ (mapcar (if vp #'transient--pixel-width #'length)
+ col)))
columns))
- (cc (transient--seq-reductions-from (apply-partially #'+ 3) cw 0)))
+ (cc (transient--seq-reductions-from
+ (apply-partially #'+ (* 3 (if vp (transient--pixel-width " ")
1)))
+ cw 0)))
(if transient-force-single-column
(dotimes (c cs)
(dotimes (r rs)
@@ -3009,11 +3016,28 @@ have a history of their own.")
(insert ?\n)))
(dotimes (r rs)
(dotimes (c cs)
- (insert (make-string (- (nth c cc) (current-column)) ?\s))
- (when-let ((cell (nth r (nth c columns))))
- (insert cell))
- (when (= c (1- cs))
- (insert ?\n)))))))
+ (if vp
+ (progn
+ (when-let ((cell (nth r (nth c columns))))
+ (insert cell))
+ (if (= c (1- cs))
+ (insert ?\n)
+ (insert (propertize " " 'display
+ `(space :align-to (,(nth (1+ c) cc)))))))
+ (insert (make-string (- (nth c cc) (current-column)) ?\s))
+ (when-let ((cell (nth r (nth c columns))))
+ (insert cell))
+ (when (= c (1- cs))
+ (insert ?\n))))))))
+
+(defun transient--pixel-width (string)
+ (save-window-excursion
+ (with-temp-buffer
+ (insert string)
+ (set-window-dedicated-p nil nil)
+ (set-window-buffer nil (current-buffer))
+ (car (window-text-pixel-size
+ nil (line-beginning-position) (point))))))
(cl-defmethod transient--insert-group ((group transient-subgroups))
(let* ((subgroups (oref group suffixes))
- [elpa] externals/transient 938b059 01/11: transient--show: Set point after displaying window again, (continued)
- [elpa] externals/transient 938b059 01/11: transient--show: Set point after displaying window again, Jonas Bernoulli, 2021/11/04
- [elpa] externals/transient 6276927 02/11: transient--describe-function: Move definition, Jonas Bernoulli, 2021/11/04
- [elpa] externals/transient 09c911e 03/11: transient--show-manual: New function, Jonas Bernoulli, 2021/11/04
- [elpa] externals/transient 2226375 06/11: transient-show-help: Refactor and improve, Jonas Bernoulli, 2021/11/04
- [elpa] externals/transient 667488e 09/11: Extend multi-value support, Jonas Bernoulli, 2021/11/04
- [elpa] externals/transient ea5ac99 07/11: transient-show-help: Support per-object help functions, Jonas Bernoulli, 2021/11/04
- [elpa] externals/transient c9ab648 08/11: transient--show-help: Update doc-strings, Jonas Bernoulli, 2021/11/04
- [elpa] externals/transient 9b6a251 04/11: transient-show-help: Avoid this-original-command, Jonas Bernoulli, 2021/11/04
- [elpa] externals/transient df1ba0f 05/11: transient-show-help: Cosmetics, Jonas Bernoulli, 2021/11/04
- [elpa] externals/transient 202271f 10/11: Resurrect transient-files class, Jonas Bernoulli, 2021/11/04
- [elpa] externals/transient 7f5520b 11/11: Add support for non-proportional text,
Jonas Bernoulli <=