Allow setting a color for dimmed text. Fixes #21

This commit is contained in:
Lars Tveito 2019-12-03 01:42:14 +01:00
parent ab42b87799
commit bf5fcff0d0

View File

@ -73,6 +73,9 @@ Things that are defined include `symbol', `list', `sexp',
(defvar focus-cursor-type cursor-type (defvar focus-cursor-type cursor-type
"Used to restore the users `cursor-type'") "Used to restore the users `cursor-type'")
(defvar focus-dim-color nil
"Overrides the color used for dimmed text.")
(defvar-local focus-current-thing nil (defvar-local focus-current-thing nil
"Overrides the choice of thing dictated by `focus-mode-to-thing' if set.") "Overrides the choice of thing dictated by `focus-mode-to-thing' if set.")
@ -149,7 +152,7 @@ adds `focus-move-focus' to `post-command-hook'."
(setq focus-pre-overlay (make-overlay (point-min) (point-min)) (setq focus-pre-overlay (make-overlay (point-min) (point-min))
focus-post-overlay (make-overlay (point-max) (point-max)) focus-post-overlay (make-overlay (point-max) (point-max))
focus-buffer (current-buffer)) focus-buffer (current-buffer))
(let ((color (focus-make-dim-color))) (let ((color (or focus-dim-color (focus-make-dim-color))))
(mapc (lambda (o) (overlay-put o 'face (cons 'foreground-color color))) (mapc (lambda (o) (overlay-put o 'face (cons 'foreground-color color)))
(list focus-pre-overlay focus-post-overlay))) (list focus-pre-overlay focus-post-overlay)))
(add-hook 'post-command-hook 'focus-move-focus nil t) (add-hook 'post-command-hook 'focus-move-focus nil t)
@ -273,9 +276,10 @@ It cleans up the `focus-read-only-blink-timer' and hooks."
:keymap (let ((map (make-sparse-keymap))) :keymap (let ((map (make-sparse-keymap)))
(define-key map (kbd "C-c C-q") 'focus-read-only-mode) (define-key map (kbd "C-c C-q") 'focus-read-only-mode)
map) map)
(unless (and (color-defined-p (face-attribute 'default :background)) (unless (or (and (color-defined-p (face-attribute 'default :background))
(color-defined-p (face-attribute 'default :foreground))) (color-defined-p (face-attribute 'default :foreground)))
(message "Can't enable focus mode when no theme is loaded.") focus-dim-color)
(message "Can't enable focus mode when no theme is loaded. Try setting focus-dim-color!")
(setq focus-mode nil)) (setq focus-mode nil))
(if focus-mode (focus-init) (focus-terminate))) (if focus-mode (focus-init) (focus-terminate)))