summaryrefslogtreecommitdiff
path: root/dashboard.el
diff options
context:
space:
mode:
authorJSDurand <mmemmew@gmail.com>2024-03-04 16:58:33 +0800
committerJSDurand <mmemmew@gmail.com>2024-03-04 16:58:33 +0800
commit5ca627fe4fa9685090ceea961a4dde339c4245e0 (patch)
tree3327031fb65f97ef997e4491fd9ef71d1267184a /dashboard.el
parent6aec34070b26580b2fbb4f2a0455ed5bba9c1029 (diff)
dashboard: center the image correctly
* dashboard.el (dashboard): My dashboard has an image at the center of the buffer. Since I now know how to center the image at the center with pixel-level precision, this is updated.
Diffstat (limited to 'dashboard.el')
-rw-r--r--dashboard.el23
1 files changed, 18 insertions, 5 deletions
diff --git a/dashboard.el b/dashboard.el
index 4e1914e..1abc53d 100644
--- a/dashboard.el
+++ b/dashboard.el
@@ -42,13 +42,26 @@ If FORCE is non-nil, re-gerenate the dashboard buffer."
(erase-buffer)
(cond
((display-graphic-p)
- (let ((image (create-image (expand-file-name "cat.png" user-emacs-directory))))
+ (let* ((image
+ (create-image
+ (expand-file-name
+ "cat.png"
+ user-emacs-directory)))
+ (str (propertize
+ " "
+ 'display image
+ 'rear-nonsticky '(display)))
+ (str-width (string-pixel-width str)))
(insert
(make-string 3 10)
- (center-string-in-width
- (propertize " " 'display image 'rear-nonsticky '(display))
- (round (- (window-body-width)
- (* (car (image-size image)) 1)))))))
+ (propertize
+ (string 32)
+ 'display
+ (list
+ 'space
+ :width
+ (list (floor (- (window-body-width nil t) str-width) 2))))
+ str)))
((mapc (function
(lambda (str)
(insert