Commit 3dc885c4 authored by Nalin Dahyabhai's avatar Nalin Dahyabhai

fix logic for skipping over particular settings so that setting 1048

* src/vte.c(vte_sequence_handler_decset_internal): fix logic for skipping over
	particular settings so that setting 1048 actually works.
* src/vte.c(vte_terminal_process_incoming): in debug mode, print out characters
	with codepoints higher than 255 in hex rather than decimal.
* src/iso2022.c(_vte_iso2022_ambiguous_width): rename to
	_vte_iso2022_ambiguous_width_guess because that's all we can do without
	more context.
* src/iso2022.c(_vte_iso2022_ambiguous_width): add for using the current
	encoding to determine what the width of an ambiguously-wide character
	should be.  This seems to work better.
parent 7fe2fc15
2003-05-30 nalin
* src/vte.c(vte_sequence_handler_decset_internal): fix logic for
skipping over particular settings so that setting 1048 actually works.
* src/vte.c(vte_terminal_process_incoming): in debug mode, print out
characters with codepoints higher than 255 in hex rather than decimal.
* src/iso2022.c(_vte_iso2022_ambiguous_width): rename to
_vte_iso2022_ambiguous_width_guess because that's all we can do without
more context.
* src/iso2022.c(_vte_iso2022_ambiguous_width): add for using the
current encoding to determine what the width of an ambiguously-wide
character should be. This seems to work better.
2003-05-30 Padraig O'Briain <padraig.obriain@sun.com>
* src/vteaccess.c: Add implementation for get_character_extents,
get_offset_at_point and get_run_attributes. This fixes bug #110770.
......
......@@ -318,8 +318,10 @@ _vte_iso2022_is_ambiguous(gunichar c)
return g_tree_lookup(ambiguous, p) == p;
}
/* If we only have a codepoint, guess what the ambiguous width should be based
* on the default region. Just hope we don't do this too often. */
static int
_vte_iso2022_ambiguous_width(void)
_vte_iso2022_ambiguous_width_guess(void)
{
const char *lang = NULL;
int ret = 1;
......@@ -355,6 +357,54 @@ _vte_iso2022_ambiguous_width(void)
return ret;
}
/* If we have the encoding, decide how wide an ambiguously-wide character is
* based on the encoding. This is basically what GNU libc does, and it sounds
* reasonable, so.... */
static int
_vte_iso2022_ambiguous_width(struct _vte_iso2022_state *state)
{
const char *wide_codelist[] = {
"big5",
"euccn",
"eucjp",
"euckr",
"euctw",
"gb18030",
"gb2312",
"gbk",
"tcvn",
};
int i, j;
char codeset[16];
/* Catch weirdo cases. */
if ((state->codeset == NULL) || (state->codeset[0] == '\0')) {
return 1;
}
/* Sort-of canonify the encoding name. */
i = j = 0;
for (i = 0; state->codeset[i] != '\0'; i++) {
if (g_ascii_isalnum(state->codeset[i])) {
codeset[j++] = g_ascii_tolower(state->codeset[i]);
}
if (j >= sizeof(codeset) - 1) {
break;
}
}
codeset[j] = '\0';
/* Check for the name in the list. */
for (i = 0; i < G_N_ELEMENTS(wide_codelist); i++) {
if (strcmp(codeset, wide_codelist[i]) == 0) {
return 2;
}
}
/* Not in the list => not wide. */
return 1;
}
static GTree *
_vte_iso2022_map_init(const struct _vte_iso2022_map *map, gssize length)
{
......@@ -1159,7 +1209,7 @@ process_8_bit_sequence(struct _vte_iso2022_state *state,
width = force_width;
} else {
if (_vte_iso2022_is_ambiguous(c)) {
width = _vte_iso2022_ambiguous_width();
width = _vte_iso2022_ambiguous_width(state);
}
}
#ifdef VTE_DEBUG
......@@ -1182,7 +1232,7 @@ static glong
process_cdata(struct _vte_iso2022_state *state, guchar *cdata, gsize length,
GArray *gunichars)
{
static int ambiguous_width = 0;
int ambiguous_width = 0;
glong processed = 0;
GTree *map;
gint bytes_per_char, force_width, current;
......@@ -1196,9 +1246,7 @@ process_cdata(struct _vte_iso2022_state *state, guchar *cdata, gsize length,
gpointer p;
gboolean single, stop;
if (ambiguous_width == 0) {
ambiguous_width = _vte_iso2022_ambiguous_width();
}
ambiguous_width = _vte_iso2022_ambiguous_width(state);
single = (state->override != -1);
current = (state->override != -1) ? state->override : state->current;
......@@ -1269,6 +1317,7 @@ process_cdata(struct _vte_iso2022_state *state, guchar *cdata, gsize length,
for (i = 0; &buf[i] < (char*)outbuf; i += sizeof(gunichar)) {
c = *(gunichar*)(buf + i);
if (c == '\0') {
/* Skip the padding character. */
continue;
}
if (_vte_iso2022_is_ambiguous(c)) {
......@@ -1762,7 +1811,7 @@ _vte_iso2022_unichar_width(gunichar c)
{
c = c & ~(VTE_ISO2022_ENCODED_WIDTH_MASK); /* just in case */
if (_vte_iso2022_is_ambiguous(c)) {
return _vte_iso2022_ambiguous_width();
return _vte_iso2022_ambiguous_width_guess();
}
if (g_unichar_iswide(c)) {
return 2;
......
......@@ -4506,7 +4506,9 @@ vte_sequence_handler_decset_internal(VteTerminal *terminal,
if (settings[i].setting == setting) {
recognized = TRUE;
/* Handle settings we want to ignore. */
if (settings[i].fvalue == settings[i].tvalue) {
if ((settings[i].fvalue == settings[i].tvalue) &&
(settings[i].set == NULL) &&
(settings[i].reset == NULL)) {
continue;
}
......@@ -7150,7 +7152,7 @@ vte_terminal_process_incoming(gpointer data)
c = c & ~VTE_ISO2022_ENCODED_WIDTH_MASK;
if (_vte_debug_on(VTE_DEBUG_PARSE)) {
if (c > 255) {
fprintf(stderr, "%ld\n", (long) c);
fprintf(stderr, "U+%04lx\n", (long) c);
} else {
if (c > 127) {
fprintf(stderr, "%ld = ",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment