Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defun elmo-read-passwd (prompt &optional stars)
- "Read a single line of text from user without echoing, and return it."
- (let ((ans "")
- (c 0)
- (echo-keystrokes 0)
- (cursor-in-echo-area t)
- (log-message-max-size 0)
- message-log-max done msg truncate)
- (while (not done)
- (if (or (not stars) (string= "" ans))
- (setq msg prompt)
- (setq msg (concat prompt (make-string (length ans) ?.)))
- (setq truncate
- (1+ (- (length msg) (window-width (minibuffer-window)))))
- (and (> truncate 0)
- (setq msg (concat "$" (substring msg (1+ truncate))))))
- (message "%s" msg)
- (setq c (elmo-read-char-exclusive))
- (cond ((= c ?\C-g)
- (setq quit-flag t
- done t))
- ((or (= c ?\r) (= c ?\n) (= c ?\e))
- (setq done t))
- ((= c ?\C-u)
- (setq ans ""))
- ((and (/= c ?\b) (/= c ?\177))
- (setq ans (concat ans (char-to-string c))))
- ((> (length ans) 0)
- (setq ans (substring ans 0 -1)))))
- (if quit-flag
- (prog1
- (setq quit-flag nil)
- (message "Quit")
- (beep t))
- (message "")
- ans)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement