Browse code
added listener colors
Alexey Veretennikov authored on 21/05/2015 21:36:21
Showing 1 changed files
Showing 1 changed files
... | ... |
@@ -8,28 +8,37 @@ |
8 | 8 |
|
9 | 9 |
(cl:in-package #:cl-user) |
10 | 10 |
|
11 |
+ |
|
11 | 12 |
(defpackage #:editor-color-theme |
12 | 13 |
(:use #:cl) |
13 | 14 |
(:export #:*foreground-color* |
14 |
- #:*background-color* |
|
15 |
- #:all-color-themes |
|
16 |
- #:color-theme-args |
|
17 |
- #:color-theme |
|
18 |
- #:define-color-theme |
|
19 |
- #:remove-color-theme |
|
20 |
- )) |
|
15 |
+ #:*background-color* |
|
16 |
+ #:*listener-foreground-color* |
|
17 |
+ #:*listener-background-color* |
|
18 |
+ #:all-color-themes |
|
19 |
+ #:color-theme-args |
|
20 |
+ #:color-theme |
|
21 |
+ #:define-color-theme |
|
22 |
+ #:remove-color-theme |
|
23 |
+ )) |
|
21 | 24 |
|
22 | 25 |
(in-package #:editor-color-theme) |
23 | 26 |
|
24 | 27 |
|
25 | 28 |
;;; Configuration |
26 | 29 |
|
30 |
+;; Editor foreground and background colors |
|
27 | 31 |
(defvar *foreground-color* nil) |
28 |
- |
|
29 | 32 |
(defvar *background-color* nil) |
30 | 33 |
|
31 |
-(defconstant +default-foreground-color :black) |
|
32 |
-(defconstant +default-background-color :white) |
|
34 |
+;; Listener foreground and background colors |
|
35 |
+(defvar *listener-foreground-color* nil) |
|
36 |
+(defvar *listener-background-color* nil) |
|
37 |
+ |
|
38 |
+ |
|
39 |
+;; Default foreground and background colors |
|
40 |
+(defconstant +default-foreground-color+ :black) |
|
41 |
+(defconstant +default-background-color+ :white) |
|
33 | 42 |
|
34 | 43 |
|
35 | 44 |
;;; Implementation |
... | ... |
@@ -38,16 +47,16 @@ |
38 | 47 |
|
39 | 48 |
(defun all-color-themes () |
40 | 49 |
(maphash #'(lambda (key value) |
41 |
- (declare (ignore value)) |
|
42 |
- key) |
|
43 |
- *all-color-themes*)) |
|
50 |
+ (declare (ignore value)) |
|
51 |
+ key) |
|
52 |
+ *all-color-themes*)) |
|
44 | 53 |
|
45 | 54 |
(defun color-theme-data (theme-name) |
46 |
- (multiple-value-bind (color-theme-data found?) |
|
55 |
+ (multiple-value-bind (data found?) |
|
47 | 56 |
(gethash theme-name *all-color-themes*) |
48 | 57 |
(if found? |
49 |
- color-theme-data |
|
50 |
- (error "No color theme named ~s found." theme-name)))) |
|
58 |
+ data |
|
59 |
+ (error "No color theme named ~s found." theme-name)))) |
|
51 | 60 |
|
52 | 61 |
(defun color-theme-super-theme-names (theme-name) |
53 | 62 |
(first (color-theme-data theme-name))) |
... | ... |
@@ -56,18 +65,14 @@ |
56 | 65 |
(rest (color-theme-data theme-name))) |
57 | 66 |
|
58 | 67 |
(defvar *all-editor-panes* (make-hash-table :test 'eq |
59 |
- :weak-kind :key)) |
|
60 |
- |
|
61 |
-(defun get-background-color () |
|
62 |
- (or *background-color* +default-background-color)) |
|
63 |
- |
|
64 |
-(defun get-foreground-color () |
|
65 |
- (or *foreground-color* +default-foreground-color)) |
|
68 |
+ :weak-kind :key)) |
|
66 | 69 |
|
70 |
+(defvar *all-listener-editor-panes* (make-hash-table :test 'eq |
|
71 |
+ :weak-kind :key)) |
|
67 | 72 |
|
68 |
-(defun update-editor-pane (pane) |
|
69 |
- (setf (capi:simple-pane-foreground pane) (get-foreground-color)) |
|
70 |
- (setf (capi:simple-pane-background pane) (get-background-color)) |
|
73 |
+(defun update-editor-pane (pane foreground background) |
|
74 |
+ (setf (capi:simple-pane-foreground pane) foreground) |
|
75 |
+ (setf (capi:simple-pane-background pane) background) |
|
71 | 76 |
|
72 | 77 |
(let ((recolorize-p (editor::buffer-font-lock-mode-p (capi:editor-pane-buffer pane)))) |
73 | 78 |
(when recolorize-p |
... | ... |
@@ -75,12 +80,25 @@ |
75 | 80 |
(values)) |
76 | 81 |
|
77 | 82 |
(defun update-editor-panes () |
78 |
- (maphash #'(lambda (pane value) |
|
79 |
- (declare (ignore value)) |
|
80 |
- (update-editor-pane pane)) |
|
81 |
- *all-editor-panes*) |
|
83 |
+ (let ((foreground (or *foreground-color* +default-foreground-color+)) |
|
84 |
+ (background (or *background-color* +default-background-color+))) |
|
85 |
+ (maphash #'(lambda (pane value) |
|
86 |
+ (declare (ignore value)) |
|
87 |
+ (update-editor-pane pane foreground background)) |
|
88 |
+ *all-editor-panes*)) |
|
82 | 89 |
(values)) |
83 | 90 |
|
91 |
+ |
|
92 |
+(defun update-listener-panes () |
|
93 |
+ (let ((foreground (or *listener-foreground-color* +default-foreground-color+)) |
|
94 |
+ (background (or *listener-background-color* +default-background-color+))) |
|
95 |
+ (maphash #'(lambda (pane value) |
|
96 |
+ (declare (ignore value)) |
|
97 |
+ (update-editor-pane pane foreground background)) |
|
98 |
+ *all-listener-editor-panes*)) |
|
99 |
+ (values)) |
|
100 |
+ |
|
101 |
+ |
|
84 | 102 |
(defvar *editor-face-names* |
85 | 103 |
'(:region |
86 | 104 |
:show-point-face |
... | ... |
@@ -103,20 +121,28 @@ |
103 | 121 |
|
104 | 122 |
(defun set-color-theme (theme-name) |
105 | 123 |
(destructuring-bind (&rest color-theme-args |
106 |
- &key foreground background &allow-other-keys) |
|
124 |
+ &key foreground background |
|
125 |
+ listener-foreground |
|
126 |
+ listener-background |
|
127 |
+ &allow-other-keys) |
|
107 | 128 |
(color-theme-args theme-name) |
108 |
- |
|
109 |
- (setf *foreground-color* (or foreground +default-foreground-color)) |
|
110 |
- (setf *background-color* (or background +default-background-color)) |
|
111 |
- |
|
129 |
+ |
|
130 |
+ ;; editor foreground and background |
|
131 |
+ (setf *foreground-color* (or foreground +default-foreground-color+)) |
|
132 |
+ (setf *background-color* (or background +default-background-color+)) |
|
133 |
+ |
|
134 |
+ ;; listener foreground and background |
|
135 |
+ (setf *listener-foreground-color* (or listener-foreground +default-foreground-color+)) |
|
136 |
+ (setf *listener-background-color* (or listener-background +default-background-color+)) |
|
137 |
+ |
|
112 | 138 |
(dolist (name *editor-face-names*) |
113 | 139 |
(let* ((color-theme-args-for-face (getf color-theme-args name)) |
114 |
- (face-name (intern (string name) '#:editor)) |
|
115 |
- (face (editor:make-face face-name :if-exists t))) |
|
116 |
- (apply 'editor:make-face face-name :if-exists :overwrite |
|
117 |
- :documentation (or (getf color-theme-args-for-face :documentation) |
|
118 |
- (slot-value face 'documentation)) |
|
119 |
- color-theme-args-for-face)))) |
|
140 |
+ (face-name (intern (string name) '#:editor)) |
|
141 |
+ (face (editor:make-face face-name :if-exists t))) |
|
142 |
+ (apply 'editor:make-face face-name :if-exists :overwrite |
|
143 |
+ :documentation (or (getf color-theme-args-for-face :documentation) |
|
144 |
+ (slot-value face 'documentation)) |
|
145 |
+ color-theme-args-for-face)))) |
|
120 | 146 |
|
121 | 147 |
theme-name) |
122 | 148 |
|
... | ... |
@@ -125,17 +151,20 @@ |
125 | 151 |
(set-color-theme theme-name) |
126 | 152 |
|
127 | 153 |
(update-editor-panes) |
154 |
+ (update-listener-panes) |
|
128 | 155 |
|
129 | 156 |
theme-name) |
130 | 157 |
|
131 | 158 |
(defun define-color-theme (theme-name super-theme-names |
132 |
- &rest color-theme-args &key &allow-other-keys) |
|
159 |
+ &rest color-theme-args &key &allow-other-keys) |
|
160 |
+ (unless super-theme-names |
|
161 |
+ (setf super-theme-names '("default"))) |
|
133 | 162 |
(dolist (super-theme-name super-theme-names) |
134 | 163 |
(multiple-value-bind (color-theme-data found?) |
135 |
- (gethash super-theme-name *all-color-themes*) |
|
164 |
+ (gethash super-theme-name *all-color-themes*) |
|
136 | 165 |
(declare (ignore color-theme-data)) |
137 | 166 |
(unless found? |
138 |
- (warn "Inherited color theme ~s not defined." super-theme-name)))) |
|
167 |
+ (warn "Inherited color theme ~s not defined." super-theme-name)))) |
|
139 | 168 |
|
140 | 169 |
(setf (gethash theme-name *all-color-themes*) (list* super-theme-names color-theme-args)) |
141 | 170 |
|
... | ... |
@@ -154,6 +183,25 @@ |
154 | 183 |
(when *background-color* |
155 | 184 |
(setf (capi:simple-pane-background pane) *background-color*)))))) |
156 | 185 |
|
186 |
+(defun set-listener-pane-colors (pane) |
|
187 |
+ (typecase pane |
|
188 |
+ (capi:editor-pane |
|
189 |
+ (progn |
|
190 |
+ (setf (gethash pane *all-listener-editor-panes*) pane) |
|
191 |
+ (when *listener-foreground-color* |
|
192 |
+ (setf (capi:simple-pane-foreground pane) *listener-foreground-color*)) |
|
193 |
+ (when *listener-background-color* |
|
194 |
+ (setf (capi:simple-pane-background pane) *listener-background-color*)))) |
|
195 |
+ (capi:editor-pane |
|
196 |
+ (progn |
|
197 |
+ (setf (gethash pane *all-listener-editor-panes*) pane) |
|
198 |
+ (when *listener-foreground-color* |
|
199 |
+ (setf (capi:simple-pane-foreground pane) *listener-foreground-color*)) |
|
200 |
+ (when *listener-background-color* |
|
201 |
+ (setf (capi:simple-pane-background pane) *listener-background-color*)))) |
|
202 |
+ )) |
|
203 |
+ |
|
204 |
+ |
|
157 | 205 |
|
158 | 206 |
(lispworks:defadvice ((method capi:interface-display :before (lw-tools:editor)) |
159 | 207 |
change-editor-colors |
... | ... |
@@ -163,6 +211,14 @@ |
163 | 211 |
(capi:map-pane-descendant-children interface 'set-editor-pane-colors)) |
164 | 212 |
|
165 | 213 |
|
214 |
+;; we don't have defined capi:interface-display for lw-tools::listener, |
|
215 |
+;; so nothing to advice. Instead we need to define our own |
|
216 |
+(sys::without-warning-on-redefinition |
|
217 |
+ (defmethod capi:interface-display :before ((self lw-tools::listener)) |
|
218 |
+ (capi:map-pane-descendant-children |
|
219 |
+ self 'set-listener-pane-colors))) |
|
220 |
+ |
|
221 |
+ |
|
166 | 222 |
;; This makes it "work" after the podium is launched |
167 | 223 |
(defun is-editor-pane-p (obj) |
168 | 224 |
(and (typep obj 'capi:editor-pane) |
... | ... |
@@ -185,7 +241,7 @@ |
185 | 241 |
:foreground nil |
186 | 242 |
:background nil |
187 | 243 |
:region '(:foreground :color_highlighttext |
188 |
- :background :color_highlight) |
|
244 |
+ :background :color_highlight) |
|
189 | 245 |
:show-point-face '(:background :green) |
190 | 246 |
:interactive-input-face '(:foreground :red3) |
191 | 247 |
:highlight '(:bold-p t) |
... | ... |
@@ -206,7 +262,7 @@ |
206 | 262 |
(define-color-theme "plain" () |
207 | 263 |
:foreground nil :background nil |
208 | 264 |
:region '(:foreground :color_highlighttext |
209 |
- :background :color_highlight) |
|
265 |
+ :background :color_highlight) |
|
210 | 266 |
:show-point-face '() |
211 | 267 |
:interactive-input-face '() |
212 | 268 |
:highlight '(:bold-p t) |
... | ... |
@@ -226,9 +282,9 @@ |
226 | 282 |
|
227 | 283 |
|
228 | 284 |
(define-color-theme "emacs" () |
229 |
- :foreground nil :background nil |
|
285 |
+ ;; :foreground nil :background nil |
|
230 | 286 |
:region '(:foreground :color_highlighttext |
231 |
- :background :color_highlight) |
|
287 |
+ :background :color_highlight) |
|
232 | 288 |
:show-point-face '(:background :green) |
233 | 289 |
:interactive-input-face '(:foreground :red3) |
234 | 290 |
:highlight '(:bold-p t) |
... | ... |
@@ -251,7 +307,7 @@ |
251 | 307 |
:foreground (color:make-rgb 0.8s0 0.8s0 0.8s0) |
252 | 308 |
:background (color:make-rgb 0.0s0 0.0s0 0.0s0) |
253 | 309 |
:region '(:foreground :color_highlighttext |
254 |
- :background :color_highlight) |
|
310 |
+ :background :color_highlight) |
|
255 | 311 |
:show-point-face `(:background ,(color:make-rgb 0.6275s0 0.1255s0 0.9412s0)) |
256 | 312 |
:interactive-input-face '(:foreground :pink) |
257 | 313 |
:highlight '(:bold-p t) |