[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ef-themes 2127ac4c0a 260/281: Implement colour preview
From: |
ELPA Syncer |
Subject: |
[elpa] externals/ef-themes 2127ac4c0a 260/281: Implement colour preview commands |
Date: |
Tue, 16 Aug 2022 16:58:39 -0400 (EDT) |
branch: externals/ef-themes
commit 2127ac4c0ad763c3b173bf90c70c17b1976b5103
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Implement colour preview commands
---
ef-themes.el | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 63 insertions(+)
diff --git a/ef-themes.el b/ef-themes.el
index 563c4b9809..57d38ccb0c 100644
--- a/ef-themes.el
+++ b/ef-themes.el
@@ -97,6 +97,69 @@ When called from Lisp, THEME is a symbol."
(mapc #'disable-theme (ef-themes--list-known-themes))
(load-theme theme :no-confirm))
+(defun ef-themes--preview-colors-render (buffer theme &rest _)
+ "Render colors in BUFFER from THEME.
+Routine for `ef-themes-preview-colors'."
+ (let ((palette (seq-remove (lambda (cell)
+ (symbolp (cadr cell)))
+ (symbol-value (ef-themes--palette theme))))
+ (current-buffer buffer)
+ (current-theme theme))
+ (with-help-window buffer
+ (with-current-buffer standard-output
+ (erase-buffer)
+ (when (<= (display-color-cells) 256)
+ (insert (concat "Your display terminal may not render all color
previews!\n"
+ "It seems to only support <= 256 colors.\n\n"))
+ (put-text-property (point-min) (point) 'face 'warning))
+ ;; We need this to properly render the first line.
+ (insert " ")
+ (dolist (cell palette)
+ (let* ((name (car cell))
+ (color (cadr cell))
+ (fg (readable-foreground-color color))
+ (pad (make-string 5 ?\s)))
+ (let ((old-point (point)))
+ (insert (format "%s %s" color pad))
+ (put-text-property old-point (point) 'face `( :foreground
,color)))
+ (let ((old-point (point)))
+ (insert (format " %s %s %s\n" color pad name))
+ (put-text-property old-point (point)
+ 'face `( :background ,color
+ :foreground ,fg
+ :extend t)))
+ ;; We need this to properly render the last line.
+ (insert " ")))
+ (setq-local revert-buffer-function
+ (lambda (_ignore-auto _noconfirm)
+ (ef-themes--preview-colors-render current-buffer
current-theme)))))))
+
+(defvar ef-themes--preview-colors-prompt-history '()
+ "Minibuffer history for `ef-themes--preview-colors-prompt'.")
+
+(defun ef-themes--preview-colors-prompt ()
+ "Prompt for Ef theme.
+Helper function for `ef-themes-preview-colors'."
+ (let ((def (format "%s" (ef-themes--current-theme))))
+ (completing-read
+ (format "Use palette from theme [%s]: " def)
+ (ef-themes--list-known-themes) nil t nil
+ 'ef-themes--preview-colors-prompt-history def)))
+
+;;;###autoload
+(defun ef-themes-preview-colors (theme)
+ "Preview palette of the Ef THEME of choice."
+ (interactive (list (intern (ef-themes--preview-colors-prompt))))
+ (ef-themes--preview-colors-render
+ (format "*%s-preview-colors*" theme)
+ theme))
+
+;;;###autoload
+(defun ef-themes-preview-colors-current ()
+ "Call `ef-themes-preview-colors' for the current Ef theme."
+ (interactive)
+ (ef-themes-preview-colors (ef-themes--current-theme)))
+
;;; Faces and variables
(defconst ef-themes-faces
- [elpa] externals/ef-themes fe964c37ed 191/281: ef-dark: add modus-vivendi (oops, wrong repo!), (continued)
- [elpa] externals/ef-themes fe964c37ed 191/281: ef-dark: add modus-vivendi (oops, wrong repo!), ELPA Syncer, 2022/08/16
- [elpa] externals/ef-themes 4ed9a19ba6 196/281: Tweak spacing in all palettes, ELPA Syncer, 2022/08/16
- [elpa] externals/ef-themes adc697e4f8 224/281: Add support for all-the-icons, ELPA Syncer, 2022/08/16
- [elpa] externals/ef-themes 5ab3941827 219/281: Refine mode-line-emphasis, ELPA Syncer, 2022/08/16
- [elpa] externals/ef-themes d065c9f62a 228/281: ef-autumn: tweak diff hues, ELPA Syncer, 2022/08/16
- [elpa] externals/ef-themes 61b9480289 226/281: Add support for rectangle-preview face, ELPA Syncer, 2022/08/16
- [elpa] externals/ef-themes 025d150f20 233/281: Add support for ruler-mode, ELPA Syncer, 2022/08/16
- [elpa] externals/ef-themes 914ba8be0d 231/281: Tweak a couple of all-the-icons faces, ELPA Syncer, 2022/08/16
- [elpa] externals/ef-themes ae6e2a3096 251/281: Abstract function to return current palette, ELPA Syncer, 2022/08/16
- [elpa] externals/ef-themes 8e3ba5eab9 273/281: Update themes to 0.0.1 (NOT AN ACTUAL RELEASE), ELPA Syncer, 2022/08/16
- [elpa] externals/ef-themes 2127ac4c0a 260/281: Implement colour preview commands,
ELPA Syncer <=
- [elpa] externals/ef-themes 2b9b75c1a1 272/281: Add the manual, ELPA Syncer, 2022/08/16
- [elpa] externals/ef-themes c338674fbe 189/281: Tweak transient faces, ELPA Syncer, 2022/08/16
- [elpa] externals/ef-themes ddcf16939a 193/281: ef-spring: tweak bg-green, ELPA Syncer, 2022/08/16
- [elpa] externals/ef-themes 14319e33a0 209/281: ef-winter: tweak fg-alt, ELPA Syncer, 2022/08/16
- [elpa] externals/ef-themes 1f972d4ecc 213/281: ef-day: tweak bg-hl-line, ELPA Syncer, 2022/08/16
- [elpa] externals/ef-themes 195194874c 227/281: ef-day: tweak diff hues, ELPA Syncer, 2022/08/16
- [elpa] externals/ef-themes b7a8858dfa 229/281: Simplify bookmark-face, ELPA Syncer, 2022/08/16
- [elpa] externals/ef-themes a37525dab0 277/281: ef-night: tweak green-cooler, ELPA Syncer, 2022/08/16
- [elpa] externals/ef-themes f4c7182309 275/281: ef-winter: tweak yellow-cooler, ELPA Syncer, 2022/08/16
- [elpa] externals/ef-themes 18672e0cf9 240/281: ef-summer: revise mappings for headings/rainbow, ELPA Syncer, 2022/08/16