git.fiddlerwoaroof.com
Browse code

started refactoring with CLOS

Alexey Veretennikov authored on 26/05/2015 20:09:52
Showing 1 changed files
... ...
@@ -58,14 +58,19 @@
58 58
 
59 59
 (defclass editor-panes-theme ()
60 60
   ((editor-panes :initform nil :accessor editor-panes)
61
-   (output-panes :initform nil :accessor output-panes)))
61
+   (editor-background :initform +default-background-color+ :accessor bg) 
62
+   (editor-foreground :initform +default-foreground-color+ :accessor fg)))
62 63
 
63 64
 (defclass listener-panes-theme ()
64
-  ((listener-panes :initform nil :accessor listener-panes)))
65
+  ((listener-panes :initform nil :accessor listener-panes)
66
+   (listener-foreground :initform +default-foreground-color+ :accessor bg)
67
+   (listener-background :initform +default-background-color+ :accessor fg)))
65 68
 
66 69
 
67 70
 (defclass general-panes-theme ()
68
-  ((output-panes :initform nil :accessor output-panes)))
71
+  ((output-panes :initform nil :accessor output-panes)
72
+   (output-foreground :initform +default-foreground-color+ :accessor output-fg)
73
+   (output-background :initform +default-background-color+ :accessor output-bg)))
69 74
 
70 75
 (defvar *editor-tool* (make-instance 'editor-panes-theme))
71 76
 (defvar *listener-tool* (make-instance 'listener-panes-theme))
... ...
@@ -105,27 +110,19 @@
105 110
   (values))
106 111
 
107 112
 (defun update-editor-panes ()
108
-  (let ((foreground (gethash :foreground-color *current-colors*))
109
-        (background (gethash :background-color *current-colors*)))
113
+  (let ((foreground (fg *editor-tool*))
114
+        (background (bg *editor-tool*)))
110 115
     (mapcar #'(lambda (pane)
111 116
                  (update-pane-colors pane foreground background))
112 117
              (editor-panes *editor-tool*))))
113 118
 
114 119
 
115 120
 (defun update-listener-panes ()
116
-  (let ((foreground (gethash :listener-foreground-color *current-colors*))
117
-        (background (gethash :listener-background-color *current-colors*)))
121
+  (let ((foreground (fg *listener-tool*))
122
+        (background (bg *listener-tool*)))
118 123
     (mapcar #'(lambda (pane)
119 124
                  (update-pane-colors pane foreground background))
120
-             (listener-panes *listener-tool*)))
121
-  (let ((foreground (gethash :output-foreground-color *current-colors*))
122
-        (background (gethash :output-background-color *current-colors*)))
123
-    (mapcar #'(lambda (pane)
124
-                (update-pane-colors pane foreground background))
125
-            (output-panes *all-tools*))))
126
-
127
-
128
-
125
+             (listener-panes *listener-tool*))))
129 126
 
130 127
 (defun set-color-theme (theme-name)
131 128
   (destructuring-bind (&rest color-theme-args
... ...
@@ -138,31 +135,27 @@
138 135
       (color-theme-args theme-name)
139 136
 
140 137
     ;; editor foreground and background
141
-    (setf (gethash :foreground-color *current-colors*)
142
-          (or foreground +default-foreground-color+)
143
-          (gethash :background-color *current-colors*)
144
-          (or background +default-background-color+))
138
+    (when foreground
139
+      (setf (fg *editor-tool*) foreground))
140
+    (when background
141
+      (setf (bg *editor-tool*) background))
145 142
     ;; listener foreground and background, uses
146 143
     ;; the :background and :foreground if not specified
147
-    (setf (gethash :listener-foreground-color *current-colors*)
144
+    (setf (fg *listener-tool*)
148 145
           (or listener-foreground
149
-              (gethash :foreground-color *current-colors*)
150
-              +default-foreground-color+)
151
-          (gethash :listener-background-color *current-colors*)
146
+              (fg *editor-tool*))
147
+          (bg *listener-tool*)
152 148
           (or listener-background
153
-              (gethash :background-color *current-colors*)
154
-              +default-background-color+))
149
+              (bg *editor-tool*)))
150
+
155 151
     ;; output foreground and background, uses :background and
156 152
     ;; :foreground if not specified
157
-    (setf (gethash :output-foreground-color *current-colors*)
153
+    (setf (output-fg *all-tools*)
158 154
           (or output-foreground
159
-              (gethash :foreground-color *current-colors*)
160
-              +default-foreground-color+)
161
-          (gethash :output-background-color *current-colors*)
155
+              (fg *editor-tool*))
156
+          (output-bg *all-tools*)
162 157
           (or output-background
163
-              (gethash :background-color *current-colors*)
164
-              +default-background-color+))
165
-    
158
+              (bg *editor-tool*)))
166 159
                                  
167 160
     (dolist (name *editor-face-names*)
168 161
       (let* ((color-theme-args-for-face (getf color-theme-args name))
... ...
@@ -204,24 +197,13 @@
204 197
 
205 198
 (defun set-editor-pane-colors (pane)
206 199
   (typecase pane
207
-     (capi:collector-pane
208
-     (progn
209
-       (pushnew pane (output-panes *all-tools*))
210
-       (let ((bg-color (gethash :output-background-color *current-colors*))
211
-             (fg-color (gethash :output-foreground-color *current-colors*)))
212
-         (when fg-color
213
-           (setf (capi:simple-pane-foreground pane) fg-color))
214
-         (when bg-color
215
-           (setf (capi:simple-pane-background pane) bg-color)))))
216 200
     (capi:editor-pane
217 201
      (progn
218 202
        (pushnew pane (editor-panes *editor-tool*))
219
-       (let ((bg-color (gethash :background-color *current-colors*))
220
-             (fg-color (gethash :foreground-color *current-colors*)))
221
-         (when fg-color
222
-           (setf (capi:simple-pane-foreground pane) fg-color))
223
-         (when bg-color
224
-           (setf (capi:simple-pane-background pane) bg-color)))))))
203
+       (let ((bg-color (bg *editor-tool*))
204
+             (fg-color (fg *editor-tool*)))
205
+         (setf (capi:simple-pane-foreground pane) fg-color)
206
+         (setf (capi:simple-pane-background pane) bg-color))))))
225 207
 
226 208
 
227 209
 (defun set-listener-pane-colors (pane)
... ...
@@ -229,24 +211,19 @@
229 211
     (capi:editor-pane
230 212
      (progn
231 213
        (pushnew pane (listener-panes *listener-tool*))
232
-       (let ((bg-color (gethash :listener-background-color *current-colors*))
233
-             (fg-color (gethash :listener-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)))))))
214
+       (let ((bg-color (bg *listener-tool*))
215
+             (fg-color (fg *listener-tool*)))
216
+         (setf (capi:simple-pane-foreground pane) fg-color)
217
+         (setf (capi:simple-pane-background pane) bg-color))))))
238 218
 
239 219
 
240 220
 (defun set-collector-pane-colors (pane)
241
-  ;; only for listener output panes
242
-  ;(when (typep (capi:top-level-interface o) 'lw-tools:listener)
243
-    (pushnew pane (output-panes *all-tools*))
244
-    (let ((bg-color (gethash :output-background-color *current-colors*))
245
-          (fg-color (gethash :output-foreground-color *current-colors*)))
246
-      (when fg-color
247
-        (setf (capi:simple-pane-foreground pane) fg-color))
248
-      (when bg-color
249
-        (setf (capi:simple-pane-background pane) bg-color))))
221
+  ;;(when (typep (capi:top-level-interface pane) 'lw-tools:listener)
222
+  (pushnew pane (output-panes *all-tools*))
223
+  (let ((bg-color (output-bg *all-tools*))
224
+        (fg-color (output-fg *all-tools*)))
225
+    (setf (capi:simple-pane-foreground pane) fg-color)
226
+    (setf (capi:simple-pane-background pane) bg-color)))
250 227
    
251 228
 
252 229
 (lispworks:defadvice ((method capi:interface-display :before (lw-tools:editor))
... ...
@@ -264,8 +241,6 @@
264 241
     (capi:map-pane-descendant-children
265 242
      self 'set-listener-pane-colors)))
266 243
 
267
-(defvar called nil)
268
-
269 244
 ;; capi:collector-pane does'nt have interface-display method called,
270 245
 ;; so we adding the :after constuctor instead
271 246
 (sys::without-warning-on-redefinition