[mcclim-cvs] CVS mcclim/Drei

thenriksen thenriksen at common-lisp.net
Wed Nov 8 13:08:12 UTC 2006


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

Modified Files:
	input-editor.lisp drei-clim.lisp 
Log Message:
Implemented `add-input-editor-command' as per the Franz User Guide.


--- /project/mcclim/cvsroot/mcclim/Drei/input-editor.lisp	2006/11/08 01:15:33	1.1
+++ /project/mcclim/cvsroot/mcclim/Drei/input-editor.lisp	2006/11/08 13:08:12	1.2
@@ -176,8 +176,7 @@
   (with-accessors ((buffer buffer)) (drei-instance stream)
     (let* ((array (buffer-sequence buffer 0 (size buffer))))
       (make-array (length array)
-                  :fill-pointer t
-                  :adjustable t
+                  :fill-pointer (length array)
                   :initial-contents array))))
 
 (defmethod replace-input ((stream drei-input-editing-mixin) (new-input array)
@@ -252,6 +251,10 @@
                  printed-rep)
              args))))
 
+(defvar *drei-input-editing-stream* nil
+  "Used to provide CLIM-specified input-editing-commands with the
+input-editing-stream. Bound when executing a command.")
+
 ;;; Have to reexamine how many of the keyword arguments to
 ;;; stream-read-gesture should really be passed to the encapsulated
 ;;; stream.
@@ -356,7 +359,8 @@
          (drei (drei-instance stream))
          (*command-processor* drei)
          (was-directly-processing (directly-processing-p drei))
-         (minibuffer (or (minibuffer drei) *minibuffer*)))
+         (minibuffer (or (minibuffer drei) *minibuffer*))
+         (*drei-input-editing-stream* stream))
     (with-bound-drei-special-variables (drei
                                         ;; If the minibuffer is the
                                         ;; stream we are encapsulating
@@ -500,19 +504,22 @@
 ;;; CLIM spec does not define, or even suggest, any kind of
 ;;; programmatic access to the data structures of the input-editor for
 ;;; these function, it is utterly impossible to write portable
-;;; input-editor functions using this
-;;; facility. `Add-input-editor-command' is implemented like this in
-;;; Drei: the specified gesture sequence is bound to the provided
-;;; function in the `editor-table' command table, and will have a
-;;; standard Drei command environment when invoked. This is sufficient
-;;; for only the most trivial of commands, using `define-command' and
-;;; `set-key' is a much, much more powerful mechanism, and it allows
-;;; far more elegant handling of numeric arguments.
+;;; input-editor functions using this facility. Fortunately, Franz's
+;;; user guide saves us. An input-editor-command defined via this
+;;; facility takes four arguments: the input-editing stream, the input
+;;; buffer (ugh!), the gesture used to invoke the command, and the
+;;; accumulated numeric argument.
 
 (defun add-input-editor-command (gestures function)
   "Set up Drei so performing `gestures' will result in the
 invocation of `function' "
-  (set-key function 'editor-table gestures))
+  (set-key `(,(lambda (numeric-argument)
+                      (funcall function *drei-input-editing-stream*
+                               (stream-input-buffer *drei-input-editing-stream*)
+                               gestures
+                               numeric-argument)) ,*numeric-argument-marker*)
+           'exclusive-input-editor-table
+           gestures))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; 
--- /project/mcclim/cvsroot/mcclim/Drei/drei-clim.lisp	2006/11/08 01:15:33	1.1
+++ /project/mcclim/cvsroot/mcclim/Drei/drei-clim.lisp	2006/11/08 13:08:12	1.2
@@ -58,20 +58,20 @@
 (make-command-table 'self-insert-table :errorp nil)
 
 ;;; Command table for concrete editor stuff.
-(make-command-table 'editor-table
-                    :errorp nil
-                    :inherit-from '(comment-table
-                                    deletion-table
-                                    editing-table
-                                    case-table
-                                    fill-table
-                                    indent-table
-                                    marking-table
-                                    movement-table
-                                    search-table
-                                    info-table
-                                    self-insert-table
-                                    keyboard-macro-table))
+(define-syntax-command-table editor-table
+    :errorp nil
+    :inherit-from '(comment-table
+                    deletion-table
+                    editing-table
+                    case-table
+                    fill-table
+                    indent-table
+                    marking-table
+                    movement-table
+                    search-table
+                    info-table
+                    self-insert-table
+                    keyboard-macro-table))
 
 ;; Command table for commands that are only available when Drei is a
 ;; pane.




More information about the Mcclim-cvs mailing list