diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2019-07-05 13:29:16 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2019-07-05 13:29:16 +0000 |
| commit | 1b07015d493a5f9d33c81e6941298999b91de504 (patch) | |
| tree | afe869ebb12050c60b4f58320f80de9a9c3f5b01 | |
| parent | input: bug: row is calculated from the cell *height*, not width (diff) | |
term: implement MOUSE_SGR mouse event reporting style
This style is enabled with the \e[?1006h sequence, and changes how
mouse events (button presses, releases and motion events).
| -rw-r--r-- | terminal.c | 31 |
1 files changed, 26 insertions, 5 deletions
@@ -426,10 +426,28 @@ static void report_mouse_click(struct terminal *term, int encoded_button, int row, int col, bool release) { - char response[16]; - snprintf(response, sizeof(response), "\033[M%c%c%c", - 32 + encoded_button, 32 + col + 1, 32 + row + 1); - write(term->ptmx, response, strlen(response)); + switch (term->mouse_reporting) { + case MOUSE_NORMAL: { + char response[16]; + snprintf(response, sizeof(response), "\033[M%c%c%c", + 32 + (release ? 3 : encoded_button), 32 + col + 1, 32 + row + 1); + write(term->ptmx, response, strlen(response)); + break; + } + + case MOUSE_SGR: { + char response[128]; + snprintf(response, sizeof(response), "\033[<%d;%d;%d%c", + encoded_button, col + 1, row + 1, release ? 'm' : 'M'); + write(term->ptmx, response, strlen(response)); + break; + } + + case MOUSE_UTF8: + case MOUSE_URXVT: + /* Unimplemented */ + break; + } } static void @@ -480,7 +498,10 @@ term_mouse_up(struct terminal *term, int button, int row, int col, return; } - int encoded = 3; + int encoded = encode_xbutton(xbutton); + if (encoded == -1) + return; + encoded += (shift ? 4 : 0) + (alt ? 8 : 0) + (ctrl ? 16 : 0); switch (term->mouse_tracking) { |
