CLIM mail archive
I want a version of read-line that does not echo. I need
it to read a password. The following code works in dynamic
windows but not in CLIM 1.1 (Allegro 4.1). It does not
work because read-char never returns #\rubout, it
just beeps, therefore the typist had better not make a mistake.
I can't tell if the fault is with CLIM or with Allegro underneath.
This is used as the parser for a presentation-type and
invoked from an accepting values dialog.
What should I do?
(defun all-characters (&optional (n (1+ (char-code #\rubout))))
(let ((list nil))
(dotimes (i n) (push (code-char i) list))
(defvar *all-characters* nil)
(defun readline-no-echo (stream)
;; The trick to echo suppression is to define every character as an
;; activation character.
(let ((all-characters (or *all-characters*
(setq *all-characters* (all-characters))))
(return (elt (format nil "~%") 0))) ; implementation-dependent value
(with-accept-activation-chars (all-characters :override t)
(let ((line (make-array 1 :fill-pointer 0
(let ((char (read-char stream nil nil)))
(cond ((eql char return)
(return (values line char)))
((eql char #\rubout)
(if (zerop (fill-pointer line))
(decf (fill-pointer line))))
((not (characterp char))
(vector-push-extend char line)))))))))
Main Index |