From 771e9b120f05cc6b900e50618d6fbfd06f96e1ff Mon Sep 17 00:00:00 2001 From: "Paul \"LeoNerd\" Evans" Date: Tue, 6 Sep 2022 16:00:35 +0100 Subject: [PATCH] Also accept the DECSGR sequences for superscript/subscript control, for greater compatibility --- doc/seqs.txt | 1 + src/state.c | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/doc/seqs.txt b/doc/seqs.txt index 16bfee26..27f28b91 100644 --- a/doc/seqs.txt +++ b/doc/seqs.txt @@ -122,6 +122,7 @@ x = xterm 123x CSI l = RM, Reset mode 123x CSI ? l = DECRM, DEC reset mode 123x CSI m = SGR, Set Graphic Rendition + CSI ? m = DECSGR, private Set Graphic Rendition 123x CSI n = DSR, Device Status Report 23x 5 = operating status 23x 6 = CPR = cursor position diff --git a/src/state.c b/src/state.c index 302ec0f1..ccc69817 100644 --- a/src/state.c +++ b/src/state.c @@ -1341,6 +1341,29 @@ static int on_csi(const char *leader, const long args[], int argcount, const cha vterm_state_setpen(state, args, argcount); break; + case LEADER('?', 0x6d): // DECSGR + /* No actual DEC terminal recognised these, but some printers did. These + * are alternative ways to request subscript/superscript/off + */ + for(int argi = 0; argi < argcount; argi++) { + long arg; + switch(arg = CSI_ARG(args[argi])) { + case 4: // Superscript on + arg = 73; + vterm_state_setpen(state, &arg, 1); + break; + case 5: // Subscript on + arg = 74; + vterm_state_setpen(state, &arg, 1); + break; + case 24: // Super+subscript off + arg = 75; + vterm_state_setpen(state, &arg, 1); + break; + } + } + break; + case 0x6e: // DSR - ECMA-48 8.3.35 case LEADER('?', 0x6e): // DECDSR val = CSI_ARG_OR(args[0], 0);