##// END OF EJS Templates
inputhook: further cleanups for stdin_ready()...
Christian Boos -
Show More
@@ -37,18 +37,27 b" GUI_PYGLET = 'pyglet'"
37 # Utilities
37 # Utilities
38 #-----------------------------------------------------------------------------
38 #-----------------------------------------------------------------------------
39
39
40 def stdin_ready():
40 def _stdin_ready_posix():
41 if os.name == 'posix':
41 """Return True if there's something to read on stdin (posix version)."""
42 import select
42 infds, outfds, erfds = select.select([sys.stdin],[],[],0)
43 infds, outfds, erfds = select.select([sys.stdin],[],[],0)
43 return bool(infds)
44 if infds:
44
45 return True
45 def _stdin_ready_nt():
46 else:
46 """Return True if there's something to read on stdin (nt version)."""
47 return False
47 return msvcrt.kbhit()
48 elif os.name == 'nt':
48
49 import msvcrt
49 def _stdin_ready_other():
50 return msvcrt.kbhit()
50 """Return True, assuming there's something to read on stdin."""
51 return True # assume there's something so that we won't wait forever
51 return True #
52
53 if os.name == 'posix':
54 import select
55 stdin_ready = _stdin_ready_posix
56 elif os.name == 'nt':
57 import msvcrt
58 stdin_ready = _stdin_ready_nt
59 else:
60 stdin_ready = _stdin_ready_other
52
61
53
62
54 #-----------------------------------------------------------------------------
63 #-----------------------------------------------------------------------------
General Comments 0
You need to be logged in to leave comments. Login now