mirror of
https://github.com/vim/vim.git
synced 2025-09-27 04:14:06 -04:00
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Problem: Cannot easily see what Vim sends to the terminal. Solution: Write output to the channel log if it contains terminal control sequences. Avoid warnings for tputs() argument.
This commit is contained in:
@@ -315,6 +315,9 @@ edit(
|
|||||||
#endif
|
#endif
|
||||||
if (!p_ek)
|
if (!p_ek)
|
||||||
{
|
{
|
||||||
|
#ifdef FEAT_JOB_CHANNEL
|
||||||
|
ch_log_output = TRUE;
|
||||||
|
#endif
|
||||||
// Disable bracketed paste mode, we won't recognize the escape
|
// Disable bracketed paste mode, we won't recognize the escape
|
||||||
// sequences.
|
// sequences.
|
||||||
out_str(T_BD);
|
out_str(T_BD);
|
||||||
@@ -3724,6 +3727,9 @@ ins_esc(
|
|||||||
#endif
|
#endif
|
||||||
if (!p_ek)
|
if (!p_ek)
|
||||||
{
|
{
|
||||||
|
#ifdef FEAT_JOB_CHANNEL
|
||||||
|
ch_log_output = TRUE;
|
||||||
|
#endif
|
||||||
// Re-enable bracketed paste mode.
|
// Re-enable bracketed paste mode.
|
||||||
out_str(T_BE);
|
out_str(T_BE);
|
||||||
|
|
||||||
|
@@ -1898,6 +1898,10 @@ EXTERN int did_repeated_msg INIT(= 0);
|
|||||||
# define REPEATED_MSG_LOOKING 1
|
# define REPEATED_MSG_LOOKING 1
|
||||||
# define REPEATED_MSG_SAFESTATE 2
|
# define REPEATED_MSG_SAFESTATE 2
|
||||||
|
|
||||||
|
// This flag is set when outputting a terminal control code and reset in
|
||||||
|
// out_flush() when characters have been written.
|
||||||
|
EXTERN int ch_log_output INIT(= FALSE);
|
||||||
|
|
||||||
#define FOR_ALL_CHANNELS(ch) \
|
#define FOR_ALL_CHANNELS(ch) \
|
||||||
for ((ch) = first_channel; (ch) != NULL; (ch) = (ch)->ch_next)
|
for ((ch) = first_channel; (ch) != NULL; (ch) = (ch)->ch_next)
|
||||||
#define FOR_ALL_JOBS(job) \
|
#define FOR_ALL_JOBS(job) \
|
||||||
|
@@ -897,6 +897,9 @@ getcount:
|
|||||||
#endif
|
#endif
|
||||||
if ((State & INSERT) && !p_ek)
|
if ((State & INSERT) && !p_ek)
|
||||||
{
|
{
|
||||||
|
#ifdef FEAT_JOB_CHANNEL
|
||||||
|
ch_log_output = TRUE;
|
||||||
|
#endif
|
||||||
// Disable bracketed paste and modifyOtherKeys here, we won't
|
// Disable bracketed paste and modifyOtherKeys here, we won't
|
||||||
// recognize the escape sequences with 'esckeys' off.
|
// recognize the escape sequences with 'esckeys' off.
|
||||||
out_str(T_BD);
|
out_str(T_BD);
|
||||||
@@ -907,6 +910,9 @@ getcount:
|
|||||||
|
|
||||||
if ((State & INSERT) && !p_ek)
|
if ((State & INSERT) && !p_ek)
|
||||||
{
|
{
|
||||||
|
#ifdef FEAT_JOB_CHANNEL
|
||||||
|
ch_log_output = TRUE;
|
||||||
|
#endif
|
||||||
// Re-enable bracketed paste mode and modifyOtherKeys
|
// Re-enable bracketed paste mode and modifyOtherKeys
|
||||||
out_str(T_BE);
|
out_str(T_BE);
|
||||||
out_str(T_CTI);
|
out_str(T_CTI);
|
||||||
|
@@ -1434,6 +1434,9 @@ did_set_string_option(
|
|||||||
}
|
}
|
||||||
if (varp == &T_BE && termcap_active)
|
if (varp == &T_BE && termcap_active)
|
||||||
{
|
{
|
||||||
|
#ifdef FEAT_JOB_CHANNEL
|
||||||
|
ch_log_output = TRUE;
|
||||||
|
#endif
|
||||||
if (*T_BE == NUL)
|
if (*T_BE == NUL)
|
||||||
// When clearing t_BE we assume the user no longer wants
|
// When clearing t_BE we assume the user no longer wants
|
||||||
// bracketed paste, thus disable it by writing t_BD.
|
// bracketed paste, thus disable it by writing t_BD.
|
||||||
|
56
src/term.c
56
src/term.c
@@ -43,7 +43,7 @@
|
|||||||
# ifdef HAVE_OUTFUNTYPE
|
# ifdef HAVE_OUTFUNTYPE
|
||||||
# define TPUTSFUNCAST (outfuntype)
|
# define TPUTSFUNCAST (outfuntype)
|
||||||
# else
|
# else
|
||||||
# define TPUTSFUNCAST (int (*)())
|
# define TPUTSFUNCAST (int (*)(int))
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
@@ -2515,6 +2515,14 @@ out_flush(void)
|
|||||||
len = out_pos;
|
len = out_pos;
|
||||||
out_pos = 0;
|
out_pos = 0;
|
||||||
ui_write(out_buf, len);
|
ui_write(out_buf, len);
|
||||||
|
#ifdef FEAT_JOB_CHANNEL
|
||||||
|
if (ch_log_output)
|
||||||
|
{
|
||||||
|
out_buf[len] = NUL;
|
||||||
|
ch_log(NULL, "raw terminal output: \"%s\"", out_buf);
|
||||||
|
ch_log_output = FALSE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2586,13 +2594,14 @@ out_char(unsigned c)
|
|||||||
/*
|
/*
|
||||||
* Output "c" like out_char(), but don't flush when p_wd is set.
|
* Output "c" like out_char(), but don't flush when p_wd is set.
|
||||||
*/
|
*/
|
||||||
static void
|
static int
|
||||||
out_char_nf(unsigned c)
|
out_char_nf(int c)
|
||||||
{
|
{
|
||||||
out_buf[out_pos++] = c;
|
out_buf[out_pos++] = (unsigned)c;
|
||||||
|
|
||||||
if (out_pos >= OUT_SIZE)
|
if (out_pos >= OUT_SIZE)
|
||||||
out_flush();
|
out_flush();
|
||||||
|
return (unsigned)c;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -3031,6 +3040,9 @@ term_ul_rgb_color(guicolor_T rgb)
|
|||||||
void
|
void
|
||||||
term_settitle(char_u *title)
|
term_settitle(char_u *title)
|
||||||
{
|
{
|
||||||
|
#ifdef FEAT_JOB_CHANNEL
|
||||||
|
ch_log_output = TRUE;
|
||||||
|
#endif
|
||||||
// t_ts takes one argument: column in status line
|
// t_ts takes one argument: column in status line
|
||||||
OUT_STR(tgoto((char *)T_TS, 0, 0)); // set title start
|
OUT_STR(tgoto((char *)T_TS, 0, 0)); // set title start
|
||||||
out_str_nf(title);
|
out_str_nf(title);
|
||||||
@@ -3529,6 +3541,9 @@ settmode(tmode_T tmode)
|
|||||||
if (termcap_active && tmode != TMODE_SLEEP
|
if (termcap_active && tmode != TMODE_SLEEP
|
||||||
&& cur_tmode != TMODE_SLEEP)
|
&& cur_tmode != TMODE_SLEEP)
|
||||||
{
|
{
|
||||||
|
#ifdef FEAT_JOB_CHANNEL
|
||||||
|
ch_log_output = TRUE;
|
||||||
|
#endif
|
||||||
if (tmode != TMODE_RAW)
|
if (tmode != TMODE_RAW)
|
||||||
{
|
{
|
||||||
out_str(T_BD); // disable bracketed paste mode
|
out_str(T_BD); // disable bracketed paste mode
|
||||||
@@ -3559,6 +3574,9 @@ starttermcap(void)
|
|||||||
{
|
{
|
||||||
if (full_screen && !termcap_active)
|
if (full_screen && !termcap_active)
|
||||||
{
|
{
|
||||||
|
#ifdef FEAT_JOB_CHANNEL
|
||||||
|
ch_log_output = TRUE;
|
||||||
|
#endif
|
||||||
out_str(T_TI); // start termcap mode
|
out_str(T_TI); // start termcap mode
|
||||||
out_str(T_CTI); // start "raw" mode
|
out_str(T_CTI); // start "raw" mode
|
||||||
out_str(T_KS); // start "keypad transmit" mode
|
out_str(T_KS); // start "keypad transmit" mode
|
||||||
@@ -3610,6 +3628,9 @@ stoptermcap(void)
|
|||||||
// get them.
|
// get them.
|
||||||
check_for_codes_from_term();
|
check_for_codes_from_term();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef FEAT_JOB_CHANNEL
|
||||||
|
ch_log_output = TRUE;
|
||||||
#endif
|
#endif
|
||||||
out_str(T_BD); // disable bracketed paste mode
|
out_str(T_BD); // disable bracketed paste mode
|
||||||
out_str(T_KE); // stop "keypad transmit" mode
|
out_str(T_KE); // stop "keypad transmit" mode
|
||||||
@@ -3646,6 +3667,9 @@ may_req_termresponse(void)
|
|||||||
&& starting == 0
|
&& starting == 0
|
||||||
&& *T_CRV != NUL)
|
&& *T_CRV != NUL)
|
||||||
{
|
{
|
||||||
|
#ifdef FEAT_JOB_CHANNEL
|
||||||
|
ch_log_output = TRUE;
|
||||||
|
#endif
|
||||||
LOG_TR(("Sending CRV request"));
|
LOG_TR(("Sending CRV request"));
|
||||||
out_str(T_CRV);
|
out_str(T_CRV);
|
||||||
termrequest_sent(&crv_status);
|
termrequest_sent(&crv_status);
|
||||||
@@ -3684,6 +3708,9 @@ check_terminal_behavior(void)
|
|||||||
// width, that will be (1, 2). This function has the side effect that
|
// width, that will be (1, 2). This function has the side effect that
|
||||||
// changes cursor position, so it must be called immediately after
|
// changes cursor position, so it must be called immediately after
|
||||||
// entering termcap mode.
|
// entering termcap mode.
|
||||||
|
#ifdef FEAT_JOB_CHANNEL
|
||||||
|
ch_log_output = TRUE;
|
||||||
|
#endif
|
||||||
LOG_TR(("Sending request for ambiwidth check"));
|
LOG_TR(("Sending request for ambiwidth check"));
|
||||||
// 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>.
|
||||||
@@ -3712,6 +3739,9 @@ check_terminal_behavior(void)
|
|||||||
// sequence is ignored and the cursor does not move. If the terminal
|
// sequence is ignored and the cursor does not move. If the terminal
|
||||||
// handles test sequence incorrectly, a garbage string is displayed and
|
// handles test sequence incorrectly, a garbage string is displayed and
|
||||||
// the cursor does move.
|
// the cursor does move.
|
||||||
|
#ifdef FEAT_JOB_CHANNEL
|
||||||
|
ch_log_output = TRUE;
|
||||||
|
#endif
|
||||||
LOG_TR(("Sending xterm compatibility test sequence."));
|
LOG_TR(("Sending xterm compatibility test sequence."));
|
||||||
// Do this in the third row. Second row is used by ambiguous
|
// Do this in the third row. Second row is used by ambiguous
|
||||||
// chararacter width check.
|
// chararacter width check.
|
||||||
@@ -3762,6 +3792,9 @@ may_req_bg_color(void)
|
|||||||
// Only request foreground if t_RF is set.
|
// Only request foreground if t_RF is set.
|
||||||
if (rfg_status.tr_progress == STATUS_GET && *T_RFG != NUL)
|
if (rfg_status.tr_progress == STATUS_GET && *T_RFG != NUL)
|
||||||
{
|
{
|
||||||
|
#ifdef FEAT_JOB_CHANNEL
|
||||||
|
ch_log_output = TRUE;
|
||||||
|
#endif
|
||||||
LOG_TR(("Sending FG request"));
|
LOG_TR(("Sending FG request"));
|
||||||
out_str(T_RFG);
|
out_str(T_RFG);
|
||||||
termrequest_sent(&rfg_status);
|
termrequest_sent(&rfg_status);
|
||||||
@@ -3772,6 +3805,9 @@ may_req_bg_color(void)
|
|||||||
// Only request background if t_RB is set.
|
// Only request background if t_RB is set.
|
||||||
if (rbg_status.tr_progress == STATUS_GET && *T_RBG != NUL)
|
if (rbg_status.tr_progress == STATUS_GET && *T_RBG != NUL)
|
||||||
{
|
{
|
||||||
|
#ifdef FEAT_JOB_CHANNEL
|
||||||
|
ch_log_output = TRUE;
|
||||||
|
#endif
|
||||||
LOG_TR(("Sending BG request"));
|
LOG_TR(("Sending BG request"));
|
||||||
out_str(T_RBG);
|
out_str(T_RBG);
|
||||||
termrequest_sent(&rbg_status);
|
termrequest_sent(&rbg_status);
|
||||||
@@ -3835,6 +3871,9 @@ scroll_start(void)
|
|||||||
{
|
{
|
||||||
if (*T_VS != NUL && *T_CVS != NUL)
|
if (*T_VS != NUL && *T_CVS != NUL)
|
||||||
{
|
{
|
||||||
|
#ifdef FEAT_JOB_CHANNEL
|
||||||
|
ch_log_output = TRUE;
|
||||||
|
#endif
|
||||||
out_str(T_VS);
|
out_str(T_VS);
|
||||||
out_str(T_CVS);
|
out_str(T_CVS);
|
||||||
screen_start(); // don't know where cursor is now
|
screen_start(); // don't know where cursor is now
|
||||||
@@ -4685,6 +4724,9 @@ handle_version_response(int first, int *arg, int argc, char_u *tp)
|
|||||||
&& *T_CSH != NUL
|
&& *T_CSH != NUL
|
||||||
&& *T_CRS != NUL)
|
&& *T_CRS != NUL)
|
||||||
{
|
{
|
||||||
|
#ifdef FEAT_JOB_CHANNEL
|
||||||
|
ch_log_output = TRUE;
|
||||||
|
#endif
|
||||||
LOG_TR(("Sending cursor style request"));
|
LOG_TR(("Sending cursor style request"));
|
||||||
out_str(T_CRS);
|
out_str(T_CRS);
|
||||||
termrequest_sent(&rcs_status);
|
termrequest_sent(&rcs_status);
|
||||||
@@ -4699,6 +4741,9 @@ handle_version_response(int first, int *arg, int argc, char_u *tp)
|
|||||||
&& term_props[TPR_CURSOR_BLINK].tpr_status == TPR_YES
|
&& term_props[TPR_CURSOR_BLINK].tpr_status == TPR_YES
|
||||||
&& *T_CRC != NUL)
|
&& *T_CRC != NUL)
|
||||||
{
|
{
|
||||||
|
#ifdef FEAT_JOB_CHANNEL
|
||||||
|
ch_log_output = TRUE;
|
||||||
|
#endif
|
||||||
LOG_TR(("Sending cursor blink mode request"));
|
LOG_TR(("Sending cursor blink mode request"));
|
||||||
out_str(T_CRC);
|
out_str(T_CRC);
|
||||||
termrequest_sent(&rbm_status);
|
termrequest_sent(&rbm_status);
|
||||||
@@ -6120,6 +6165,9 @@ req_more_codes_from_term(void)
|
|||||||
{
|
{
|
||||||
char *key_name = key_names[xt_index_out];
|
char *key_name = key_names[xt_index_out];
|
||||||
|
|
||||||
|
#ifdef FEAT_JOB_CHANNEL
|
||||||
|
ch_log_output = TRUE;
|
||||||
|
#endif
|
||||||
LOG_TR(("Requesting XT %d: %s", xt_index_out, key_name));
|
LOG_TR(("Requesting XT %d: %s", xt_index_out, key_name));
|
||||||
sprintf(buf, "\033P+q%02x%02x\033\\", key_name[0], key_name[1]);
|
sprintf(buf, "\033P+q%02x%02x\033\\", key_name[0], key_name[1]);
|
||||||
out_str_nf((char_u *)buf);
|
out_str_nf((char_u *)buf);
|
||||||
|
@@ -754,6 +754,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 */
|
||||||
|
/**/
|
||||||
|
1595,
|
||||||
/**/
|
/**/
|
||||||
1594,
|
1594,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user