Skip to content

Commit 37fef16

Browse files
committed
patch 9.0.0321: cannot use the message popup window directly
Problem: Cannot use the message popup window directly. Solution: Add ":echowindow".
1 parent 54acb90 commit 37fef16

File tree

14 files changed

+114
-31
lines changed

14 files changed

+114
-31
lines changed

runtime/doc/eval.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3821,6 +3821,16 @@ text...
38213821
:echomsg "It's a Zizzer Zazzer Zuzz, as you can plainly see."
38223822
< See |:echo-redraw| to avoid the message disappearing
38233823
when the screen is redrawn.
3824+
3825+
*:echow* *:echowin* *:echowindow*
3826+
:echow[indow] {expr1} ..
3827+
Like |:echomsg| but when the messages popup window is
3828+
available the message is displayed there. This means
3829+
it will show for three seconds and avoid a
3830+
|hit-enter| prompt.
3831+
The message window is available when Vim was compiled
3832+
with the +timer and the +popupwin features.
3833+
38243834
*:echoe* *:echoerr*
38253835
:echoe[rr] {expr1} .. Echo the expression(s) as an error message, saving the
38263836
message in the |message-history|. When used in a

src/eval.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2078,7 +2078,8 @@ set_context_for_expression(
20782078
if ((cmdidx == CMD_execute
20792079
|| cmdidx == CMD_echo
20802080
|| cmdidx == CMD_echon
2081-
|| cmdidx == CMD_echomsg)
2081+
|| cmdidx == CMD_echomsg
2082+
|| cmdidx == CMD_echowindow)
20822083
&& xp->xp_context == EXPAND_EXPRESSION)
20832084
{
20842085
for (;;)
@@ -6709,6 +6710,7 @@ get_echo_attr(void)
67096710
/*
67106711
* ":execute expr1 ..." execute the result of an expression.
67116712
* ":echomsg expr1 ..." Print a message
6713+
* ":echowindow expr1 ..." Print a message in the messages window
67126714
* ":echoerr expr1 ..." Print an error
67136715
* ":echoconsole expr1 ..." Print a message on stdout
67146716
* Each gets spaces around each argument and a newline at the end for
@@ -6726,6 +6728,9 @@ ex_execute(exarg_T *eap)
67266728
long start_lnum = SOURCING_LNUM;
67276729

67286730
ga_init2(&ga, 1, 80);
6731+
#ifdef HAS_MESSAGE_WINDOW
6732+
in_echowindow = (eap->cmdidx == CMD_echowindow);
6733+
#endif
67296734

67306735
if (eap->skip)
67316736
++emsg_skip;
@@ -6780,15 +6785,17 @@ ex_execute(exarg_T *eap)
67806785
// use the first line of continuation lines for messages
67816786
SOURCING_LNUM = start_lnum;
67826787

6783-
if (eap->cmdidx == CMD_echomsg || eap->cmdidx == CMD_echoerr)
6788+
if (eap->cmdidx == CMD_echomsg
6789+
|| eap->cmdidx == CMD_echowindow
6790+
|| eap->cmdidx == CMD_echoerr)
67846791
{
67856792
// Mark the already saved text as finishing the line, so that what
67866793
// follows is displayed on a new line when scrolling back at the
67876794
// more prompt.
67886795
msg_sb_eol();
67896796
}
67906797

6791-
if (eap->cmdidx == CMD_echomsg)
6798+
if (eap->cmdidx == CMD_echomsg || eap->cmdidx == CMD_echowindow)
67926799
{
67936800
msg_attr(ga.ga_data, echo_attr);
67946801
out_flush();
@@ -6835,6 +6842,7 @@ ex_execute(exarg_T *eap)
68356842
if (msg_col == 0)
68366843
msg_col = 1;
68376844
}
6845+
in_echowindow = FALSE;
68386846
#endif
68396847
set_nextcmd(eap, arg);
68406848
}

src/ex_cmdidxs.h

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,27 @@ static const unsigned short cmdidxs1[26] =
1010
/* c */ 45,
1111
/* d */ 112,
1212
/* e */ 137,
13-
/* f */ 165,
14-
/* g */ 182,
15-
/* h */ 188,
16-
/* i */ 197,
17-
/* j */ 217,
18-
/* k */ 219,
19-
/* l */ 224,
20-
/* m */ 287,
21-
/* n */ 305,
22-
/* o */ 325,
23-
/* p */ 337,
24-
/* q */ 376,
25-
/* r */ 379,
26-
/* s */ 399,
27-
/* t */ 469,
28-
/* u */ 515,
29-
/* v */ 526,
30-
/* w */ 547,
31-
/* x */ 561,
32-
/* y */ 571,
33-
/* z */ 572
13+
/* f */ 166,
14+
/* g */ 183,
15+
/* h */ 189,
16+
/* i */ 198,
17+
/* j */ 218,
18+
/* k */ 220,
19+
/* l */ 225,
20+
/* m */ 288,
21+
/* n */ 306,
22+
/* o */ 326,
23+
/* p */ 338,
24+
/* q */ 377,
25+
/* r */ 380,
26+
/* s */ 400,
27+
/* t */ 470,
28+
/* u */ 516,
29+
/* v */ 527,
30+
/* w */ 548,
31+
/* x */ 562,
32+
/* y */ 572,
33+
/* z */ 573
3434
};
3535

3636
/*
@@ -45,7 +45,7 @@ static const unsigned char cmdidxs2[26][26] =
4545
/* 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 },
4646
/* 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 },
4747
/* 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 },
48-
/* 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 },
48+
/* 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 },
4949
/* 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 },
5050
/* 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 },
5151
/* 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,4 +69,4 @@ static const unsigned char cmdidxs2[26][26] =
6969
/* 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 }
7070
};
7171

72-
static const int command_count = 589;
72+
static const int command_count = 590;

src/ex_cmds.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,9 @@ EXCMD(CMD_echoconsole, "echoconsole", ex_execute,
548548
EXCMD(CMD_echon, "echon", ex_echo,
549549
EX_EXTRA|EX_NOTRLCOM|EX_EXPR_ARG|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK,
550550
ADDR_NONE),
551+
EXCMD(CMD_echowindow, "echowindow", ex_execute,
552+
EX_EXTRA|EX_NOTRLCOM|EX_EXPR_ARG|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK,
553+
ADDR_NONE),
551554
EXCMD(CMD_else, "else", ex_else,
552555
EX_TRLBAR|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK|EX_WHOLE,
553556
ADDR_NONE),

src/ex_getln.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3872,6 +3872,8 @@ redrawcmdprompt(void)
38723872
void
38733873
redrawcmd(void)
38743874
{
3875+
int save_in_echowindow = in_echowindow;
3876+
38753877
if (cmd_silent)
38763878
return;
38773879

@@ -3883,6 +3885,9 @@ redrawcmd(void)
38833885
return;
38843886
}
38853887

3888+
// Do not put this in the message window.
3889+
in_echowindow = FALSE;
3890+
38863891
sb_text_restart_cmdline();
38873892
msg_start();
38883893
redrawcmdprompt();
@@ -3906,6 +3911,8 @@ redrawcmd(void)
39063911
// Typing ':' at the more prompt may set skip_redraw. We don't want this
39073912
// in cmdline mode
39083913
skip_redraw = FALSE;
3914+
3915+
in_echowindow = save_in_echowindow;
39093916
}
39103917

39113918
void

src/globals.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ EXTERN int uncaught_emsg; // number of times emsg() was
236236
EXTERN int did_emsg_syntax; // did_emsg set because of a
237237
// syntax error
238238
EXTERN int called_emsg; // always incremented by emsg()
239+
EXTERN int in_echowindow; // executing ":echowindow"
239240
EXTERN int ex_exitval INIT(= 0); // exit value for ex mode
240241
EXTERN int emsg_on_display INIT(= FALSE); // there is an error message
241242
EXTERN int rc_did_emsg INIT(= FALSE); // vim_regcomp() called emsg()

src/message.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1438,7 +1438,8 @@ use_message_window(void)
14381438
#ifdef HAS_MESSAGE_WINDOW
14391439
// TRUE if there is no command line showing ('cmdheight' is zero and not
14401440
// already editing or showing a message) use a popup window for messages.
1441-
return p_ch == 0 && cmdline_row >= Rows;
1441+
// Also when using ":echowindow".
1442+
return (p_ch == 0 && cmdline_row >= Rows) || in_echowindow;
14421443
#else
14431444
return FALSE;
14441445
#endif
@@ -1484,8 +1485,9 @@ msg_start(void)
14841485
#ifdef HAS_MESSAGE_WINDOW
14851486
if (use_message_window())
14861487
{
1487-
if (popup_message_win_visible() && msg_col > 0
1488-
&& (msg_scroll || !full_screen))
1488+
if (popup_message_win_visible()
1489+
&& ((msg_col > 0 && (msg_scroll || !full_screen))
1490+
|| in_echowindow))
14891491
{
14901492
win_T *wp = popup_get_message_win();
14911493

src/popupwin.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1302,7 +1302,8 @@ popup_adjust_position(win_T *wp)
13021302
}
13031303
if (wp->w_popup_pos == POPPOS_BOTTOM)
13041304
// assume that each buffer line takes one screen line
1305-
wp->w_winrow = MAX(Rows - wp->w_buffer->b_ml.ml_line_count - 1, 0);
1305+
wp->w_winrow = MAX(cmdline_row
1306+
- wp->w_buffer->b_ml.ml_line_count - 1, 0);
13061307

13071308
if (!use_wantcol)
13081309
center_hor = TRUE;

src/structs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2606,7 +2606,7 @@ typedef enum {
26062606
POPPOS_BOTRIGHT,
26072607
POPPOS_TOPRIGHT,
26082608
POPPOS_CENTER,
2609-
POPPOS_BOTTOM, // bottom of popup at bottom of screen
2609+
POPPOS_BOTTOM, // bottom of popup just above the command line
26102610
POPPOS_NONE
26112611
} poppos_T;
26122612

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
>s+0&#ffffff0|o|m|e| |t|e|x|t| @65
2+
|~+0#4040ff13&| @73
3+
|~| @73
4+
|~| @73
5+
|~| @73
6+
|═+0#e000002&@74
7+
|f|i|r|s|t| |l|i|n|e| @64
8+
| +0#0000000&@56|1|,|1| @10|A|l@1|

0 commit comments

Comments
 (0)