To: vim_dev@googlegroups.com Subject: Patch 9.0.0321 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.0321 Problem: Cannot use the message popup window directly. Solution: Add ":echowindow". Files: runtime/doc/eval.txt, src/globals.h, src/structs.h, src/popupwin.c, src/message.c, src/ex_cmds.h, src/ex_cmdidxs.h, src/eval.c, src/ex_getln.c, src/testdir/test_messages.vim, src/testdir/dumps/Test_echowindow_1.dump, src/testdir/dumps/Test_echowindow_2.dump, src/testdir/dumps/Test_echowindow_3.dump *** ../vim-9.0.0320/runtime/doc/eval.txt 2022-07-27 14:39:57.308548748 +0100 --- runtime/doc/eval.txt 2022-08-29 17:01:07.618391049 +0100 *************** *** 3820,3825 **** --- 3821,3836 ---- :echomsg "It's a Zizzer Zazzer Zuzz, as you can plainly see." < See |:echo-redraw| to avoid the message disappearing when the screen is redrawn. + + *:echow* *:echowin* *:echowindow* + :echow[indow] {expr1} .. + Like |:echomsg| but when the messages popup window is + available the message is displayed there. This means + it will show for three seconds and avoid a + |hit-enter| prompt. + The message window is available when Vim was compiled + with the +timer and the +popupwin features. + *:echoe* *:echoerr* :echoe[rr] {expr1} .. Echo the expression(s) as an error message, saving the message in the |message-history|. When used in a *** ../vim-9.0.0320/src/globals.h 2022-08-26 16:58:46.139489368 +0100 --- src/globals.h 2022-08-29 17:15:49.449946564 +0100 *************** *** 236,241 **** --- 236,242 ---- EXTERN int did_emsg_syntax; // did_emsg set because of a // syntax error EXTERN int called_emsg; // always incremented by emsg() + EXTERN int in_echowindow; // executing ":echowindow" EXTERN int ex_exitval INIT(= 0); // exit value for ex mode EXTERN int emsg_on_display INIT(= FALSE); // there is an error message EXTERN int rc_did_emsg INIT(= FALSE); // vim_regcomp() called emsg() *** ../vim-9.0.0320/src/structs.h 2022-08-28 19:16:11.976716179 +0100 --- src/structs.h 2022-08-29 16:25:34.989264608 +0100 *************** *** 2606,2612 **** POPPOS_BOTRIGHT, POPPOS_TOPRIGHT, POPPOS_CENTER, ! POPPOS_BOTTOM, // bottom of popup at bottom of screen POPPOS_NONE } poppos_T; --- 2606,2612 ---- POPPOS_BOTRIGHT, POPPOS_TOPRIGHT, POPPOS_CENTER, ! POPPOS_BOTTOM, // bottom of popup just above the command line POPPOS_NONE } poppos_T; *** ../vim-9.0.0320/src/popupwin.c 2022-08-29 13:44:24.166897355 +0100 --- src/popupwin.c 2022-08-29 16:27:28.548965926 +0100 *************** *** 1302,1308 **** } if (wp->w_popup_pos == POPPOS_BOTTOM) // assume that each buffer line takes one screen line ! wp->w_winrow = MAX(Rows - wp->w_buffer->b_ml.ml_line_count - 1, 0); if (!use_wantcol) center_hor = TRUE; --- 1302,1309 ---- } if (wp->w_popup_pos == POPPOS_BOTTOM) // assume that each buffer line takes one screen line ! wp->w_winrow = MAX(cmdline_row ! - wp->w_buffer->b_ml.ml_line_count - 1, 0); if (!use_wantcol) center_hor = TRUE; *** ../vim-9.0.0320/src/message.c 2022-08-29 15:06:46.720715534 +0100 --- src/message.c 2022-08-29 18:08:25.687497426 +0100 *************** *** 1438,1444 **** #ifdef HAS_MESSAGE_WINDOW // TRUE if there is no command line showing ('cmdheight' is zero and not // already editing or showing a message) use a popup window for messages. ! return p_ch == 0 && cmdline_row >= Rows; #else return FALSE; #endif --- 1438,1445 ---- #ifdef HAS_MESSAGE_WINDOW // TRUE if there is no command line showing ('cmdheight' is zero and not // already editing or showing a message) use a popup window for messages. ! // Also when using ":echowindow". ! return (p_ch == 0 && cmdline_row >= Rows) || in_echowindow; #else return FALSE; #endif *************** *** 1484,1491 **** #ifdef HAS_MESSAGE_WINDOW if (use_message_window()) { ! if (popup_message_win_visible() && msg_col > 0 ! && (msg_scroll || !full_screen)) { win_T *wp = popup_get_message_win(); --- 1485,1493 ---- #ifdef HAS_MESSAGE_WINDOW if (use_message_window()) { ! if (popup_message_win_visible() ! && ((msg_col > 0 && (msg_scroll || !full_screen)) ! || in_echowindow)) { win_T *wp = popup_get_message_win(); *** ../vim-9.0.0320/src/ex_cmds.h 2022-05-21 15:13:35.000000000 +0100 --- src/ex_cmds.h 2022-08-29 16:56:34.314497750 +0100 *************** *** 548,553 **** --- 548,556 ---- EXCMD(CMD_echon, "echon", ex_echo, EX_EXTRA|EX_NOTRLCOM|EX_EXPR_ARG|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK, ADDR_NONE), + EXCMD(CMD_echowindow, "echowindow", ex_execute, + EX_EXTRA|EX_NOTRLCOM|EX_EXPR_ARG|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK, + ADDR_NONE), EXCMD(CMD_else, "else", ex_else, EX_TRLBAR|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK|EX_WHOLE, ADDR_NONE), *** ../vim-9.0.0320/src/ex_cmdidxs.h 2021-12-24 20:23:30.000000000 +0000 --- src/ex_cmdidxs.h 2022-08-29 17:01:59.422361845 +0100 *************** *** 10,36 **** /* c */ 45, /* d */ 112, /* e */ 137, ! /* f */ 165, ! /* g */ 182, ! /* h */ 188, ! /* i */ 197, ! /* j */ 217, ! /* k */ 219, ! /* l */ 224, ! /* m */ 287, ! /* n */ 305, ! /* o */ 325, ! /* p */ 337, ! /* q */ 376, ! /* r */ 379, ! /* s */ 399, ! /* t */ 469, ! /* u */ 515, ! /* v */ 526, ! /* w */ 547, ! /* x */ 561, ! /* y */ 571, ! /* z */ 572 }; /* --- 10,36 ---- /* c */ 45, /* d */ 112, /* e */ 137, ! /* f */ 166, ! /* g */ 183, ! /* h */ 189, ! /* i */ 198, ! /* j */ 218, ! /* k */ 220, ! /* l */ 225, ! /* m */ 288, ! /* n */ 306, ! /* o */ 326, ! /* p */ 338, ! /* q */ 377, ! /* r */ 380, ! /* s */ 400, ! /* t */ 470, ! /* u */ 516, ! /* v */ 527, ! /* w */ 548, ! /* x */ 562, ! /* y */ 572, ! /* z */ 573 }; /* *************** *** 45,51 **** /* b */ { 2, 0, 0, 5, 6, 8, 0, 0, 0, 0, 0, 9, 10, 11, 12, 13, 0, 14, 0, 0, 0, 0, 23, 0, 0, 0 }, /* c */ { 3, 12, 16, 18, 20, 22, 25, 0, 0, 0, 0, 33, 38, 41, 47, 57, 59, 60, 61, 0, 63, 0, 66, 0, 0, 0 }, /* d */ { 0, 0, 0, 0, 0, 0, 0, 0, 8, 18, 0, 19, 0, 0, 20, 0, 0, 22, 23, 0, 0, 0, 0, 0, 0, 0 }, ! /* e */ { 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 8, 10, 11, 0, 0, 0, 0, 0, 0, 0, 22, 0, 23, 0, 0 }, /* f */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0 }, /* g */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 2, 0, 0, 4, 5, 0, 0, 0, 0 }, /* h */ { 5, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, --- 45,51 ---- /* b */ { 2, 0, 0, 5, 6, 8, 0, 0, 0, 0, 0, 9, 10, 11, 12, 13, 0, 14, 0, 0, 0, 0, 23, 0, 0, 0 }, /* c */ { 3, 12, 16, 18, 20, 22, 25, 0, 0, 0, 0, 33, 38, 41, 47, 57, 59, 60, 61, 0, 63, 0, 66, 0, 0, 0 }, /* d */ { 0, 0, 0, 0, 0, 0, 0, 0, 8, 18, 0, 19, 0, 0, 20, 0, 0, 22, 23, 0, 0, 0, 0, 0, 0, 0 }, ! /* e */ { 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 9, 11, 12, 0, 0, 0, 0, 0, 0, 0, 23, 0, 24, 0, 0 }, /* f */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0 }, /* g */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 2, 0, 0, 4, 5, 0, 0, 0, 0 }, /* h */ { 5, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, *************** *** 69,72 **** /* z */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }; ! static const int command_count = 589; --- 69,72 ---- /* z */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }; ! static const int command_count = 590; *** ../vim-9.0.0320/src/eval.c 2022-08-28 21:36:17.150095067 +0100 --- src/eval.c 2022-08-29 16:57:40.614480500 +0100 *************** *** 2078,2084 **** if ((cmdidx == CMD_execute || cmdidx == CMD_echo || cmdidx == CMD_echon ! || cmdidx == CMD_echomsg) && xp->xp_context == EXPAND_EXPRESSION) { for (;;) --- 2078,2085 ---- if ((cmdidx == CMD_execute || cmdidx == CMD_echo || cmdidx == CMD_echon ! || cmdidx == CMD_echomsg ! || cmdidx == CMD_echowindow) && xp->xp_context == EXPAND_EXPRESSION) { for (;;) *************** *** 6709,6714 **** --- 6710,6716 ---- /* * ":execute expr1 ..." execute the result of an expression. * ":echomsg expr1 ..." Print a message + * ":echowindow expr1 ..." Print a message in the messages window * ":echoerr expr1 ..." Print an error * ":echoconsole expr1 ..." Print a message on stdout * Each gets spaces around each argument and a newline at the end for *************** *** 6726,6731 **** --- 6728,6736 ---- long start_lnum = SOURCING_LNUM; ga_init2(&ga, 1, 80); + #ifdef HAS_MESSAGE_WINDOW + in_echowindow = (eap->cmdidx == CMD_echowindow); + #endif if (eap->skip) ++emsg_skip; *************** *** 6780,6786 **** // use the first line of continuation lines for messages SOURCING_LNUM = start_lnum; ! if (eap->cmdidx == CMD_echomsg || eap->cmdidx == CMD_echoerr) { // Mark the already saved text as finishing the line, so that what // follows is displayed on a new line when scrolling back at the --- 6785,6793 ---- // use the first line of continuation lines for messages SOURCING_LNUM = start_lnum; ! if (eap->cmdidx == CMD_echomsg ! || eap->cmdidx == CMD_echowindow ! || eap->cmdidx == CMD_echoerr) { // Mark the already saved text as finishing the line, so that what // follows is displayed on a new line when scrolling back at the *************** *** 6788,6794 **** msg_sb_eol(); } ! if (eap->cmdidx == CMD_echomsg) { msg_attr(ga.ga_data, echo_attr); out_flush(); --- 6795,6801 ---- msg_sb_eol(); } ! if (eap->cmdidx == CMD_echomsg || eap->cmdidx == CMD_echowindow) { msg_attr(ga.ga_data, echo_attr); out_flush(); *************** *** 6835,6840 **** --- 6842,6848 ---- if (msg_col == 0) msg_col = 1; } + in_echowindow = FALSE; #endif set_nextcmd(eap, arg); } *** ../vim-9.0.0320/src/ex_getln.c 2022-08-29 16:21:21.449992388 +0100 --- src/ex_getln.c 2022-08-29 17:21:22.733791697 +0100 *************** *** 3872,3877 **** --- 3872,3879 ---- void redrawcmd(void) { + int save_in_echowindow = in_echowindow; + if (cmd_silent) return; *************** *** 3883,3888 **** --- 3885,3893 ---- return; } + // Do not put this in the message window. + in_echowindow = FALSE; + sb_text_restart_cmdline(); msg_start(); redrawcmdprompt(); *************** *** 3906,3911 **** --- 3911,3918 ---- // Typing ':' at the more prompt may set skip_redraw. We don't want this // in cmdline mode skip_redraw = FALSE; + + in_echowindow = save_in_echowindow; } void *** ../vim-9.0.0320/src/testdir/test_messages.vim 2022-08-28 21:36:17.150095067 +0100 --- src/testdir/test_messages.vim 2022-08-29 17:58:34.892859551 +0100 *************** *** 537,541 **** --- 537,566 ---- set cmdheight& endfunc + func Test_echowindow() + CheckScreendump + + let lines =<< trim END + call setline(1, 'some text') + func ShowMessage(arg) + echowindow a:arg + endfunc + echowindow 'first line' + END + call writefile(lines, 'XtestEchowindow') + let buf = RunVimInTerminal('-S XtestEchowindow', #{rows: 8}) + call VerifyScreenDump(buf, 'Test_echowindow_1', {}) + + call term_sendkeys(buf, ":call ShowMessage('second line')\") + call VerifyScreenDump(buf, 'Test_echowindow_2', {}) + + call term_sendkeys(buf, ":call popup_clear()\") + call VerifyScreenDump(buf, 'Test_echowindow_3', {}) + + " clean up + call StopVimInTerminal(buf) + call delete('XtestEchowindow') + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-9.0.0320/src/testdir/dumps/Test_echowindow_1.dump 2022-08-29 18:14:20.642833137 +0100 --- src/testdir/dumps/Test_echowindow_1.dump 2022-08-29 17:58:47.460824664 +0100 *************** *** 0 **** --- 1,8 ---- + >s+0&#ffffff0|o|m|e| |t|e|x|t| @65 + |~+0#4040ff13&| @73 + |~| @73 + |~| @73 + |~| @73 + |═+0#e000002&@74 + |f|i|r|s|t| |l|i|n|e| @64 + | +0#0000000&@56|1|,|1| @10|A|l@1| *** ../vim-9.0.0320/src/testdir/dumps/Test_echowindow_2.dump 2022-08-29 18:14:20.646833130 +0100 --- src/testdir/dumps/Test_echowindow_2.dump 2022-08-29 18:08:33.463482088 +0100 *************** *** 0 **** --- 1,8 ---- + >s+0&#ffffff0|o|m|e| |t|e|x|t| @65 + |~+0#4040ff13&| @73 + |~| @73 + |~| @73 + |═+0#e000002&@74 + |f|i|r|s|t| |l|i|n|e| @64 + |s|e|c|o|n|d| |l|i|n|e| @63 + | +0#0000000&@56|1|,|1| @10|A|l@1| *** ../vim-9.0.0320/src/testdir/dumps/Test_echowindow_3.dump 2022-08-29 18:14:20.650833123 +0100 --- src/testdir/dumps/Test_echowindow_3.dump 2022-08-29 17:58:49.768818298 +0100 *************** *** 0 **** --- 1,8 ---- + >s+0&#ffffff0|o|m|e| |t|e|x|t| @65 + |~+0#4040ff13&| @73 + |~| @73 + |~| @73 + |~| @73 + |~| @73 + |~| @73 + | +0#0000000&@56|1|,|1| @10|A|l@1| *** ../vim-9.0.0320/src/version.c 2022-08-29 16:21:21.453992376 +0100 --- src/version.c 2022-08-29 18:01:22.428421668 +0100 *************** *** 709,710 **** --- 709,712 ---- { /* Add new patch number below this line */ + /**/ + 321, /**/ -- We apologise again for the fault in the subtitles. Those responsible for sacking the people who have just been sacked have been sacked. "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 ///