diff options
author | Nalin Dahyabhai <nalin@src.gnome.org> | 2002-05-03 21:21:25 +0000 |
---|---|---|
committer | Nalin Dahyabhai <nalin@src.gnome.org> | 2002-05-03 21:21:25 +0000 |
commit | 4b3f54222ae0eaafc64e1a9326042c5a012a1c2f (patch) | |
tree | aded7797eeb35b84f90905988382557aa435904f | |
parent | cf348c8da67cc21b8f0f1bc04cb112becfaf91c2 (diff) |
Export a vte_termcap_strip() function for preprocessing escape sequencesvte_0_3_7
* src/termcap.c: Export a vte_termcap_strip() function for preprocessing
escape sequences and whatnot from capability values.
* src/typescrypt: Removed.
* src/vte.c: Pass the hard-coded xterm-specific capabilities through
vte_termcap_strip(), which fixes a few weird bugs. Discard invalid
might-be-control-sequence sequences, like other emulators do. Don't
consider modifier keys, by themselves, to be enough to scroll-on-key.
When snapshotting, actually snapshot all of a row instead of just the
last character. Don't run past the end of snapshot contents when
reading them.
* src/vteaccess.c: Clamp offsets so that they always sort right.
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | src/termcap.c | 14 | ||||
-rw-r--r-- | src/termcap.h | 3 | ||||
-rw-r--r-- | src/trie.c | 15 | ||||
-rw-r--r-- | src/typescript | 76 | ||||
-rw-r--r-- | src/vte.c | 62 | ||||
-rw-r--r-- | src/vteaccess.c | 98 | ||||
-rw-r--r-- | vte.spec | 6 |
8 files changed, 174 insertions, 112 deletions
@@ -1,3 +1,15 @@ +2002-05-03 nalin + * src/termcap.c: Export a vte_termcap_strip() function for preprocessing + escape sequences and whatnot from capability values. + * src/typescrypt: Removed. + * src/vte.c: Pass the hard-coded xterm-specific capabilities through + vte_termcap_strip(), which fixes a few weird bugs. Discard invalid + might-be-control-sequence sequences, like other emulators do. Don't + consider modifier keys, by themselves, to be enough to scroll-on-key. + When snapshotting, actually snapshot all of a row instead of just the + last character. Don't run past the end of snapshot contents when + reading them. + * src/vteaccess.c: Clamp offsets so that they always sort right. 2002-05-02 nalin * src/termcap.c: Fix handling of triple-digit escaped characters, which weren't being processed right if the first digit was '1' instead diff --git a/src/termcap.c b/src/termcap.c index bd42123..40f645e 100644 --- a/src/termcap.c +++ b/src/termcap.c @@ -202,7 +202,7 @@ vte_termcap_add_entry(struct vte_termcap *termcap, const char *s, ssize_t length } static void -vte_termcap_strip(const char *termcap, char **stripped, ssize_t *len) +vte_termcap_strip_with_pad(const char *termcap, char **stripped, ssize_t *len) { char *ret; ssize_t i, o, length; @@ -304,6 +304,16 @@ vte_termcap_strip(const char *termcap, char **stripped, ssize_t *len) *len = o; } +void +vte_termcap_strip(const char *termcap, char **stripped, ssize_t *len) +{ + vte_termcap_strip_with_pad(termcap, stripped, len); + while ((len > 0) && ((*stripped)[(*len) - 1] == ':')) { + (*len)--; + (*stripped)[*len] = '\0'; + } +} + static gint vte_direct_compare(gconstpointer a, gconstpointer b) { @@ -330,7 +340,7 @@ vte_termcap_new(const char *filename) ret->nametree = g_tree_new(vte_direct_compare); } stripped = NULL; - vte_termcap_strip(s, &stripped, &slen); + vte_termcap_strip_with_pad(s, &stripped, &slen); if (stripped) { vte_termcap_add_entry(ret, stripped, slen, comment); diff --git a/src/termcap.h b/src/termcap.h index 2e8e044..64f9882 100644 --- a/src/termcap.h +++ b/src/termcap.h @@ -51,6 +51,9 @@ char *vte_termcap_find_string_length(struct vte_termcap *termcap, const char *tname, const char *cap, ssize_t *length); +/* Preprocess a termcap-style string, expanding any escape sequences. */ +void vte_termcap_strip(const char *termcap, char **stripped, ssize_t *len); + G_END_DECLS #endif @@ -684,10 +684,17 @@ vte_trie_printx(struct vte_trie *trie, const char *previous) trie->trie_paths[i].data.inc); break; case any: - snprintf(buf + strlen(buf), - sizeof(buf) - strlen(buf), - "{char+`%lc'}", - (wint_t)trie->trie_paths[i].data.c); + if (trie->trie_paths[i].data.c < 32) { + snprintf(buf + strlen(buf), + sizeof(buf) - strlen(buf), + "{char+0x%02lx}", + (long)trie->trie_paths[i].data.c); + } else { + snprintf(buf + strlen(buf), + sizeof(buf) - strlen(buf), + "{char+`%lc'}", + (wint_t)trie->trie_paths[i].data.c); + } break; case string: snprintf(buf + strlen(buf), diff --git a/src/typescript b/src/typescript deleted file mode 100644 index 86ac59a..0000000 --- a/src/typescript +++ /dev/null @@ -1,76 +0,0 @@ -Script started on Mon Jan 28 23:02:33 2002 -]2;nalin@blade.devel.redhat.com:/home/devel/nalin/projects/vte/srcnalin has logged on pts/0 from local.
-nalin has logged on tty1 from local.
-]2;nalin@blade.devel.redhat.com:/home/devel/nalin/projects/vte/srcnalin@blade:~/projects/vte/src> less trie.c
-7[?47h[?1h=[24;1H[K/*
- * Copyright (C) 2001 Red Hat, Inc.
- *
- * This is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Library General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include "../config.h"
-#include <sys/types.h>
-#include <assert.h>
-#include <ctype.h>
-#include <stdio.h>
-[24;1H[K[7mtrie.c [m[24;1H[24;1H[K#include <stdlib.h>
-#include <string.h>
-#include <wchar.h>
-#include <glib.h>
-#include <glib-object.h>
-#include "trie.h"
-
-#ifndef TRIE_MAYBE_STATIC
-#define TRIE_MAYBE_STATIC
-#endif
-
-/* Structures and whatnot for tracking character classes. */
-struct char_class_data {
- wchar_t c; /* A character. */
- int i; /* An integer. */
- char *s; /* A string. */
- int inc; /* An increment value. */
-};
-
-struct char_class {
- enum cclass {
- exact = 0, /* Not a special class. */
- digit, /* Multiple-digit special class. */
-[24;1H[K:[24;1H[HM#include <stdio.h>
-[HM#include <ctype.h>
-[HM#include <assert.h>
-[HM#include <sys/types.h>
-[HM#include "../config.h"
-[HM
-[HM */
-[HM * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-[HM * License along with this program; if not, write to the Free Software
-[HM * You should have received a copy of the GNU Library General Public
-[HM *
-[HM * General Public License for more details.
-[HM * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-[HM * WITHOUT ANY WARRANTY; without even the implied warranty of
-[HM * This program is distributed in the hope that it will be useful, but
-[HM *
-[HM * (at your option) any later version.
-[HM * the Free Software Foundation; either version 2 of the License, or
-[HM * the terms of the GNU Library General Public License as published by
-[HM * This is free software; you can redistribute it and/or modify it under
-[HM *
-[HM * Copyright (C) 2001 Red Hat, Inc.
-[HM/*
-[24;1H[K:[24;1H[K[?1l>[2J[?47l8]2;nalin@blade.devel.redhat.com:/home/devel/nalin/projects/vte/srcnalin@blade:~/projects/vte/src> ^Dexit
- -Script done on Mon Jan 28 23:02:39 2002 @@ -533,6 +533,7 @@ vte_terminal_adjust_adjustments(VteTerminal *terminal) "(delta = %ld, scroll = %ld).\n", delta, terminal->pvt->screen->scroll_delta); #endif + vte_terminal_emit_contents_changed(terminal); gtk_adjustment_changed(terminal->adjustment); } } @@ -3615,8 +3616,21 @@ vte_terminal_process_incoming(gpointer data) } else { /* Case three: the read broke in the middle of a * control sequence, so we're undecided with no more - * data to consult. */ - leftovers = TRUE; + * data to consult. If we have data following the + * middle of the sequence, then it's just garbage data, + * and for compatibility, we should discard it. */ + if (wbuf + wcount > next) { +#ifdef VTE_DEBUG + fprintf(stderr, "Invalid control sequence, " + "discarding %d characters.\n", + next - (wbuf + start)); +#endif + /* Discard. */ + start = next - wbuf; + } else { + /* Pause processing and wait for more data. */ + leftovers = TRUE; + } } /* Free any parameters we don't care about any more. */ free_params_array(params); @@ -4326,7 +4340,6 @@ vte_terminal_key_press(GtkWidget *widget, GdkEventKey *event) vte_terminal_send(terminal, "UTF-8", normal, normal_length); g_free(normal); - normal = NULL; } else /* If the key maps to characters, send them to the child. */ if (special != NULL) { @@ -4342,7 +4355,9 @@ vte_terminal_key_press(GtkWidget *widget, GdkEventKey *event) g_free(special); } /* Keep the cursor on-screen. */ - if (!scrolled && terminal->pvt->scroll_on_keystroke) { + if (!scrolled && + ((normal != NULL) || (special != NULL)) && + terminal->pvt->scroll_on_keystroke) { vte_terminal_scroll_to_bottom(terminal); } return TRUE; @@ -5511,6 +5526,8 @@ static void vte_terminal_set_emulation(VteTerminal *terminal, const char *emulation) { const char *code, *value; + char *stripped; + size_t stripped_length; GQuark quark; char *tmp; int i; @@ -5555,9 +5572,12 @@ vte_terminal_set_emulation(VteTerminal *terminal, const char *emulation) terminal->pvt->terminal, code); if ((tmp != NULL) && (tmp[0] != '\0')) { - vte_trie_add(terminal->pvt->trie, tmp, strlen(tmp), + vte_termcap_strip(tmp, &stripped, &stripped_length); + vte_trie_add(terminal->pvt->trie, + stripped, stripped_length, vte_terminal_capability_strings[i].capability, 0); + g_free(stripped); } g_free(tmp); } @@ -5566,7 +5586,10 @@ vte_terminal_set_emulation(VteTerminal *terminal, const char *emulation) for (i = 0; vte_xterm_capability_strings[i].value != NULL; i++) { code = vte_xterm_capability_strings[i].code; value = vte_xterm_capability_strings[i].value; - vte_trie_add(terminal->pvt->trie, code, strlen(code), value, 0); + vte_termcap_strip(code, &stripped, &stripped_length); + vte_trie_add(terminal->pvt->trie, stripped, stripped_length, + value, 0); + g_free(stripped); } #ifdef VTE_DEBUG fprintf(stderr, "Trie contents:\n"); @@ -6984,7 +7007,7 @@ vte_terminal_class_init(VteTerminalClass *klass, gconstpointer data) _vte_marshal_VOID__VOID, G_TYPE_NONE, 0); klass->window_title_changed_signal = - g_signal_new("window_title_changed", + g_signal_new("window-title-changed", G_OBJECT_CLASS_TYPE(klass), G_SIGNAL_RUN_LAST, 0, @@ -6993,7 +7016,7 @@ vte_terminal_class_init(VteTerminalClass *klass, gconstpointer data) _vte_marshal_VOID__VOID, G_TYPE_NONE, 0); klass->icon_title_changed_signal = - g_signal_new("icon_title_changed", + g_signal_new("icon-title-changed", G_OBJECT_CLASS_TYPE(klass), G_SIGNAL_RUN_LAST, 0, @@ -7002,7 +7025,7 @@ vte_terminal_class_init(VteTerminalClass *klass, gconstpointer data) _vte_marshal_VOID__VOID, G_TYPE_NONE, 0); klass->char_size_changed_signal = - g_signal_new("char_size_changed", + g_signal_new("char-size-changed", G_OBJECT_CLASS_TYPE(klass), G_SIGNAL_RUN_LAST, 0, @@ -7011,7 +7034,7 @@ vte_terminal_class_init(VteTerminalClass *klass, gconstpointer data) _vte_marshal_VOID__UINT_UINT, G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT); klass->selection_changed_signal = - g_signal_new ("selection_changed", + g_signal_new ("selection-changed", G_OBJECT_CLASS_TYPE(klass), G_SIGNAL_RUN_LAST, 0, @@ -7020,7 +7043,7 @@ vte_terminal_class_init(VteTerminalClass *klass, gconstpointer data) _vte_marshal_VOID__VOID, G_TYPE_NONE, 0); klass->contents_changed_signal = - g_signal_new("contents_changed", + g_signal_new("contents-changed", G_OBJECT_CLASS_TYPE(klass), G_SIGNAL_RUN_LAST, 0, @@ -7029,7 +7052,7 @@ vte_terminal_class_init(VteTerminalClass *klass, gconstpointer data) _vte_marshal_VOID__VOID, G_TYPE_NONE, 0); klass->cursor_moved_signal = - g_signal_new("cursor_moved", + g_signal_new("cursor-moved", G_OBJECT_CLASS_TYPE(klass), G_SIGNAL_RUN_LAST, 0, @@ -7623,15 +7646,15 @@ vte_terminal_get_snapshot(VteTerminal *terminal) ret->columns = terminal->column_count; /* Save the window contents. */ - ret->contents = g_malloc(sizeof(struct VteTerminalSnapshotCell*) * - (ret->rows + 1)); + ret->contents = g_malloc0(sizeof(struct VteTerminalSnapshotCell*) * + (ret->rows + 1)); for (row = 0; row < ret->rows; row++) { - ret->contents[row] = g_malloc(sizeof(struct VteTerminalSnapshotCell) * - (ret->columns + 1)); + ret->contents[row] = g_malloc0(sizeof(struct VteTerminalSnapshotCell) * + (ret->columns + 1)); column = x = 0; while (column < ret->columns) { cell = vte_terminal_find_charcell(terminal, - row + terminal->pvt->screen->insert_delta, + row + terminal->pvt->screen->scroll_delta, x++); if (cell == NULL) { break; @@ -7642,6 +7665,9 @@ vte_terminal_get_snapshot(VteTerminal *terminal) /* Get the text. FIXME: convert from wchar_t to * gunichar when they're not interchangeable. */ +#ifdef VTE_DEBUG + fprintf(stderr, "%lc", cell->c); +#endif ret->contents[row][column].c = cell->c; /* Get text attributes which aren't represented as @@ -7668,6 +7694,8 @@ vte_terminal_get_snapshot(VteTerminal *terminal) terminal->pvt->palette[back].green; ret->contents[row][column].attributes.background.blue = terminal->pvt->palette[back].blue; + + column++; } } ret->contents[row] = NULL; diff --git a/src/vteaccess.c b/src/vteaccess.c index c55ff75..872397c 100644 --- a/src/vteaccess.c +++ b/src/vteaccess.c @@ -98,15 +98,22 @@ vte_terminal_accessible_update_private_data_if_needed(AtkObject *text) priv->snapshot_cells = g_array_new(FALSE, TRUE, sizeof(cell)); priv->snapshot_linebreaks = g_array_new(FALSE, TRUE, sizeof(int)); caret = -1; - for (row = 0; priv->snapshot->contents[row] != NULL; row++) { + for (row = 0; + (row < priv->snapshot->rows) && + (priv->snapshot->contents[row] != NULL); + row++) { for (col = 0; - priv->snapshot->contents[row][col].c != 0; + (col < priv->snapshot->columns) && + (priv->snapshot->contents[row][col].c != 0); col++) { if ((row == priv->snapshot->cursor.y) && (col == priv->snapshot->cursor.x)) { caret = priv->snapshot_cells->len; } cell = priv->snapshot->contents[row][col]; +#ifdef VTE_DEBUG + fprintf(stderr, "%lc", cell.c); +#endif g_array_append_val(priv->snapshot_cells, cell); } @@ -120,6 +127,11 @@ vte_terminal_accessible_update_private_data_if_needed(AtkObject *text) caret = priv->snapshot_cells->len; } priv->snapshot_caret = caret; +#ifdef VTE_DEBUG + fprintf(stderr, "Refreshed accessibility snapshot, %ld cells.\n", + (long)priv->snapshot_cells->len); +#endif + priv->snapshot_invalid = FALSE; } static void @@ -154,6 +166,10 @@ vte_terminal_accessible_invalidate(VteTerminal *terminal, gpointer data) VTE_TERMINAL_ACCESSIBLE_PRIVATE_DATA); g_return_if_fail(priv != NULL); +#ifdef VTE_DEBUG + fprintf(stderr, "Invalidating accessibility snapshot.\n"); +#endif + priv->snapshot_invalid = TRUE; } @@ -202,10 +218,10 @@ vte_terminal_accessible_new(VteTerminal *terminal) g_object_set_data(G_OBJECT(access), VTE_TERMINAL_ACCESSIBLE_PRIVATE_DATA, vte_terminal_accessible_new_private_data()); - g_signal_connect(G_OBJECT(terminal), "contents_changed", + g_signal_connect(G_OBJECT(terminal), "contents-changed", GTK_SIGNAL_FUNC(vte_terminal_accessible_invalidate), access); - g_signal_connect(G_OBJECT(terminal), "cursor_moved", + g_signal_connect(G_OBJECT(terminal), "cursor-moved", GTK_SIGNAL_FUNC(vte_terminal_accessible_invalidate), access); g_signal_connect(G_OBJECT(terminal), "hierarchy-changed", @@ -236,14 +252,41 @@ vte_terminal_accessible_finalize(GObject *object) accessible = GTK_ACCESSIBLE(object); gobject_class = g_type_class_peek_parent(VTE_TERMINAL_ACCESSIBLE_GET_CLASS(object)); - g_signal_handlers_disconnect_by_func(G_OBJECT(accessible->widget), - GTK_SIGNAL_FUNC(vte_terminal_accessible_invalidate), + g_signal_handlers_disconnect_matched(G_OBJECT(accessible->widget), + (G_SIGNAL_MATCH_ID | + G_SIGNAL_MATCH_DATA), + g_signal_lookup("contents-changed", + VTE_TYPE_TERMINAL), + 0, + NULL, + NULL, + accessible); + g_signal_handlers_disconnect_matched(G_OBJECT(accessible->widget), + (G_SIGNAL_MATCH_ID | + G_SIGNAL_MATCH_DATA), + g_signal_lookup("cursor-moved", + VTE_TYPE_TERMINAL), + 0, + NULL, + NULL, accessible); - g_signal_handlers_disconnect_by_func(G_OBJECT(accessible->widget), - GTK_SIGNAL_FUNC(vte_terminal_accessible_hierarchy_changed), + g_signal_handlers_disconnect_matched(G_OBJECT(accessible->widget), + (G_SIGNAL_MATCH_ID | + G_SIGNAL_MATCH_DATA), + g_signal_lookup("hierarchy-changed", + VTE_TYPE_TERMINAL), + 0, + NULL, + NULL, accessible); - g_signal_handlers_disconnect_by_func(G_OBJECT(accessible->widget), - GTK_SIGNAL_FUNC(vte_terminal_accessible_title_changed), + g_signal_handlers_disconnect_matched(G_OBJECT(accessible->widget), + (G_SIGNAL_MATCH_ID | + G_SIGNAL_MATCH_DATA), + g_signal_lookup("window-title-changed", + VTE_TYPE_TERMINAL), + 0, + NULL, + NULL, accessible); if (gobject_class->finalize != NULL) { gobject_class->finalize(object); @@ -258,22 +301,33 @@ vte_terminal_accessible_get_text(AtkText *text, gchar *buf, *p; int i; + g_return_val_if_fail(end_offset >= start_offset, g_strdup("")); + vte_terminal_accessible_update_private_data_if_needed(ATK_OBJECT(text)); priv = g_object_get_data(G_OBJECT(text), VTE_TERMINAL_ACCESSIBLE_PRIVATE_DATA); - g_return_val_if_fail(VTE_IS_TERMINAL_ACCESSIBLE(text), NULL); +#ifdef VTE_DEBUG + fprintf(stderr, "Getting text from %d to %d of %d.\n", + start_offset, end_offset, priv->snapshot_cells->len); +#endif + g_return_val_if_fail(ATK_IS_TEXT(text), NULL); /* If the requested area is after all of the text, just return an * empty string. */ if (start_offset >= priv->snapshot_cells->len) { return g_strdup(""); } + if (end_offset > priv->snapshot_cells->len) { + return g_strdup(""); + } /* Allocate space to hold as many UTF-8 characters as we have * unicode characters. */ p = buf = g_malloc((end_offset - start_offset) * VTE_UTF8_BPC + 1); - for (i = start_offset; i < end_offset; i++) { + for (i = start_offset; + (i < end_offset) && (i < priv->snapshot_cells->len); + i++) { p += g_unichar_to_utf8(g_array_index(priv->snapshot_cells, struct VteTerminalSnapshotCell, i).c, @@ -301,6 +355,23 @@ vte_terminal_accessible_get_text_somewhere(AtkText *text, priv = g_object_get_data(G_OBJECT(text), VTE_TERMINAL_ACCESSIBLE_PRIVATE_DATA); +#ifdef VTE_DEBUG + fprintf(stderr, "Getting %s %s at %d of %d.\n", + (direction == 0) ? "this" : + ((direction == 1) ? "next" : "previous"), + (boundary_type == ATK_TEXT_BOUNDARY_CHAR) ? "char" : + ((boundary_type == ATK_TEXT_BOUNDARY_LINE_START) ? "line (start)" : + ((boundary_type == ATK_TEXT_BOUNDARY_LINE_END) ? "line (end)" : + ((boundary_type == ATK_TEXT_BOUNDARY_WORD_START) ? "word (start)" : + ((boundary_type == ATK_TEXT_BOUNDARY_WORD_END) ? "word (end)" : + ((boundary_type == ATK_TEXT_BOUNDARY_SENTENCE_START) ? "sentence (start)" : + ((boundary_type == ATK_TEXT_BOUNDARY_SENTENCE_END) ? "sentence (end)" : "unknown")))))), + offset, priv->snapshot_cells->len); +#endif + g_return_val_if_fail(priv->snapshot_cells != NULL, g_strdup("")); + g_return_val_if_fail(offset < priv->snapshot_cells->len, g_strdup("")); + g_return_val_if_fail(offset >= 0, g_strdup("")); + switch (boundary_type) { case ATK_TEXT_BOUNDARY_CHAR: /* We're either looking at the character at this @@ -424,6 +495,9 @@ vte_terminal_accessible_get_text_somewhere(AtkText *text, *start_offset = *end_offset = 0; break; } + *start_offset = MAX(*start_offset, priv->snapshot_cells->len - 1); + *end_offset = MAX(*start_offset, *end_offset); + *end_offset = MIN(*end_offset, priv->snapshot_cells->len); return vte_terminal_accessible_get_text(text, *start_offset, *end_offset); @@ -1,5 +1,5 @@ Name: vte -Version: 0.3.6 +Version: 0.3.7 Release: 1 Summary: An experimental terminal emulator. License: LGPL @@ -53,6 +53,10 @@ make install DESTDIR=$RPM_BUILD_ROOT %{_libdir}/pkgconfig/* %changelog +* Fri May 3 2002 Nalin Dahyabhai <nalin@redhat.com> 0.3.7-1 +- discard invalid control sequences +- recognize designate-??-character-set correctly + * Thu May 2 2002 Nalin Dahyabhai <nalin@redhat.com> 0.3.6-1 - add a couple of sequence handlers, fix a couple of accessibility crashbugs |