Don't require window-mode-line-height.

Addresses Issue #38
This commit is contained in:
Matthew L. Fidler 2016-08-05 08:50:28 -05:00
parent d02cbbddcb
commit 48f8fd04bc

View file

@ -455,6 +455,11 @@ This only works with xpm files."
ACTIVE tells if current window is active." ACTIVE tells if current window is active."
(or face (and active 'mode-line) 'mode-line-inactive)) (or face (and active 'mode-line) 'mode-line-inactive))
(defun mode-icons-line-height (&optional window)
"Gets the height in pixels of WINDOW's mode-line, if accessible.
This uses `window-mode-line-height' on emacs 24.4+. Otherwise it assumes 16."
(or (and (fboundp 'window-mode-line-height) (window-mode-line-height window)) 16))
(defun mode-icons-get-icon-display (icon type &optional face active) (defun mode-icons-get-icon-display (icon type &optional face active)
"Get the value for the display property of ICON having TYPE. "Get the value for the display property of ICON having TYPE.
@ -488,14 +493,14 @@ ACTIVE is an indicator that the current window is active."
t :ascent 'center t :ascent 'center
:face face :face face
:xpm-bw t :xpm-bw t
:height (window-mode-line-height) :height (mode-icons-line-height)
:icon icon)) :icon icon))
((eq type 'xpm-bw) ((eq type 'xpm-bw)
(create-image icon-path (create-image icon-path
(or (and (fboundp 'imagemagick-types) (or (and (fboundp 'imagemagick-types)
(memq 'png (imagemagick-types)) 'imagemagick) (memq 'png (imagemagick-types)) 'imagemagick)
'xpm) 'xpm)
:height (window-mode-line-height) :height (mode-icons-line-height)
:ascent 'center :ascent 'center
:face face :face face
:icon icon)) :icon icon))
@ -507,7 +512,7 @@ ACTIVE is an indicator that the current window is active."
(memq 'png (imagemagick-types)) 'imagemagick) (memq 'png (imagemagick-types)) 'imagemagick)
'xpm) t 'xpm) t
:ascent 'center :ascent 'center
:height (window-mode-line-height) :height (mode-icons-line-height)
:face face :icon icon)) :face face :icon icon))
(t (t
(create-image icon-path (create-image icon-path
@ -516,7 +521,7 @@ ACTIVE is an indicator that the current window is active."
'imagemagick) 'imagemagick)
(or (and (eq type 'jpg) 'jpeg) type)) (or (and (eq type 'jpg) 'jpeg) type))
nil nil
:height (window-mode-line-height) :height (mode-icons-line-height)
:ascent 'center :face face :icon icon))))) :ascent 'center :face face :icon icon)))))
((and (eq type 'emoji) (setq tmp (mode-icons--get-emoji " " (list "" icon type) face))) ((and (eq type 'emoji) (setq tmp (mode-icons--get-emoji " " (list "" icon type) face)))
(get-text-property 0 'display tmp)) (get-text-property 0 'display tmp))
@ -1059,7 +1064,7 @@ ACTIVE is a flag telling if the current window is active."
(memq 'png (imagemagick-types))) (memq 'png (imagemagick-types)))
'imagemagick) 'png) 'imagemagick) 'png)
nil nil
:height (window-mode-line-height) :height (mode-icons-line-height)
:ascent 'center :ascent 'center
:heuristic-mask t :heuristic-mask t
:face face) :face face)
@ -1117,7 +1122,7 @@ ACTIVE is a flag for if the current window is active."
:face face :face face
;; :background (emojify--get-image-background beg end) ;; :background (emojify--get-image-background beg end)
;; no-op if imagemagick is not available ;; no-op if imagemagick is not available
:height (window-mode-line-height)) :height (mode-icons-line-height))
'face face 'face face
'mode-icons-p icon-spec)))))) 'mode-icons-p icon-spec))))))