[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Beginners question about program framework



>We got a problem with the :command-evaluator option in the program
>framework macro. Apprently the function "fonction" below does not
>seem to be called. Any ideas why ? We didn't find any example in
>the manual which shows how to use this option.
>
>                                   - thanks for any help
>(defun fonction (gs co &rest args)
>  (ignore gs)
>  (read-char (dw:get-program-pane 'listener-pane))
>  (apply co args)
>  (princ "foo" (dw:get-program-pane 'listener-pane)))
>
>(dw:define-program-framework graphic-symbol-frame  
>  
>  :pretty-name "Graphic Symbol System"	        ;pretty name  
>
>  :select-key #\g				;select key
>
>  :command-definer t				;we will use the command definition macro  
>						;(see below)
>  :command-table                                ;specifies options to cp:make-command-table  
>  (:inherit-from '("colon full command" "standard arguments" "standard scrolling")
>   :kbd-accelerator-p nil)  
>
>  :top-level					;our own top level function
>  (top-level-function)				;(in place of dw:default-command-top-level)
>						;(see below)
>  :system-menu t				;graphic-symbol appears in the system menu 
>						;(trie-it !)
>  :command-evaluator
>  (fonction)
>  :panes
>  ((title-pane
>     :title					;pane type
>     :default-character-style '(:swiss :bold-italic :very-large)
>     :height-in-lines 2)
>   (graphic-symbol-display-pane
>   ..................
>   ..................))))
>
>
>
>(defmethod  (top-level-function graphic-symbol-frame) ()
>  (in-package 'graphic-symbol)
>  (dw:default-command-top-level self :dispatch-mode :command-preferred))
>

It appears that there is a bug in dw::read-program-command that causes
it to return a third value of :form even if the thing read was a
command. (Dispatch mode is :command-preferred.)  That in turn causes
dw:default-command-top-level to ignore your command evaluator.

This is how you can work around this bug:

(defun form-evaluator (form)
  (princ "before")
  (eval form)
  (princ "after"))

(defmethod  (top-level-function graphic-symbol-frame) ()
  (dw:default-command-top-level self :dispatch-mode :command-preferred :form-evaluator #'form-evaluator))

(define-graphic-symbol-frame-command (com-do-nothing) ((x 'integer)) (print x))