branch: externals/taxy-magit-section commit 9e76b7fd59ba1ae096f520fb782adfed0077b21f Author: Adam Porter <a...@alphapapa.net> Commit: Adam Porter <a...@alphapapa.net>
Fix: (-format-items) Calculating image widths if on a text frame Try to find a graphical frame when calculating image widths for column widths (or signal an error if none are available, rather than leaving IMAGE-SIZE to signal an error). For example, if both graphical and text frames are available, and a column's values contain an image, and the buffer is being redisplayed on a text frame, try to use a graphical frame for calculating the image width, rather than just signaling an error. If only text frames are available, images should not be present in strings to begin with, so we don't try to handle that case. --- README.org | 1 + taxy-magit-section.el | 11 ++++++-- taxy-magit-section.info | 75 ++++++++++++++++++++++++++++++++----------------- 3 files changed, 60 insertions(+), 27 deletions(-) diff --git a/README.org b/README.org index c11baaf67e..1be669256b 100644 --- a/README.org +++ b/README.org @@ -36,6 +36,7 @@ This library renders [[https://github.com/alphapapa/taxy.el][Taxy]] structs with *Fixes* + Don't pass string as ~ELLIPSIS~ argument to ~truncate-string-to-width~; pass t, which defaults to value of variable ~truncate-string-ellipsis~. (The width of the string passed before, the U+2026 HORIZONTAL ELLIPSIS character, varies by font, and fonts which display it with a width different than that of a single space cause misalignment of columns. Now users may specify the ellipsis string according to their needs.) ++ Try to find a graphical frame when calculating image widths for column widths (or signal an error if none are available, rather than leaving ~image-size~ to signal an error). (For example, if both graphical and text frames are available, and a column's values contain an image, and the buffer is being redisplayed on a text frame, try to use a graphical frame for calculating the image width, rather than just signaling an error.) ** 0.14 diff --git a/taxy-magit-section.el b/taxy-magit-section.el index 8fd7fcfb85..33aaeddb79 100644 --- a/taxy-magit-section.el +++ b/taxy-magit-section.el @@ -382,7 +382,7 @@ and values are the column width. Each string is formatted according to `columns' and takes into account the width of all the items' values for each column." (let ((table (make-hash-table)) - column-aligns column-sizes image-p) + column-aligns column-sizes image-p window-system-frame) (cl-labels ((string-width* (string) (if-let (pos (text-property-not-all 0 (length string) 'display nil string)) @@ -399,7 +399,14 @@ the items' values for each column." ;; TODO: Do we need to specify the frame? What if the ;; buffer isn't currently displayed? (setf image-p t) - (floor (car (image-size spec)))) + (floor (car (image-size + spec nil + (or window-system-frame + (setf window-system-frame + (cl-loop for frame in (frame-list) + when (member (framep frame) '(x w32 ns pgtk)) + return frame)) + (error "taxy-magit-section-format-items: No graphical frame to calculate image size")))))) (_ ;; No image: just use `string-width'. (setf image-p nil) diff --git a/taxy-magit-section.info b/taxy-magit-section.info index 4f7098f5b0..a41ed324ff 100644 --- a/taxy-magit-section.info +++ b/taxy-magit-section.info @@ -29,6 +29,7 @@ structs with magit-section (https://melpa.org/#/magit-section). Changelog +* 0.14.1-pre: 0141-pre. * 0.14: 014. * 0.13: 013. * 0.12.2: 0122. @@ -59,6 +60,7 @@ File: README.info, Node: Changelog, Next: Development, Prev: Installation, U * Menu: +* 0.14.1-pre: 0141-pre. * 0.14: 014. * 0.13: 013. * 0.12.2: 0122. @@ -70,9 +72,31 @@ File: README.info, Node: Changelog, Next: Development, Prev: Installation, U * 0.9: 09. -File: README.info, Node: 014, Next: 013, Up: Changelog +File: README.info, Node: 0141-pre, Next: 014, Up: Changelog -2.1 0.14 +2.1 0.14.1-pre +============== + +*Fixes* + • Don’t pass string as ‘ELLIPSIS’ argument to + ‘truncate-string-to-width’; pass t, which defaults to value of + variable ‘truncate-string-ellipsis’. (The width of the string + passed before, the U+2026 HORIZONTAL ELLIPSIS character, varies by + font, and fonts which display it with a width different than that + of a single space cause misalignment of columns. Now users may + specify the ellipsis string according to their needs.) + • Try to find a graphical frame when calculating image widths for + column widths (or signal an error if none are available, rather + than leaving ‘image-size’ to signal an error). (For example, if + both graphical and text frames are available, and a column’s values + contain an image, and the buffer is being redisplayed on a text + frame, try to use a graphical frame for calculating the image + width, rather than just signaling an error.) + + +File: README.info, Node: 014, Next: 013, Prev: 0141-pre, Up: Changelog + +2.2 0.14 ======== *Fixes* @@ -82,7 +106,7 @@ File: README.info, Node: 014, Next: 013, Up: Changelog File: README.info, Node: 013, Next: 0122, Prev: 014, Up: Changelog -2.2 0.13 +2.3 0.13 ======== *Additions* @@ -96,7 +120,7 @@ File: README.info, Node: 013, Next: 0122, Prev: 014, Up: Changelog File: README.info, Node: 0122, Next: 0121, Prev: 013, Up: Changelog -2.3 0.12.2 +2.4 0.12.2 ========== *Fixes* @@ -105,7 +129,7 @@ File: README.info, Node: 0122, Next: 0121, Prev: 013, Up: Changelog File: README.info, Node: 0121, Next: 012, Prev: 0122, Up: Changelog -2.4 0.12.1 +2.5 0.12.1 ========== *Fixes* @@ -114,7 +138,7 @@ File: README.info, Node: 0121, Next: 012, Prev: 0122, Up: Changelog File: README.info, Node: 012, Next: 011, Prev: 0121, Up: Changelog -2.5 0.12 +2.6 0.12 ======== *Fixes* @@ -123,7 +147,7 @@ File: README.info, Node: 012, Next: 011, Prev: 0121, Up: Changelog File: README.info, Node: 011, Next: 010, Prev: 012, Up: Changelog -2.6 0.11 +2.7 0.11 ======== *Additions* @@ -133,7 +157,7 @@ File: README.info, Node: 011, Next: 010, Prev: 012, Up: Changelog File: README.info, Node: 010, Next: 091, Prev: 011, Up: Changelog -2.7 0.10 +2.8 0.10 ======== *Fixes* @@ -142,7 +166,7 @@ File: README.info, Node: 010, Next: 091, Prev: 011, Up: Changelog File: README.info, Node: 091, Next: 09, Prev: 010, Up: Changelog -2.8 0.9.1 +2.9 0.9.1 ========= *Fixes* @@ -155,8 +179,8 @@ File: README.info, Node: 091, Next: 09, Prev: 010, Up: Changelog File: README.info, Node: 09, Prev: 091, Up: Changelog -2.9 0.9 -======= +2.10 0.9 +======== • ‘taxy-magit-section’ moved to separate package. • Better align columns whose values are images. @@ -191,20 +215,21 @@ GPLv3 Tag Table: Node: Top221 -Node: Installation826 -Node: Changelog1180 -Node: 0141427 -Node: 0131619 -Node: 01222090 -Node: 01212222 -Node: 0122355 -Node: 0112492 -Node: 0102693 -Node: 0912848 -Node: 093240 -Node: Development3430 -Node: Credits3657 -Node: License3847 +Node: Installation850 +Node: Changelog1204 +Node: 0141-pre1475 +Node: 0142529 +Node: 0132738 +Node: 01223209 +Node: 01213341 +Node: 0123474 +Node: 0113611 +Node: 0103812 +Node: 0913967 +Node: 094359 +Node: Development4551 +Node: Credits4778 +Node: License4968 End Tag Table