X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=console.lisp;fp=console.lisp;h=7bf4f140c0b8dbd50ab6bd0f50ea061937a56ce7;hb=bb182c7eda90fcb76d7bbf99b13a49d40c0a8847;hp=96d2e81da4c8e3a7b38ac10f92164d31f36f8c53;hpb=291bf6649b6f445d7588c1d4c5a906ad2456fe03;p=lifp.git 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)))