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

Re: hiding the listener



> Is there a simple way to make the listener go away? Ideally it 
>would not appear at all in the application that I save out when
>I launch it.
>
> I imagine that this has soemthing to do with toplevel-loop, but...

The file "ccl:examples;binhex;binhex.lisp" in the 2.0 final
distribution is an example of an application that hides the
Listener. The important thing is to make sure that *terminal-io*,
*debug-io*, *standard-output*, and *error-output* are all bound
to something that doesn't pop up the Listener. The binhex example
uses a bit bucket stream.

Here's an excerpt from the binhex example:

----------------------------------------------------------------

(defclass bit-bucket (output-stream) ())

(defmethod stream-tyo ((s bit-bucket) char)
  (declare (ignore s char)))

(defmethod stream-write-string ((s bit-bucket) string start end)
  (declare (ignore s string start end)))

(defmethod stream-fresh-line ((s bit-bucket))
  (declare (ignore s)))

(defmethod stream-force-output ((s bit-bucket))
  (declare (ignore s)))

(defparameter *bit-bucket* (make-instance 'bit-bucket))

;...

(defun binhex-toplevel ()
  (let ((*error-output* *bit-bucket*)
        (*debug-io* *bit-bucket*)
        (*standard-output* *bit-bucket*)
        (*terminal-io* *bit-bucket*)
        (*print-escape* nil)
        (*print-pretty* nil)
        ; below not necessary if we only use ~A
        (*print-readably* nil))
    (handler-bind
       ((file-error #'binhex-file-error)
        (serious-condition #'binhex-unexpected-error)
        (warning #'binhex-ignore))
      ; should this be (event-dispatch t) ?
      (loop (event-dispatch t)))))