CLIM mail archive

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

Wanted: readline-no-echo




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?

jeff morrill
jmorrill@bbn.com

-----------

(defun all-characters (&optional (n (1+ (char-code #\rubout))))
  (let ((list nil))
    (dotimes (i n) (push (code-char i) list))
    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
			      :adjustable t
			      :element-type 'character)))
	(loop
	  (let ((char (read-char stream nil nil)))
	    (cond ((eql char return)
		   (return (values line char)))
		  ((eql char #\rubout)
		   (if (zerop (fill-pointer line))
		       (beep)
		       (decf (fill-pointer line))))
		  ((not (characterp char))
		   (beep))
		  (t
		   (vector-push-extend char line)))))))))


Follow-Ups:

Main Index | Thread Index