Add a minimum height for the hud's middle part (#445)

This looks nicer, and it also makes sure it is not possible to try to
draw an image with a negative height for the middle part (which might
happen if window-start and buffer-size are out of sync).
This commit is contained in:
marienz 2021-05-21 21:22:37 +10:00 committed by GitHub
parent 3b393766f4
commit 0466d88d71
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -164,6 +164,14 @@ It's only respected in GUI."
:type 'boolean
:group 'doom-modeline)
(defcustom doom-modeline-hud-min-height 2
"Minimum height in pixels of the \"thumb\" of the hud.
Only respected in GUI."
:type 'integer
:set (lambda (sym val)
(set sym (if (> val 1) val 1)))
:group 'doom-modeline)
(defcustom doom-modeline-window-width-limit fill-column
"The limit of the window width.
@ -1124,6 +1132,11 @@ TOP-MARGIN and BOTTOM-MARGIN are the size of the margin above and below the bar,
respectively."
(when (and (display-graphic-p)
(image-type-available-p 'pbm))
(let ((min-height (min height doom-modeline-hud-min-height)))
(unless (> (- height top-margin bottom-margin) min-height)
(let ((margin (- height min-height)))
(setq top-margin (/ (* margin top-margin) (+ top-margin bottom-margin))
bottom-margin (- margin top-margin)))))
(propertize
" " 'display
(let ((color1 (or (face-background face1 nil t) "None"))