def get_input(self):
while msvcrt.kbhit():
c = msvcrt.getwch()
if c == u'\r': # new line
c = u'\n'
stdout.write(c)
self.input += c
self.protocol.dataReceived(self.input)
self.input = ''
elif c in (u'\xE0', u'\x00'):
# ignore special characters
msvcrt.getwch()
elif c == u'\x08': # delete
self.input = self.input[:-1]
stdout.write('\x08 \x08')
else:
self.input += c
stdout.write(c)
reactor.callLater(self.interval, self.get_input)
评论列表
文章目录