git.fiddlerwoaroof.com
Browse code

Added support for the output background

Alexey Veretennikov authored on 25/05/2015 20:51:11
Showing 1 changed files
... ...
@@ -34,6 +34,35 @@
34 34
 
35 35
 (defvar *all-color-themes* (make-hash-table :test 'string=))
36 36
 
37
+(defvar *editor-face-names*
38
+  '(:region
39
+    :show-point-face
40
+    :interactive-input-face
41
+    :highlight
42
+    :non-focus-complete-face
43
+    :font-lock-function-name-face
44
+    :font-lock-comment-face
45
+    :font-lock-type-face
46
+    :font-lock-variable-name-face
47
+    :font-lock-string-face
48
+    :font-lock-keyword-face
49
+    :font-lock-builtin-face
50
+    :compiler-note-highlight
51
+    :compiler-warning-highlight
52
+    :compiler-error-highlight
53
+    :incremental-search-face
54
+    :incremental-search-other-matches-face
55
+    ))
56
+
57
+(defvar *all-editor-panes* nil)
58
+
59
+(defvar *all-listener-editor-panes* nil)
60
+
61
+(defvar *all-collector-panes* nil)
62
+                              
63
+
64
+;; (eq (capi:capi-object-name b) 'lw-tools::buffers-list)
65
+
37 66
 (defun all-color-themes ()
38 67
   (maphash #'(lambda (key value)
39 68
                (declare (ignore value))
... ...
@@ -53,13 +82,9 @@
53 82
 (defun color-theme-args (theme-name)
54 83
   (rest (color-theme-data theme-name)))
55 84
 
56
-(defvar *all-editor-panes* (make-hash-table :test 'eq
57
-                                            :weak-kind :key))
58 85
 
59
-(defvar *all-listener-editor-panes* (make-hash-table :test 'eq
60
-                                                     :weak-kind :key))
61 86
 
62
-(defun update-editor-pane (pane foreground background)
87
+(defun update-pane-colors (pane foreground background)
63 88
   (setf (capi:simple-pane-foreground pane) foreground)
64 89
   (setf (capi:simple-pane-background pane) background)
65 90
   
... ...
@@ -71,49 +96,32 @@
71 96
 (defun update-editor-panes ()
72 97
   (let ((foreground (gethash :foreground-color *current-colors*))
73 98
         (background (gethash :background-color *current-colors*)))
74
-    (maphash #'(lambda (pane value)
75
-                 (declare (ignore value))
76
-                 (update-editor-pane pane foreground background))
77
-             *all-editor-panes*))
78
-  (values))
99
+    (mapcar #'(lambda (pane)
100
+                 (update-pane-colors pane foreground background))
101
+             *all-editor-panes*)))
79 102
 
80 103
 
81 104
 (defun update-listener-panes ()
82 105
   (let ((foreground (gethash :listener-foreground-color *current-colors*))
83 106
         (background (gethash :listener-background-color *current-colors*)))
84
-    (maphash #'(lambda (pane value)
85
-                 (declare (ignore value))
86
-                 (update-editor-pane pane foreground background))
107
+    (mapcar #'(lambda (pane)
108
+                 (update-pane-colors pane foreground background))
87 109
              *all-listener-editor-panes*))
88
-    (values))
110
+  (let ((foreground (gethash :output-foreground-color *current-colors*))
111
+        (background (gethash :output-background-color *current-colors*)))
112
+    (mapcar #'(lambda (pane)
113
+                (update-pane-colors pane foreground background))
114
+            *all-collector-panes*)))
89 115
 
90 116
 
91
-(defvar *editor-face-names*
92
-  '(:region
93
-    :show-point-face
94
-    :interactive-input-face
95
-    :highlight
96
-    :non-focus-complete-face
97
-    :font-lock-function-name-face
98
-    :font-lock-comment-face
99
-    :font-lock-type-face
100
-    :font-lock-variable-name-face
101
-    :font-lock-string-face
102
-    :font-lock-keyword-face
103
-    :font-lock-builtin-face
104
-    :compiler-note-highlight
105
-    :compiler-warning-highlight
106
-    :compiler-error-highlight
107
-    :incremental-search-face
108
-    :incremental-search-other-matches-face
109
-    ))
110
-
111 117
 
112 118
 (defun set-color-theme (theme-name)
113 119
   (destructuring-bind (&rest color-theme-args
114 120
                              &key foreground background
115 121
                              listener-foreground
116 122
                              listener-background
123
+                             output-foreground
124
+                             output-background
117 125
                              &allow-other-keys)
118 126
       (color-theme-args theme-name)
119 127
 
... ...
@@ -132,6 +140,17 @@
132 140
           (or listener-background
133 141
               (gethash :background-color *current-colors*)
134 142
               +default-background-color+))
143
+    ;; output foreground and background, uses :background and
144
+    ;; :foreground if not specified
145
+    (setf (gethash :output-foreground-color *current-colors*)
146
+          (or output-foreground
147
+              (gethash :foreground-color *current-colors*)
148
+              +default-foreground-color+)
149
+          (gethash :output-background-color *current-colors*)
150
+          (or output-background
151
+              (gethash :background-color *current-colors*)
152
+              +default-background-color+))
153
+    
135 154
                                  
136 155
     (dolist (name *editor-face-names*)
137 156
       (let* ((color-theme-args-for-face (getf color-theme-args name))
... ...
@@ -173,9 +192,18 @@
173 192
 
174 193
 (defun set-editor-pane-colors (pane)
175 194
   (typecase pane
195
+     (capi:collector-pane
196
+     (progn
197
+       (pushnew pane *all-collector-panes*)
198
+       (let ((bg-color (gethash :output-background-color *current-colors*))
199
+             (fg-color (gethash :output-foreground-color *current-colors*)))
200
+         (when fg-color
201
+           (setf (capi:simple-pane-foreground pane) fg-color))
202
+         (when bg-color
203
+           (setf (capi:simple-pane-background pane) bg-color)))))
176 204
     (capi:editor-pane
177 205
      (progn
178
-       (setf (gethash pane *all-editor-panes*) pane)
206
+       (pushnew pane *all-editor-panes*)
179 207
        (let ((bg-color (gethash :background-color *current-colors*))
180 208
              (fg-color (gethash :foreground-color *current-colors*)))
181 209
          (when fg-color
... ...
@@ -183,11 +211,12 @@
183 211
          (when bg-color
184 212
            (setf (capi:simple-pane-background pane) bg-color)))))))
185 213
 
214
+
186 215
 (defun set-listener-pane-colors (pane)
187 216
   (typecase pane
188 217
     (capi:editor-pane
189 218
      (progn
190
-       (setf (gethash pane *all-listener-editor-panes*) pane)
219
+       (pushnew pane *all-listener-editor-panes*)
191 220
        (let ((bg-color (gethash :listener-background-color *current-colors*))
192 221
              (fg-color (gethash :listener-foreground-color *current-colors*)))
193 222
          (when fg-color
... ...
@@ -196,6 +225,19 @@
196 225
            (setf (capi:simple-pane-background pane) bg-color)))))))
197 226
 
198 227
 
228
+(defun set-collector-pane-colors (pane)
229
+  ;; only for listener output panes
230
+  ;(when (typep (capi:top-level-interface o) 'lw-tools:listener)
231
+    (pushnew pane *all-collector-panes*)
232
+    (let ((bg-color (gethash :output-background-color *current-colors*))
233
+          (fg-color (gethash :output-foreground-color *current-colors*)))
234
+      (when fg-color
235
+        (setf (capi:simple-pane-foreground pane) fg-color))
236
+      (when bg-color
237
+        (setf (capi:simple-pane-background pane) bg-color))))
238
+   
239
+
240
+
199 241
 
200 242
 (lispworks:defadvice ((method capi:interface-display :before (lw-tools:editor))
201 243
                       change-editor-colors
... ...
@@ -212,6 +254,15 @@
212 254
     (capi:map-pane-descendant-children
213 255
      self 'set-listener-pane-colors)))
214 256
 
257
+(defvar called nil)
258
+
259
+;; capi:collector-pane does'nt have interface-display method called,
260
+;; so we adding the :after constuctor instead
261
+(sys::without-warning-on-redefinition
262
+  (defmethod initialize-instance :after ((self capi:collector-pane) &rest
263
+                                         clos::initargs &key &allow-other-keys)
264
+    (set-collector-pane-colors self)))
265
+
215 266
 
216 267
 ;; This makes it "work" after the podium is launched
217 268
 (defun is-editor-pane-p (obj)
... ...
@@ -219,7 +270,7 @@
219 270
        (not (eq obj (hcl:class-prototype (class-of obj))))))
220 271
 
221 272
 (defun cache-existing-pane (pane)
222
-  (setf (gethash pane *all-editor-panes*) pane))
273
+  (pushnew pane *all-editor-panes*))
223 274
 
224 275
 (defun cache-if-pane (obj)
225 276
   (when (is-editor-pane-p obj)