|
@@ -82,7 +82,7 @@ class MMGenTermLinux(MMGenTerm):
|
|
|
break
|
|
|
|
|
|
@classmethod
|
|
|
- def get_char(cls,prompt='',immed_chars='',prehold_protect=True,num_chars=5,sleep=None):
|
|
|
+ def get_char(cls,prompt='',immed_chars='',prehold_protect=True,num_chars=5):
|
|
|
"""
|
|
|
Use os.read(), not file.read(), to get a variable number of bytes without blocking.
|
|
|
Request 5 bytes to cover escape sequences generated by F1, F2, .. Fn keys (5 bytes)
|
|
@@ -90,8 +90,6 @@ class MMGenTermLinux(MMGenTerm):
|
|
|
"""
|
|
|
timeout = 0.3
|
|
|
tty.setcbreak(cls.stdin_fd)
|
|
|
- if sleep:
|
|
|
- time.sleep(sleep)
|
|
|
msg_r(prompt)
|
|
|
if g.test_suite:
|
|
|
prehold_protect = False
|
|
@@ -111,10 +109,8 @@ class MMGenTermLinux(MMGenTerm):
|
|
|
return s
|
|
|
|
|
|
@classmethod
|
|
|
- def get_char_raw(cls,prompt='',num_chars=5,sleep=None):
|
|
|
+ def get_char_raw(cls,prompt='',num_chars=5):
|
|
|
tty.setcbreak(cls.stdin_fd)
|
|
|
- if sleep:
|
|
|
- time.sleep(sleep)
|
|
|
msg_r(prompt)
|
|
|
s = os.read(cls.stdin_fd,num_chars).decode()
|
|
|
termios.tcsetattr(cls.stdin_fd, termios.TCSADRAIN, cls.old_term)
|
|
@@ -127,9 +123,7 @@ class MMGenTermLinuxStub(MMGenTermLinux):
|
|
|
cls.stdin_fd = sys.stdin.fileno()
|
|
|
|
|
|
@classmethod
|
|
|
- def get_char(cls,prompt='',immed_chars='',prehold_protect=None,num_chars=None,sleep=None):
|
|
|
- if sleep:
|
|
|
- time.sleep(0.1)
|
|
|
+ def get_char(cls,prompt='',immed_chars='',prehold_protect=None,num_chars=None):
|
|
|
msg_r(prompt)
|
|
|
return sys.stdin.read(1)
|
|
|
|
|
@@ -177,14 +171,12 @@ class MMGenTermMSWin(MMGenTerm):
|
|
|
return
|
|
|
|
|
|
@classmethod
|
|
|
- def get_char(cls,prompt='',immed_chars='',prehold_protect=True,num_chars=None,sleep=None):
|
|
|
+ def get_char(cls,prompt='',immed_chars='',prehold_protect=True,num_chars=None):
|
|
|
"""
|
|
|
always return a single character, ignore num_chars
|
|
|
first character of 2-character sequence returned by F1-F12 keys is discarded
|
|
|
prehold_protect is ignored
|
|
|
"""
|
|
|
- if sleep:
|
|
|
- time.sleep(sleep)
|
|
|
msg_r(prompt)
|
|
|
timeout = 0.5
|
|
|
while True:
|
|
@@ -202,14 +194,12 @@ class MMGenTermMSWin(MMGenTerm):
|
|
|
return ch
|
|
|
|
|
|
@classmethod
|
|
|
- def get_char_raw(cls,prompt='',num_chars=None,sleep=None):
|
|
|
+ def get_char_raw(cls,prompt='',num_chars=None):
|
|
|
"""
|
|
|
always return a single character, ignore num_chars
|
|
|
first character of 2-character sequence returned by F1-F12 keys is discarded
|
|
|
"""
|
|
|
while True:
|
|
|
- if sleep:
|
|
|
- time.sleep(sleep)
|
|
|
msg_r(prompt)
|
|
|
ch = chr(msvcrt.getch()[0])
|
|
|
if ch in '\x00\xe0': # first char of 2-char sequence for F1-F12 keys
|
|
@@ -221,9 +211,7 @@ class MMGenTermMSWin(MMGenTerm):
|
|
|
class MMGenTermMSWinStub(MMGenTermMSWin):
|
|
|
|
|
|
@classmethod
|
|
|
- def get_char(cls,prompt='',immed_chars='',prehold_protect=None,num_chars=None,sleep=None):
|
|
|
- if sleep:
|
|
|
- time.sleep(0.1)
|
|
|
+ def get_char(cls,prompt='',immed_chars='',prehold_protect=None,num_chars=None):
|
|
|
msg_r(prompt)
|
|
|
return os.read(0,1).decode()
|
|
|
|