From 0718a9a7f9300b2526eddb0fc74e25eef34795ba Mon Sep 17 00:00:00 2001 From: Christian Persch Date: Thu, 3 Feb 2022 20:58:11 +0100 Subject: emulation: Support XTVERSION sequence --- src/parser-reply.hh | 1 + src/parser-seq.py | 2 ++ src/vteseq.cc | 32 ++++++++++++++++++++++++++++++-- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/parser-reply.hh b/src/parser-reply.hh index 1ba3022a..c9046b1a 100644 --- a/src/parser-reply.hh +++ b/src/parser-reply.hh @@ -57,6 +57,7 @@ _VTE_REPLY(DECCTR, DCS, 's', NONE, CASH, _VTE_REPLY_PARAMS({2})) /* color _VTE_REPLY(DECAUPSS, DCS, 'u', NONE, BANG, ) /* assign user preferred supplemental set */ _VTE_REPLY(DECCIR, DCS, 'u', NONE, CASH, _VTE_REPLY_PARAMS({1})) /* cursor information report */ _VTE_REPLY(DECRPTUI, DCS, '|', NONE, BANG, _VTE_REPLY_STRING("7E565445") /* "~VTE" */) /* report terminal unit ID */ +_VTE_REPLY(XTERM_DSR, DCS, '|', GT, NONE, ) /* xterm terminal version report */ _VTE_REPLY(DECRPFK, DCS, '}', NONE, DQUOTE,) /* report function key */ _VTE_REPLY(DECCKSR, DCS, '~', NONE, BANG, ) /* memory checksum report */ _VTE_REPLY(DECRPAK, DCS, '~', NONE, DQUOTE,) /* report all modifiers/alphanumeric key */ diff --git a/src/parser-seq.py b/src/parser-seq.py index 2243a203..83b067fd 100755 --- a/src/parser-seq.py +++ b/src/parser-seq.py @@ -756,6 +756,8 @@ sequences = [ comment='select terminal id'), seq_CSI('DECCRTST', 'q', intermediates=(Intermediate.MINUS,), flags=Flags.NOP, comment='CRT saver time'), + seq_CSI('XTERM_VERSION', 'q', pintro=(ParameterIntro.GT,), + comment='request xterm version report'), seq_CSI('DECSTBM', 'r', comment='set top and bottom margins'), seq_CSI('DECSKCV', 'r', intermediates=(Intermediate.SPACE,), flags=Flags.NOP, diff --git a/src/vteseq.cc b/src/vteseq.cc index 3945fcac..9efde087 100644 --- a/src/vteseq.cc +++ b/src/vteseq.cc @@ -69,6 +69,11 @@ enum { VTE_SGR_COLOR_SPEC_LEGACY = 5 }; +inline constexpr int firmware_version() noexcept +{ + return (VTE_MAJOR_VERSION * 100 + VTE_MINOR_VERSION) * 100 + VTE_MICRO_VERSION; +} + void vte::parser::Sequence::print() const noexcept { @@ -2435,8 +2440,7 @@ Terminal::DA2(vte::parser::Sequence const& seq) if (seq.collect1(0, 0) != 0) return; - int const version = (VTE_MAJOR_VERSION * 100 + VTE_MINOR_VERSION) * 100 + VTE_MICRO_VERSION; - reply(seq, VTE_REPLY_DECDA2R, {65, version, 1}); + reply(seq, VTE_REPLY_DECDA2R, {65, firmware_version(), 1}); } void @@ -9063,6 +9067,30 @@ Terminal::XTERM_STCAP(vte::parser::Sequence const& seq) */ } +void +Terminal::XTERM_VERSION(vte::parser::Sequence const& seq) +{ + /* + * XTERM_VERSION - xterm request version report + * + * Returns the xterm name and version as XTERM_DSR. + * + * Arguments: + * args[0]: select function + * 0: report xterm name and version + * + * Defaults: + * args[0]: no defaults + * + * References: XTERM + */ + + if (seq.collect1(0) != 0) + return; + + reply(seq, VTE_REPLY_XTERM_DSR, {}, "VTE(%d)", firmware_version()); +} + void Terminal::XTERM_WM(vte::parser::Sequence const& seq) { -- cgit v1.2.1