summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNalin Dahyabhai <nalin@src.gnome.org>2002-05-06 21:53:07 +0000
committerNalin Dahyabhai <nalin@src.gnome.org>2002-05-06 21:53:07 +0000
commit14b0aa82214da4bfc5243be3ab8c097924d69528 (patch)
tree365f03086a1fc479c1a2e0e09a69ca2434737b5b
parent9d8fe49fb582d45b30c417e4139581053122d6bf (diff)
Start handling mouse button down / button up events.vte_0_3_9
* src/vte.c: Start handling mouse button down / button up events.
-rw-r--r--ChangeLog2
-rw-r--r--src/vte.c105
-rw-r--r--vte.spec5
3 files changed, 105 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 0271a45..23c9e3d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,7 +3,7 @@
signals to be more consistent. Add thin wrappers for emitting signals,
and use them everywhere. Support pangox even when XFT isn't available.
Try to provide bold text again. Added signals for most of the window
- manipulation control sequences.
+ manipulation control sequences. Start handling mouse button events.
* src/caps.c, src/caps.h: Export definitions of VTE_CAP_CSI and friends.
2002-05-04 nalin
* src/vte.c: Implement device-status-report and dec-device-status-
diff --git a/src/vte.c b/src/vte.c
index c8f1fa7..8110f58 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -226,6 +226,12 @@ struct _VteTerminalPrivate {
VteTerminalEraseBinding backspace_binding, delete_binding;
gboolean xterm_font_tweak;
+
+ gboolean mouse_send_xy_on_click;
+ gboolean mouse_send_xy_on_button;
+ gboolean mouse_hilite_tracking;
+ gboolean mouse_cell_motion_tracking;
+ gboolean mouse_all_motion_tracking;
};
/* A function which can handle a terminal control sequence. */
@@ -2315,7 +2321,11 @@ vte_sequence_handler_decset_internal(VteTerminal *terminal,
/* FIXME: set or unset autorepeat keys. */
break;
case 9:
- /* FIXME: send mouse X and Y on button. */
+#ifdef VTE_DEBUG
+ fprintf(stderr, "Setting send-coords-on-click "
+ "to %s.\n", set ? "ON" : "OFF");
+#endif
+ terminal->pvt->mouse_send_xy_on_click = set;
break;
case 25:
terminal->pvt->screen->cursor_visible = set;
@@ -2353,12 +2363,31 @@ vte_sequence_handler_decset_internal(VteTerminal *terminal,
terminal->row_count);
break;
case 1000:
- /* FIXME: send mouse X and Y on press and
- * release. */
+#ifdef VTE_DEBUG
+ fprintf(stderr, "Setting send-coords-on-button "
+ "to %s.\n", set ? "ON" : "OFF");
+#endif
+ terminal->pvt->mouse_send_xy_on_button = set;
break;
case 1001:
- /* FIXME: use (or not) hilite mouse tracking. */
+#ifdef VTE_DEBUG
+ fprintf(stderr, "Setting hilite-tracking "
+ "to %s.\n", set ? "ON" : "OFF");
+#endif
+ terminal->pvt->mouse_hilite_tracking = set;
break;
+ case 1002:
+#ifdef VTE_DEBUG
+ fprintf(stderr, "Setting cell-tracking "
+ "to %s.\n", set ? "ON" : "OFF");
+#endif
+ terminal->pvt->mouse_cell_motion_tracking = set;
+ case 1003:
+#ifdef VTE_DEBUG
+ fprintf(stderr, "Setting all-tracking "
+ "to %s.\n", set ? "ON" : "OFF");
+#endif
+ terminal->pvt->mouse_all_motion_tracking = set;
default:
break;
}
@@ -3876,7 +3905,7 @@ vte_terminal_process_incoming(gpointer data)
* bytes that claim to be part of this character. */
if ((end > start) &&
(strcmp(terminal->pvt->encoding, "UTF-8") == 0) &&
- ((terminal->pvt->incoming[end] & 0xc0) != 0xc0)) {
+ ((terminal->pvt->incoming[end] & 0xc0) == 0xc0)) {
break;
}
@@ -5271,6 +5300,60 @@ vte_terminal_paste(VteTerminal *terminal, GdkAtom board)
}
}
+/* Send a button down or up notification. */
+static void
+vte_terminal_send_mouse_button(VteTerminal *terminal, GdkEventButton *event)
+{
+ unsigned char cb = 0, cx = 0, cy = 0;
+ char buf[LINE_MAX];
+ GdkModifierType modifiers;
+ g_return_if_fail(VTE_IS_TERMINAL(terminal));
+ /* Read the modifiers. */
+ if (gdk_event_get_state((GdkEvent*)event, &modifiers) == FALSE) {
+ modifiers = 0;
+ }
+ /* Encode the button information in cb. */
+ if (event->type == GDK_BUTTON_PRESS) {
+ switch (event->button) {
+ case 1:
+ cb = 0;
+ break;
+ case 2:
+ cb = 1;
+ break;
+ case 3:
+ cb = 2;
+ break;
+ case 4:
+ cb = 64; /* FIXME: check */
+ break;
+ case 5:
+ cb = 65; /* FIXME: check */
+ break;
+ }
+ }
+ if (event->type == GDK_BUTTON_RELEASE) {
+ cb = 3;
+ }
+ cb |= 32;
+ /* Encode the modifiers. */
+ if (modifiers & GDK_SHIFT_MASK) {
+ cb |= 4;
+ }
+ if (modifiers & GDK_MOD1_MASK) {
+ cb |= 8;
+ }
+ if (modifiers & GDK_CONTROL_MASK) {
+ cb |= 16;
+ }
+ /* Encode the cursor coordinates. */
+ cx = 32 + 1 + (event->x / terminal->char_width);
+ cy = 32 + 1 + (event->y / terminal->char_height);
+ /* Send the event to the child. */
+ snprintf(buf, sizeof(buf), "%sM%c%c%c", VTE_CAP_CSI, cb, cx, cy);
+ vte_terminal_feed_child(terminal, buf, strlen(buf));
+}
+
/* Read and handle a pointing device buttonpress event. */
static gint
vte_terminal_button_press(GtkWidget *widget, GdkEventButton *event)
@@ -5289,6 +5372,10 @@ vte_terminal_button_press(GtkWidget *widget, GdkEventButton *event)
fprintf(stderr, "button %d pressed at (%lf,%lf)\n",
event->button, event->x, event->y);
#endif
+ if ((terminal->pvt->mouse_send_xy_on_button) ||
+ (terminal->pvt->mouse_send_xy_on_click)) {
+ vte_terminal_send_mouse_button(terminal, event);
+ }
if (event->button == 1) {
if (!GTK_WIDGET_HAS_FOCUS(widget)) {
gtk_widget_grab_focus(widget);
@@ -5375,6 +5462,9 @@ vte_terminal_button_release(GtkWidget *widget, GdkEventButton *event)
fprintf(stderr, "button %d released at (%lf,%lf)\n",
event->button, event->x, event->y);
#endif
+ if (terminal->pvt->mouse_send_xy_on_button) {
+ vte_terminal_send_mouse_button(terminal, event);
+ }
if (event->button == 1) {
vte_terminal_copy(terminal, GDK_SELECTION_PRIMARY);
}
@@ -6336,6 +6426,11 @@ vte_terminal_init(VteTerminal *terminal, gpointer *klass)
/* Set various other settings. */
pvt->xterm_font_tweak = FALSE;
+ pvt->mouse_send_xy_on_click = FALSE;
+ pvt->mouse_send_xy_on_button = FALSE;
+ pvt->mouse_hilite_tracking = FALSE;
+ pvt->mouse_cell_motion_tracking = FALSE;
+ pvt->mouse_all_motion_tracking = FALSE;
}
/* Tell GTK+ how much space we need. */
diff --git a/vte.spec b/vte.spec
index d5e3fcf..845c2a2 100644
--- a/vte.spec
+++ b/vte.spec
@@ -1,5 +1,5 @@
Name: vte
-Version: 0.3.8
+Version: 0.3.9
Release: 1
Summary: An experimental terminal emulator.
License: LGPL
@@ -53,6 +53,9 @@ make install DESTDIR=$RPM_BUILD_ROOT
%{_libdir}/pkgconfig/*
%changelog
+* Mon May 6 2002 Nalin Dahyabhai <nalin@redhat.com> 0.3.9-1
+- start handling mouse events
+
* Mon May 6 2002 Nalin Dahyabhai <nalin@redhat.com> 0.3.8-1
- handle window manipulation sequences