summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-03-22 16:19:45 +0100
committerBram Moolenaar <Bram@vim.org>2021-03-22 16:19:45 +0100
commit4c86830fc578bcb47a51cf0983da5388cdbfe6cc (patch)
tree8c2b04a8cfaf7e00f8a20e38a5e5d09a5043b951
parent09f8b3a02200a1900a8bb41d7436f9d17ebd2d1b (diff)
downloadvim-git-4c86830fc578bcb47a51cf0983da5388cdbfe6cc.tar.gz
patch 8.2.2638: cannot write a message to the terminal from the GUIv8.2.2638
Problem: Cannot write a message to the terminal from the GUI. Solution: Add :echoconsole and use it in the test runner. (issue #7975)
-rw-r--r--runtime/doc/eval.txt7
-rw-r--r--src/eval.c6
-rw-r--r--src/ex_cmdidxs.h46
-rw-r--r--src/ex_cmds.h3
-rw-r--r--src/proto/ui.pro4
-rw-r--r--src/term.c2
-rw-r--r--src/testdir/runtest.vim2
-rw-r--r--src/ui.c14
-rw-r--r--src/version.c2
9 files changed, 54 insertions, 32 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 723a7329b..86df7b570 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -13141,7 +13141,12 @@ text...
< If you just want a highlighted message use |:echohl|.
And to get a beep: >
:exe "normal \<Esc>"
-<
+
+:echoc[onsole] {expr1} .. *:echoc* *:echoconsole*
+ Intended for testing: works like `:echomsg` but when
+ running in the GUI and started from a terminal write
+ the text to stdout.
+
*:eval*
:eval {expr} Evaluate {expr} and discard the result. Example: >
:eval Getlist()->Filter()->append('$')
diff --git a/src/eval.c b/src/eval.c
index 6cdc10f68..95dd5e2e6 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -6117,6 +6117,7 @@ get_echo_attr(void)
* ":execute expr1 ..." execute the result of an expression.
* ":echomsg expr1 ..." Print a message
* ":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
* echo commands
*/
@@ -6194,6 +6195,11 @@ ex_execute(exarg_T *eap)
msg_attr(ga.ga_data, echo_attr);
out_flush();
}
+ else if (eap->cmdidx == CMD_echoconsole)
+ {
+ ui_write(ga.ga_data, (int)STRLEN(ga.ga_data), TRUE);
+ ui_write((char_u *)"\r\n", 2, TRUE);
+ }
else if (eap->cmdidx == CMD_echoerr)
{
int save_did_emsg = did_emsg;
diff --git a/src/ex_cmdidxs.h b/src/ex_cmdidxs.h
index 8afc44535..70fb71a79 100644
--- a/src/ex_cmdidxs.h
+++ b/src/ex_cmdidxs.h
@@ -10,27 +10,27 @@ static const unsigned short cmdidxs1[26] =
/* c */ 43,
/* d */ 109,
/* e */ 134,
- /* f */ 157,
- /* g */ 174,
- /* h */ 180,
- /* i */ 189,
- /* j */ 208,
- /* k */ 210,
- /* l */ 215,
- /* m */ 277,
- /* n */ 295,
- /* o */ 315,
- /* p */ 327,
- /* q */ 366,
- /* r */ 369,
- /* s */ 389,
- /* t */ 458,
- /* u */ 503,
- /* v */ 514,
- /* w */ 535,
- /* x */ 549,
- /* y */ 559,
- /* z */ 560
+ /* f */ 158,
+ /* g */ 175,
+ /* h */ 181,
+ /* i */ 190,
+ /* j */ 209,
+ /* k */ 211,
+ /* l */ 216,
+ /* m */ 278,
+ /* n */ 296,
+ /* o */ 316,
+ /* p */ 328,
+ /* q */ 367,
+ /* r */ 370,
+ /* s */ 390,
+ /* t */ 459,
+ /* u */ 504,
+ /* v */ 515,
+ /* w */ 536,
+ /* x */ 550,
+ /* y */ 560,
+ /* z */ 561
};
/*
@@ -45,7 +45,7 @@ static const unsigned char cmdidxs2[26][26] =
/* 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, 37, 40, 46, 56, 58, 59, 60, 0, 62, 0, 65, 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, 7, 9, 10, 0, 0, 0, 0, 0, 0, 0, 17, 0, 18, 0, 0 },
+ /* e */ { 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 8, 10, 11, 0, 0, 0, 0, 0, 0, 0, 18, 0, 19, 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,4 +69,4 @@ static const unsigned char cmdidxs2[26][26] =
/* 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 = 575;
+static const int command_count = 576;
diff --git a/src/ex_cmds.h b/src/ex_cmds.h
index 90fd01538..aa41ab3a2 100644
--- a/src/ex_cmds.h
+++ b/src/ex_cmds.h
@@ -530,6 +530,9 @@ EXCMD(CMD_echohl, "echohl", ex_echohl,
EXCMD(CMD_echomsg, "echomsg", ex_execute,
EX_EXTRA|EX_NOTRLCOM|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK,
ADDR_NONE),
+EXCMD(CMD_echoconsole, "echoconsole", ex_execute,
+ EX_EXTRA|EX_NOTRLCOM|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK,
+ ADDR_NONE),
EXCMD(CMD_echon, "echon", ex_echo,
EX_EXTRA|EX_NOTRLCOM|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK,
ADDR_NONE),
diff --git a/src/proto/ui.pro b/src/proto/ui.pro
index 5aad9d8a0..e75be32b9 100644
--- a/src/proto/ui.pro
+++ b/src/proto/ui.pro
@@ -1,11 +1,11 @@
/* ui.c */
-void ui_write(char_u *s, int len);
+void ui_write(char_u *s, int len, int console);
void ui_inchar_undo(char_u *s, int len);
int ui_inchar(char_u *buf, int maxlen, long wtime, int tb_change_cnt);
int inchar_loop(char_u *buf, int maxlen, long wtime, int tb_change_cnt, int (*wait_func)(long wtime, int *interrupted, int ignore_input), int (*resize_func)(int check_only));
int ui_wait_for_chars_or_timer(long wtime, int (*wait_func)(long wtime, int *interrupted, int ignore_input), int *interrupted, int ignore_input);
int ui_char_avail(void);
-void ui_delay(long msec, int ignoreinput);
+void ui_delay(long msec_arg, int ignoreinput);
void ui_suspend(void);
void suspend_shell(void);
int ui_get_shellsize(void);
diff --git a/src/term.c b/src/term.c
index d2ada6c2b..8ce577ec1 100644
--- a/src/term.c
+++ b/src/term.c
@@ -2545,7 +2545,7 @@ out_flush(void)
// set out_pos to 0 before ui_write, to avoid recursiveness
len = out_pos;
out_pos = 0;
- ui_write(out_buf, len);
+ ui_write(out_buf, len, FALSE);
#ifdef FEAT_JOB_CHANNEL
if (ch_log_output)
{
diff --git a/src/testdir/runtest.vim b/src/testdir/runtest.vim
index 4602051a7..e43dd8d94 100644
--- a/src/testdir/runtest.vim
+++ b/src/testdir/runtest.vim
@@ -162,7 +162,7 @@ function GetAllocId(name)
endfunc
func RunTheTest(test)
- echo 'Executing ' . a:test
+ echoconsole 'Executing ' . a:test
if has('reltime')
let func_start = reltime()
endif
diff --git a/src/ui.c b/src/ui.c
index 3f4304f69..6c1c1de02 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -18,10 +18,14 @@
#include "vim.h"
void
-ui_write(char_u *s, int len)
+ui_write(char_u *s, int len, int console UNUSED)
{
#ifdef FEAT_GUI
- if (gui.in_use && !gui.dying && !gui.starting)
+ if (gui.in_use && !gui.dying && !gui.starting
+# ifndef NO_CONSOLE
+ && !console
+# endif
+ )
{
gui_write(s, len);
if (p_wd)
@@ -33,7 +37,7 @@ ui_write(char_u *s, int len)
// Don't output anything in silent mode ("ex -s") unless 'verbose' set
if (!(silent_mode && p_verbose == 0))
{
-#if !defined(MSWIN)
+# if !defined(MSWIN)
char_u *tofree = NULL;
if (output_conv.vc_type != CONV_NONE)
@@ -43,9 +47,11 @@ ui_write(char_u *s, int len)
if (tofree != NULL)
s = tofree;
}
-#endif
+# endif
mch_write(s, len);
+ if (console && s[len - 1] == '\n')
+ fsync(1);
# if !defined(MSWIN)
if (output_conv.vc_type != CONV_NONE)
diff --git a/src/version.c b/src/version.c
index 399539d8c..40411d8be 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 2638,
+/**/
2637,
/**/
2636,