From 4921b3d4379c51e9363460a64b1ef40ae0a647fe Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 17 Oct 2016 00:05:36 +0530 Subject: [PATCH] Add support for the secondary device attributes control code (DA2) --- kitty/screen.py | 18 ++++++++++++++---- pyte/streams.py | 10 ++++++---- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/kitty/screen.py b/kitty/screen.py index 57b9dc744..56c4fca50 100644 --- a/kitty/screen.py +++ b/kitty/screen.py @@ -832,10 +832,20 @@ class Screen(QObject): .. versionadded:: 0.5.0 """ - # We only implement "primary" DA which is the only DA request - # VT102 understood, see ``VT102ID`` in ``linux/drivers/tty/vt.c``. - if mode == 0: - self.write_process_input(ctrl.CSI + b"?6c") + # Use the same responses as libvte v0.46 running in termite + # Ignore mode since vte seems to ignore it + if kwargs.get('secondary') == '>': + # http://www.vt100.net/docs/vt510-rm/DA2.html + # If you implement xterm keycode querying you can change this to + # mimic xterm instead (>41;327;0c) then vim wont need terminfo to + # get keycodes (see :help xterm-codes) + self.write_process_input(ctrl.CSI + b'>1;4600;0c') + else: + # xterm gives: [[?64;1;2;6;9;15;18;21;22c + # use the simpler vte response, since we dont support + # windowing/horizontal scrolling etc. + # [[?64;1;2;6;9;15;18;21;22c + self.write_process_input(ctrl.CSI + b"?62c") def report_device_status(self, mode): """Reports terminal status or cursor position. diff --git a/pyte/streams.py b/pyte/streams.py index 1bfcc7795..68584f91e 100644 --- a/pyte/streams.py +++ b/pyte/streams.py @@ -297,7 +297,7 @@ class Stream(object): # arguments. params = [] current = bytearray() - private = False + private = secondary = False while True: char = yield if char == b"?": @@ -305,8 +305,7 @@ class Stream(object): elif char in ALLOWED_IN_CSI: basic_dispatch[char]() elif char in SP_OR_GT: - # We don't handle secondary DA atm. - pass + secondary = char.decode('ascii') # Added by Kovid elif char in CAN_OR_SUB: # If CAN or SUB is received during a sequence, the # current sequence is aborted; terminal displays @@ -325,7 +324,10 @@ class Stream(object): if private: csi_dispatch[char](*params, private=True) else: - csi_dispatch[char](*params) + if secondary: # Added by Kovid + csi_dispatch[char](*params, secondary=secondary) + else: + csi_dispatch[char](*params) break # CSI is finished. elif char == OSC: code = yield