From: grue Date: Mon, 13 Feb 2006 20:47:49 +0000 (+0000) Subject: *no-output* mode X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=bb182c7eda90fcb76d7bbf99b13a49d40c0a8847;p=lifp.git *no-output* mode darcs-hash:81f0be3800ed94653deabc2048028985dbed1190 --- diff --git a/console.lisp b/console.lisp index 96d2e81..7bf4f14 100644 --- a/console.lisp +++ b/console.lisp @@ -9,12 +9,14 @@ (:use :common-lisp :ltk :com.gigamonkeys.pathnames) (:export :terminal-in :terminal-out :run-console :console-running-p :textwidth :offset :style - :*text* :get-input :ltk-after :*repl-mode* :*hard-quit* :quit-lisp + :*text* :get-input :ltk-after :*repl-mode* :*no-output* + :*hard-quit* :quit-lisp :close-console :load-module :print-message)) (in-package :if-console) (defparameter *repl-mode* nil) +(defparameter *no-output* nil) (defparameter *console-on* nil) (defparameter *text* nil) (defparameter *inp* nil) @@ -35,9 +37,10 @@ (defmethod gray:stream-write-char ((s terminal-out) char) (unless (console-running-p) (error "No console is running")) + (unless *no-output* (if *repl-mode* (princ char) (append-text (first *console-on*) - (make-string 1 :initial-element char)))) + (make-string 1 :initial-element char))))) (defmethod gray:stream-line-column ((s terminal-out)) (offset s)) @@ -45,11 +48,12 @@ (defmethod gray:stream-write-char-sequence ((s terminal-out) str &optional start end) (unless (console-running-p) (error "No console is running")) + (unless *no-output* (let ((toprint (subseq str (if start start 0) (if end end nil)))) (if *repl-mode* (princ toprint) (progn (append-text (first *console-on*) toprint) - (see (first *console-on*) "insert"))))) + (see (first *console-on*) "insert")))))) (defmethod gray:stream-read-char ((s terminal-in)) (if *repl-mode* (read-char *standard-input*) @@ -141,8 +145,8 @@ (defun load-module (startup lib-loader) "Loads IF module into the interpreter" (multiple-value-bind (file dir) (pick-file) - (unless file (append-text *text* "Failed to load module. -")) + (unless file (append-text *text* (format nil "Failed to load module.~%")) + (return-from load-module nil)) (funcall lib-loader file dir) (funcall startup)))