[mcclim-cvs] CVS mcclim

thenriksen thenriksen at common-lisp.net
Wed Jan 30 22:29:11 UTC 2008


Update of /project/mcclim/cvsroot/mcclim
In directory clnet:/tmp/cvs-serv21204

Modified Files:
	input-editing-drei.lisp input-editing.lisp 
Log Message:
Try to centralise the with-input-editing logic a bit.

Make with-input-editing work for input-editing-streams.


--- /project/mcclim/cvsroot/mcclim/input-editing-drei.lisp	2008/01/30 21:21:43	1.9
+++ /project/mcclim/cvsroot/mcclim/input-editing-drei.lisp	2008/01/30 22:29:07	1.10
@@ -124,9 +124,6 @@
     (setf (stream-cursor-position real-stream)
           (values 0 (nth-value 3 (input-editing-stream-bounding-rectangle stream))))))
 
-(defgeneric invoke-with-input-editing
-    (stream continuation input-sensitizer initial-contents class))
-
 (defmethod invoke-with-input-editing :around ((stream extended-output-stream)
 					      continuation
 					      input-sensitizer
@@ -153,24 +150,12 @@
 				      input-sensitizer
 				      initial-contents
 				      class)
-  (let ((editing-stream (make-instance class
-                         :stream stream)))
-    (if (stringp initial-contents)
-        (replace-input editing-stream initial-contents)
-        (presentation-replace-input editing-stream
-                                    (first initial-contents)
-                                    (second initial-contents)
-                                    (stream-default-view editing-stream)))
-    (unwind-protect
-         (loop
-          (block rescan
-            (handler-bind ((rescan-condition
-                            #'(lambda (c)
-                                (declare (ignore c))
-                                (reset-scan-pointer editing-stream)
-                                (return-from rescan nil))))
-              (return-from invoke-with-input-editing
-                (funcall continuation editing-stream)))))
+  (let ((editing-stream (make-instance class :stream stream)))
+    (unwind-protect (with-input-editing (editing-stream
+                                         :input-sensitizer input-sensitizer
+                                         :initial-contents initial-contents
+                                         :class class)
+                      (funcall continuation editing-stream))
       (finalize editing-stream input-sensitizer))))
 
 (defmethod immediate-rescan ((stream standard-input-editing-stream))
--- /project/mcclim/cvsroot/mcclim/input-editing.lisp	2008/01/30 21:21:44	1.59
+++ /project/mcclim/cvsroot/mcclim/input-editing.lisp	2008/01/30 22:29:07	1.60
@@ -230,11 +230,37 @@
        (return-from input-editing-rescan-loop
 	 (funcall continuation editing-stream))))))
 
+(defgeneric invoke-with-input-editing
+    (stream continuation input-sensitizer initial-contents class)
+  (:documentation "Implements `with-input-editing'. `Class' is
+the class of the input-editing stream to create, if necessary."))
+
 (defmethod invoke-with-input-editing
     (stream continuation input-sensitizer initial-contents class)
   (declare (ignore input-sensitizer initial-contents class))
   (funcall continuation stream))
 
+(defmethod invoke-with-input-editing ((stream input-editing-stream)
+                                      continuation input-sensitizer
+                                      initial-contents class)
+  (let ((start-scan-pointer (stream-scan-pointer stream)))
+    (if (stringp initial-contents)
+        (replace-input stream initial-contents)
+        (presentation-replace-input stream
+                                    (first initial-contents)
+                                    (second initial-contents)
+                                    (stream-default-view stream)))
+    (unwind-protect
+         (loop (block rescan
+                 (handler-bind ((rescan-condition
+                                 #'(lambda (c)
+                                     (declare (ignore c))
+                                     (reset-scan-pointer stream
+                                                         start-scan-pointer)
+                                     (return-from rescan nil))))
+                   (return-from invoke-with-input-editing
+                     (funcall continuation stream))))))))
+
 (defgeneric input-editing-stream-bounding-rectangle (stream)
   (:documentation "Return the bounding rectangle of `stream' as
 four values. This function does not appear in the spec but is




More information about the Mcclim-cvs mailing list