forked from aniani/vim
patch 8.0.1762: terminal debug logging is a bit complicated
Problem: Terminal debug logging is a bit complicated. Solution: Make log_tr() use variable arguments (Ozaki Kiichi, closes #2730)
This commit is contained in:
100
src/term.c
100
src/term.c
@@ -108,10 +108,10 @@ char *tgetstr(char *, char **);
|
|||||||
/* Change this to "if 1" to debug what happens with termresponse. */
|
/* Change this to "if 1" to debug what happens with termresponse. */
|
||||||
# if 0
|
# if 0
|
||||||
# define DEBUG_TERMRESPONSE
|
# define DEBUG_TERMRESPONSE
|
||||||
static void log_tr(char *msg);
|
static void log_tr(const char *fmt, ...);
|
||||||
# define LOG_TR(msg) log_tr(msg)
|
# define LOG_TR(msg) log_tr msg
|
||||||
# else
|
# else
|
||||||
# define LOG_TR(msg)
|
# define LOG_TR(msg) do { /**/ } while (0)
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# define STATUS_GET 1 /* send request when switching to RAW mode */
|
# define STATUS_GET 1 /* send request when switching to RAW mode */
|
||||||
@@ -1516,15 +1516,13 @@ may_adjust_color_count(int val)
|
|||||||
init_highlight(TRUE, FALSE);
|
init_highlight(TRUE, FALSE);
|
||||||
# ifdef DEBUG_TERMRESPONSE
|
# ifdef DEBUG_TERMRESPONSE
|
||||||
{
|
{
|
||||||
char buf[100];
|
int r = redraw_asap(CLEAR);
|
||||||
int r = redraw_asap(CLEAR);
|
|
||||||
|
|
||||||
sprintf(buf, "Received t_Co, redraw_asap(): %d", r);
|
log_tr("Received t_Co, redraw_asap(): %d", r);
|
||||||
log_tr(buf);
|
|
||||||
}
|
}
|
||||||
# else
|
#else
|
||||||
redraw_asap(CLEAR);
|
redraw_asap(CLEAR);
|
||||||
# endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -1948,7 +1946,7 @@ set_termname(char_u *term)
|
|||||||
full_screen = TRUE; /* we can use termcap codes from now on */
|
full_screen = TRUE; /* we can use termcap codes from now on */
|
||||||
set_term_defaults(); /* use current values as defaults */
|
set_term_defaults(); /* use current values as defaults */
|
||||||
#ifdef FEAT_TERMRESPONSE
|
#ifdef FEAT_TERMRESPONSE
|
||||||
LOG_TR("setting crv_status to STATUS_GET");
|
LOG_TR(("setting crv_status to STATUS_GET"));
|
||||||
crv_status = STATUS_GET; /* Get terminal version later */
|
crv_status = STATUS_GET; /* Get terminal version later */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -3510,7 +3508,7 @@ may_req_termresponse(void)
|
|||||||
&& starting == 0
|
&& starting == 0
|
||||||
&& *T_CRV != NUL)
|
&& *T_CRV != NUL)
|
||||||
{
|
{
|
||||||
LOG_TR("Sending CRV request");
|
LOG_TR(("Sending CRV request"));
|
||||||
out_str(T_CRV);
|
out_str(T_CRV);
|
||||||
crv_status = STATUS_SENT;
|
crv_status = STATUS_SENT;
|
||||||
/* check for the characters now, otherwise they might be eaten by
|
/* check for the characters now, otherwise they might be eaten by
|
||||||
@@ -3541,7 +3539,7 @@ may_req_ambiguous_char_width(void)
|
|||||||
{
|
{
|
||||||
char_u buf[16];
|
char_u buf[16];
|
||||||
|
|
||||||
LOG_TR("Sending U7 request");
|
LOG_TR(("Sending U7 request"));
|
||||||
/* Do this in the second row. In the first row the returned sequence
|
/* Do this in the second row. In the first row the returned sequence
|
||||||
* may be CSI 1;2R, which is the same as <S-F3>. */
|
* may be CSI 1;2R, which is the same as <S-F3>. */
|
||||||
term_windgoto(1, 0);
|
term_windgoto(1, 0);
|
||||||
@@ -3583,7 +3581,7 @@ may_req_bg_color(void)
|
|||||||
/* Only request foreground if t_RF is set. */
|
/* Only request foreground if t_RF is set. */
|
||||||
if (rfg_status == STATUS_GET && *T_RFG != NUL)
|
if (rfg_status == STATUS_GET && *T_RFG != NUL)
|
||||||
{
|
{
|
||||||
LOG_TR("Sending FG request");
|
LOG_TR(("Sending FG request"));
|
||||||
out_str(T_RFG);
|
out_str(T_RFG);
|
||||||
rfg_status = STATUS_SENT;
|
rfg_status = STATUS_SENT;
|
||||||
didit = TRUE;
|
didit = TRUE;
|
||||||
@@ -3593,7 +3591,7 @@ may_req_bg_color(void)
|
|||||||
/* Only request background if t_RB is set. */
|
/* Only request background if t_RB is set. */
|
||||||
if (rbg_status == STATUS_GET && *T_RBG != NUL)
|
if (rbg_status == STATUS_GET && *T_RBG != NUL)
|
||||||
{
|
{
|
||||||
LOG_TR("Sending BG request");
|
LOG_TR(("Sending BG request"));
|
||||||
out_str(T_RBG);
|
out_str(T_RBG);
|
||||||
rbg_status = STATUS_SENT;
|
rbg_status = STATUS_SENT;
|
||||||
didit = TRUE;
|
didit = TRUE;
|
||||||
@@ -3611,11 +3609,12 @@ may_req_bg_color(void)
|
|||||||
|
|
||||||
# ifdef DEBUG_TERMRESPONSE
|
# ifdef DEBUG_TERMRESPONSE
|
||||||
static void
|
static void
|
||||||
log_tr(char *msg)
|
log_tr(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
static FILE *fd_tr = NULL;
|
static FILE *fd_tr = NULL;
|
||||||
static proftime_T start;
|
static proftime_T start;
|
||||||
proftime_T now;
|
proftime_T now;
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
if (fd_tr == NULL)
|
if (fd_tr == NULL)
|
||||||
{
|
{
|
||||||
@@ -3624,11 +3623,14 @@ log_tr(char *msg)
|
|||||||
}
|
}
|
||||||
now = start;
|
now = start;
|
||||||
profile_end(&now);
|
profile_end(&now);
|
||||||
fprintf(fd_tr, "%s: %s %s\n",
|
fprintf(fd_tr, "%s: %s ", profile_msg(&now),
|
||||||
profile_msg(&now),
|
must_redraw == NOT_VALID ? "NV"
|
||||||
must_redraw == NOT_VALID ? "NV"
|
: must_redraw == CLEAR ? "CL" : " ");
|
||||||
: must_redraw == CLEAR ? "CL" : " ",
|
va_start(ap, fmt);
|
||||||
msg);
|
vfprintf(fd_tr, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
fputc('\n', fd_tr);
|
||||||
|
fflush(fd_tr);
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
@@ -4179,7 +4181,7 @@ switch_to_8bit(void)
|
|||||||
need_gather = TRUE; /* need to fill termleader[] */
|
need_gather = TRUE; /* need to fill termleader[] */
|
||||||
}
|
}
|
||||||
detected_8bit = TRUE;
|
detected_8bit = TRUE;
|
||||||
LOG_TR("Switching to 8 bit");
|
LOG_TR(("Switching to 8 bit"));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -4512,7 +4514,7 @@ check_termcode(
|
|||||||
}
|
}
|
||||||
if (i == len)
|
if (i == len)
|
||||||
{
|
{
|
||||||
LOG_TR("Not enough characters for CRV");
|
LOG_TR(("Not enough characters for CRV"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (extra > 0)
|
if (extra > 0)
|
||||||
@@ -4529,7 +4531,7 @@ check_termcode(
|
|||||||
{
|
{
|
||||||
char *aw = NULL;
|
char *aw = NULL;
|
||||||
|
|
||||||
LOG_TR("Received U7 status");
|
LOG_TR(("Received U7 status: %s", tp));
|
||||||
u7_status = STATUS_GOT;
|
u7_status = STATUS_GOT;
|
||||||
did_cursorhold = TRUE;
|
did_cursorhold = TRUE;
|
||||||
if (col == 2)
|
if (col == 2)
|
||||||
@@ -4545,13 +4547,9 @@ check_termcode(
|
|||||||
(char_u *)aw, 0);
|
(char_u *)aw, 0);
|
||||||
# ifdef DEBUG_TERMRESPONSE
|
# ifdef DEBUG_TERMRESPONSE
|
||||||
{
|
{
|
||||||
char buf[100];
|
int r = redraw_asap(CLEAR);
|
||||||
int r = redraw_asap(CLEAR);
|
|
||||||
|
|
||||||
sprintf(buf,
|
log_tr("set 'ambiwidth', redraw_asap(): %d", r);
|
||||||
"set 'ambiwidth', redraw_asap(): %d",
|
|
||||||
r);
|
|
||||||
log_tr(buf);
|
|
||||||
}
|
}
|
||||||
# else
|
# else
|
||||||
redraw_asap(CLEAR);
|
redraw_asap(CLEAR);
|
||||||
@@ -4572,7 +4570,7 @@ check_termcode(
|
|||||||
{
|
{
|
||||||
int version = col;
|
int version = col;
|
||||||
|
|
||||||
LOG_TR("Received CRV response");
|
LOG_TR(("Received CRV response: %s", tp));
|
||||||
crv_status = STATUS_GOT;
|
crv_status = STATUS_GOT;
|
||||||
did_cursorhold = TRUE;
|
did_cursorhold = TRUE;
|
||||||
|
|
||||||
@@ -4598,7 +4596,7 @@ check_termcode(
|
|||||||
/* if xterm version >= 141 try to get termcap codes */
|
/* if xterm version >= 141 try to get termcap codes */
|
||||||
if (version >= 141)
|
if (version >= 141)
|
||||||
{
|
{
|
||||||
LOG_TR("Enable checking for XT codes");
|
LOG_TR(("Enable checking for XT codes"));
|
||||||
check_for_codes = TRUE;
|
check_for_codes = TRUE;
|
||||||
need_gather = TRUE;
|
need_gather = TRUE;
|
||||||
req_codes_from_term();
|
req_codes_from_term();
|
||||||
@@ -4688,7 +4686,7 @@ check_termcode(
|
|||||||
&& *T_CSH != NUL
|
&& *T_CSH != NUL
|
||||||
&& *T_CRS != NUL)
|
&& *T_CRS != NUL)
|
||||||
{
|
{
|
||||||
LOG_TR("Sending cursor style request");
|
LOG_TR(("Sending cursor style request"));
|
||||||
out_str(T_CRS);
|
out_str(T_CRS);
|
||||||
rcs_status = STATUS_SENT;
|
rcs_status = STATUS_SENT;
|
||||||
need_flush = TRUE;
|
need_flush = TRUE;
|
||||||
@@ -4701,7 +4699,7 @@ check_termcode(
|
|||||||
&& !is_not_xterm
|
&& !is_not_xterm
|
||||||
&& *T_CRC != NUL)
|
&& *T_CRC != NUL)
|
||||||
{
|
{
|
||||||
LOG_TR("Sending cursor blink mode request");
|
LOG_TR(("Sending cursor blink mode request"));
|
||||||
out_str(T_CRC);
|
out_str(T_CRC);
|
||||||
rbm_status = STATUS_SENT;
|
rbm_status = STATUS_SENT;
|
||||||
need_flush = TRUE;
|
need_flush = TRUE;
|
||||||
@@ -4737,7 +4735,7 @@ check_termcode(
|
|||||||
{
|
{
|
||||||
initial_cursor_blink = (tp[j + 4] == '1');
|
initial_cursor_blink = (tp[j + 4] == '1');
|
||||||
rbm_status = STATUS_GOT;
|
rbm_status = STATUS_GOT;
|
||||||
LOG_TR("Received cursor blinking mode response");
|
LOG_TR(("Received cursor blinking mode response: %s", tp));
|
||||||
key_name[0] = (int)KS_EXTRA;
|
key_name[0] = (int)KS_EXTRA;
|
||||||
key_name[1] = (int)KE_IGNORE;
|
key_name[1] = (int)KE_IGNORE;
|
||||||
slen = i + 1;
|
slen = i + 1;
|
||||||
@@ -4779,7 +4777,7 @@ check_termcode(
|
|||||||
}
|
}
|
||||||
if (i == len)
|
if (i == len)
|
||||||
{
|
{
|
||||||
LOG_TR("not enough characters for winpos");
|
LOG_TR(("not enough characters for winpos"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4825,7 +4823,7 @@ check_termcode(
|
|||||||
char *newval = (3 * '6' < tp[j+7] + tp[j+12]
|
char *newval = (3 * '6' < tp[j+7] + tp[j+12]
|
||||||
+ tp[j+17]) ? "light" : "dark";
|
+ tp[j+17]) ? "light" : "dark";
|
||||||
|
|
||||||
LOG_TR("Received RBG response");
|
LOG_TR(("Received RBG response: %s", tp));
|
||||||
rbg_status = STATUS_GOT;
|
rbg_status = STATUS_GOT;
|
||||||
#ifdef FEAT_TERMINAL
|
#ifdef FEAT_TERMINAL
|
||||||
bg_r = rval;
|
bg_r = rval;
|
||||||
@@ -4845,7 +4843,7 @@ check_termcode(
|
|||||||
#ifdef FEAT_TERMINAL
|
#ifdef FEAT_TERMINAL
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LOG_TR("Received RFG response");
|
LOG_TR(("Received RFG response: %s", tp));
|
||||||
rfg_status = STATUS_GOT;
|
rfg_status = STATUS_GOT;
|
||||||
fg_r = rval;
|
fg_r = rval;
|
||||||
fg_g = gval;
|
fg_g = gval;
|
||||||
@@ -4866,7 +4864,7 @@ check_termcode(
|
|||||||
}
|
}
|
||||||
if (i == len)
|
if (i == len)
|
||||||
{
|
{
|
||||||
LOG_TR("not enough characters for RB");
|
LOG_TR(("not enough characters for RB"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4940,7 +4938,7 @@ check_termcode(
|
|||||||
initial_cursor_shape_blink =
|
initial_cursor_shape_blink =
|
||||||
(number & 1) ? FALSE : TRUE;
|
(number & 1) ? FALSE : TRUE;
|
||||||
rcs_status = STATUS_GOT;
|
rcs_status = STATUS_GOT;
|
||||||
LOG_TR("Received cursor shape response");
|
LOG_TR(("Received cursor shape response: %s", tp));
|
||||||
|
|
||||||
key_name[0] = (int)KS_EXTRA;
|
key_name[0] = (int)KS_EXTRA;
|
||||||
key_name[1] = (int)KE_IGNORE;
|
key_name[1] = (int)KE_IGNORE;
|
||||||
@@ -4957,7 +4955,7 @@ check_termcode(
|
|||||||
{
|
{
|
||||||
/* These codes arrive many together, each code can be
|
/* These codes arrive many together, each code can be
|
||||||
* truncated at any point. */
|
* truncated at any point. */
|
||||||
LOG_TR("not enough characters for XT");
|
LOG_TR(("not enough characters for XT"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5910,7 +5908,7 @@ check_termcode(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef FEAT_TERMRESPONSE
|
#ifdef FEAT_TERMRESPONSE
|
||||||
LOG_TR("normal character");
|
LOG_TR(("normal character"));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return 0; /* no match found */
|
return 0; /* no match found */
|
||||||
@@ -6393,15 +6391,10 @@ req_more_codes_from_term(void)
|
|||||||
* many, there can be a buffer overflow somewhere. */
|
* many, there can be a buffer overflow somewhere. */
|
||||||
while (xt_index_out < xt_index_in + 10 && key_names[xt_index_out] != NULL)
|
while (xt_index_out < xt_index_in + 10 && key_names[xt_index_out] != NULL)
|
||||||
{
|
{
|
||||||
# ifdef DEBUG_TERMRESPONSE
|
char *key_name = key_names[xt_index_out];
|
||||||
char dbuf[100];
|
|
||||||
|
|
||||||
sprintf(dbuf, "Requesting XT %d: %s",
|
LOG_TR(("Requesting XT %d: %s", xt_index_out, key_name));
|
||||||
xt_index_out, key_names[xt_index_out]);
|
sprintf(buf, "\033P+q%02x%02x\033\\", key_name[0], key_name[1]);
|
||||||
log_tr(dbuf);
|
|
||||||
# endif
|
|
||||||
sprintf(buf, "\033P+q%02x%02x\033\\",
|
|
||||||
key_names[xt_index_out][0], key_names[xt_index_out][1]);
|
|
||||||
out_str_nf((char_u *)buf);
|
out_str_nf((char_u *)buf);
|
||||||
++xt_index_out;
|
++xt_index_out;
|
||||||
}
|
}
|
||||||
@@ -6444,14 +6437,9 @@ got_code_from_term(char_u *code, int len)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# ifdef DEBUG_TERMRESPONSE
|
|
||||||
{
|
|
||||||
char buf[100];
|
|
||||||
|
|
||||||
sprintf(buf, "Received XT %d: %s", xt_index_in, (char *)name);
|
LOG_TR(("Received XT %d: %s", xt_index_in, (char *)name));
|
||||||
log_tr(buf);
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
if (key_names[i] != NULL)
|
if (key_names[i] != NULL)
|
||||||
{
|
{
|
||||||
for (i = 8; (c = hexhex2nr(code + i)) >= 0; i += 2)
|
for (i = 8; (c = hexhex2nr(code + i)) >= 0; i += 2)
|
||||||
|
|||||||
@@ -761,6 +761,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 */
|
||||||
|
/**/
|
||||||
|
1762,
|
||||||
/**/
|
/**/
|
||||||
1761,
|
1761,
|
||||||
/**/
|
/**/
|
||||||
|
|||||||
Reference in New Issue
Block a user