|
@ -15,9 +15,13 @@ def getch(): |
|
|
# fd, as follows: [iflag, oflag, cflag, lflag, ispeed, ospeed, cc]" |
|
|
# fd, as follows: [iflag, oflag, cflag, lflag, ispeed, ospeed, cc]" |
|
|
# from https://docs.python.org/2/library/termios.html |
|
|
# from https://docs.python.org/2/library/termios.html |
|
|
original_tty_attributes = termios.tcgetattr(stdin_fd) |
|
|
original_tty_attributes = termios.tcgetattr(stdin_fd) |
|
|
new_tty_attributes = original_tty_attributes[:] |
|
|
|
|
|
|
|
|
new_tty_attributes = termios.tcgetattr(stdin_fd) |
|
|
# Change the lflag (local modes) to turn off canonical mode |
|
|
# Change the lflag (local modes) to turn off canonical mode |
|
|
new_tty_attributes[3] &= ~termios.ICANON |
|
|
new_tty_attributes[3] &= ~termios.ICANON |
|
|
|
|
|
# Set VMIN = 0 and VTIME > 0 for a timed read, as explained in: |
|
|
|
|
|
# http://unixwiz.net/techtips/termios-vmin-vtime.html |
|
|
|
|
|
new_tty_attributes[6][termios.VMIN] = b'\x00' |
|
|
|
|
|
new_tty_attributes[6][termios.VTIME] = b'\x01' |
|
|
try: |
|
|
try: |
|
|
termios.tcsetattr(stdin_fd, termios.TCSAFLUSH, new_tty_attributes) |
|
|
termios.tcsetattr(stdin_fd, termios.TCSAFLUSH, new_tty_attributes) |
|
|
ch1 = sys.stdin.read(1) |
|
|
ch1 = sys.stdin.read(1) |
|
|