(in-package "KPML-I")

;;; File: winacl-actions.lisp
;;; Author: John.
;;; 
;;; THE FOLLOWING SHOULD ONLY BE ACTIVATED
;;; WHEN KPML IS RUNNING IN THE CONTEXT OF ALLEGRO COMMON LISP
;;; (ACL3.0.2+) FOR WINDOWS.
;;; ** This replaces ../emacs-actions.lisp **
;;;
;;; Provides the function definitions that link the general editing
;;; actions with those using the WinACL text editor windows under
;;; Windows.
;;;

(defun EDITING-POSSIBLE? () 
  T)


;;; Following gives the pseudo nonsynchronous editing behaviour...

#+acl3.0
(defun EDIT-OBJECT (object type)
  (let ((stream (clim:get-frame-pane *resource-inspector-frame* 'inspector)))
        (cond ((eq (cdr (assoc type *kpml-editing-method*)) :kpml)
	   (direct-kpml-internal-editing-request object type))
	  (T
	   (when (editing-possible?)
		 (case type
		       (:spl-term
			(edit-spl-term object))
		       (:inq-impl
			(edit-inquiry-implementation object)) 
		       ;; INSTALLATION DEPENDENT.
		       (otherwise
			(let ((result 
			       (edit-kpml-form-and-wait 
				(let ((kpml::*file-writing* T))  ;; 1.0.5
				  (kpml::systemic-display 
				   object :object-type type :stream nil)))))
			  (format 
			   stream 
			   "~%To make changes, edit and evaluate in
the editing window."))
			)))))))

;;; Normally, the following function  should take a prettified string,
;;; and outputs this  in some editor buffer,  waiting for the modified
;;; strong to be returned.  If  the string  "NOOP" is  returned,  then
;;; nothing   is done and   the function  returns  nil; otherwise, the
;;; result of evaluating   the  string is returned.    However,  under
;;; Windows ACL, we  get  a editing window that  sticks  around for as
;;; long as required. Changes can be accepted by evaluating the
;;; modified definition; otherwise (for example if  the window is killed or if
;;; the Cancel button is clicked)  no changes are  made and the window
;;; just goes away. 

(defun EDIT-KPML-FORM-AND-WAIT (string)
  (make-kpml-resource-editor string)
  (values nil))
   
(defun KPML-I::EVALUATE-KPML-EDITED-FORM ()
  nil)



;;; ----------------------------------------------------------------------
;;; Inquiry implementations...

(defun EDIT-INQUIRY-IMPLEMENTATION (inquiry-implementation)
  (let ((s (clim:get-frame-pane *resource-inspector-frame* 'inspector)))
    (format 
     s "~%Automatic inquiry Implementation editing not yet 
     available under Windows.")
    (return-from EDIT-INQUIRY-IMPLEMENTATION nil)))


