Refactor dashboard banner display & centering
This commit is contained in:
parent
87c8f6e18e
commit
e33cb446aa
1 changed files with 27 additions and 29 deletions
|
@ -12,13 +12,15 @@
|
|||
dashboard. These functions take no arguments and the dashboard buffer is current
|
||||
while they run.")
|
||||
|
||||
;; (defvar +doom-dashboard-banner-file "e.png"
|
||||
;; "The path to the image file to be used in on the dashboard. The path is
|
||||
;; relative to modules/ui/doom-dashboard/banners/. If nil, always use the ASCII
|
||||
;; banner.")
|
||||
(defvar +doom-dashboard-banner-file "default.png"
|
||||
"The path to the image file to be used in on the dashboard. The path is
|
||||
relative to `+doom-dashboard-banner-dir'. If nil, always use the ASCII banner.")
|
||||
|
||||
;; (defvar +doom-dashboard-banner-dir (concat (DIR!) "banners/")
|
||||
;; "Where to look for `+doom-dashboard-banner-file'.")
|
||||
(defvar +doom-dashboard-banner-dir (concat (DIR!) "banners/")
|
||||
"Where to look for `+doom-dashboard-banner-file'.")
|
||||
|
||||
(defvar +doom-dashboard-banner-padding '(4 . 4)
|
||||
"Number of newlines to pad the banner with, above and below, respectively.")
|
||||
|
||||
(defvar +doom-dashboard-inhibit-refresh nil
|
||||
"If non-nil, the doom buffer won't be refreshed.")
|
||||
|
@ -88,7 +90,6 @@ PLIST can have the following properties:
|
|||
;;
|
||||
(defvar +doom-dashboard--last-cwd nil)
|
||||
(defvar +doom-dashboard--width 80)
|
||||
(defvar +doom-dashboard--hoffset 2)
|
||||
(defvar +doom-dashboard--old-fringe-indicator fringe-indicator-alist)
|
||||
(defvar +doom-dashboard--pwd-alist ())
|
||||
|
||||
|
@ -235,11 +236,10 @@ whose dimensions may not be fully initialized by the time this is run."
|
|||
(point)))
|
||||
(insert (make-string
|
||||
(max 0 (- (/ (window-height (get-buffer-window)) 2)
|
||||
(truncate (/ (+ (count-lines (point-min) (point-max))
|
||||
+doom-dashboard--hoffset)
|
||||
2))))
|
||||
?\n)
|
||||
"\n")))))))
|
||||
(round (/ (+ (count-lines (point-min) (point-max))
|
||||
(car +doom-dashboard-banner-padding))
|
||||
2))))
|
||||
?\n))))))))
|
||||
|
||||
(defun +doom-dashboard|detect-project (&rest _)
|
||||
"Check for a `last-project-root' parameter in the perspective, and set the
|
||||
|
@ -300,7 +300,6 @@ controlled by `+doom-dashboard-pwd-policy'."
|
|||
(unless (eq major-mode '+doom-dashboard-mode)
|
||||
(+doom-dashboard-mode))
|
||||
(erase-buffer)
|
||||
(insert "\n")
|
||||
(run-hooks '+doom-dashboard-functions)))
|
||||
(+doom-dashboard|resize)
|
||||
(+doom-dashboard|detect-project)
|
||||
|
@ -365,22 +364,21 @@ controlled by `+doom-dashboard-pwd-policy'."
|
|||
"==' _-' E M A C S \\/ `=="
|
||||
"\\ _-' `-_ /"
|
||||
" `'' ``'"))
|
||||
;; TODO Add Doom logo
|
||||
;; (when (and +doom-dashboard-banner-file (display-graphic-p))
|
||||
;; (let* ((image (create-image (expand-file-name +doom-dashboard-banner-file
|
||||
;; +doom-dashboard-banner-dir)
|
||||
;; 'png nil))
|
||||
;; (size (image-size image))
|
||||
;; (margin (+ 1 (/ (- +doom-dashboard--width (car size)) 2))))
|
||||
;; (setq +doom-dashboard--hoffset (- (cdr size) 2))
|
||||
;; (add-text-properties
|
||||
;; point (point) `(display ,image rear-nonsticky (display)))
|
||||
;; (when (> margin 0)
|
||||
;; (save-excursion
|
||||
;; (goto-char point)
|
||||
;; (insert (make-string (truncate margin) ? )))))
|
||||
;; (insert "\n\n\n\n"))
|
||||
))
|
||||
(when (and (stringp +doom-dashboard-banner-file)
|
||||
(display-graphic-p)
|
||||
(file-exists-p! +doom-dashboard-banner-file +doom-dashboard-banner-dir))
|
||||
(let* ((image (create-image (expand-file-name +doom-dashboard-banner-file
|
||||
+doom-dashboard-banner-dir)
|
||||
'png nil))
|
||||
(size (image-size image nil))
|
||||
(margin (+ 1 (/ (- +doom-dashboard--width (car size)) 2))))
|
||||
(add-text-properties
|
||||
point (point) `(display ,image rear-nonsticky (display)))
|
||||
(when (> margin 0)
|
||||
(save-excursion
|
||||
(goto-char point)
|
||||
(insert (make-string (truncate margin) ? )))))
|
||||
(insert (make-string (or (cdr +doom-dashboard-banner-padding) 0) ?\n)))))
|
||||
|
||||
(defun doom-dashboard-widget-loaded ()
|
||||
(insert
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue