Merge branch 'csi-cleanup'

This commit is contained in:
Craig Barnes 2021-08-30 21:35:06 +01:00
commit f26251d3bd

45
csi.c
View file

@ -795,8 +795,8 @@ csi_dispatch(struct terminal *term, uint8_t final)
* *
* Note: tertiary DA responds with "FOOT". * Note: tertiary DA responds with "FOOT".
*/ */
const char *reply = "\033[?62;4;22c"; static const char reply[] = "\033[?62;4;22c";
term_to_slave(term, reply, strlen(reply)); term_to_slave(term, reply, sizeof(reply) - 1);
break; break;
} }
@ -1062,17 +1062,15 @@ csi_dispatch(struct terminal *term, uint8_t final)
} }
case 'S': { case 'S': {
int amount = min( const struct scroll_region *r = &term->scroll_region;
vt_param_get(term, 0, 1), int amount = min(vt_param_get(term, 0, 1), r->end - r->start);
term->scroll_region.end - term->scroll_region.start);
term_scroll(term, amount); term_scroll(term, amount);
break; break;
} }
case 'T': { case 'T': {
int amount = min( const struct scroll_region *r = &term->scroll_region;
vt_param_get(term, 0, 1), int amount = min(vt_param_get(term, 0, 1), r->end - r->start);
term->scroll_region.end - term->scroll_region.start);
term_scroll_reverse(term, amount); term_scroll_reverse(term, amount);
break; break;
} }
@ -1219,20 +1217,12 @@ csi_dispatch(struct terminal *term, uint8_t final)
break; break;
case 13: { /* report window position */ case 13: { /* report window position */
int x = -1;
int y = -1;
/* We don't know our position - always report (0,0) */ /* We don't know our position - always report (0,0) */
static const char reply[] = "\033[3;0;0t";
switch (vt_param_get(term, 1, 0)) { switch (vt_param_get(term, 1, 0)) {
case 0: case 0: /* window position */
/* window position */ case 2: /* text area position */
x = y = 0; term_to_slave(term, reply, sizeof(reply) - 1);
break;
case 2:
/* text area position */
x = y = 0;
break; break;
default: default:
@ -1240,12 +1230,6 @@ csi_dispatch(struct terminal *term, uint8_t final)
break; break;
} }
if (x >= 0 && y >= 0) {
char reply[64];
size_t n = xsnprintf(reply, sizeof(reply), "\033[3;%d;%dt",
x / term->scale, y / term->scale);
term_to_slave(term, reply, n);
}
break; break;
} }
@ -1616,15 +1600,12 @@ csi_dispatch(struct terminal *term, uint8_t final)
} }
case '!': { case '!': {
switch (final) { if (final == 'p') {
case 'p':
term_reset(term, false); term_reset(term, false);
break; break;
default:
UNHANDLED();
break;
} }
UNHANDLED();
break; /* private[0] == '!' */ break; /* private[0] == '!' */
} }