From e106bf94eff07d9a59771d9ccc4406421e18ab64 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 4 May 2024 19:35:20 +0200 Subject: Adding upstream version 3.0.36. Signed-off-by: Daniel Baumann --- tools/debug_vt100_input.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 tools/debug_vt100_input.py (limited to 'tools/debug_vt100_input.py') 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() -- cgit v1.2.3