summaryrefslogtreecommitdiffstats
path: root/tools/debug_vt100_input.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 16:35:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 16:35:31 +0000
commit4f1a3b5f9ad05aa7b08715d48909a2b06ee2fcb1 (patch)
treee5dee7be2f0d963da4faad6517278d03783e3adc /tools/debug_vt100_input.py
parentInitial commit. (diff)
downloadprompt-toolkit-4f1a3b5f9ad05aa7b08715d48909a2b06ee2fcb1.tar.xz
prompt-toolkit-4f1a3b5f9ad05aa7b08715d48909a2b06ee2fcb1.zip
Adding upstream version 3.0.43.upstream/3.0.43
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tools/debug_vt100_input.py')
-rwxr-xr-xtools/debug_vt100_input.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/tools/debug_vt100_input.py b/tools/debug_vt100_input.py
new file mode 100755
index 0000000..d3660b9
--- /dev/null
+++ b/tools/debug_vt100_input.py
@@ -0,0 +1,32 @@
+#!/usr/bin/env python
+"""
+Parse vt100 input and print keys.
+For testing terminal input.
+
+(This does not use the `Input` implementation, but only the `Vt100Parser`.)
+"""
+import sys
+
+from prompt_toolkit.input.vt100 import raw_mode
+from prompt_toolkit.input.vt100_parser import Vt100Parser
+from prompt_toolkit.keys import Keys
+
+
+def callback(key_press):
+ print(key_press)
+
+ if key_press.key == Keys.ControlC:
+ sys.exit(0)
+
+
+def main():
+ stream = Vt100Parser(callback)
+
+ with raw_mode(sys.stdin.fileno()):
+ while True:
+ c = sys.stdin.read(1)
+ stream.feed(c)
+
+
+if __name__ == "__main__":
+ main()