mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-03-22 06:38:37 -05:00
Robert de Bath's patch: sort out once and for all the confusion
between ESC [ ... Q and ESC [ ... ? Q (for all values of Q). [originally from svn r402]
This commit is contained in:
parent
3ee28098bc
commit
06060def52
92
terminal.c
92
terminal.c
@ -46,6 +46,8 @@ static int alt_which;
|
|||||||
static int esc_args[ARGS_MAX];
|
static int esc_args[ARGS_MAX];
|
||||||
static int esc_nargs;
|
static int esc_nargs;
|
||||||
static int esc_query;
|
static int esc_query;
|
||||||
|
#define ANSI(x,y) ((x)+((y)<<8))
|
||||||
|
#define ANSI_QUE(x) ANSI(x,TRUE)
|
||||||
|
|
||||||
#define OSC_STR_MAX 2048
|
#define OSC_STR_MAX 2048
|
||||||
static int osc_strlen;
|
static int osc_strlen;
|
||||||
@ -662,31 +664,30 @@ void term_out(void) {
|
|||||||
}
|
}
|
||||||
else switch (termstate) {
|
else switch (termstate) {
|
||||||
case TOPLEVEL:
|
case TOPLEVEL:
|
||||||
if (c >= ' ' && c != 0234) {
|
/* Only graphic characters get this far, ctrls are stripped above */
|
||||||
if (wrapnext) {
|
if (wrapnext) {
|
||||||
cpos[1] = ATTR_WRAPPED;
|
cpos[1] = ATTR_WRAPPED;
|
||||||
if (curs_y == marg_b)
|
if (curs_y == marg_b)
|
||||||
scroll (marg_t, marg_b, 1, TRUE);
|
scroll (marg_t, marg_b, 1, TRUE);
|
||||||
else if (curs_y < rows-1)
|
else if (curs_y < rows-1)
|
||||||
curs_y++;
|
curs_y++;
|
||||||
curs_x = 0;
|
curs_x = 0;
|
||||||
fix_cpos;
|
fix_cpos;
|
||||||
wrapnext = FALSE;
|
wrapnext = FALSE;
|
||||||
nl_count++;
|
nl_count++;
|
||||||
}
|
|
||||||
if (insert)
|
|
||||||
insch (1);
|
|
||||||
check_selection (cpos, cpos+1);
|
|
||||||
*cpos++ = xlat_tty2scr((unsigned char)c) | curr_attr |
|
|
||||||
(c <= 0x7F ? cset_attr[cset] : ATTR_ASCII);
|
|
||||||
curs_x++;
|
|
||||||
if (curs_x == cols) {
|
|
||||||
cpos--;
|
|
||||||
curs_x--;
|
|
||||||
wrapnext = wrap;
|
|
||||||
}
|
|
||||||
seen_disp_event = 1;
|
|
||||||
}
|
}
|
||||||
|
if (insert)
|
||||||
|
insch (1);
|
||||||
|
check_selection (cpos, cpos+1);
|
||||||
|
*cpos++ = xlat_tty2scr((unsigned char)c) | curr_attr |
|
||||||
|
(c <= 0x7F ? cset_attr[cset] : ATTR_ASCII);
|
||||||
|
curs_x++;
|
||||||
|
if (curs_x == cols) {
|
||||||
|
cpos--;
|
||||||
|
curs_x--;
|
||||||
|
wrapnext = wrap;
|
||||||
|
}
|
||||||
|
seen_disp_event = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IGNORE_NEXT:
|
case IGNORE_NEXT:
|
||||||
@ -789,9 +790,8 @@ void term_out(void) {
|
|||||||
break;
|
break;
|
||||||
case SEEN_CSI:
|
case SEEN_CSI:
|
||||||
termstate = TOPLEVEL; /* default */
|
termstate = TOPLEVEL; /* default */
|
||||||
switch (c) {
|
if( isdigit(c) )
|
||||||
case '0': case '1': case '2': case '3': case '4':
|
{
|
||||||
case '5': case '6': case '7': case '8': case '9':
|
|
||||||
if (esc_nargs <= ARGS_MAX) {
|
if (esc_nargs <= ARGS_MAX) {
|
||||||
if (esc_args[esc_nargs-1] == ARG_DEFAULT)
|
if (esc_args[esc_nargs-1] == ARG_DEFAULT)
|
||||||
esc_args[esc_nargs-1] = 0;
|
esc_args[esc_nargs-1] = 0;
|
||||||
@ -799,16 +799,21 @@ void term_out(void) {
|
|||||||
10 * esc_args[esc_nargs-1] + c - '0';
|
10 * esc_args[esc_nargs-1] + c - '0';
|
||||||
}
|
}
|
||||||
termstate = SEEN_CSI;
|
termstate = SEEN_CSI;
|
||||||
break;
|
}
|
||||||
case ';':
|
else if( c == ';' )
|
||||||
|
{
|
||||||
if (++esc_nargs <= ARGS_MAX)
|
if (++esc_nargs <= ARGS_MAX)
|
||||||
esc_args[esc_nargs-1] = ARG_DEFAULT;
|
esc_args[esc_nargs-1] = ARG_DEFAULT;
|
||||||
termstate = SEEN_CSI;
|
termstate = SEEN_CSI;
|
||||||
break;
|
}
|
||||||
case '?':
|
else if( c < '@' )
|
||||||
esc_query = TRUE;
|
{
|
||||||
|
if( esc_query ) esc_query = -1;
|
||||||
|
else if( c == '?' ) esc_query = TRUE;
|
||||||
|
else esc_query = c;
|
||||||
termstate = SEEN_CSI;
|
termstate = SEEN_CSI;
|
||||||
break;
|
}
|
||||||
|
else switch (ANSI(c,esc_query)) {
|
||||||
case 'A': /* move up N lines */
|
case 'A': /* move up N lines */
|
||||||
move (curs_x, curs_y - def(esc_args[0], 1), 1);
|
move (curs_x, curs_y - def(esc_args[0], 1), 1);
|
||||||
seen_disp_event = TRUE;
|
seen_disp_event = TRUE;
|
||||||
@ -898,9 +903,11 @@ void term_out(void) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'h': /* toggle a mode to high */
|
case 'h': /* toggle a mode to high */
|
||||||
|
case ANSI_QUE('h'):
|
||||||
toggle_mode (esc_args[0], esc_query, TRUE);
|
toggle_mode (esc_args[0], esc_query, TRUE);
|
||||||
break;
|
break;
|
||||||
case 'l': /* toggle a mode to low */
|
case 'l': /* toggle a mode to low */
|
||||||
|
case ANSI_QUE('l'):
|
||||||
toggle_mode (esc_args[0], esc_query, FALSE);
|
toggle_mode (esc_args[0], esc_query, FALSE);
|
||||||
break;
|
break;
|
||||||
case 'g': /* clear tabs */
|
case 'g': /* clear tabs */
|
||||||
@ -915,7 +922,7 @@ void term_out(void) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'r': /* set scroll margins */
|
case 'r': /* set scroll margins */
|
||||||
if (!esc_query && esc_nargs <= 2) {
|
if (esc_nargs <= 2) {
|
||||||
int top, bot;
|
int top, bot;
|
||||||
top = def(esc_args[0], 1) - 1;
|
top = def(esc_args[0], 1) - 1;
|
||||||
if (top < 0)
|
if (top < 0)
|
||||||
@ -1033,7 +1040,8 @@ void term_out(void) {
|
|||||||
cset_attr[termstate == SET_GL ? 0 : 1] = ATTR_ASCII;
|
cset_attr[termstate == SET_GL ? 0 : 1] = ATTR_ASCII;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
termstate = TOPLEVEL;
|
if( c != '%' )
|
||||||
|
termstate = TOPLEVEL;
|
||||||
break;
|
break;
|
||||||
case SEEN_OSC:
|
case SEEN_OSC:
|
||||||
osc_w = FALSE;
|
osc_w = FALSE;
|
||||||
@ -1071,7 +1079,19 @@ void term_out(void) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OSC_STRING:
|
case OSC_STRING:
|
||||||
if (c == 0234 || c == '\007') {
|
/*
|
||||||
|
* This OSC stuff is EVIL. It takes just one character to get into
|
||||||
|
* sysline mode and it's not initially obvious how to get out.
|
||||||
|
* So I've added CR and LF as string aborts.
|
||||||
|
* This shouldn't effect compatibility as I believe embedded
|
||||||
|
* control characters are supposed to be interpreted (maybe?)
|
||||||
|
* and they don't display anything useful anyway.
|
||||||
|
*
|
||||||
|
* -- RDB
|
||||||
|
*/
|
||||||
|
if (c == '\n' || c == '\r') {
|
||||||
|
termstate = TOPLEVEL;
|
||||||
|
} else if (c == 0234 || c == '\007' ) {
|
||||||
/*
|
/*
|
||||||
* These characters terminate the string; ST and BEL
|
* These characters terminate the string; ST and BEL
|
||||||
* terminate the sequence and trigger instant
|
* terminate the sequence and trigger instant
|
||||||
|
Loading…
x
Reference in New Issue
Block a user