(linenum→info "unix/slp.c:2238")

gauche/0.8.12/examples/noecho.scm

    1: ;; Example of gauche.termios
    2: ;;  $Id: noecho.scm,v 1.1 2003/01/08 02:06:27 shirok Exp $
    3: 
    4: (use gauche.termios)
    5: 
    6: (define (get-password prompt)
    7:   (let* ((port (current-input-port))
    8:          (attr (sys-tcgetattr port))
    9:          (lflag (slot-ref attr 'lflag)))
   10:     ;; Show prompt
   11:     (display prompt)
   12:     (flush)
   13:     ;; Turn off echo during reading.
   14:     (dynamic-wind
   15:      (lambda ()
   16:        (slot-set! attr 'lflag (logand lflag (lognot |ECHO|)))
   17:        (sys-tcsetattr port |TCSAFLUSH| attr))
   18:      (lambda ()
   19:        (read-line port))
   20:      (lambda ()
   21:        (slot-set! attr 'lflag lflag)
   22:        (sys-tcsetattr port |TCSANOW| attr)))))
   23: 
   24: 
   25: 
Syntax (Markdown)