diff options
author | Nalin Dahyabhai <nalin@src.gnome.org> | 2003-05-29 04:50:48 +0000 |
---|---|---|
committer | Nalin Dahyabhai <nalin@src.gnome.org> | 2003-05-29 04:50:48 +0000 |
commit | 8de1e351b857e2ad8131bce4780cf24a75c694bc (patch) | |
tree | 6bd0659f72eb00c74bdd511d4c0275cce13f57c7 /src | |
parent | fe6545d62d857fed89f471d938213c9a88d64546 (diff) |
handle control characters in the middle of control sequences. fix origin
* src/vte.c(vte_terminal_process_incoming): handle control characters in the
middle of control sequences.
* src/vte.c(vte_sequence_handler_cm): fix origin mode.
* src/vte.c(vte_sequence_handler_cv): fix origin mode.
* src/vte.c(vte_sequence_handler_cs): snap the cursor to the scrolling region
which is set.
* src/table.c(_vte_table_extract_number): extract a number digit by digit as
we do in the trie parser.
* src/vte.h: declare 'struct vte_char_attributes' again to restore API back
compat with 0.10.x.
* src/iso2022.c(_vte_iso2022_sequence_length): don't recognize PM messages --
Xterm doesn't do anything with them and we don't want to appear to hang
when we're really just waiting for the end of the message.
Diffstat (limited to 'src')
-rw-r--r-- | src/iso2022.c | 8 | ||||
-rw-r--r-- | src/table.c | 10 | ||||
-rw-r--r-- | src/vte.c | 54 | ||||
-rw-r--r-- | src/vte.h | 7 |
4 files changed, 65 insertions, 14 deletions
diff --git a/src/iso2022.c b/src/iso2022.c index 344c81c..7bb1d8e 100644 --- a/src/iso2022.c +++ b/src/iso2022.c @@ -925,10 +925,14 @@ _vte_iso2022_sequence_length(const unsigned char *nextctl, gsize length) } break; #endif +#if 0 case '^': + /* ESC ^, the PM. Search for a string + * terminator. */ +#endif case 'P': - /* ESC ^, the PM, or ESC P, the DCS. - * Search for a string terminator. */ + /* ESC P, the DCS. Search for a string + * terminator. */ for (i = 2; i < length - 1; i++) { if ((nextctl[i] == '\033') && (nextctl[i + 1] == '\\')) { diff --git a/src/table.c b/src/table.c index dcbb544..1274ce0 100644 --- a/src/table.c +++ b/src/table.c @@ -365,7 +365,8 @@ _vte_table_extract_number(GValueArray **array, GValue value = {0,}; GString *tmp; char **vals; - int i; + int i, j; + long total; tmp = g_string_new(""); for (i = 0; i < arginfo->length; i++) { @@ -381,7 +382,12 @@ _vte_table_extract_number(GValueArray **array, if (*array == NULL) { *array = g_value_array_new(1); } - g_value_set_long(&value, atol(vals[i])); + for (total = 0, j = 0; vals[i][j] != '\0'; j++) { + total *= 10; + total += g_unichar_digit_value(vals[i][j]) == -1 ? + 0 : g_unichar_digit_value(vals[i][j]); + } + g_value_set_long(&value, total); g_value_array_append(*array, &value); } @@ -2447,7 +2447,7 @@ vte_sequence_handler_cm(VteTerminal *terminal, GValueArray *params) { GValue *row, *col; - long rowval, colval; + long rowval, colval, origin; VteScreen *screen; screen = terminal->pvt->screen; @@ -2458,7 +2458,13 @@ vte_sequence_handler_cm(VteTerminal *terminal, col = g_value_array_get_nth(params, 1); if (G_VALUE_HOLDS_LONG(row) && G_VALUE_HOLDS_LONG(col)) { - rowval = g_value_get_long(row); + if (screen->origin_mode && + screen->scrolling_restricted) { + origin = screen->scrolling_region.start; + } else { + origin = 0; + } + rowval = g_value_get_long(row) + origin; colval = g_value_get_long(col); rowval = CLAMP(rowval, 0, terminal->row_count - 1); colval = CLAMP(colval, 0, terminal->column_count - 1); @@ -2553,6 +2559,11 @@ vte_sequence_handler_cs(VteTerminal *terminal, (terminal->pvt->screen->scrolling_region.end == rows - 1)) { terminal->pvt->screen->scrolling_restricted = FALSE; } + /* Clamp the cursor to the scrolling region. */ + terminal->pvt->screen->cursor_current.row = CLAMP(terminal->pvt->screen->cursor_current.row, + terminal->pvt->screen->insert_delta + start, + terminal->pvt->screen->insert_delta + end); + vte_terminal_ensure_cursor(terminal, TRUE); } /* Restrict scrolling and updates to a subset of the visible lines, because @@ -2587,6 +2598,11 @@ vte_sequence_handler_cS(VteTerminal *terminal, (terminal->pvt->screen->scrolling_region.end == rows - 1)) { terminal->pvt->screen->scrolling_restricted = FALSE; } + /* Clamp the cursor to the scrolling region. */ + terminal->pvt->screen->cursor_current.row = CLAMP(terminal->pvt->screen->cursor_current.row, + terminal->pvt->screen->insert_delta + start, + terminal->pvt->screen->insert_delta + end); + vte_terminal_ensure_cursor(terminal, TRUE); } /* Clear all tab stops. */ @@ -2649,16 +2665,21 @@ vte_sequence_handler_cv(VteTerminal *terminal, { VteScreen *screen; GValue *value; - long val; + long val, origin; screen = terminal->pvt->screen; /* We only care if there's a parameter in there. */ if ((params != NULL) && (params->n_values > 0)) { value = g_value_array_get_nth(params, 0); if (G_VALUE_HOLDS_LONG(value)) { /* Move the cursor. */ - val = CLAMP(g_value_get_long(value), - 0, - terminal->row_count - 1); + if (screen->origin_mode && + screen->scrolling_restricted) { + origin = screen->scrolling_region.start; + } else { + origin = 0; + } + val = g_value_get_long(value) + origin; + val = CLAMP(val, 0, terminal->row_count - 1); screen->cursor_current.row = screen->insert_delta + val; } } @@ -4339,15 +4360,11 @@ vte_sequence_handler_decset_internal(VteTerminal *terminal, GINT_TO_POINTER(FALSE), GINT_TO_POINTER(TRUE), NULL, NULL,}, -#if 0 /* 6: Origin mode. */ {6, &terminal->pvt->screen->origin_mode, NULL, NULL, GINT_TO_POINTER(FALSE), GINT_TO_POINTER(TRUE), NULL, NULL,}, -#else - {6, NULL, NULL, NULL, NULL, NULL, NULL, NULL,}, -#endif /* 7: Wraparound mode. */ {7, &terminal->pvt->flags.am, NULL, NULL, GINT_TO_POINTER(FALSE), @@ -7082,6 +7099,23 @@ vte_terminal_process_incoming(gpointer data) * we're currently examining into the screen. */ if (match == NULL) { c = wbuf[start]; + /* If it's a control character, permute the order, per + * vttest. */ + if ((c != *next) && + ((*next & 0x1f) == *next) && + (start + 1 < next - wbuf)) { + gunichar ctrl; + int i; + /* Save the control character. */ + ctrl = *next; + /* Move everything before it up a slot. */ + for (i = next - wbuf; i > start; i--) { + wbuf[i] = wbuf[i - 1]; + } + /* Move the control character to the front. */ + wbuf[i] = ctrl; + continue; + } #ifdef VTE_DEBUG c = c & ~VTE_ISO2022_ENCODED_WIDTH_MASK; if (_vte_debug_on(VTE_DEBUG_PARSE)) { @@ -121,6 +121,13 @@ struct _VteCharAttributes { }; typedef struct _VteCharAttributes VteCharAttributes; +/* The name of the same structure in the 0.10 series, for API compatibility. */ +struct vte_char_attributes { + long row, column; + GdkColor fore, back; + gboolean underline:1, strikethrough:1; +}; + /* The widget's type. */ GtkType vte_terminal_get_type(void); GtkType vte_terminal_erase_binding_get_type(void); |