Merge pull request #46 from kissge/fix-wrong-color

Fix wrong color in xpm images
This commit is contained in:
Matthew Fidler 2017-01-10 09:20:33 -06:00 committed by GitHub
commit 7d864662b9
2 changed files with 11 additions and 4 deletions

View file

@ -34,6 +34,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
missing from the system missing from the system
- mode-icons now allows for a default icon. This can be turned on - mode-icons now allows for a default icon. This can be turned on
with the new option `mode-icons-use-default-icon` with the new option `mode-icons-use-default-icon`
- Fix coloring algorithm for xpm images.
## [0.4.0] ## [0.4.0]

View file

@ -315,12 +315,18 @@ If ICON-PATH is a string, return that."
(and (stringp icon-path) icon-path))) (and (stringp icon-path) icon-path)))
(defun mode-icons-get-icon-display-xpm-replace (icon-path rep-alist &optional name) (defun mode-icons-get-icon-display-xpm-replace (icon-path rep-alist &optional name)
"Get xpm image from ICON-PATH and reaplce REP-ALIST in file. "Get xpm image from ICON-PATH and replace REP-ALIST in file.
When NAME is non-nil, also replace the internal xpm image name." When NAME is non-nil, also replace the internal xpm image name."
(let ((case-fold-search t) (let ((case-fold-search t)
(img (mode-icons-get-xpm-string icon-path))) (img (mode-icons-get-xpm-string icon-path))
(i 0))
(dolist (c rep-alist) (dolist (c rep-alist)
(setq img (replace-regexp-in-string (regexp-quote (car c)) (cdr c) img t t))) (setq img (replace-regexp-in-string (regexp-quote (car c)) (format "COLOR<%d>" i) img t t)
i (1+ i)))
(let ((i 0))
(dolist (c rep-alist)
(setq img (replace-regexp-in-string (format "COLOR<%d>" i) (cdr c) img t t)
i (1+ i))))
(when name (when name
(setq img (replace-regexp-in-string "^[ ]*static[ ]+char[ ]+[*][ ]+.*?\\[" (concat "static char * " name "[") img t t))) (setq img (replace-regexp-in-string "^[ ]*static[ ]+char[ ]+[*][ ]+.*?\\[" (concat "static char * " name "[") img t t)))
img)) img))
@ -383,7 +389,7 @@ In order, will try to get the foreground color from:
"Change xpm at ICON-PATH to match FACE. "Change xpm at ICON-PATH to match FACE.
The white is changed to the background color. The white is changed to the background color.
The black is changed to the foreground color. The black is changed to the foreground color.
Grayscale colors are aslo changed by `mode-icons-interpolate-from-scale'." Grayscale colors are also changed by `mode-icons-interpolate-from-scale'."
(let* ((background (mode-icons-background-color face)) (let* ((background (mode-icons-background-color face))
(foreground (mode-icons-foreground-color face)) (foreground (mode-icons-foreground-color face))
(lst (mode-icons-interpolate-from-scale foreground background)) (lst (mode-icons-interpolate-from-scale foreground background))