To: vim_dev@googlegroups.com Subject: Patch 8.2.5056 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.5056 Problem: The channel log only contains some of the raw terminal output. Solution: Add the "o" flag to log all terminal output. Use it for "--log". Files: runtime/doc/channel.txt, runtime/doc/starting.txt, src/main.c, src/channel.c, src/vim.h, src/term.c, src/edit.c, src/normal.c, src/optionstr.c *** ../vim-8.2.5055/runtime/doc/channel.txt 2022-05-22 14:48:26.323247294 +0100 --- runtime/doc/channel.txt 2022-06-04 21:46:48.836883656 +0100 *************** *** 628,642 **** Start logging channel activity to {fname}. When {fname} is an empty string: stop logging. ! When {mode} is omitted or "a" append to the file. ! When {mode} is "w" start with an empty file. Use |ch_log()| to write log messages. The file is flushed after every message, on Unix you can use "tail -f" to see what is going on in real time. To enable the log very early, to see what is received from a ! terminal during startup, use |--log|: > vim --log logfile < This function is not available in the |sandbox|. --- 628,645 ---- Start logging channel activity to {fname}. When {fname} is an empty string: stop logging. ! When {mode} is omitted or contains "a" or is "o" then append ! to the file. ! When {mode} contains "w" and not "a" start with an empty file. ! When {mode} contains "o" then log all terminal output. ! Otherwise only some interesting terminal output is logged. Use |ch_log()| to write log messages. The file is flushed after every message, on Unix you can use "tail -f" to see what is going on in real time. To enable the log very early, to see what is received from a ! terminal during startup, use |--log| (this uses mode "ao"): > vim --log logfile < This function is not available in the |sandbox|. *** ../vim-8.2.5055/runtime/doc/starting.txt 2022-05-22 14:48:26.339247289 +0100 --- runtime/doc/starting.txt 2022-06-04 22:07:45.885029423 +0100 *************** *** 346,352 **** < --log {filename} *--log* Start logging and write entries to {filename}. ! This works like calling `ch_logfile({filename}, 'a')` very early during startup. {only available with the +channel feature} --- 346,352 ---- < --log {filename} *--log* Start logging and write entries to {filename}. ! This works like calling `ch_logfile({filename}, 'ao')` very early during startup. {only available with the +channel feature} *** ../vim-8.2.5055/src/main.c 2022-05-21 20:16:51.007567185 +0100 --- src/main.c 2022-06-04 21:44:30.501063862 +0100 *************** *** 152,158 **** # endif # ifdef FEAT_JOB_CHANNEL if (STRICMP(argv[i], "--log") == 0) ! ch_logfile((char_u *)(argv[i + 1]), (char_u *)"a"); # endif } #endif --- 152,158 ---- # endif # ifdef FEAT_JOB_CHANNEL if (STRICMP(argv[i], "--log") == 0) ! ch_logfile((char_u *)(argv[i + 1]), (char_u *)"ao"); # endif } #endif *** ../vim-8.2.5055/src/channel.c 2022-05-09 20:09:19.278641427 +0100 --- src/channel.c 2022-06-04 22:10:23.041040566 +0100 *************** *** 152,158 **** void ch_logfile(char_u *fname, char_u *opt) { ! FILE *file = NULL; if (log_fd != NULL) { --- 152,159 ---- void ch_logfile(char_u *fname, char_u *opt) { ! FILE *file = NULL; ! char *mode = "a"; if (log_fd != NULL) { *************** *** 163,171 **** fclose(log_fd); } if (*fname != NUL) { ! file = fopen((char *)fname, *opt == 'w' ? "w" : "a"); if (file == NULL) { semsg(_(e_cant_open_file_str), fname); --- 164,177 ---- fclose(log_fd); } + // The "a" flag overrules the "w" flag. + if (vim_strchr(opt, 'a') == NULL && vim_strchr(opt, 'w') != NULL) + mode = "w"; + ch_log_output = vim_strchr(opt, 'o') != NULL ? LOG_ALWAYS : FALSE; + if (*fname != NUL) { ! file = fopen((char *)fname, mode); if (file == NULL) { semsg(_(e_cant_open_file_str), fname); *** ../vim-8.2.5055/src/vim.h 2022-05-23 13:10:39.726713326 +0100 --- src/vim.h 2022-06-04 22:11:19.141037347 +0100 *************** *** 1479,1484 **** --- 1479,1495 ---- #define MAYBE 2 // sometimes used for a variant on TRUE + #define LOG_ALWAYS 9 // must be different from TRUE and FALSE + + #ifdef FEAT_JOB_CHANNEL + // If "--log logfile" was used or ch_logfile() was called then log some or all + // terminal output. + # define MAY_WANT_TO_LOG_THIS if (ch_log_output == FALSE) ch_log_output = TRUE; + #else + // no logging support + # define MAY_WANT_TO_LOG_THIS + #endif + #ifndef UINT32_T typedef UINT32_TYPEDEF UINT32_T; #endif *** ../vim-8.2.5055/src/term.c 2022-05-20 10:10:29.948122642 +0100 --- src/term.c 2022-06-04 22:12:00.893032856 +0100 *************** *** 2570,2576 **** out_pos = 0; ui_write(out_buf, len, FALSE); #ifdef FEAT_JOB_CHANNEL ! if (ch_log_output) { out_buf[len] = NUL; ch_log(NULL, "raw %s output: \"%s\"", --- 2570,2576 ---- out_pos = 0; ui_write(out_buf, len, FALSE); #ifdef FEAT_JOB_CHANNEL ! if (ch_log_output != FALSE) { out_buf[len] = NUL; ch_log(NULL, "raw %s output: \"%s\"", *************** *** 2579,2585 **** # endif "terminal", out_buf); ! ch_log_output = FALSE; } #endif } --- 2579,2586 ---- # endif "terminal", out_buf); ! if (ch_log_output == TRUE) ! ch_log_output = FALSE; // only log once } #endif } *************** *** 3106,3114 **** 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); --- 3107,3114 ---- void term_settitle(char_u *title) { ! MAY_WANT_TO_LOG_THIS; ! // t_ts takes one argument: column in status line OUT_STR(tgoto((char *)T_TS, 0, 0)); // set title start out_str_nf(title); *************** *** 3610,3618 **** 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 --- 3610,3617 ---- if (termcap_active && tmode != TMODE_SLEEP && cur_tmode != TMODE_SLEEP) { ! MAY_WANT_TO_LOG_THIS; ! if (tmode != TMODE_RAW) { out_str(T_BD); // disable bracketed paste mode *************** *** 3643,3651 **** { 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 --- 3642,3649 ---- { if (full_screen && !termcap_active) { ! MAY_WANT_TO_LOG_THIS; ! out_str(T_TI); // start termcap mode out_str(T_CTI); // start "raw" mode out_str(T_KS); // start "keypad transmit" mode *************** *** 3705,3713 **** check_for_codes_from_term(); } #endif ! #ifdef FEAT_JOB_CHANNEL ! ch_log_output = TRUE; ! #endif #if defined(UNIX) || defined(VMS) // Disable xterm's focus reporting mode if 'esckeys' is set. --- 3703,3709 ---- check_for_codes_from_term(); } #endif ! MAY_WANT_TO_LOG_THIS; #if defined(UNIX) || defined(VMS) // Disable xterm's focus reporting mode if 'esckeys' is set. *************** *** 3750,3758 **** && 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); --- 3746,3752 ---- && starting == 0 && *T_CRV != NUL) { ! MAY_WANT_TO_LOG_THIS; LOG_TR(("Sending CRV request")); out_str(T_CRV); termrequest_sent(&crv_status); *************** *** 3791,3799 **** // 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 . --- 3785,3791 ---- // 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. ! MAY_WANT_TO_LOG_THIS; 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 . *************** *** 3822,3830 **** // 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 // character width check. --- 3814,3820 ---- // 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. ! MAY_WANT_TO_LOG_THIS; LOG_TR(("Sending xterm compatibility test sequence.")); // Do this in the third row. Second row is used by ambiguous // character width check. *************** *** 3875,3883 **** // 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); --- 3865,3871 ---- // Only request foreground if t_RF is set. if (rfg_status.tr_progress == STATUS_GET && *T_RFG != NUL) { ! MAY_WANT_TO_LOG_THIS; LOG_TR(("Sending FG request")); out_str(T_RFG); termrequest_sent(&rfg_status); *************** *** 3888,3896 **** // 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); --- 3876,3882 ---- // Only request background if t_RB is set. if (rbg_status.tr_progress == STATUS_GET && *T_RBG != NUL) { ! MAY_WANT_TO_LOG_THIS; LOG_TR(("Sending BG request")); out_str(T_RBG); termrequest_sent(&rbg_status); *************** *** 3954,3962 **** { 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 --- 3940,3946 ---- { if (*T_VS != NUL && *T_CVS != NUL) { ! MAY_WANT_TO_LOG_THIS; out_str(T_VS); out_str(T_CVS); screen_start(); // don't know where cursor is now *************** *** 4866,4874 **** && *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); --- 4850,4856 ---- && *T_CSH != NUL && *T_CRS != NUL) { ! MAY_WANT_TO_LOG_THIS; LOG_TR(("Sending cursor style request")); out_str(T_CRS); termrequest_sent(&rcs_status); *************** *** 4883,4891 **** && 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); --- 4865,4871 ---- && term_props[TPR_CURSOR_BLINK].tpr_status == TPR_YES && *T_CRC != NUL) { ! MAY_WANT_TO_LOG_THIS; LOG_TR(("Sending cursor blink mode request")); out_str(T_CRC); termrequest_sent(&rbm_status); *************** *** 6455,6463 **** { 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); --- 6435,6441 ---- { char *key_name = key_names[xt_index_out]; ! MAY_WANT_TO_LOG_THIS; 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.5055/src/edit.c 2022-05-27 17:26:50.538119977 +0100 --- src/edit.c 2022-06-04 21:54:52.300273633 +0100 *************** *** 319,327 **** #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); --- 319,326 ---- #endif if (!p_ek) { ! MAY_WANT_TO_LOG_THIS; ! // Disable bracketed paste mode, we won't recognize the escape // sequences. out_str(T_BD); *************** *** 3690,3698 **** #endif if (!p_ek) { ! #ifdef FEAT_JOB_CHANNEL ! ch_log_output = TRUE; ! #endif // Re-enable bracketed paste mode. out_str(T_BE); --- 3689,3696 ---- #endif if (!p_ek) { ! MAY_WANT_TO_LOG_THIS; ! // Re-enable bracketed paste mode. out_str(T_BE); *** ../vim-8.2.5055/src/normal.c 2022-05-26 16:32:40.808137960 +0100 --- src/normal.c 2022-06-04 21:55:20.064239216 +0100 *************** *** 431,439 **** #endif if ((State & MODE_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); --- 431,438 ---- #endif if ((State & MODE_INSERT) && !p_ek) { ! MAY_WANT_TO_LOG_THIS; ! // Disable bracketed paste and modifyOtherKeys here, we won't // recognize the escape sequences with 'esckeys' off. out_str(T_BD); *************** *** 444,452 **** if ((State & MODE_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); --- 443,450 ---- if ((State & MODE_INSERT) && !p_ek) { ! MAY_WANT_TO_LOG_THIS; ! // Re-enable bracketed paste mode and modifyOtherKeys out_str(T_BE); out_str(T_CTI); *** ../vim-8.2.5055/src/optionstr.c 2022-05-21 20:16:51.007567185 +0100 --- src/optionstr.c 2022-06-04 21:55:28.856228328 +0100 *************** *** 1462,1470 **** } 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. --- 1462,1469 ---- } if (varp == &T_BE && termcap_active) { ! MAY_WANT_TO_LOG_THIS; ! 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.5055/src/version.c 2022-06-04 19:57:56.068098112 +0100 --- src/version.c 2022-06-04 21:45:49.884960032 +0100 *************** *** 736,737 **** --- 736,739 ---- { /* Add new patch number below this line */ + /**/ + 5056, /**/ -- FATHER: You killed eight wedding guests in all! LAUNCELOT: Er, Well ... the thing is ... I thought your son was a lady. FATHER: I can understand that. "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///