269 lines
8.3 KiB
Diff
269 lines
8.3 KiB
Diff
--- vte-0.28.2-clean/src/mev.c 2011-08-16 23:52:48.000000000 +0200
|
|
+++ vte-0.28.2-clean/src/mev.c 2018-05-03 22:07:30.275915172 +0200
|
|
@@ -42,7 +42,9 @@
|
|
tracking_mouse = 1000,
|
|
tracking_hilite = 1001,
|
|
tracking_cell_motion = 1002,
|
|
- tracking_all_motion = 1003
|
|
+ tracking_all_motion = 1003,
|
|
+ tracking_xterm_ext = 1006,
|
|
+ tracking_urxvt = 1015
|
|
} tracking_mode = 0;
|
|
|
|
static void
|
|
@@ -59,6 +61,8 @@
|
|
decset(tracking_hilite, FALSE);
|
|
decset(tracking_cell_motion, FALSE);
|
|
decset(tracking_all_motion, FALSE);
|
|
+ decset(tracking_xterm_ext, FALSE);
|
|
+ decset(tracking_urxvt, FALSE);
|
|
fflush(stdout);
|
|
}
|
|
|
|
@@ -93,6 +97,14 @@
|
|
fprintf(stdout, "All motion tracking enabled.\r\n");
|
|
decset(tracking_all_motion, TRUE);
|
|
break;
|
|
+ case tracking_xterm_ext:
|
|
+ fprintf(stdout, "Xterm 1006 mouse tracking extension enabled.\r\n");
|
|
+ decset(tracking_xterm_ext, TRUE);
|
|
+ break;
|
|
+ case tracking_urxvt:
|
|
+ fprintf(stdout, "rxvt-unicode 1015 mouse tracking extension enabled.\r\n");
|
|
+ decset(tracking_urxvt, TRUE);
|
|
+ break;
|
|
default:
|
|
fprintf(stdout, "Tracking disabled.\r\n");
|
|
break;
|
|
@@ -102,6 +114,8 @@
|
|
fprintf(stdout, "C - Hilite tracking [FIXME: NOT IMPLEMENTED].\r\n");
|
|
fprintf(stdout, "D - Cell motion tracking.\r\n");
|
|
fprintf(stdout, "E - All motion tracking.\r\n");
|
|
+ fprintf(stdout, "F - Xterm 1006 extension.\r\n");
|
|
+ fprintf(stdout, "G - rxvt-unicode extension.\r\n");
|
|
fprintf(stdout, "%s", _VTE_CAP_ESC "8");
|
|
fflush(stdout);
|
|
}
|
|
@@ -153,6 +167,18 @@
|
|
0 : tracking_all_motion;
|
|
i++;
|
|
break;
|
|
+ case 'F':
|
|
+ case 'f':
|
|
+ tracking_mode = (tracking_mode == tracking_xterm_ext) ?
|
|
+ 0 : tracking_xterm_ext;
|
|
+ i++;
|
|
+ break;
|
|
+ case 'G':
|
|
+ case 'g':
|
|
+ tracking_mode = (tracking_mode == tracking_urxvt) ?
|
|
+ 0 : tracking_urxvt;
|
|
+ i++;
|
|
+ break;
|
|
case 'Q':
|
|
case 'q':
|
|
ret = TRUE;
|
|
--- vte-0.28.2-clean/src/vte.c 2018-05-03 22:04:27.780199219 +0200
|
|
+++ vte-0.28.2-clean/src/vte.c 2018-05-03 22:07:30.277915158 +0200
|
|
@@ -5816,21 +5816,20 @@
|
|
}
|
|
|
|
static void
|
|
-vte_terminal_get_mouse_tracking_info (VteTerminal *terminal,
|
|
- int button,
|
|
- long col,
|
|
- long row,
|
|
- unsigned char *pb,
|
|
- unsigned char *px,
|
|
- unsigned char *py)
|
|
+vte_terminal_feed_mouse_event(VteTerminal *terminal,
|
|
+ int button,
|
|
+ gboolean is_drag,
|
|
+ gboolean is_release,
|
|
+ long col,
|
|
+ long row)
|
|
{
|
|
- unsigned char cb = 0, cx = 0, cy = 0;
|
|
+ unsigned char cb = 0;
|
|
+ long cx, cy;
|
|
+ char buf[LINE_MAX];
|
|
+ gint len = 0;
|
|
|
|
/* Encode the button information in cb. */
|
|
switch (button) {
|
|
- case 0: /* Release/no buttons. */
|
|
- cb = 3;
|
|
- break;
|
|
case 1: /* Left. */
|
|
cb = 0;
|
|
break;
|
|
@@ -5847,7 +5846,12 @@
|
|
cb = 65; /* Scroll down. */
|
|
break;
|
|
}
|
|
- cb += 32; /* 32 for normal */
|
|
+
|
|
+ /* With the exception of the 1006 mode, button release is also encoded here. */
|
|
+ /* Note that if multiple extensions are enabled, the 1006 is used, so it's okay to check for only that. */
|
|
+ if (is_release && !terminal->pvt->mouse_xterm_extension) {
|
|
+ cb = 3;
|
|
+ }
|
|
|
|
/* Encode the modifiers. */
|
|
if (terminal->pvt->modifiers & GDK_SHIFT_MASK) {
|
|
@@ -5860,38 +5864,46 @@
|
|
cb |= 16;
|
|
}
|
|
|
|
- /* Encode the cursor coordinates. */
|
|
- cx = 32 + CLAMP(1 + col,
|
|
- 1, terminal->column_count);
|
|
- cy = 32 + CLAMP(1 + row,
|
|
- 1, terminal->row_count);;
|
|
-
|
|
- *pb = cb;
|
|
- *px = cx;
|
|
- *py = cy;
|
|
+ /* Encode a drag event. */
|
|
+ if (is_drag) {
|
|
+ cb |= 32;
|
|
+ }
|
|
+
|
|
+ /* Clamp the cursor coordinates. Make them 1-based. */
|
|
+ cx = CLAMP(1 + col,
|
|
+ 1, terminal->column_count);
|
|
+ cy = CLAMP(1 + row,
|
|
+ 1, terminal->row_count);
|
|
+
|
|
+ /* Check the extensions in decreasing order of preference. Encoding the release event above assumes that 1006 comes first. */
|
|
+ if (terminal->pvt->mouse_xterm_extension) {
|
|
+ /* xterm's extended mode (1006) */
|
|
+ len = g_snprintf(buf, sizeof(buf), _VTE_CAP_CSI "<%d;%ld;%ld%c", cb, cx, cy, is_release ? 'm' : 'M');
|
|
+ } else if (terminal->pvt->mouse_urxvt_extension) {
|
|
+ /* urxvt's extended mode (1015) */
|
|
+ len = g_snprintf(buf, sizeof(buf), _VTE_CAP_CSI "%d;%ld;%ldM", 32 + cb, cx, cy);
|
|
+ } else if (cx <= 231 && cy <= 231) {
|
|
+ /* legacy mode */
|
|
+ len = g_snprintf(buf, sizeof(buf), _VTE_CAP_CSI "M%c%c%c", 32 + cb, 32 + (guchar)cx, 32 + (guchar)cy);
|
|
+ }
|
|
+
|
|
+ /* Send event direct to the child, this is binary not text data */
|
|
+ vte_terminal_feed_child_binary(terminal, buf, len);
|
|
}
|
|
|
|
static void
|
|
vte_terminal_send_mouse_button_internal(VteTerminal *terminal,
|
|
int button,
|
|
+ gboolean is_release,
|
|
long x,
|
|
long y)
|
|
{
|
|
- unsigned char cb, cx, cy;
|
|
- char buf[LINE_MAX];
|
|
- gint len;
|
|
int width = terminal->char_width;
|
|
int height = terminal->char_height;
|
|
long col = (x - terminal->pvt->inner_border.left) / width;
|
|
long row = (y - terminal->pvt->inner_border.top) / height;
|
|
|
|
- vte_terminal_get_mouse_tracking_info (terminal,
|
|
- button, col, row,
|
|
- &cb, &cx, &cy);
|
|
-
|
|
- /* Send event direct to the child, this is binary not text data */
|
|
- len = g_snprintf(buf, sizeof(buf), _VTE_CAP_CSI "M%c%c%c", cb, cx, cy);
|
|
- vte_terminal_feed_child_binary(terminal, buf, len);
|
|
+ vte_terminal_feed_mouse_event(terminal, button, FALSE /* not drag */, is_release, col, row);
|
|
}
|
|
|
|
/* Send a mouse button click/release notification. */
|
|
@@ -5919,7 +5931,8 @@
|
|
}
|
|
|
|
vte_terminal_send_mouse_button_internal(terminal,
|
|
- (event->type == GDK_BUTTON_PRESS) ? event->button : 0,
|
|
+ event->button,
|
|
+ event->type == GDK_BUTTON_RELEASE,
|
|
event->x, event->y);
|
|
}
|
|
|
|
@@ -5927,9 +5940,6 @@
|
|
static void
|
|
vte_terminal_maybe_send_mouse_drag(VteTerminal *terminal, GdkEventMotion *event)
|
|
{
|
|
- unsigned char cb, cx, cy;
|
|
- char buf[LINE_MAX];
|
|
- gint len;
|
|
int width = terminal->char_width;
|
|
int height = terminal->char_height;
|
|
long col = ((long) event->x - terminal->pvt->inner_border.left) / width;
|
|
@@ -5958,14 +5968,9 @@
|
|
break;
|
|
}
|
|
|
|
- vte_terminal_get_mouse_tracking_info (terminal,
|
|
- terminal->pvt->mouse_last_button, col, row,
|
|
- &cb, &cx, &cy);
|
|
- cb += 32; /* for movement */
|
|
-
|
|
- /* Send event direct to the child, this is binary not text data */
|
|
- len = g_snprintf(buf, sizeof(buf), _VTE_CAP_CSI "M%c%c%c", cb, cx, cy);
|
|
- vte_terminal_feed_child_binary(terminal, buf, len);
|
|
+ vte_terminal_feed_mouse_event(terminal, terminal->pvt->mouse_last_button,
|
|
+ TRUE /* drag */, FALSE /* not release */,
|
|
+ col, row);
|
|
}
|
|
|
|
/* Clear all match hilites. */
|
|
@@ -11384,6 +11389,7 @@
|
|
/* Encode the parameters and send them to the app. */
|
|
vte_terminal_send_mouse_button_internal(terminal,
|
|
button,
|
|
+ FALSE /* not release */,
|
|
event->x,
|
|
event->y);
|
|
}
|
|
@@ -14091,6 +14097,8 @@
|
|
pvt->mouse_last_button = 0;
|
|
pvt->mouse_last_x = 0;
|
|
pvt->mouse_last_y = 0;
|
|
+ pvt->mouse_xterm_extension = FALSE;
|
|
+ pvt->mouse_urxvt_extension = FALSE;
|
|
/* Clear modifiers. */
|
|
pvt->modifiers = 0;
|
|
/* Reset miscellaneous stuff. */
|
|
--- vte-0.28.2-clean/src/vte-private.h 2018-05-03 22:04:27.773199268 +0200
|
|
+++ vte-0.28.2-clean/src/vte-private.h 2018-05-03 22:07:30.275915172 +0200
|
|
@@ -305,6 +305,8 @@
|
|
long mouse_last_x, mouse_last_y;
|
|
gboolean mouse_autohide;
|
|
guint mouse_autoscroll_tag;
|
|
+ gboolean mouse_xterm_extension;
|
|
+ gboolean mouse_urxvt_extension;
|
|
|
|
/* State variables for handling match checks. */
|
|
char *match_contents;
|
|
--- vte-0.28.2-clean/src/vteseq.c 2018-05-03 22:04:27.773199268 +0200
|
|
+++ vte-0.28.2-clean/src/vteseq.c 2018-05-03 22:07:30.277915158 +0200
|
|
@@ -685,10 +685,20 @@
|
|
GINT_TO_POINTER(0),
|
|
GINT_TO_POINTER(MOUSE_TRACKING_ALL_MOTION_TRACKING),
|
|
NULL, NULL,},
|
|
+ /* 1006: Extended mouse coordinates. */
|
|
+ {1006, &terminal->pvt->mouse_xterm_extension, NULL, NULL,
|
|
+ GINT_TO_POINTER(FALSE),
|
|
+ GINT_TO_POINTER(TRUE),
|
|
+ NULL, NULL,},
|
|
/* 1010/rxvt: disallowed, scroll-on-output is set by user. */
|
|
{1010, NULL, NULL, NULL, NULL, NULL, NULL, NULL,},
|
|
/* 1011/rxvt: disallowed, scroll-on-keypress is set by user. */
|
|
{1011, NULL, NULL, NULL, NULL, NULL, NULL, NULL,},
|
|
+ /* 1015/urxvt: Extended mouse coordinates. */
|
|
+ {1015, &terminal->pvt->mouse_urxvt_extension, NULL, NULL,
|
|
+ GINT_TO_POINTER(FALSE),
|
|
+ GINT_TO_POINTER(TRUE),
|
|
+ NULL, NULL,},
|
|
/* 1035: disallowed, don't know what to do with it. */
|
|
{1035, NULL, NULL, NULL, NULL, NULL, NULL, NULL,},
|
|
/* 1036: Meta-sends-escape. */
|