To: vim_dev@googlegroups.com Subject: Patch 8.2.1595 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.1595 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. Files: src/term.c, src/globals.h, src/edit.c, src/normal.c, src/optionstr.c *** ../vim-8.2.1594/src/term.c 2020-08-23 14:28:24.107838497 +0200 --- src/term.c 2020-09-05 14:21:45.855301895 +0200 *************** *** 43,49 **** # ifdef HAVE_OUTFUNTYPE # define TPUTSFUNCAST (outfuntype) # else ! # define TPUTSFUNCAST (int (*)()) # endif # endif #endif --- 43,49 ---- # ifdef HAVE_OUTFUNTYPE # define TPUTSFUNCAST (outfuntype) # else ! # define TPUTSFUNCAST (int (*)(int)) # endif # endif #endif *************** *** 2515,2520 **** --- 2515,2528 ---- len = out_pos; out_pos = 0; 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,2598 **** /* * Output "c" like out_char(), but don't flush when p_wd is set. */ ! static void ! out_char_nf(unsigned c) { ! out_buf[out_pos++] = c; if (out_pos >= OUT_SIZE) out_flush(); } /* --- 2594,2607 ---- /* * Output "c" like out_char(), but don't flush when p_wd is set. */ ! static int ! out_char_nf(int c) { ! out_buf[out_pos++] = (unsigned)c; if (out_pos >= OUT_SIZE) out_flush(); + return (unsigned)c; } /* *************** *** 3031,3036 **** --- 3040,3048 ---- void term_settitle(char_u *title) { + #ifdef FEAT_JOB_CHANNEL + ch_log_output = TRUE; + #endif // t_ts takes one argument: column in status line OUT_STR(tgoto((char *)T_TS, 0, 0)); // set title start out_str_nf(title); *************** *** 3529,3534 **** --- 3541,3549 ---- if (termcap_active && tmode != TMODE_SLEEP && cur_tmode != TMODE_SLEEP) { + #ifdef FEAT_JOB_CHANNEL + ch_log_output = TRUE; + #endif if (tmode != TMODE_RAW) { out_str(T_BD); // disable bracketed paste mode *************** *** 3559,3564 **** --- 3574,3582 ---- { if (full_screen && !termcap_active) { + #ifdef FEAT_JOB_CHANNEL + ch_log_output = TRUE; + #endif out_str(T_TI); // start termcap mode out_str(T_CTI); // start "raw" mode out_str(T_KS); // start "keypad transmit" mode *************** *** 3611,3616 **** --- 3629,3637 ---- check_for_codes_from_term(); } #endif + #ifdef FEAT_JOB_CHANNEL + ch_log_output = TRUE; + #endif out_str(T_BD); // disable bracketed paste mode out_str(T_KE); // stop "keypad transmit" mode out_flush(); *************** *** 3646,3651 **** --- 3667,3675 ---- && starting == 0 && *T_CRV != NUL) { + #ifdef FEAT_JOB_CHANNEL + ch_log_output = TRUE; + #endif LOG_TR(("Sending CRV request")); out_str(T_CRV); termrequest_sent(&crv_status); *************** *** 3684,3689 **** --- 3708,3716 ---- // width, that will be (1, 2). This function has the side effect that // changes cursor position, so it must be called immediately after // entering termcap mode. + #ifdef FEAT_JOB_CHANNEL + ch_log_output = TRUE; + #endif LOG_TR(("Sending request for ambiwidth check")); // Do this in the second row. In the first row the returned sequence // may be CSI 1;2R, which is the same as . *************** *** 3712,3717 **** --- 3739,3747 ---- // sequence is ignored and the cursor does not move. If the terminal // handles test sequence incorrectly, a garbage string is displayed and // the cursor does move. + #ifdef FEAT_JOB_CHANNEL + ch_log_output = TRUE; + #endif LOG_TR(("Sending xterm compatibility test sequence.")); // Do this in the third row. Second row is used by ambiguous // chararacter width check. *************** *** 3762,3767 **** --- 3792,3800 ---- // Only request foreground if t_RF is set. if (rfg_status.tr_progress == STATUS_GET && *T_RFG != NUL) { + #ifdef FEAT_JOB_CHANNEL + ch_log_output = TRUE; + #endif LOG_TR(("Sending FG request")); out_str(T_RFG); termrequest_sent(&rfg_status); *************** *** 3772,3777 **** --- 3805,3813 ---- // Only request background if t_RB is set. if (rbg_status.tr_progress == STATUS_GET && *T_RBG != NUL) { + #ifdef FEAT_JOB_CHANNEL + ch_log_output = TRUE; + #endif LOG_TR(("Sending BG request")); out_str(T_RBG); termrequest_sent(&rbg_status); *************** *** 3835,3840 **** --- 3871,3879 ---- { if (*T_VS != NUL && *T_CVS != NUL) { + #ifdef FEAT_JOB_CHANNEL + ch_log_output = TRUE; + #endif out_str(T_VS); out_str(T_CVS); screen_start(); // don't know where cursor is now *************** *** 4685,4690 **** --- 4724,4732 ---- && *T_CSH != NUL && *T_CRS != NUL) { + #ifdef FEAT_JOB_CHANNEL + ch_log_output = TRUE; + #endif LOG_TR(("Sending cursor style request")); out_str(T_CRS); termrequest_sent(&rcs_status); *************** *** 4699,4704 **** --- 4741,4749 ---- && term_props[TPR_CURSOR_BLINK].tpr_status == TPR_YES && *T_CRC != NUL) { + #ifdef FEAT_JOB_CHANNEL + ch_log_output = TRUE; + #endif LOG_TR(("Sending cursor blink mode request")); out_str(T_CRC); termrequest_sent(&rbm_status); *************** *** 6120,6125 **** --- 6165,6173 ---- { 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)); sprintf(buf, "\033P+q%02x%02x\033\\", key_name[0], key_name[1]); out_str_nf((char_u *)buf); *** ../vim-8.2.1594/src/globals.h 2020-09-02 21:21:30.964799806 +0200 --- src/globals.h 2020-09-05 14:02:17.269249855 +0200 *************** *** 1898,1903 **** --- 1898,1907 ---- # define REPEATED_MSG_LOOKING 1 # 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) \ for ((ch) = first_channel; (ch) != NULL; (ch) = (ch)->ch_next) #define FOR_ALL_JOBS(job) \ *** ../vim-8.2.1594/src/edit.c 2020-09-04 16:35:06.425571289 +0200 --- src/edit.c 2020-09-05 14:07:23.616925571 +0200 *************** *** 315,320 **** --- 315,323 ---- #endif if (!p_ek) { + #ifdef FEAT_JOB_CHANNEL + ch_log_output = TRUE; + #endif // Disable bracketed paste mode, we won't recognize the escape // sequences. out_str(T_BD); *************** *** 3724,3729 **** --- 3727,3735 ---- #endif if (!p_ek) { + #ifdef FEAT_JOB_CHANNEL + ch_log_output = TRUE; + #endif // Re-enable bracketed paste mode. out_str(T_BE); *** ../vim-8.2.1594/src/normal.c 2020-08-30 20:46:34.470356761 +0200 --- src/normal.c 2020-09-05 14:07:13.904939106 +0200 *************** *** 897,902 **** --- 897,905 ---- #endif if ((State & INSERT) && !p_ek) { + #ifdef FEAT_JOB_CHANNEL + ch_log_output = TRUE; + #endif // Disable bracketed paste and modifyOtherKeys here, we won't // recognize the escape sequences with 'esckeys' off. out_str(T_BD); *************** *** 907,912 **** --- 910,918 ---- if ((State & INSERT) && !p_ek) { + #ifdef FEAT_JOB_CHANNEL + ch_log_output = TRUE; + #endif // Re-enable bracketed paste mode and modifyOtherKeys out_str(T_BE); out_str(T_CTI); *** ../vim-8.2.1594/src/optionstr.c 2020-07-20 21:31:01.268823457 +0200 --- src/optionstr.c 2020-09-05 14:05:46.369052732 +0200 *************** *** 1434,1439 **** --- 1434,1442 ---- } if (varp == &T_BE && termcap_active) { + #ifdef FEAT_JOB_CHANNEL + ch_log_output = TRUE; + #endif if (*T_BE == NUL) // When clearing t_BE we assume the user no longer wants // bracketed paste, thus disable it by writing t_BD. *** ../vim-8.2.1594/src/version.c 2020-09-05 13:48:35.742661008 +0200 --- src/version.c 2020-09-05 14:26:41.786650210 +0200 *************** *** 756,757 **** --- 756,759 ---- { /* Add new patch number below this line */ + /**/ + 1595, /**/ -- ARTHUR: Be quiet! DENNIS: Well you can't expect to wield supreme executive power just 'cause some watery tart threw a sword at you! ARTHUR: Shut up! DENNIS: I mean, if I went around sayin' I was an empereror just because some moistened bint had lobbed a scimitar at me they'd put me away! The Quest for the Holy Grail (Monty Python) /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///