-
-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1502 from jfaz1/theme-click
Use buttons for theme list
- Loading branch information
Showing
3 changed files
with
47 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
(in-package :lem-core) | ||
|
||
(define-major-mode color-theme-selector-mode () | ||
(:name "Themes" | ||
:keymap *color-theme-selector-keymap*)) | ||
|
||
(define-key *color-theme-selector-keymap* "Return" 'color-theme-selector-select) | ||
|
||
(define-command color-theme-selector-select () () | ||
(with-point ((point (current-point))) | ||
(line-start point) | ||
(let ((theme (text-property-at point 'theme))) | ||
(load-theme theme)))) | ||
|
||
(define-command list-color-themes () () | ||
(let* ((buffer (make-buffer "*Color Themes*")) | ||
(point (buffer-point buffer)) | ||
(dark-themes '()) | ||
(light-themes '())) | ||
(with-buffer-read-only buffer nil | ||
(erase-buffer buffer) | ||
(dolist (name (all-color-themes)) | ||
(let ((theme (find-color-theme name))) | ||
(if (eq :dark (get-color-theme-color theme :display-background-mode)) | ||
(push (cons name theme) dark-themes) | ||
(push (cons name theme) light-themes)))) | ||
(loop :for (name . theme) :in (append dark-themes light-themes) | ||
:do (let ((button-start (copy-point point :temporary)) | ||
(theme-name name)) | ||
(lem/button:insert-button | ||
point | ||
theme-name | ||
(lambda () (load-theme theme-name)) | ||
:attribute (make-attribute | ||
:foreground (get-color-theme-color theme :foreground) | ||
:background (get-color-theme-color theme :background))) | ||
(put-text-property button-start point 'theme theme-name) | ||
(insert-character point #\newline)))) | ||
(buffer-start point) | ||
(setf (buffer-read-only-p buffer) t) | ||
(switch-to-buffer buffer) | ||
(change-buffer-mode buffer 'color-theme-selector-mode))) |