Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (require :sb-posix)
- (import '(sb-posix:termios sb-posix:termios-lflag sb-posix:termios-cc
- sb-posix:tcgetattr sb-posix:tcsetattr
- sb-posix:tcsadrain
- sb-posix:icanon sb-posix:echo sb-posix:echoe sb-posix:echok
- sb-posix:echonl sb-posix:vmin sb-posix:vtime))
- #| What "less" does:
- s.c_lflag &= ~(ICANON|ECHO|ECHOE|ECHOK|ECHONL);
- s.c_oflag |= (OPOST|ONLCR|TAB3);
- s.c_oflag &= ~(OCRNL|ONOCR|ONLRET);
- s.c_cc[VMIN] = 1;
- s.c_cc[VTIME] = 0;
- |#
- (defun read-char-no-echo-cbreak (&optional (stream *query-io*))
- (let ((old (tcgetattr 0))
- (new (tcgetattr 0))
- (bits (logior icanon echo echoe echok echonl)))
- (unwind-protect
- (progn
- (setf (termios-lflag new) (logandc2 (termios-lflag old) bits)
- (aref (termios-cc new) vmin) 1
- (aref (termios-cc new) vtime) 0)
- (tcsetattr 0 tcsadrain new)
- (read-char stream))
- (tcsetattr 0 tcsadrain old))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement