+2002-06-17 nalin
+ * src/trie.c (vte_trie_match, vte_trie_match_x): Sort out greedy vs.
+ non-greedy pattern matching.
+ * src/vte.c (vte_sequence_handler_decset_internal): Make 1047 an alias
+ for 47 (use alternate buffer), and handle cursor save/restore properly.
2002-06-14 nalin
* src/vte.c, src/vte.h (vte_terminal_fork_command): Add a parameter for
passing in environment variables to add.
implemented (ff, fs, i1, i3, is, iP, LF, LO, MC, mh, ML, mm, mo, nw, pf,
pk, pl, pf, po, pO, ps, px, r1, r2, r3, RA, RF, rp, rs, RX, SA, SX, wi,
several more from the XTerm set).
-- Sequence matching is greedy, so that C=AB matches C and not A and then B.
- Bold doesn't work right if the default foreground color isn't gray. Need
to move to 20-color palette to fix this right.
- I'm not sure the widget implementation itself is correct. There are many
* works, and the result string if we have an exact match. */
static const char *
vte_trie_matchx(struct vte_trie *trie, const wchar_t *pattern, size_t length,
+ gboolean greedy,
const char **res, const wchar_t **consumed,
GQuark *quark, GValueArray *array)
{
/* Trivial cases. We've matched an entire pattern, or we're out of
* pattern to match. */
- if (trie->result) {
+ if (trie->result != NULL) {
*res = trie->result;
*quark = trie->quark;
*consumed = pattern;
return vte_trie_matchx(path->trie,
pattern + partial,
length - partial,
+ FALSE,
res,
consumed,
quark,
const char *tmp;
GQuark tmpquark = 0;
GValueArray *tmparray;
+ gboolean better = FALSE;
/* Move past characters which might match this
* part of the string... */
while (cclass->multiple &&
vte_trie_matchx(subtrie,
prospect,
length - (prospect - pattern),
+ greedy,
&tmp,
consumed,
&tmpquark,
tmparray);
- /* If it's a better match than any we've seen
- * so far, call it the "best so far". */
- if ((best == NULL) ||
- ((best[0] == '\0') &&
- (tmp != NULL) &&
- (tmp[0] != '\0'))) {
+ /* If we haven't seen any matches yet, go ahead
+ * and go by this result. */
+ if (best == NULL) {
+ better = TRUE;
+ }
+ /* If we have a match, and we didn't have one
+ * already, go by this result. */
+ if ((best != NULL) &&
+ (best[0] == '\0') &&
+ (tmp != NULL) &&
+ (tmp[0] != '\0')) {
+ better = TRUE;
+ }
+ /* If we already have a match, and this one's
+ * better (longer if we're greedy, shorter if
+ * we're not), then go by this result. */
+ if ((tmp != NULL) &&
+ (tmp[0] != '\0') &&
+ (bestconsumed != NULL) &&
+ (consumed != NULL) &&
+ (*consumed != NULL)) {
+ if (greedy &&
+ (bestconsumed < *consumed)) {
+ better = TRUE;
+ }
+ if (!greedy &&
+ (bestconsumed > *consumed)) {
+ better = TRUE;
+ }
+ }
+ if (better) {
best = tmp;
if (bestarray != NULL) {
g_value_array_free(bestarray);
GValue *value;
const wchar_t *dummyconsumed;
gpointer ptr;
+ gboolean greedy = FALSE;
int i;
valuearray = g_value_array_new(0);
}
*consumed = pattern;
- ret = vte_trie_matchx(trie, pattern, length, res, consumed,
- quark, valuearray);
+ ret = vte_trie_matchx(trie, pattern, length, greedy,
+ res, consumed, quark, valuearray);
if (((ret == NULL) || (ret[0] == '\0')) || (valuearray->n_values == 0)){
if (valuearray != NULL) {
g_quark_from_string("vtmatch"));
vte_trie_add(trie, "<esc>[%i%mL", 11, "multimatch",
g_quark_from_string("multimatch"));
+ vte_trie_add(trie, "<esc>[%mL<esc>[%mL", 18, "greedy",
+ g_quark_from_string("greedy"));
vte_trie_add(trie, "<esc>]2;%sh", 11, "decset-title",
g_quark_from_string("decset-title"));
if (argc > 1) {
g_value_array_free(array);
}
+ quark = 0;
+ convert_mbstowcs("<esc>[25L", 9, buf, &buflen, sizeof(buf));
+ g_print("`%s' = `%s'\n", "<esc>[25L",
+ vte_trie_match(trie, buf, buflen,
+ NULL, &consumed, &quark, &array));
+ g_print("=> `%s' (%d)\n", g_quark_to_string(quark), consumed - buf);
+ if (array != NULL) {
+ dump_array(array);
+ g_value_array_free(array);
+ }
+
+ quark = 0;
+ convert_mbstowcs("<esc>[25L<esc>[24L", 18, buf, &buflen, sizeof(buf));
+ g_print("`%s' = `%s'\n", "<esc>[25L<esc>[24L",
+ vte_trie_match(trie, buf, buflen,
+ NULL, &consumed, &quark, &array));
+ g_print("=> `%s' (%d)\n", g_quark_to_string(quark), consumed - buf);
+ if (array != NULL) {
+ dump_array(array);
+ g_value_array_free(array);
+ }
+
quark = 0;
convert_mbstowcs("<esc>[25;26L", 12, buf, &buflen, sizeof(buf));
g_print("`%s' = `%s'\n", "<esc>[25;26L",
gpointer *pvalue;
gpointer fvalue;
gpointer tvalue;
+ VteTerminalSequenceHandler reset, set;
} settings[] = {
/* Application/normal keypad. */
{1, NULL, &terminal->pvt->keypad, NULL,
GINT_TO_POINTER(VTE_KEYPAD_NORMAL),
- GINT_TO_POINTER(VTE_KEYPAD_APPLICATION),},
+ GINT_TO_POINTER(VTE_KEYPAD_APPLICATION),
+ NULL, NULL,},
/* Reverse video. */
{5, &terminal->pvt->screen->reverse_mode, NULL, NULL,
GINT_TO_POINTER(FALSE),
- GINT_TO_POINTER(TRUE),},
+ GINT_TO_POINTER(TRUE),
+ NULL, NULL,},
/* Send-coords-on-click. */
{9, &terminal->pvt->mouse_send_xy_on_click, NULL, NULL,
GINT_TO_POINTER(FALSE),
- GINT_TO_POINTER(TRUE),},
+ GINT_TO_POINTER(TRUE),
+ NULL, NULL,},
/* Cursor visible. */
{25, &terminal->pvt->screen->cursor_visible, NULL, NULL,
GINT_TO_POINTER(FALSE),
- GINT_TO_POINTER(TRUE),},
+ GINT_TO_POINTER(TRUE),
+ NULL, NULL,},
/* Alternate screen. */
{47, NULL, NULL, (gpointer*) &terminal->pvt->screen,
&terminal->pvt->normal_screen,
- &terminal->pvt->alternate_screen,},
+ &terminal->pvt->alternate_screen,
+ NULL, NULL,},
/* Send-coords-on-button. */
{1000, &terminal->pvt->mouse_send_xy_on_button, NULL, NULL,
GINT_TO_POINTER(FALSE),
- GINT_TO_POINTER(TRUE),},
+ GINT_TO_POINTER(TRUE),
+ NULL, NULL,},
/* Hilite tracking*/
{1001, &terminal->pvt->mouse_hilite_tracking, NULL, NULL,
GINT_TO_POINTER(FALSE),
- GINT_TO_POINTER(TRUE),},
+ GINT_TO_POINTER(TRUE),
+ NULL, NULL,},
/* Cell motion tracking*/
{1002, &terminal->pvt->mouse_cell_motion_tracking, NULL, NULL,
GINT_TO_POINTER(FALSE),
- GINT_TO_POINTER(TRUE),},
+ GINT_TO_POINTER(TRUE),
+ NULL, NULL,},
/* All motion tracking*/
{1003, &terminal->pvt->mouse_all_motion_tracking, NULL, NULL,
GINT_TO_POINTER(FALSE),
- GINT_TO_POINTER(TRUE),},
+ GINT_TO_POINTER(TRUE),
+ NULL, NULL,},
+ /* Use alternate screen buffer. */
+ {1047, NULL, NULL, (gpointer*) &terminal->pvt->screen,
+ &terminal->pvt->normal_screen,
+ &terminal->pvt->alternate_screen,
+ NULL, NULL,},
+ /* Save/restore cursor position. */
+ {1048, NULL, NULL, NULL,
+ NULL,
+ NULL,
+ vte_sequence_handler_rc,
+ vte_sequence_handler_sc,},
};
g_return_if_fail(VTE_IS_TERMINAL(terminal));
*(settings[i].pvalue) = set ?
settings[i].tvalue :
settings[i].fvalue;
+ } else
+ if (settings[i].set && settings[i].reset) {
+ if (set) {
+ settings[i].set(terminal, NULL,
+ 0, NULL);
+ } else {
+ settings[i].reset(terminal, NULL,
+ 0, NULL);
+ }
}
}
}
vte_invalidate_all(terminal);
break;
case 25:
+ case 1048:
/* Repaint the cell the cursor is in. */
vte_invalidate_cursor_once(terminal);
break;
case 47:
+ case 1047:
/* Reset scrollbars and repaint everything. */
vte_terminal_adjust_adjustments(terminal);
vte_invalidate_all(terminal);
Name: vte
-Version: 0.4.0
+Version: 0.4.1
Release: 1
Summary: An experimental terminal emulator.
License: LGPL
%{_libdir}/pkgconfig/*
%changelog
+* Tue Jun 18 2002 Nalin Dahyabhai <nalin@redhat.com> 0.4.1-1
+- fix use of alternate buffer in xterm emulation mode
+
* Fri Jun 14 2002 Nalin Dahyabhai <nalin@redhat.com> 0.4.0-1
- add a means for apps to add environment variables