X-Git-Url: http://git.kpe.io/?p=cl-readline.git;a=blobdiff_plain;f=readline.lisp;h=ea2dedef0de5c5794710d9691403208eba6608ce;hp=95c460f235689d2629427a40d1f57de72a0a39b2;hb=8e1c2386d4bd733c6b82717dec20248ed1d82019;hpb=1640f89acdd00711a4b1dd29d53a3bf4168da433 diff --git a/readline.lisp b/readline.lisp index 95c460f..ea2dede 100644 --- a/readline.lisp +++ b/readline.lisp @@ -101,13 +101,16 @@ (defun readline (&key (prompt "") (history t)) "Read a line from current TTY with line-editing." (with-cstring (c-prompt prompt) - (let ((str (string-trim *whitespace* - (convert-and-free-foreign-string (c-readline c-prompt))))) - (when (and history (not (string= "" str))) - (add-history str)) + (let* ((str (convert-and-free-foreign-string (c-readline c-prompt))) + (str2 (string-trim *whitespace* str))) + (when (and history (not (string= "" str2))) + (add-history str2)) str))) -(defun readexpr (&key (primary-prompt "=> ") (secondary-prompt "| ") (history t)) +(defun readexpr (&key + (primary-prompt "=> ") + (secondary-prompt "| ") + (history t)) "Read an expression from current TTY with line-editing." (let (expr) (do* ((str (readline :prompt primary-prompt :history history) @@ -118,5 +121,23 @@ (read in nil nil)))) expr)))) +;; +;; Termios +;; - +(def-function "no_echo" + () + :module "cl-termios" + :returning :void) + +(def-function "restore_term" + () + :module "cl-termios" + :returning :void) + +(defmacro without-echo (&body forms) + `(unwind-protect + (progn + (no-echo) + ,@forms) + (restore-term)))