Hi all,
In cl-wav-synth, I use the code below to edit a form previously evaluated in the listener.
It works very well for me but is this an acceptable way to do it and is there something planed to add the editing capability in the listener ? (I've looked in the source and found something about history but I doesn't found how to use it).
Best regards,
Philippe
---------------------------------------------------------------------- (define-command (com-eval :menu t :command-table lisp-commands) ((form 'clim:form :prompt "Form")) (let ((values (multiple-value-list (handler-case (eval form) (error (condition) (format nil "~A" condition)))))) (fresh-line) (shuffle-specials form values) (display-evalues values) (fresh-line)))
(define-command (com-edit-form :name t :menu t :command-table lisp-commands) ((form 'form :prompt "Form")) (multiple-value-bind (x1 y1) (stream-cursor-position *standard-input*) (let ((new-form (accept 'clim:form :stream (frame-standard-input *application-frame*) :prompt "New form" :default form :insert-default t))) (multiple-value-bind (x2 y2) (stream-cursor-position *standard-input*) (declare (ignore x2)) (let* ((interactor (find-pane-named *application-frame* 'cl-wav-synth-clim::interactor)) (output-history (stream-output-history interactor)) (width (bounding-rectangle-width interactor))) (decf y1 (stream-line-height interactor)) (map-over-output-records-overlapping-region #'(lambda (rec) (delete-output-record rec output-history)) output-history (make-rectangle* 0 y1 width y2)) (draw-rectangle* interactor 0 y1 width y2 :ink (pane-background interactor)) (setf (stream-cursor-position *standard-input*) (values x1 y1)) (print-listener-prompt interactor *application-frame*) (present new-form 'form) (fresh-line) (force-output) (execute-frame-command *application-frame* `(com-eval ,new-form)))))))
(define-presentation-to-command-translator edit-form (clim:command com-edit-form lisp-commands :gesture :describe :echo t :documentation ((object stream) (format stream "Edit ~A" (second object))) :pointer-documentation ((object stream) (format stream "Edit ~A" (second object))) :tester ((object) (eql (car object) 'com-eval))) (object) (list (second object)))
(define-presentation-to-command-translator edit-form-form (clim:form com-edit-form lisp-commands :gesture :describe :echo t :documentation ((object stream) (format stream "Edit ~A" object)) :pointer-documentation ((object stream) (format stream "Edit ~A" object))) (object) (list object))
(define-presentation-to-command-translator eval-form (clim:form com-eval lisp-commands :gesture :select :echo t :documentation ((object stream) (format stream "Eval ~A" object)) :pointer-documentation ((object stream) (format stream "Eval ~A" object))) (object) (list object)) ----------------------------------------------------------------------