From 52ecdfe3a92c7935c528ca8108d6371d3a27d277 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 3 Dec 2017 21:31:51 +0530 Subject: [PATCH] Fix incorrect termcap query responses Did not realize that the responses had to be processed via tparm() i.e. they should be the actual bytes not the textual representation of them. This broke the backspace key in vim. --- kitty/terminfo.py | 7 +++++-- kitty_tests/parser.py | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/kitty/terminfo.py b/kitty/terminfo.py index e301e53af..167f5b5f0 100644 --- a/kitty/terminfo.py +++ b/kitty/terminfo.py @@ -436,7 +436,7 @@ def get_capabilities(query_string): ans = [] try: for q in query_string.split(';'): - name = unhexlify(q).decode('utf-8') + name = qname = unhexlify(q).decode('utf-8') if name == 'TN': val = names[0] else: @@ -444,10 +444,13 @@ def get_capabilities(query_string): val = queryable_capabilities[name] except KeyError: try: - val = queryable_capabilities[termcap_aliases[name]] + qname = termcap_aliases[name] + val = queryable_capabilities[qname] except Exception as e: safe_print(ERROR_PREFIX, 'Unknown terminfo property:', name) raise + if qname in string_capabilities and '%' not in val: + val = key_as_bytes(qname).decode('ascii') ans.append(q + '=' + hexlify(str(val).encode('utf-8')).decode('ascii')) return b'\033P1+r' + ';'.join(ans).encode('utf-8') + b'\033\\' except Exception: diff --git a/kitty_tests/parser.py b/kitty_tests/parser.py index ae365b4a8..c01b28430 100644 --- a/kitty_tests/parser.py +++ b/kitty_tests/parser.py @@ -198,7 +198,7 @@ class TestParser(BaseTest): q = hexlify(b'kind').decode('ascii') pb('a\033P+q{}\x9cbcde'.format(q), 'a', ('screen_request_capabilities', 43, q), 'bcde') self.ae(str(s.line(0)), 'abcde') - self.ae(c.wtcbuf, '\033P1+r{}={}\033\\'.format(q, '5c455b313b3242').encode('ascii')) + self.ae(c.wtcbuf, '\033P1+r{}={}\033\\'.format(q, '1b5b313b3242').encode('ascii')) c.clear() pb('\033P$q q\033\\', ('screen_request_capabilities', ord('$'), ' q')) self.ae(c.wtcbuf, b'\033P1$r1 q\033\\')