csi: implement URXVT style mouse event reporting

This commit is contained in:
Daniel Eklöf 2019-07-05 19:40:52 +02:00
parent 450f6c7dcc
commit c76e620d71
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
2 changed files with 13 additions and 12 deletions

3
csi.c
View file

@ -614,8 +614,7 @@ csi_dispatch(struct terminal *term, uint8_t final)
break; break;
case 1015: case 1015:
LOG_WARN("unimplemented: URXVT mosue"); term->mouse_reporting = MOUSE_URXVT;
/* term->mouse_reporting = MOUSE_URXVT; */
break; break;
case 1049: case 1049:

View file

@ -426,28 +426,30 @@ static void
report_mouse_click(struct terminal *term, int encoded_button, int row, int col, report_mouse_click(struct terminal *term, int encoded_button, int row, int col,
bool release) bool release)
{ {
char response[128];
switch (term->mouse_reporting) { switch (term->mouse_reporting) {
case MOUSE_NORMAL: { case MOUSE_NORMAL:
char response[16];
snprintf(response, sizeof(response), "\033[M%c%c%c", snprintf(response, sizeof(response), "\033[M%c%c%c",
32 + (release ? 3 : encoded_button), 32 + col + 1, 32 + row + 1); 32 + (release ? 3 : encoded_button), 32 + col + 1, 32 + row + 1);
write(term->ptmx, response, strlen(response));
break; break;
}
case MOUSE_SGR: { case MOUSE_SGR:
char response[128];
snprintf(response, sizeof(response), "\033[<%d;%d;%d%c", snprintf(response, sizeof(response), "\033[<%d;%d;%d%c",
encoded_button, col + 1, row + 1, release ? 'm' : 'M'); encoded_button, col + 1, row + 1, release ? 'm' : 'M');
write(term->ptmx, response, strlen(response));
break; break;
}
case MOUSE_URXVT:
snprintf(response, sizeof(response), "\033[%d;%d;%dM",
32 + (release ? 3 : encoded_button), col + 1, row + 1);
break;
case MOUSE_UTF8: case MOUSE_UTF8:
case MOUSE_URXVT:
/* Unimplemented */ /* Unimplemented */
break; return;
} }
write(term->ptmx, response, strlen(response));
} }
static void static void