1
0
mirror of https://github.com/mnaberez/py65.git synced 2024-06-06 20:29:34 +00:00

Added fix for input on OSX

This commit is contained in:
Sam Colwell 2019-02-09 11:20:12 -05:00
parent abe83dce13
commit 3a0fe6b33d

View File

@ -37,6 +37,7 @@ if sys.platform[:3] == "win":
else:
import termios
from select import select
oldattr = None
@ -115,9 +116,12 @@ else:
# If we didn't get a character, ask again.
while char == '':
try:
char = stdin.read(1)
# stdin has already been set up with a 0.1s delay, so we
# don't need an additional delay here.
# On OSX, calling read when no data is available causes the
# file handle to never return any future data, so we need to
# use select to make sure there is at least one char to read.
rd,wr,er = select([stdin], [], [], 0.01)
if rd != []:
char = stdin.read(1)
except KeyboardInterrupt:
# Pass along a CTRL-C interrupt.
raise
@ -133,8 +137,14 @@ else:
# Using non-blocking read
noncanonical_mode(stdin)
try:
char = stdin.read(1)
# On OSX, calling read when no data is available causes the
# file handle to never return any future data, so we need to
# use select to make sure there is at least one char to read.
rd,wr,er = select([stdin], [], [], 0.01)
if rd != []:
char = stdin.read(1)
except KeyboardInterrupt:
# Pass along a CTRL-C interrupt.
raise