Lisp HUG Maillist Archive

How do you wait for an interface?

Hi!

A (probably rather dumb) CAPI question:

This works:

(defpackage "TEST"
  (:use "CL" "CAPI")
  (:export "TEST"))

(in-package "TEST")

(define-interface test ()
  ((stream :initarg :stream :reader test-stream))
  (:panes
   (read-it push-button :text "Read Line"
            :callback (lambda (data interface)
                        (declare (ignore data interface))
                        (display-message "Got ~A" (read-line stream nil nil))))))

(defun test (file-name)
  (with-open-file (stream file-name)
    (mp:process-wait "Waiting for interface."
                     (lambda (process)
                       (not (mp:process-alive-p process)))
                     (capi-internals:interface-process
                      (display (make-instance 'test :stream stream))))))

but it looks rather clumsy to me.  I'd prefer to give a :process nil
argument to CAPI:DISPLAY, but how do make the current process process
events then?

Regards,
-- 
Nils Gösche
"Don't ask for whom the <CTRL-G> tolls."

PGP key ID 0x0655CFA0


Re: How do you wait for an interface?

I <cartan@cartan.de> wrote:

>                      (lambda (process)
>                        (not (mp:process-alive-p process)))

Never mind COMPLEMENT ;-)

Regards,
-- 
Nils Gösche
"Don't ask for whom the <CTRL-G> tolls."

PGP key ID 0x0655CFA0


Re: How do you wait for an interface?

Unable to parse email body. Email id is 834

Re: How do you wait for an interface?

David Fox <davef@xanalys.com> writes:

> try this:
> 
> (defun test2 (file-name)
>   (with-open-file (stream file-name)
> 		  (capi-internals:loop-process-events 
> 		   (display (make-instance 'test
> 					   :stream stream) 
> 			    :process nil)  
> 		   (list #'(lambda (pane stream) 
> 			     (not (listen stream))) 
> 			 stream) 
> 		   nil  "Waiting" nil)))

Cool, thanks.  However, I'd rather wait until the window is closed (or
destroyed).  Like this:

(defun test (file-name)
  (with-open-file (stream file-name)
    (let ((done nil))
      (capi-internals:loop-process-events
       (display (make-instance 'test
                               :stream stream
                               :destroy-callback
                               (lambda (interface)
                                 (declare (ignore interface))
                                 (setq done t)))
                :process nil)
       (list (lambda (pane)
               (declare (ignore pane))
               done))
       nil "Wating" nil))))

Is there some function like ``destroyed-p´´ that I could call on the
interface?

Regards,
-- 
Nils Gösche
"Don't ask for whom the <CTRL-G> tolls."

PGP key ID 0x0655CFA0


Unable to render article 837 because of ":DEFAULT stream decoding error on #<SB-SYS:FD-STREAM for \"socket 192.168.43.216:64947, peer: 116.202.254.214:119\" {1001BCD263}>: the octet sequence #(180) cannot be decoded." error

Re: How do you wait for an interface?

David Fox <davef@xanalys.com> writes:

> Yes, you can call CAPI:TOP-LEVEL-INTERFACE-DISPLAY-STATE. If this
> returns NIL, the interface has been destroyed:
> 
> (defun test4 (file-name)
>      (with-open-file (stream file-name)
>        (capi-internals:loop-process-events
> 	  (display (make-instance 'test
> 				  :stream stream)
> 		   :process nil)
> 	  (list (lambda (pane)
> 		  (not (capi:top-level-interface-display-state pane))))
> 	  nil "Wating" nil)))

Perfect; thanks again!

Regards,
-- 
Nils Gösche
"Don't ask for whom the <CTRL-G> tolls."

PGP key ID 0x0655CFA0


Updated at: 2020-12-10 09:01 UTC