##// 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 """Return True if there's something to read on stdin (posix version)."""
42 infds, outfds, erfds = select.select([sys.stdin],[],[],0)
43 return bool(infds)
44
45 def _stdin_ready_nt():
46 """Return True if there's something to read on stdin (nt version)."""
47 return msvcrt.kbhit()
48
49 def _stdin_ready_other():
50 """Return True, assuming there's something to read on stdin."""
51 return True #
52
41 if os.name == 'posix':
53 if os.name == 'posix':
42 import select
54 import select
43 infds, outfds, erfds = select.select([sys.stdin],[],[],0)
55 stdin_ready = _stdin_ready_posix
44 if infds:
45 return True
46 else:
47 return False
48 elif os.name == 'nt':
56 elif os.name == 'nt':
49 import msvcrt
57 import msvcrt
50 return msvcrt.kbhit()
58 stdin_ready = _stdin_ready_nt
51 return True # assume there's something so that we won't wait forever
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