summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorJonathan Slenders <jonathan@slenders.be>2016-01-18 22:11:22 +0100
committerJonathan Slenders <jonathan@slenders.be>2016-01-18 22:11:38 +0100
commit3e0b6fb6941c2350a13942a603c2e4c91accdfc2 (patch)
tree5d3c31d37f536f4b235aeea7c1848ba2df036aec /tools
parent9927cbe6a5a125847584c83b5b02574f4270538f (diff)
Added debug_vt100_input.py. A tool for debugging the vt100 parser.
Diffstat (limited to 'tools')
-rwxr-xr-xtools/debug_vt100_input.py30
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()