forked from aniani/vim
patch 9.0.1068: no information about whether request term codes has an effect
Problem: No information about whether requesting term codes has an effect. Solution: Add ch_log() calls to report the effect of term code responses. Avoid deleting an entry and then adding back the same one.
This commit is contained in:
52
src/term.c
52
src/term.c
@@ -4401,6 +4401,9 @@ add_termcode(char_u *name, char_u *string, int flags)
|
|||||||
int i, j;
|
int i, j;
|
||||||
char_u *s;
|
char_u *s;
|
||||||
int len;
|
int len;
|
||||||
|
#ifdef FEAT_EVAL
|
||||||
|
char *action = "Setting";
|
||||||
|
#endif
|
||||||
|
|
||||||
if (string == NULL || *string == NUL)
|
if (string == NULL || *string == NUL)
|
||||||
{
|
{
|
||||||
@@ -4493,6 +4496,9 @@ add_termcode(char_u *name, char_u *string, int flags)
|
|||||||
== termcodes[i].code[termcodes[i].len - 1])
|
== termcodes[i].code[termcodes[i].len - 1])
|
||||||
{
|
{
|
||||||
// They are equal but for the ";*": don't add it.
|
// They are equal but for the ";*": don't add it.
|
||||||
|
#ifdef FEAT_EVAL
|
||||||
|
ch_log(NULL, "Termcap entry %s did not change", name);
|
||||||
|
#endif
|
||||||
vim_free(s);
|
vim_free(s);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -4500,6 +4506,10 @@ add_termcode(char_u *name, char_u *string, int flags)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Replace old code.
|
// Replace old code.
|
||||||
|
#ifdef FEAT_EVAL
|
||||||
|
ch_log(NULL, "Termcap entry %s was: %s",
|
||||||
|
name, termcodes[i].code);
|
||||||
|
#endif
|
||||||
vim_free(termcodes[i].code);
|
vim_free(termcodes[i].code);
|
||||||
--tc_len;
|
--tc_len;
|
||||||
break;
|
break;
|
||||||
@@ -4509,11 +4519,17 @@ add_termcode(char_u *name, char_u *string, int flags)
|
|||||||
/*
|
/*
|
||||||
* Found alphabetical larger entry, move rest to insert new entry
|
* Found alphabetical larger entry, move rest to insert new entry
|
||||||
*/
|
*/
|
||||||
|
#ifdef FEAT_EVAL
|
||||||
|
action = "Adding";
|
||||||
|
#endif
|
||||||
for (j = tc_len; j > i; --j)
|
for (j = tc_len; j > i; --j)
|
||||||
termcodes[j] = termcodes[j - 1];
|
termcodes[j] = termcodes[j - 1];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef FEAT_EVAL
|
||||||
|
ch_log(NULL, "%s termcap entry %s to %s", action, name, s);
|
||||||
|
#endif
|
||||||
termcodes[i].name[0] = name[0];
|
termcodes[i].name[0] = name[0];
|
||||||
termcodes[i].name[1] = name[1];
|
termcodes[i].name[1] = name[1];
|
||||||
termcodes[i].code = s;
|
termcodes[i].code = s;
|
||||||
@@ -6940,18 +6956,50 @@ got_code_from_term(char_u *code, int len)
|
|||||||
if (name[0] == 'C' && name[1] == 'o')
|
if (name[0] == 'C' && name[1] == 'o')
|
||||||
{
|
{
|
||||||
// Color count is not a key code.
|
// Color count is not a key code.
|
||||||
may_adjust_color_count(atoi((char *)str));
|
int val = atoi((char *)str);
|
||||||
|
#if defined(FEAT_EVAL)
|
||||||
|
if (val == t_colors)
|
||||||
|
ch_log(NULL, "got_code_from_term(Co): no change (%d)", val);
|
||||||
|
else
|
||||||
|
ch_log(NULL,
|
||||||
|
"got_code_from_term(Co): changed from %d to %d",
|
||||||
|
t_colors, val);
|
||||||
|
#endif
|
||||||
|
may_adjust_color_count(val);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// First delete any existing entry with the same code.
|
|
||||||
i = find_term_bykeys(str);
|
i = find_term_bykeys(str);
|
||||||
|
if (i >= 0 && name[0] == termcodes[i].name[0]
|
||||||
|
&& name[1] == termcodes[i].name[1])
|
||||||
|
{
|
||||||
|
// Existing entry with the same name and code - skip.
|
||||||
|
#ifdef FEAT_EVAL
|
||||||
|
ch_log(NULL, "got_code_from_term(): Entry %c%c did not change",
|
||||||
|
name[0], name[1]);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
if (i >= 0)
|
if (i >= 0)
|
||||||
|
{
|
||||||
|
// Delete an existing entry using the same code.
|
||||||
|
#ifdef FEAT_EVAL
|
||||||
|
ch_log(NULL, "got_code_from_term(): Deleting entry %c%c with matching keys %s",
|
||||||
|
termcodes[i].name[0], termcodes[i].name[1], str);
|
||||||
|
#endif
|
||||||
del_termcode_idx(i);
|
del_termcode_idx(i);
|
||||||
|
}
|
||||||
|
#ifdef FEAT_EVAL
|
||||||
|
else
|
||||||
|
ch_log(NULL, "got_code_from_term(): Adding entry %c%c with keys %s",
|
||||||
|
name[0], name[1], str);
|
||||||
|
#endif
|
||||||
add_termcode(name, str, ATC_FROM_TERM);
|
add_termcode(name, str, ATC_FROM_TERM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// May request more codes now that we received one.
|
// May request more codes now that we received one.
|
||||||
++xt_index_in;
|
++xt_index_in;
|
||||||
|
@@ -695,6 +695,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1068,
|
||||||
/**/
|
/**/
|
||||||
1067,
|
1067,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user