Commit a9ffb223 authored by Jiri Slaby (SUSE)'s avatar Jiri Slaby (SUSE) Committed by Greg Kroah-Hartman

tty: vt: separate ESesc state handling into handle_esc()

Similar to the ASCII handling, the ESC handling can be easily moved away
from do_con_trol(). So create a new handle_esc() for that.

And add a comment with an example.
Signed-off-by: default avatar"Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Link: https://lore.kernel.org/r/20240202065608.14019-13-jirislaby@kernel.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent ce66f8e3
...@@ -2267,84 +2267,94 @@ static bool handle_ascii(struct tty_struct *tty, struct vc_data *vc, u8 c) ...@@ -2267,84 +2267,94 @@ static bool handle_ascii(struct tty_struct *tty, struct vc_data *vc, u8 c)
return false; return false;
} }
/* console_lock is held */ /*
static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, u8 c) * Handle a character (@c) following an ESC (when @vc is in the ESesc state).
{ * E.g. previous ESC with @c == '[' here yields the ESsquare state (that is:
/* * CSI).
* Control characters can be used in the _middle_
* of an escape sequence, aside from ANSI control strings.
*/ */
if (ansi_control_string(vc->vc_state) && c >= ASCII_IGNORE_FIRST && static void handle_esc(struct tty_struct *tty, struct vc_data *vc, u8 c)
c <= ASCII_IGNORE_LAST) {
return;
if (handle_ascii(tty, vc, c))
return;
switch(vc->vc_state) {
case ESesc:
vc->vc_state = ESnormal; vc->vc_state = ESnormal;
switch (c) { switch (c) {
case '[': case '[':
vc->vc_state = ESsquare; vc->vc_state = ESsquare;
return; break;
case ']': case ']':
vc->vc_state = ESnonstd; vc->vc_state = ESnonstd;
return; break;
case '_': case '_':
vc->vc_state = ESapc; vc->vc_state = ESapc;
return; break;
case '^': case '^':
vc->vc_state = ESpm; vc->vc_state = ESpm;
return; break;
case '%': case '%':
vc->vc_state = ESpercent; vc->vc_state = ESpercent;
return; break;
case 'E': case 'E':
cr(vc); cr(vc);
lf(vc); lf(vc);
return; break;
case 'M': case 'M':
ri(vc); ri(vc);
return; break;
case 'D': case 'D':
lf(vc); lf(vc);
return; break;
case 'H': case 'H':
if (vc->state.x < VC_TABSTOPS_COUNT) if (vc->state.x < VC_TABSTOPS_COUNT)
set_bit(vc->state.x, vc->vc_tab_stop); set_bit(vc->state.x, vc->vc_tab_stop);
return; break;
case 'P': case 'P':
vc->vc_state = ESdcs; vc->vc_state = ESdcs;
return; break;
case 'Z': case 'Z':
respond_ID(tty); respond_ID(tty);
return; break;
case '7': case '7':
save_cur(vc); save_cur(vc);
return; break;
case '8': case '8':
restore_cur(vc); restore_cur(vc);
return; break;
case '(': case '(':
vc->vc_state = ESsetG0; vc->vc_state = ESsetG0;
return; break;
case ')': case ')':
vc->vc_state = ESsetG1; vc->vc_state = ESsetG1;
return; break;
case '#': case '#':
vc->vc_state = EShash; vc->vc_state = EShash;
return; break;
case 'c': case 'c':
reset_terminal(vc, 1); reset_terminal(vc, 1);
return; break;
case '>': /* Numeric keypad */ case '>': /* Numeric keypad */
clr_kbd(vc, kbdapplic); clr_kbd(vc, kbdapplic);
return; break;
case '=': /* Appl. keypad */ case '=': /* Appl. keypad */
set_kbd(vc, kbdapplic); set_kbd(vc, kbdapplic);
return; break;
} }
}
/* console_lock is held */
static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, u8 c)
{
/*
* Control characters can be used in the _middle_
* of an escape sequence, aside from ANSI control strings.
*/
if (ansi_control_string(vc->vc_state) && c >= ASCII_IGNORE_FIRST &&
c <= ASCII_IGNORE_LAST)
return;
if (handle_ascii(tty, vc, c))
return;
switch(vc->vc_state) {
case ESesc:
handle_esc(tty, vc, c);
return; return;
case ESnonstd: case ESnonstd:
if (c=='P') { /* palette escape sequence */ if (c=='P') { /* palette escape sequence */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment