summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNalin Dahyabhai <nalin@src.gnome.org>2003-01-14 03:04:30 +0000
committerNalin Dahyabhai <nalin@src.gnome.org>2003-01-14 03:04:30 +0000
commita75a825c95122f5617b1fd5f571be9c922af7130 (patch)
treef1e85c4bb0774d86e9c8b01ddfaa7081bb84b3ae
parent7c28dd92e7d9568ba90f76d0112612c466b25335 (diff)
downloadvte-a75a825c95122f5617b1fd5f571be9c922af7130.tar.gz
don't switch terminal modes before or after echoing bytes -- doing sovte_0_10_9
* src/nativeecho.c, src/utf8echo.c: don't switch terminal modes before or after echoing bytes -- doing so confuses me now. * src/vte.c: make use of '?' to mark invalid data a compile-time define. * src/vteaccess.c(vte_terminal_accessible_text_scrolled): properly handle scrolling events with delta less than the window size (more of #95901). * src/vteaccess.c(vte_terminal_accessible_finalize): disconnect from text-inserted, text-deleted, text-modified, text-scrolled, cursor-moved, window-title-changed on finalize. * src/vte.c(vte_terminal_key_press,vte_terminal_key_release, vte_terminal_button_press,vte_terminal_button_release, vte_terminal_motion_notify,vte_terminal_focus_in,vte_terminal_focus_out, vte_terminal_scroll): track event modifiers in an object-local modifier variable. * src/vte.c(vte_terminal_key_press): always steal key events from the input method if the meta key is down (#96006). Don't munge the cursor or keypad modes before passing them to the keymapping routines. Stop overriding the cursor mode on NumLock (doesn't appear to work as documented in other terminals, needed to modify the keymap mode anyway (#96364)). * configure.in: define HAVE_XFT whenever HAVE_XFT2 is defined -- they're more or less compatible (#103130).
-rw-r--r--ChangeLog24
-rw-r--r--configure.in7
-rw-r--r--src/keymap.c8
-rw-r--r--src/keymap.h6
-rw-r--r--src/nativeecho.c4
-rw-r--r--src/utf8echo.c13
-rw-r--r--src/vte.c189
-rw-r--r--src/vteaccess.c193
-rw-r--r--vte.spec7
9 files changed, 280 insertions, 171 deletions
diff --git a/ChangeLog b/ChangeLog
index 5df5ebd8..6f8497ee 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,27 @@
+2003-01-13 nalin
+ * src/nativeecho.c, src/utf8echo.c: don't switch terminal modes before
+ or after echoing bytes -- doing so confuses me now.
+ * src/vte.c: make use of '?' to mark invalid data a compile-time define.
+ * src/vteaccess.c(vte_terminal_accessible_text_scrolled): properly
+ handle scrolling events with delta less than the window size (more
+ of #95901).
+ * src/vteaccess.c(vte_terminal_accessible_finalize): disconnect
+ from text-inserted, text-deleted, text-modified, text-scrolled,
+ cursor-moved, window-title-changed on finalize.
+ * src/vte.c(vte_terminal_key_press,vte_terminal_key_release,
+ vte_terminal_button_press,vte_terminal_button_release,
+ vte_terminal_motion_notify,vte_terminal_focus_in,vte_terminal_focus_out,
+ vte_terminal_scroll): track event modifiers in an object-local modifier
+ variable.
+ * src/vte.c(vte_terminal_key_press): always steal key events from the
+ input method if the meta key is down (#96006). Don't munge the cursor
+ or keypad modes before passing them to the keymapping routines. Stop
+ overriding the cursor mode on NumLock (doesn't appear to work as
+ documented in other terminals, needed to modify the keymap mode anyway
+ (#96364)).
+ * configure.in: define HAVE_XFT whenever HAVE_XFT2 is defined -- they're
+ more or less compatible (#103130).
+
2003-01-10 Abel Cheung <maddog@linux.org.hk>
* configure.in: Added "zh_TW" to ALL_LINGUAS.
diff --git a/configure.in b/configure.in
index 6189c2c5..dd025428 100644
--- a/configure.in
+++ b/configure.in
@@ -25,6 +25,7 @@ AC_EGREP_CPP(glibc,
# X_PRE_LIBS and X_EXTRA_LIBS to add even more libraries, and add -lX11 to
# the list of libraries for grins.
AC_PATH_XTRA
+HAVE_XFT=no
X_LIBS="$X_PRE_LIBS $X_LIBS -lX11 $X_EXTRA_LIBS"
PKG_CHECK_MODULES(GOBJECT,[glib-2.0 gobject-2.0])
savelibs="$LIBS"
@@ -32,6 +33,7 @@ LIBS="$X_LIBS $LIBS"
wantedmodules="glib-2.0 gobject-2.0 gdk-pixbuf-2.0 gtk+-2.0 pangox"
if pkg-config --exists pangoxft '>=' 1.1.0 ; then
AC_DEFINE(HAVE_XFT2,1,[Whether we have Xft version 2])
+ HAVE_XFT=yes
wantedmodules="$wantedmodules fontconfig xft"
else
AC_MSG_WARN([Xft2 not detected - performance will suffer])
@@ -44,9 +46,12 @@ savecppflags="$CPPFLAGS"
savelibs="$LIBS"
CPPFLAGS="$VTE_CFLAGS $X_CFLAGS $CPPFLAGS"
LIBS="$VTE_LIBS $X_LIBS"
-AC_CHECK_FUNC(XftDrawString32,[AC_DEFINE(HAVE_XFT,1,[Whether or not Xft is available.])],[AC_MSG_WARN([Xft not detected - performance will suffer])])
+AC_CHECK_FUNC(XftDrawString32,HAVE_XFT=yes,[AC_MSG_WARN([Xft not detected - performance will suffer])])
CPPFLAGS="$savecppflags"
LIBS="$savelibs"
+if test x$HAVE_XFT = xyes ; then
+ AC_DEFINE(HAVE_XFT,1,[If we have any version of Xft.])
+fi
# Define macros to disable accidental use of deprecated functionality.
AC_DEFINE(G_DISABLE_DEPRECATED,1,[Disable deprecated GLib features.])
diff --git a/src/keymap.c b/src/keymap.c
index 1cdc5a28..f23b9a03 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -966,12 +966,8 @@ _vte_keymap_map(guint keyval,
return;
}
- /* Build mode masks. Numlock negates application cursor mode. */
- if (modifiers & VTE_NUMLOCK_MASK) {
- cursor_mode = cursor_default;
- } else {
- cursor_mode = app_cursor_keys ? cursor_app : cursor_default;
- }
+ /* Build mode masks. */
+ cursor_mode = app_cursor_keys ? cursor_app : cursor_default;
keypad_mode = app_keypad_keys ? keypad_app : keypad_default;
if (sun_mode) {
fkey_mode = fkey_sun;
diff --git a/src/keymap.h b/src/keymap.h
index 52b8296b..0bee7fb9 100644
--- a/src/keymap.h
+++ b/src/keymap.h
@@ -27,11 +27,11 @@
#include <gdk/gdk.h>
#include "termcap.h"
-#define VTE_NUMLOCK_MASK GDK_MOD2_MASK
-#define VTE_META_MASK GDK_MOD1_MASK
-
G_BEGIN_DECLS
+#define VTE_META_MASK GDK_MOD1_MASK
+#define VTE_NUMLOCK_MASK GDK_MOD2_MASK
+
/* Map the specified keyval/modifier setup, dependent on the mode, to either
* a literal string or a capability name. */
void _vte_keymap_map(guint keyval,
diff --git a/src/nativeecho.c b/src/nativeecho.c
index 467747ed..83694e34 100644
--- a/src/nativeecho.c
+++ b/src/nativeecho.c
@@ -38,10 +38,6 @@ main(int argc, char **argv)
return 1;
}
- if (isatty(STDOUT_FILENO)) {
- printf(ESC "%%@");
- }
-
for (i = 1; i < argc; i++) {
l = strtol(argv[i], &p, 0);
while (l > 0) {
diff --git a/src/utf8echo.c b/src/utf8echo.c
index cefb5967..75c9e077 100644
--- a/src/utf8echo.c
+++ b/src/utf8echo.c
@@ -36,7 +36,6 @@ main(int argc, char **argv)
wchar_t w;
char *inbuf, *outbuf, *p;
size_t insize, outsize;
- gboolean do_reset = FALSE;
if (argc < 2) {
printf("usage: [-r] %s index [...]\n", argv[0]);
@@ -50,14 +49,7 @@ main(int argc, char **argv)
return 1;
}
- if (isatty(STDOUT_FILENO)) {
- printf(ESC "%%G");
- }
for (i = 1; i < argc; i++) {
- if (strcmp(argv[i], "-r") == 0) {
- do_reset = !do_reset;
- continue;
- }
w = (wchar_t)strtol(argv[i], &p, 0);
inbuf = (char*)&w;
insize = sizeof(w);
@@ -65,12 +57,9 @@ main(int argc, char **argv)
outbuf = buf;
outsize = sizeof(buf);
if (g_iconv(conv, &inbuf, &insize, &outbuf, &outsize) != -1) {
- printf("%*s", outbuf - buf, buf);
+ printf("%.*s", outbuf - buf, buf);
}
}
- if (isatty(STDOUT_FILENO) && do_reset) {
- printf(ESC "%%@\n");
- }
g_iconv_close(conv);
diff --git a/src/vte.c b/src/vte.c
index 0c12d5ce..7cf3bf22 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -118,6 +118,7 @@ typedef gunichar wint_t;
#define VTE_REGEXEC_FLAGS 0
#define VTE_INPUT_CHUNK_SIZE 0x1000
#define VTE_INVALID_SOURCE -1
+#define VTE_INVALID_BYTE '?'
/* The structure we use to hold characters we're supposed to display -- this
* includes any supported visible attributes. */
@@ -390,6 +391,9 @@ struct _VteTerminalPrivate {
GdkPixbuf *bg_transparent_image;
GdkPixbuf *bg_image;
long bg_saturation; /* out of VTE_SATURATION_MAX */
+
+ /* Key modifiers. */
+ GdkModifierType modifiers;
};
/* A function which can handle a terminal control sequence. */
@@ -5309,8 +5313,7 @@ vte_sequence_handler_window_manipulation(VteTerminal *terminal,
"non-iconified" : "iconified");
}
#endif
- vte_terminal_feed_child(terminal,
- buf, strlen(buf));
+ vte_terminal_feed_child(terminal, buf, strlen(buf));
break;
case 13:
/* Send window location, in pixels. */
@@ -5326,8 +5329,7 @@ vte_sequence_handler_window_manipulation(VteTerminal *terminal,
width, height);
}
#endif
- vte_terminal_feed_child(terminal,
- buf, strlen(buf));
+ vte_terminal_feed_child(terminal, buf, strlen(buf));
break;
case 14:
/* Send window size, in pixels. */
@@ -5342,8 +5344,7 @@ vte_sequence_handler_window_manipulation(VteTerminal *terminal,
"(%dx%d).\n", width, height);
}
#endif
- vte_terminal_feed_child(terminal,
- buf, strlen(buf));
+ vte_terminal_feed_child(terminal, buf, strlen(buf));
break;
case 18:
/* Send widget size, in cells. */
@@ -5356,8 +5357,7 @@ vte_sequence_handler_window_manipulation(VteTerminal *terminal,
"%s%ld;%ldt", _VTE_CAP_CSI,
terminal->row_count,
terminal->column_count);
- vte_terminal_feed_child(terminal,
- buf, strlen(buf));
+ vte_terminal_feed_child(terminal, buf, strlen(buf));
break;
case 19:
#ifdef VTE_DEBUG
@@ -5373,8 +5373,7 @@ vte_sequence_handler_window_manipulation(VteTerminal *terminal,
terminal->char_height,
DisplayWidth(display, i) /
terminal->char_width);
- vte_terminal_feed_child(terminal,
- buf, strlen(buf));
+ vte_terminal_feed_child(terminal, buf, strlen(buf));
break;
case 20:
/* Report the icon title. */
@@ -5389,8 +5388,7 @@ vte_sequence_handler_window_manipulation(VteTerminal *terminal,
terminal->icon_title ?
terminal->icon_title : "",
_VTE_CAP_ST);
- vte_terminal_feed_child(terminal,
- buf, strlen(buf));
+ vte_terminal_feed_child(terminal, buf, strlen(buf));
break;
case 21:
/* Report the window title. */
@@ -5405,8 +5403,7 @@ vte_sequence_handler_window_manipulation(VteTerminal *terminal,
terminal->window_title ?
terminal->window_title : "",
_VTE_CAP_ST);
- vte_terminal_feed_child(terminal,
- buf, strlen(buf));
+ vte_terminal_feed_child(terminal, buf, strlen(buf));
break;
default:
if (param >= 24) {
@@ -6905,7 +6902,7 @@ vte_terminal_process_incoming(gpointer data)
terminal->pvt->incoming->bytes[start]);
}
#endif
- terminal->pvt->incoming->bytes[start] = '?';
+ terminal->pvt->incoming->bytes[start] = VTE_INVALID_BYTE;
/* Try again, before we try anything else. To pull this
* off we add ourselves as a higher priority idle
* handler, and cause this lower-priority instance
@@ -7660,7 +7657,6 @@ static gint
vte_terminal_key_press(GtkWidget *widget, GdkEventKey *event)
{
VteTerminal *terminal;
- GdkModifierType modifiers;
struct _vte_termcap *termcap;
const char *tterm;
char *normal = NULL, *output;
@@ -7672,11 +7668,10 @@ vte_terminal_key_press(GtkWidget *widget, GdkEventKey *event)
struct timezone tz;
gboolean scrolled = FALSE, steal = FALSE, modifier = FALSE, handled,
suppress_meta_esc = FALSE;
- VteKeymode keypad_mode = VTE_KEYMODE_NORMAL,
- cursor_mode = VTE_KEYMODE_NORMAL;
guint keyval = 0;
gunichar keychar = 0;
char keybuf[VTE_UTF8_BPC];
+ GdkModifierType modifiers;
g_return_val_if_fail(widget != NULL, TRUE);
g_return_val_if_fail(VTE_IS_TERMINAL(widget), TRUE);
@@ -7687,6 +7682,11 @@ vte_terminal_key_press(GtkWidget *widget, GdkEventKey *event)
if (event->type == GDK_KEY_PRESS) {
/* Store a copy of the key. */
keyval = event->keyval;
+ if (gdk_event_get_state((GdkEvent*)event, &modifiers)) {
+ terminal->pvt->modifiers = modifiers;
+ } else {
+ modifiers = terminal->pvt->modifiers;
+ }
/* If we're in margin bell mode and on the border of the
* margin, bell. */
@@ -7707,27 +7707,6 @@ vte_terminal_key_press(GtkWidget *widget, GdkEventKey *event)
(tv.tv_sec * 1000) + (tv.tv_usec / 1000);
}
- /* Read the modifiers. */
- if (gdk_event_get_state((GdkEvent*)event,
- &modifiers) == FALSE) {
- modifiers = 0;
- }
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
- fprintf(stderr, "Keypress, modifiers=0x%x, "
- "keyval=0x%x, raw string=`%s'.\n",
- modifiers, keyval, event->string);
- }
-#endif
-
- /* Determine what the keypad and modes are. */
- if ((modifiers & VTE_NUMLOCK_MASK) == VTE_NUMLOCK_MASK) {
- keypad_mode = VTE_KEYMODE_NORMAL;
- } else {
- keypad_mode = terminal->pvt->keypad_mode;
- }
- cursor_mode = terminal->pvt->cursor_mode;
-
/* Determine if this is just a modifier key. */
modifier = _vte_keymap_key_is_modifier(keyval);
@@ -7736,6 +7715,15 @@ vte_terminal_key_press(GtkWidget *widget, GdkEventKey *event)
vte_terminal_set_pointer_visible(terminal, FALSE);
}
+#ifdef VTE_DEBUG
+ if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
+ fprintf(stderr, "Keypress, modifiers=0x%x, "
+ "keyval=0x%x, raw string=`%s'.\n",
+ terminal->pvt->modifiers,
+ keyval, event->string);
+ }
+#endif
+
/* We steal many keypad keys here. */
switch (keyval) {
case GDK_KP_Add:
@@ -7748,6 +7736,9 @@ vte_terminal_key_press(GtkWidget *widget, GdkEventKey *event)
default:
break;
}
+ if (modifiers & VTE_META_MASK) {
+ steal = TRUE;
+ }
}
/* Let the input method at this one first. */
@@ -7822,7 +7813,7 @@ vte_terminal_key_press(GtkWidget *widget, GdkEventKey *event)
break;
case GDK_KP_Insert:
case GDK_Insert:
- if (modifiers & GDK_SHIFT_MASK) {
+ if (terminal->pvt->modifiers & GDK_SHIFT_MASK) {
vte_terminal_paste(terminal,
GDK_SELECTION_PRIMARY);
handled = TRUE;
@@ -7832,7 +7823,7 @@ vte_terminal_key_press(GtkWidget *widget, GdkEventKey *event)
/* Keypad/motion keys. */
case GDK_KP_Page_Up:
case GDK_Page_Up:
- if (modifiers & GDK_SHIFT_MASK) {
+ if (terminal->pvt->modifiers & GDK_SHIFT_MASK) {
vte_terminal_scroll_pages(terminal, -1);
scrolled = TRUE;
handled = TRUE;
@@ -7841,7 +7832,7 @@ vte_terminal_key_press(GtkWidget *widget, GdkEventKey *event)
break;
case GDK_KP_Page_Down:
case GDK_Page_Down:
- if (modifiers & GDK_SHIFT_MASK) {
+ if (terminal->pvt->modifiers & GDK_SHIFT_MASK) {
vte_terminal_scroll_pages(terminal, 1);
scrolled = TRUE;
handled = TRUE;
@@ -7850,7 +7841,7 @@ vte_terminal_key_press(GtkWidget *widget, GdkEventKey *event)
break;
case GDK_KP_Home:
case GDK_Home:
- if (modifiers & GDK_SHIFT_MASK) {
+ if (terminal->pvt->modifiers & GDK_SHIFT_MASK) {
vte_terminal_maybe_scroll_to_top(terminal);
scrolled = TRUE;
handled = TRUE;
@@ -7858,7 +7849,7 @@ vte_terminal_key_press(GtkWidget *widget, GdkEventKey *event)
break;
case GDK_KP_End:
case GDK_End:
- if (modifiers & GDK_SHIFT_MASK) {
+ if (terminal->pvt->modifiers & GDK_SHIFT_MASK) {
vte_terminal_maybe_scroll_to_bottom(terminal);
scrolled = TRUE;
handled = TRUE;
@@ -7867,7 +7858,8 @@ vte_terminal_key_press(GtkWidget *widget, GdkEventKey *event)
/* Let Shift +/- tweak the font, like XTerm does. */
case GDK_KP_Add:
case GDK_KP_Subtract:
- if (modifiers & (GDK_SHIFT_MASK | GDK_CONTROL_MASK)) {
+ if (terminal->pvt->modifiers &
+ (GDK_SHIFT_MASK | GDK_CONTROL_MASK)) {
switch (keyval) {
case GDK_KP_Add:
vte_terminal_emit_increase_font_size(terminal);
@@ -7888,7 +7880,7 @@ vte_terminal_key_press(GtkWidget *widget, GdkEventKey *event)
/* If the above switch statement didn't do the job, try mapping
* it to a literal or capability name. */
if (handled == FALSE) {
- _vte_keymap_map(keyval, modifiers,
+ _vte_keymap_map(keyval, terminal->pvt->modifiers,
terminal->pvt->sun_fkey_mode,
terminal->pvt->hp_fkey_mode,
terminal->pvt->legacy_fkey_mode,
@@ -7926,7 +7918,7 @@ vte_terminal_key_press(GtkWidget *widget, GdkEventKey *event)
}
}
if ((normal != NULL) &&
- (modifiers & GDK_CONTROL_MASK)) {
+ (terminal->pvt->modifiers & GDK_CONTROL_MASK)) {
/* Replace characters which have "control"
* counterparts with those counterparts. */
for (i = 0; i < normal_length; i++) {
@@ -7940,7 +7932,8 @@ vte_terminal_key_press(GtkWidget *widget, GdkEventKey *event)
if (normal && _vte_debug_on(VTE_DEBUG_EVENTS)) {
fprintf(stderr, "Keypress, modifiers=0x%x, "
"keyval=0x%x, cooked string=`%s'.\n",
- modifiers, keyval, normal);
+ terminal->pvt->modifiers,
+ keyval, normal);
}
#endif
}
@@ -7949,7 +7942,7 @@ vte_terminal_key_press(GtkWidget *widget, GdkEventKey *event)
if (terminal->pvt->meta_sends_escape &&
!suppress_meta_esc &&
(normal_length > 0) &&
- (modifiers & VTE_META_MASK)) {
+ (terminal->pvt->modifiers & VTE_META_MASK)) {
vte_terminal_feed_child(terminal, "", 1);
}
if (normal_length > 0) {
@@ -7967,7 +7960,7 @@ vte_terminal_key_press(GtkWidget *widget, GdkEventKey *event)
special,
&normal_length);
_vte_keymap_key_add_key_modifiers(keyval,
- modifiers,
+ terminal->pvt->modifiers,
terminal->pvt->sun_fkey_mode,
terminal->pvt->hp_fkey_mode,
terminal->pvt->legacy_fkey_mode,
@@ -7993,9 +7986,14 @@ static gboolean
vte_terminal_key_release(GtkWidget *widget, GdkEventKey *event)
{
VteTerminal *terminal;
+ GdkModifierType modifiers;
terminal = VTE_TERMINAL(widget);
+ if (gdk_event_get_state((GdkEvent*)event, &modifiers)) {
+ terminal->pvt->modifiers = modifiers;
+ }
+
return gtk_im_context_filter_keypress(terminal->pvt->im_context, event);
}
@@ -8206,8 +8204,7 @@ vte_terminal_paste_cb(GtkClipboard *clipboard, const gchar *text, gpointer data)
static void
vte_terminal_send_mouse_button_internal(VteTerminal *terminal,
int button,
- double x, double y,
- GdkModifierType modifiers)
+ double x, double y)
{
unsigned char cb = 0, cx = 0, cy = 0;
char buf[LINE_MAX];
@@ -8238,13 +8235,13 @@ vte_terminal_send_mouse_button_internal(VteTerminal *terminal,
cb += 32; /* 32 for normal */
/* Encode the modifiers. */
- if (modifiers & GDK_SHIFT_MASK) {
+ if (terminal->pvt->modifiers & GDK_SHIFT_MASK) {
cb |= 4;
}
- if (modifiers & VTE_META_MASK) {
+ if (terminal->pvt->modifiers & VTE_META_MASK) {
cb |= 8;
}
- if (modifiers & GDK_CONTROL_MASK) {
+ if (terminal->pvt->modifiers & GDK_CONTROL_MASK) {
cb |= 16;
}
@@ -8265,8 +8262,8 @@ vte_terminal_maybe_send_mouse_button(VteTerminal *terminal,
GdkModifierType modifiers;
/* Read the modifiers. */
- if (gdk_event_get_state((GdkEvent*)event, &modifiers) == FALSE) {
- modifiers = 0;
+ if (gdk_event_get_state((GdkEvent*)event, &modifiers)) {
+ terminal->pvt->modifiers = modifiers;
}
/* Decide whether or not to do anything. */
@@ -8292,8 +8289,7 @@ vte_terminal_maybe_send_mouse_button(VteTerminal *terminal,
(event->type == GDK_BUTTON_PRESS) ?
event->button : 0,
event->x - VTE_PAD_WIDTH,
- event->y - VTE_PAD_WIDTH,
- modifiers);
+ event->y - VTE_PAD_WIDTH);
}
/* Send a mouse motion notification. */
@@ -8302,7 +8298,6 @@ vte_terminal_maybe_send_mouse_drag(VteTerminal *terminal, GdkEventMotion *event)
{
unsigned char cb = 0, cx = 0, cy = 0;
char buf[LINE_MAX];
- GdkModifierType modifiers;
g_return_if_fail(VTE_IS_TERMINAL(terminal));
@@ -8331,20 +8326,14 @@ vte_terminal_maybe_send_mouse_drag(VteTerminal *terminal, GdkEventMotion *event)
break;
}
-
- /* Read the modifiers. */
- if (gdk_event_get_state((GdkEvent*)event, &modifiers) == FALSE) {
- modifiers = 0;
- }
-
/* Encode the modifiers. */
- if (modifiers & GDK_SHIFT_MASK) {
+ if (terminal->pvt->modifiers & GDK_SHIFT_MASK) {
cb |= 4;
}
- if (modifiers & VTE_META_MASK) {
+ if (terminal->pvt->modifiers & VTE_META_MASK) {
cb |= 8;
}
- if (modifiers & GDK_CONTROL_MASK) {
+ if (terminal->pvt->modifiers & GDK_CONTROL_MASK) {
cb |= 16;
}
@@ -9347,8 +9336,8 @@ vte_terminal_motion_notify(GtkWidget *widget, GdkEventMotion *event)
vte_terminal_set_pointer_visible(terminal, TRUE);
/* Read the modifiers. */
- if (gdk_event_get_state((GdkEvent*)event, &modifiers) == FALSE) {
- modifiers = 0;
+ if (gdk_event_get_state((GdkEvent*)event, &modifiers)) {
+ terminal->pvt->modifiers = modifiers;
}
switch (event->type) {
@@ -9360,7 +9349,7 @@ vte_terminal_motion_notify(GtkWidget *widget, GdkEventMotion *event)
fprintf(stderr, "Mousing drag 1.\n");
}
#endif
- if (((modifiers & GDK_SHIFT_MASK) == GDK_SHIFT_MASK) ||
+ if ((terminal->pvt->modifiers & GDK_SHIFT_MASK) ||
(!terminal->pvt->mouse_send_xy_on_click &&
!terminal->pvt->mouse_send_xy_on_button &&
!terminal->pvt->mouse_hilite_tracking &&
@@ -9434,8 +9423,8 @@ vte_terminal_button_press(GtkWidget *widget, GdkEventButton *event)
vte_terminal_set_pointer_visible(terminal, TRUE);
/* Read the modifiers. */
- if (gdk_event_get_state((GdkEvent*)event, &modifiers) == FALSE) {
- modifiers = 0;
+ if (gdk_event_get_state((GdkEvent*)event, &modifiers)) {
+ terminal->pvt->modifiers = modifiers;
}
/* Convert the event coordinates to cell coordinates. */
@@ -9463,7 +9452,7 @@ vte_terminal_button_press(GtkWidget *widget, GdkEventButton *event)
#endif
/* If the user hit shift, override event mode. */
- if ((modifiers & GDK_SHIFT_MASK) == GDK_SHIFT_MASK) {
+ if (terminal->pvt->modifiers & GDK_SHIFT_MASK) {
if (terminal->pvt->mouse_send_xy_on_button ||
terminal->pvt->mouse_send_xy_on_click) {
/* If shift is pressed in event mode,
@@ -9506,7 +9495,7 @@ vte_terminal_button_press(GtkWidget *widget, GdkEventButton *event)
/* Paste if the user pressed shift or we're not sending events
* to the app. */
case 2:
- if (((modifiers & GDK_SHIFT_MASK) == GDK_SHIFT_MASK) ||
+ if ((terminal->pvt->modifiers & GDK_SHIFT_MASK) ||
(!terminal->pvt->mouse_send_xy_on_button &&
!terminal->pvt->mouse_send_xy_on_click)) {
vte_terminal_paste_primary(terminal);
@@ -9610,8 +9599,8 @@ vte_terminal_button_release(GtkWidget *widget, GdkEventButton *event)
vte_terminal_stop_autoscroll(terminal);
/* Read the modifiers. */
- if (gdk_event_get_state((GdkEvent*)event, &modifiers) == FALSE) {
- modifiers = 0;
+ if (gdk_event_get_state((GdkEvent*)event, &modifiers)) {
+ terminal->pvt->modifiers = modifiers;
}
switch (event->type) {
@@ -9628,7 +9617,7 @@ vte_terminal_button_release(GtkWidget *widget, GdkEventButton *event)
case 1:
/* If Shift is held down, or we're not in events mode,
* copy the selected text. */
- if (((modifiers & GDK_SHIFT_MASK) == GDK_SHIFT_MASK) ||
+ if ((terminal->pvt->modifiers & GDK_SHIFT_MASK) ||
(!terminal->pvt->mouse_send_xy_on_button)) {
/* Copy only if something was selected. */
if (terminal->pvt->has_selection &&
@@ -9674,24 +9663,38 @@ vte_terminal_button_release(GtkWidget *widget, GdkEventButton *event)
static gint
vte_terminal_focus_in(GtkWidget *widget, GdkEventFocus *event)
{
+ VteTerminal *terminal;
+ GdkModifierType modifiers;
g_return_val_if_fail(GTK_IS_WIDGET(widget), 0);
+ g_return_val_if_fail(VTE_IS_TERMINAL(widget), 0);
+ terminal = VTE_TERMINAL(widget);
GTK_WIDGET_SET_FLAGS(widget, GTK_HAS_FOCUS);
- gtk_im_context_focus_in((VTE_TERMINAL(widget))->pvt->im_context);
+ if (gdk_event_get_state((GdkEvent*)event, &modifiers)) {
+ terminal->pvt->modifiers = modifiers;
+ }
+ gtk_im_context_focus_in(terminal->pvt->im_context);
/* Force the cursor to be the foreground color twice, in case we're
* in blinking mode and the next scheduled redraw occurs just after
* the one we're about to perform. */
- (VTE_TERMINAL(widget))->pvt->cursor_force_fg = 2;
- vte_invalidate_cursor_once(VTE_TERMINAL(widget));
+ terminal->pvt->cursor_force_fg = 2;
+ vte_invalidate_cursor_once(terminal);
return FALSE;
}
static gint
vte_terminal_focus_out(GtkWidget *widget, GdkEventFocus *event)
{
+ VteTerminal *terminal;
+ GdkModifierType modifiers;
g_return_val_if_fail(GTK_WIDGET(widget), 0);
+ g_return_val_if_fail(VTE_IS_TERMINAL(widget), 0);
+ terminal = VTE_TERMINAL(widget);
GTK_WIDGET_UNSET_FLAGS(widget, GTK_HAS_FOCUS);
- gtk_im_context_focus_out((VTE_TERMINAL(widget))->pvt->im_context);
- vte_invalidate_cursor_once(VTE_TERMINAL(widget));
+ if (gdk_event_get_state((GdkEvent*)event, &modifiers)) {
+ terminal->pvt->modifiers = modifiers;
+ }
+ gtk_im_context_focus_out(terminal->pvt->im_context);
+ vte_invalidate_cursor_once(terminal);
return FALSE;
}
@@ -11392,6 +11395,9 @@ vte_terminal_init(VteTerminal *terminal, gpointer *klass)
pvt->bg_saturation = 0.4 * VTE_SATURATION_MAX;
pvt->bg_image = NULL;
+ /* Clear modifiers. */
+ pvt->modifiers = 0;
+
/* Listen for hierarchy change notifications. */
g_signal_connect(G_OBJECT(terminal), "hierarchy-changed",
G_CALLBACK(vte_terminal_hierarchy_changed),
@@ -11649,6 +11655,9 @@ vte_terminal_unrealize(GtkWidget *widget)
}
terminal->pvt->cursor_force_fg = 0;
+ /* Clear modifiers. */
+ terminal->pvt->modifiers = 0;
+
/* Mark that we no longer have a GDK window. */
GTK_WIDGET_UNSET_FLAGS(widget, GTK_REALIZED);
}
@@ -12029,6 +12038,9 @@ vte_terminal_realize(GtkWidget *widget)
terminal->pvt->mouse_mousing_cursor =
gdk_cursor_new(VTE_MOUSING_CURSOR);
+ /* Clear modifiers. */
+ terminal->pvt->modifiers = 0;
+
/* Create our invisible cursor. */
pixmap = gdk_pixmap_new(widget->window, 1, 1, 1);
mask = gdk_pixmap_new(widget->window, 1, 1, 1);
@@ -13947,8 +13959,8 @@ vte_terminal_scroll(GtkWidget *widget, GdkEventScroll *event)
terminal = VTE_TERMINAL(widget);
/* Read the modifiers. */
- if (gdk_event_get_state((GdkEvent*)event, &modifiers) == FALSE) {
- modifiers = 0;
+ if (gdk_event_get_state((GdkEvent*)event, &modifiers)) {
+ terminal->pvt->modifiers = modifiers;
}
#ifdef VTE_DEBUG
@@ -13989,8 +14001,7 @@ vte_terminal_scroll(GtkWidget *widget, GdkEventScroll *event)
vte_terminal_send_mouse_button_internal(terminal,
button,
event->x - VTE_PAD_WIDTH,
- event->y - VTE_PAD_WIDTH,
- modifiers);
+ event->y - VTE_PAD_WIDTH);
return TRUE;
}
}
@@ -15569,6 +15580,8 @@ vte_terminal_reset(VteTerminal *terminal, gboolean full, gboolean clear_history)
terminal->pvt->mouse_last_button = 0;
terminal->pvt->mouse_last_x = 0;
terminal->pvt->mouse_last_y = 0;
+ /* Clear modifiers. */
+ terminal->pvt->modifiers = 0;
/* Cause everything to be redrawn (or cleared). */
vte_terminal_maybe_scroll_to_bottom(terminal);
vte_invalidate_all(terminal);
diff --git a/src/vteaccess.c b/src/vteaccess.c
index 18167f9c..8999ce12 100644
--- a/src/vteaccess.c
+++ b/src/vteaccess.c
@@ -101,13 +101,6 @@ emit_text_changed_insert(GObject *object,
if (len == 0) {
return;
}
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
- fprintf(stderr, "Accessibility peer emitting "
- "`text-changed::insert' (%ld, %ld).\n",
- offset, len);
- }
-#endif
/* Convert the byte offsets to characters. */
for (p = text, start = 0;
p < text + offset;
@@ -119,6 +112,15 @@ emit_text_changed_insert(GObject *object,
p = g_utf8_next_char(p)) {
count++;
}
+#ifdef VTE_DEBUG
+ if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
+ fprintf(stderr, "Accessibility peer emitting "
+ "`text-changed::insert' (%ld, %ld) (%ld, %ld).\n",
+ offset, len, start, count);
+ fprintf(stderr, "Inserted text was `%.*s'.\n",
+ (int) len, text + offset);
+ }
+#endif
g_signal_emit_by_name(object, "text-changed::insert", start, count);
}
@@ -131,13 +133,6 @@ emit_text_changed_delete(GObject *object,
if (len == 0) {
return;
}
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
- fprintf(stderr, "Accessibility peer emitting "
- "`text-changed::delete' (%ld, %ld).\n",
- offset, len);
- }
-#endif
/* Convert the byte offsets to characters. */
for (p = text, start = 0;
p < text + offset;
@@ -149,6 +144,15 @@ emit_text_changed_delete(GObject *object,
p = g_utf8_next_char(p)) {
count++;
}
+#ifdef VTE_DEBUG
+ if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
+ fprintf(stderr, "Accessibility peer emitting "
+ "`text-changed::delete' (%ld, %ld) (%ld, %ld).\n",
+ offset, len, start, count);
+ fprintf(stderr, "Deleted text was `%.*s'.\n",
+ (int) len, text + offset);
+ }
+#endif
g_signal_emit_by_name(object, "text-changed::delete", start, count);
}
@@ -412,57 +416,125 @@ vte_terminal_accessible_text_scrolled(VteTerminal *terminal,
gpointer data)
{
VteTerminalAccessiblePrivate *priv;
+ struct vte_char_attributes attr;
+ long i, len, delta;
g_return_if_fail(VTE_IS_TERMINAL_ACCESSIBLE(data));
+ g_return_if_fail(howmuch != 0);
priv = g_object_get_data(G_OBJECT(data),
VTE_TERMINAL_ACCESSIBLE_PRIVATE_DATA);
g_return_if_fail(priv != NULL);
- /* FIXME: don't wuss out here, be more specific if it the delta is
- * less than the terminal's vertical height. */
-
- if (priv->snapshot_text != NULL) {
- if (priv->snapshot_text) {
- emit_text_changed_delete(G_OBJECT(data),
- priv->snapshot_text,
- 0,
- strlen(priv->snapshot_text));
+ if (((howmuch < 0) && (howmuch <= -terminal->row_count)) ||
+ ((howmuch > 0) && (howmuch >= terminal->row_count))) {
+ /* All of the text was removed. */
+ if (priv->snapshot_text != NULL) {
+ if (priv->snapshot_text) {
+ emit_text_changed_delete(G_OBJECT(data),
+ priv->snapshot_text,
+ 0,
+ strlen(priv->snapshot_text));
+ }
+ }
+ priv->snapshot_contents_invalid = TRUE;
+ vte_terminal_accessible_update_private_data_if_needed(ATK_OBJECT(data),
+ NULL);
+ /* All of the present text was added. */
+ if (priv->snapshot_text != NULL) {
+ if (priv->snapshot_text) {
+ emit_text_changed_insert(G_OBJECT(data),
+ priv->snapshot_text,
+ 0,
+ strlen(priv->snapshot_text));
+ }
+ }
+ return;
+ }
+ /* Find the start point. */
+ delta = 0;
+ if (priv->snapshot_attributes != NULL) {
+ if (priv->snapshot_attributes->len > 0) {
+ attr = g_array_index(priv->snapshot_attributes,
+ struct vte_char_attributes,
+ 0);
+ delta = attr.row;
}
}
- priv->snapshot_contents_invalid = TRUE;
- vte_terminal_accessible_update_private_data_if_needed(ATK_OBJECT(data),
- NULL);
- if (priv->snapshot_text != NULL) {
- if (priv->snapshot_text) {
- emit_text_changed_insert(G_OBJECT(data),
+ /* We scrolled up, so text was added at the top and removed
+ * from the bottom. */
+ if ((howmuch < 0) && (howmuch > -terminal->row_count)) {
+ howmuch = -howmuch;
+ /* Find the first byte that scrolled off. */
+ for (i = 0; i < priv->snapshot_attributes->len; i++) {
+ attr = g_array_index(priv->snapshot_attributes,
+ struct vte_char_attributes,
+ i);
+ if (attr.row >= delta + terminal->row_count - howmuch) {
+ break;
+ }
+ }
+ if (i < priv->snapshot_attributes->len) {
+ /* The rest of the string was deleted -- make a note. */
+ emit_text_changed_delete(G_OBJECT(data),
priv->snapshot_text,
- 0,
- strlen(priv->snapshot_text));
+ i,
+ priv->snapshot_attributes->len - i);
+ }
+ /* Refresh. Note that i is now the length of the data which
+ * we expect to have left over. */
+ priv->snapshot_contents_invalid = TRUE;
+ vte_terminal_accessible_update_private_data_if_needed(ATK_OBJECT(data),
+ NULL);
+ /* If we now have more text than before, the initial portion
+ * was added. */
+ if (priv->snapshot_text != NULL) {
+ len = strlen(priv->snapshot_text);
+ if (len > i) {
+ emit_text_changed_insert(G_OBJECT(data),
+ priv->snapshot_text,
+ 0,
+ len - i);
+ }
}
+ return;
}
-}
-
-/* A signal handler to catch "contents_changed" signals. */
-static void
-vte_terminal_accessible_invalidate_contents(VteTerminal *terminal,
- gpointer data)
-{
- VteTerminalAccessiblePrivate *priv;
-
- g_return_if_fail(VTE_IS_TERMINAL_ACCESSIBLE(data));
-
- priv = g_object_get_data(G_OBJECT(data),
- VTE_TERMINAL_ACCESSIBLE_PRIVATE_DATA);
- g_return_if_fail(priv != NULL);
-
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_MISC)) {
- fprintf(stderr, "Invalidating accessibility contents.\n");
+ /* We scrolled down, so text was added at the bottom and removed
+ * from the top. */
+ if ((howmuch > 0) && (howmuch < terminal->row_count)) {
+ /* Find the first byte that wasn't scrolled off the top. */
+ for (i = 0; i < priv->snapshot_attributes->len; i++) {
+ attr = g_array_index(priv->snapshot_attributes,
+ struct vte_char_attributes,
+ i);
+ if (attr.row >= delta + howmuch) {
+ break;
+ }
+ }
+ /* That many bytes disappeared -- make a note. */
+ emit_text_changed_delete(G_OBJECT(data),
+ priv->snapshot_text,
+ 0,
+ i);
+ /* Figure out how much text was left, and refresh. */
+ i = strlen(priv->snapshot_text + i);
+ priv->snapshot_contents_invalid = TRUE;
+ vte_terminal_accessible_update_private_data_if_needed(ATK_OBJECT(data),
+ NULL);
+ /* Any newly-added string data is new, so note that it was
+ * inserted. */
+ if (priv->snapshot_text != NULL) {
+ len = strlen(priv->snapshot_text);
+ if (len > i) {
+ emit_text_changed_insert(G_OBJECT(data),
+ priv->snapshot_text,
+ i,
+ len - i);
+ }
+ }
+ return;
}
-#endif
-
- priv->snapshot_contents_invalid = TRUE;
+ g_assert_not_reached();
}
/* A signal handler to catch "cursor-moved" signals. */
@@ -537,9 +609,6 @@ vte_terminal_accessible_new(VteTerminal *terminal)
g_signal_connect(G_OBJECT(terminal), "text-scrolled",
GTK_SIGNAL_FUNC(vte_terminal_accessible_text_scrolled),
object);
- g_signal_connect(G_OBJECT(terminal), "contents-changed",
- GTK_SIGNAL_FUNC(vte_terminal_accessible_invalidate_contents),
- object);
g_signal_connect(G_OBJECT(terminal), "cursor-moved",
GTK_SIGNAL_FUNC(vte_terminal_accessible_invalidate_cursor),
object);
@@ -575,7 +644,19 @@ vte_terminal_accessible_finalize(GObject *object)
G_SIGNAL_MATCH_FUNC |
G_SIGNAL_MATCH_DATA,
0, 0, NULL,
- (gpointer)vte_terminal_accessible_invalidate_contents,
+ vte_terminal_accessible_text_modified,
+ object);
+ g_signal_handlers_disconnect_matched(G_OBJECT(accessible->widget),
+ G_SIGNAL_MATCH_FUNC |
+ G_SIGNAL_MATCH_DATA,
+ 0, 0, NULL,
+ vte_terminal_accessible_text_scrolled,
+ object);
+ g_signal_handlers_disconnect_matched(G_OBJECT(accessible->widget),
+ G_SIGNAL_MATCH_FUNC |
+ G_SIGNAL_MATCH_DATA,
+ 0, 0, NULL,
+ vte_terminal_accessible_invalidate_cursor,
object);
g_signal_handlers_disconnect_matched(G_OBJECT(accessible->widget),
G_SIGNAL_MATCH_FUNC |
diff --git a/vte.spec b/vte.spec
index d3725b81..db982978 100644
--- a/vte.spec
+++ b/vte.spec
@@ -1,5 +1,5 @@
Name: vte
-Version: 0.10.8
+Version: 0.10.9
Release: 1
Summary: An experimental terminal emulator.
License: LGPL
@@ -93,6 +93,11 @@ rm -f $RPM_BUILD_ROOT/%{_libdir}/python*/site-packages/*.a
%{_libdir}/pkgconfig/*
%changelog
+* Mon Jan 13 2003 Nalin Dahyabhai <nalin@redhat.com> 0.10.9-1
+- fix scrolling through the accessibility layer
+- stop heeding NumLock when mapping cursor keys
+- steal keypress events from the input method if Meta modifier is in effect
+
* Mon Jan 6 2003 Nalin Dahyabhai <nalin@redhat.com> 0.10.8-1
- report changes to the accessibility layer when text is removed or moved
around, still needs work