diff options
author | Jonathan Slenders <jonathan@slenders.be> | 2016-01-18 22:11:22 +0100 |
---|---|---|
committer | Jonathan Slenders <jonathan@slenders.be> | 2016-01-18 22:11:38 +0100 |
commit | 3e0b6fb6941c2350a13942a603c2e4c91accdfc2 (patch) | |
tree | 5d3c31d37f536f4b235aeea7c1848ba2df036aec /tools | |
parent | 9927cbe6a5a125847584c83b5b02574f4270538f (diff) |
Added debug_vt100_input.py. A tool for debugging the vt100 parser.
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/debug_vt100_input.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tools/debug_vt100_input.py b/tools/debug_vt100_input.py new file mode 100755 index 00000000..53faff48 --- /dev/null +++ b/tools/debug_vt100_input.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python +""" +Parse vt100 input and print keys. +For testing terminal input. +""" + +from __future__ import unicode_literals +from prompt_toolkit.terminal.vt100_input import InputStream, raw_mode +from prompt_toolkit.keys import Keys +import sys + + +def callback(key_press): + print(key_press) + + if key_press.key == Keys.ControlC: + sys.exit(0) + + +def main(): + stream = InputStream(callback) + + with raw_mode(sys.stdin.fileno()): + while True: + c = sys.stdin.read(1) + stream.feed(c) + + +if __name__ == '__main__': + main() |