branch: elpa/dracula-theme
commit f5918cb7966ab9f8350371bbdd8767cb3db46de8
Author: Étienne Deparis <[email protected]>
Commit: Étienne Deparis <[email protected]>
Add a setting to force 24bit colors on 256 colors terms
---
README.md | 3 +++
dracula-theme.el | 21 +++++++++++++++------
2 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/README.md b/README.md
index b607b0c..c9be0df 100644
--- a/README.md
+++ b/README.md
@@ -36,6 +36,9 @@ need to be set before `load-theme` is invoked for Dracula.
;; Use less pink and bold on the mode-line and minibuffer (default nil)
(setq dracula-alternate-mode-line-and-minibuffer t)
+
+;; Force 24 bit colors (regular colors) on terminals (default nil)
+(setq dracula-use-24-bit-colors-on-256-colors-terms t)
```
## Test
diff --git a/dracula-theme.el b/dracula-theme.el
index bb364fe..e168a94 100644
--- a/dracula-theme.el
+++ b/dracula-theme.el
@@ -56,6 +56,11 @@ The theme has to be reloaded after changing anything in this
group."
:type 'boolean
:group 'dracula)
+(defcustom dracula-use-24-bit-colors-on-256-colors-terms nil
+ "Use true colors even on terminals announcing less capabilities."
+ :type 'boolean
+ :group 'dracula)
+
;;;; Theme definition:
@@ -611,17 +616,21 @@ The theme has to be reloaded after changing anything in
this group."
(graphic-colors (mapcar #'cadr colors))
(term-colors (mapcar #'car (mapcar #'cddr colors)))
(tty-colors (mapcar #'car (mapcar #'last colors)))
- (expand-for-kind (lambda (kind spec)
- (cl-progv color-names kind
- (eval `(backquote ,spec))))))
+ (expand-for-kind
+ (lambda (kind spec)
+ (when (and (string= (symbol-name kind) "term-colors")
+ dracula-use-24-bit-colors-on-256-colors-terms)
+ (setq kind 'graphic-colors))
+ (cl-progv color-names (symbol-value kind)
+ (eval `(backquote ,spec))))))
(cl-loop for (face . spec) in faces
collect `(,face
((((min-colors 16777216)) ; fully graphical envs
- ,(funcall expand-for-kind graphic-colors spec))
+ ,(funcall expand-for-kind 'graphic-colors
spec))
(((min-colors 256)) ; terminal withs 256
colors
- ,(funcall expand-for-kind term-colors spec))
+ ,(funcall expand-for-kind 'term-colors spec))
(t ; should be only
tty-like envs
- ,(funcall expand-for-kind tty-colors
spec))))))))
+ ,(funcall expand-for-kind 'tty-colors
spec))))))))
;;;###autoload