tty: vt: split DEC CSI+h/l handling into csi_DEC_hl()

The DEC and ECMA handling of CSI+h/l is needlessly complicated. Split
these two, so that DEC is handled when the state is EPdec ('CSI ?' was
seen) and ECMA is handled in the EPecma state (no '?').

Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Link: https://lore.kernel.org/r/20240202065608.14019-5-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Jiri Slaby (SUSE) 2024-02-02 07:55:50 +01:00 committed by Greg Kroah-Hartman
parent 69b2c2693a
commit 58d1af9319

View File

@ -1874,20 +1874,13 @@ enum {
CSI_DEC_hl_MOUSE_VT200 = 1000, CSI_DEC_hl_MOUSE_VT200 = 1000,
}; };
enum {
CSI_hl_DISPLAY_CTRL = 3, /* handle ansi control chars */
CSI_hl_INSERT = 4, /* IRM: insert/replace */
CSI_hl_AUTO_NL = 20, /* LNM: Enter == CrLf/Lf */
};
/* console_lock is held */ /* console_lock is held */
static void csi_hl(struct vc_data *vc, bool on_off) static void csi_DEC_hl(struct vc_data *vc, bool on_off)
{ {
int i; unsigned int i;
for (i = 0; i <= vc->vc_npar; i++) for (i = 0; i <= vc->vc_npar; i++)
if (vc->vc_priv == EPdec) { switch (vc->vc_par[i]) {
switch(vc->vc_par[i]) { /* DEC private modes set/reset */
case CSI_DEC_hl_CURSOR_KEYS: case CSI_DEC_hl_CURSOR_KEYS:
if (on_off) if (on_off)
set_kbd(vc, decckm); set_kbd(vc, decckm);
@ -1904,8 +1897,7 @@ static void csi_hl(struct vc_data *vc, bool on_off)
case CSI_DEC_hl_REVERSE_VIDEO: case CSI_DEC_hl_REVERSE_VIDEO:
if (vc->vc_decscnm != on_off) { if (vc->vc_decscnm != on_off) {
vc->vc_decscnm = on_off; vc->vc_decscnm = on_off;
invert_screen(vc, 0, invert_screen(vc, 0, vc->vc_screenbuf_size,
vc->vc_screenbuf_size,
false); false);
update_attr(vc); update_attr(vc);
} }
@ -1933,8 +1925,21 @@ static void csi_hl(struct vc_data *vc, bool on_off)
vc->vc_report_mouse = on_off ? 2 : 0; vc->vc_report_mouse = on_off ? 2 : 0;
break; break;
} }
} else { }
switch(vc->vc_par[i]) { /* ANSI modes set/reset */
enum {
CSI_hl_DISPLAY_CTRL = 3, /* handle ansi control chars */
CSI_hl_INSERT = 4, /* IRM: insert/replace */
CSI_hl_AUTO_NL = 20, /* LNM: Enter == CrLf/Lf */
};
/* console_lock is held */
static void csi_hl(struct vc_data *vc, bool on_off)
{
unsigned int i;
for (i = 0; i <= vc->vc_npar; i++)
switch (vc->vc_par[i]) { /* ANSI modes set/reset */
case CSI_hl_DISPLAY_CTRL: case CSI_hl_DISPLAY_CTRL:
vc->vc_disp_ctrl = on_off; vc->vc_disp_ctrl = on_off;
break; break;
@ -1948,7 +1953,6 @@ static void csi_hl(struct vc_data *vc, bool on_off)
clr_kbd(vc, lnm); clr_kbd(vc, lnm);
break; break;
} }
}
} }
/* console_lock is held */ /* console_lock is held */
@ -2379,12 +2383,12 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c)
vc->vc_state = ESnormal; vc->vc_state = ESnormal;
switch(c) { switch(c) {
case 'h': case 'h':
if (vc->vc_priv <= EPdec) if (vc->vc_priv == EPdec)
csi_hl(vc, true); csi_DEC_hl(vc, true);
return; return;
case 'l': case 'l':
if (vc->vc_priv <= EPdec) if (vc->vc_priv == EPdec)
csi_hl(vc, false); csi_DEC_hl(vc, false);
return; return;
case 'c': case 'c':
if (vc->vc_priv == EPdec) { if (vc->vc_priv == EPdec) {
@ -2494,6 +2498,12 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c)
else if (vc->vc_par[0] == 3) else if (vc->vc_par[0] == 3)
bitmap_zero(vc->vc_tab_stop, VC_TABSTOPS_COUNT); bitmap_zero(vc->vc_tab_stop, VC_TABSTOPS_COUNT);
return; return;
case 'h':
csi_hl(vc, true);
return;
case 'l':
csi_hl(vc, false);
return;
case 'm': case 'm':
csi_m(vc); csi_m(vc);
return; return;