Mercurial > vim
comparison src/libvterm/src/mouse.c @ 18267:da6a7491e148 v8.1.2128
patch 8.1.2128: renamed libvterm sources makes merging difficult
Commit: https://github.com/vim/vim/commit/93268054428fe3a6bbe3f89d2def2fec4eabcf5f
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Oct 10 13:22:54 2019 +0200
patch 8.1.2128: renamed libvterm sources makes merging difficult
Problem: Renamed libvterm sources makes merging difficult.
Solution: Rename back to the original name and only rename the .o files.
Also clean the libvterm build artifacts. (James McCoy,
closes #5027)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 10 Oct 2019 13:30:04 +0200 |
parents | src/libvterm/src/termmouse.c@1868ec23360e |
children | a4652d7ec99f |
comparison
equal
deleted
inserted
replaced
18266:4af19863e264 | 18267:da6a7491e148 |
---|---|
1 #include "vterm_internal.h" | |
2 | |
3 #include "utf8.h" | |
4 | |
5 static void output_mouse(VTermState *state, int code, int pressed, int modifiers, int col, int row) | |
6 { | |
7 modifiers <<= 2; | |
8 | |
9 switch(state->mouse_protocol) { | |
10 case MOUSE_X10: | |
11 if(col + 0x21 > 0xff) | |
12 col = 0xff - 0x21; | |
13 if(row + 0x21 > 0xff) | |
14 row = 0xff - 0x21; | |
15 | |
16 if(!pressed) | |
17 code = 3; | |
18 | |
19 vterm_push_output_sprintf_ctrl(state->vt, C1_CSI, "M%c%c%c", | |
20 (code | modifiers) + 0x20, col + 0x21, row + 0x21); | |
21 break; | |
22 | |
23 case MOUSE_UTF8: | |
24 { | |
25 char utf8[18]; size_t len = 0; | |
26 | |
27 if(!pressed) | |
28 code = 3; | |
29 | |
30 len += fill_utf8((code | modifiers) + 0x20, utf8 + len); | |
31 len += fill_utf8(col + 0x21, utf8 + len); | |
32 len += fill_utf8(row + 0x21, utf8 + len); | |
33 utf8[len] = 0; | |
34 | |
35 vterm_push_output_sprintf_ctrl(state->vt, C1_CSI, "M%s", utf8); | |
36 } | |
37 break; | |
38 | |
39 case MOUSE_SGR: | |
40 vterm_push_output_sprintf_ctrl(state->vt, C1_CSI, "<%d;%d;%d%c", | |
41 code | modifiers, col + 1, row + 1, pressed ? 'M' : 'm'); | |
42 break; | |
43 | |
44 case MOUSE_RXVT: | |
45 if(!pressed) | |
46 code = 3; | |
47 | |
48 vterm_push_output_sprintf_ctrl(state->vt, C1_CSI, "%d;%d;%dM", | |
49 code | modifiers, col + 1, row + 1); | |
50 break; | |
51 } | |
52 } | |
53 | |
54 void vterm_mouse_move(VTerm *vt, int row, int col, VTermModifier mod) | |
55 { | |
56 VTermState *state = vt->state; | |
57 | |
58 if(col == state->mouse_col && row == state->mouse_row) | |
59 return; | |
60 | |
61 state->mouse_col = col; | |
62 state->mouse_row = row; | |
63 | |
64 if((state->mouse_flags & MOUSE_WANT_DRAG && state->mouse_buttons) || | |
65 (state->mouse_flags & MOUSE_WANT_MOVE)) { | |
66 int button = state->mouse_buttons & MOUSE_BUTTON_LEFT ? 1 : | |
67 state->mouse_buttons & MOUSE_BUTTON_MIDDLE ? 2 : | |
68 state->mouse_buttons & MOUSE_BUTTON_RIGHT ? 3 : 4; | |
69 output_mouse(state, button-1 + 0x20, 1, mod, col, row); | |
70 } | |
71 } | |
72 | |
73 void vterm_mouse_button(VTerm *vt, int button, int pressed, VTermModifier mod) | |
74 { | |
75 VTermState *state = vt->state; | |
76 | |
77 int old_buttons = state->mouse_buttons; | |
78 | |
79 if(button > 0 && button <= 3) { | |
80 if(pressed) | |
81 state->mouse_buttons |= (1 << (button-1)); | |
82 else | |
83 state->mouse_buttons &= ~(1 << (button-1)); | |
84 } | |
85 | |
86 // Most of the time we don't get button releases from 4/5 | |
87 if(state->mouse_buttons == old_buttons && button < 4) | |
88 return; | |
89 if (!(state->mouse_flags & MOUSE_WANT_CLICK)) | |
90 return; | |
91 | |
92 if(button < 4) { | |
93 output_mouse(state, button-1, pressed, mod, state->mouse_col, state->mouse_row); | |
94 } | |
95 else if(button < 6) { | |
96 output_mouse(state, button-4 + 0x40, pressed, mod, state->mouse_col, state->mouse_row); | |
97 } | |
98 } |