emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 845d6561ed0: Fix Proced display header alignment under 'text-scal


From: Eli Zaretskii
Subject: master 845d6561ed0: Fix Proced display header alignment under 'text-scale-adjust'
Date: Fri, 21 Jul 2023 08:19:35 -0400 (EDT)

branch: master
commit 845d6561ed07a8a979200a389a39db08dffccdc8
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>

    Fix Proced display header alignment under 'text-scale-adjust'
    
    * lisp/proced.el (proced-mode): Force the header-line to scale
    according to 'text-scale-adjust'.
    (proced-header-line): Use width of the header-line's face's
    characters as align-to units, not the width of the frame's
    default face's font.  (Bug#64752)
    
    * src/xdisp.c (calc_pixel_width_or_height): Use font's
    average_width or space_width, not max_width, as the correct
    measure of the font's width.  This is consistent with the rest of
    the display engine.
---
 lisp/proced.el | 6 ++++--
 src/xdisp.c    | 4 +++-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/lisp/proced.el b/lisp/proced.el
index 03a7f1bebdf..b3d581a49d1 100644
--- a/lisp/proced.el
+++ b/lisp/proced.el
@@ -776,12 +776,12 @@ of the process.  A value of nil indicates that there are 
no active refinements."
        (while (string-match "[ \t\n]+" hl pos)
          (setq pos (match-end 0))
          (put-text-property (match-beginning 0) pos 'display
-                            `(space :align-to ,(+ pos base))
+                            `(space :align-to (,(+ pos base) . width))
                             hl)))
       (setq hl (replace-regexp-in-string ;; preserve text properties
                "\\(%\\)" "\\1\\1"
                hl)))
-    (list (propertize " " 'display `(space :align-to ,base))
+    (list (propertize " " 'display `(space :align-to (,base . width)))
           hl)))
 
 (defun proced-pid-at-point ()
@@ -894,6 +894,8 @@ normal hook `proced-post-display-hook'.
   (setq-local font-lock-defaults
               '(proced-font-lock-keywords t nil nil beginning-of-line))
   (setq-local switch-to-buffer-preserve-window-point nil)
+  ;; So that the heading scales together with the body of the table.
+  (setq-local text-scale-remap-header-line t)
   (if (and (not proced-auto-update-timer) proced-auto-update-interval)
       (setq proced-auto-update-timer
             (run-at-time t proced-auto-update-interval
diff --git a/src/xdisp.c b/src/xdisp.c
index da6e0afa8e1..2eba42e3d90 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -29093,7 +29093,9 @@ calc_pixel_width_or_height (double *res, struct it *it, 
Lisp_Object prop,
       /* 'width': the width of FONT.  */
       if (EQ (prop, Qwidth))
        return OK_PIXELS (font
-                         ? FONT_WIDTH (font)
+                         ? (font->average_width
+                            ? font->average_width
+                            : font->space_width)
                          : FRAME_COLUMN_WIDTH (it->f));
 #else
       if (EQ (prop, Qheight) || EQ (prop, Qwidth))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]