Patch 8.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)
Files:      runtime/doc/eval.txt, runtime/doc/index.txt, src/ex_cmds.h,
            src/ex_cmdidxs.h, src/eval.c, src/ui.c, src/proto/ui.pro,
            src/term.c, src/testdir/runtest.vim


*** ../vim-8.2.2637/runtime/doc/eval.txt        2021-03-14 19:46:22.003284579 
+0100
--- runtime/doc/eval.txt        2021-03-22 15:56:35.028783239 +0100
***************
*** 13136,13142 ****
  <                     If you just want a highlighted message use |:echohl|.
                        And to get a beep: >
                :exe "normal \<Esc>"
! <
                                                        *:eval*
  :eval {expr}          Evaluate {expr} and discard the result.  Example: >
                                :eval Getlist()->Filter()->append('$')
--- 13141,13152 ----
  <                     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('$')
*** ../vim-8.2.2637/runtime/doc/index.txt       2021-01-31 17:02:06.254490174 
+0100
--- runtime/doc/index.txt       2021-03-22 15:59:09.604374890 +0100
***************
*** 1176,1181 ****
--- 1176,1182 ----
  |:bNext|      :bN[ext]        go to previous buffer in the buffer list
  |:ball|               :ba[ll]         open a window for each buffer in the 
buffer list
  |:badd|               :bad[d]         add buffer to the buffer list
+ |:balt|               :balt           like ":badd" but also set the alternate 
file
  |:bdelete|    :bd[elete]      remove a buffer from the buffer list
  |:behave|     :be[have]       set mouse and selection behavior
  |:belowright| :bel[owright]   make split window appear right or below
***************
*** 1293,1298 ****
--- 1294,1300 ----
  |:edit|               :e[dit]         edit a file
  |:earlier|    :ea[rlier]      go to older change, undo
  |:echo|               :ec[ho]         echoes the result of expressions
+ |:echoconsole|        :echoc[onsole]  like :echomsg but write to stdout
  |:echoerr|    :echoe[rr]      like :echo, show like an error and use history
  |:echohl|     :echoh[l]       set highlighting for echo commands
  |:echomsg|    :echom[sg]      same as :echo, put message in history
***************
*** 1698,1704 ****
  |:version|    :ve[rsion]      print version number and other info
  |:verbose|    :verb[ose]      execute command with 'verbose' set
  |:vertical|   :vert[ical]     make following command split vertically
! |:vim9script| :vim9[script]   indicates Vim9 script file
  |:vimgrep|    :vim[grep]      search for pattern in files
  |:vimgrepadd| :vimgrepa[dd]   like :vimgrep, but append to current list
  |:visual|     :vi[sual]       same as ":edit", but turns off "Ex" mode
--- 1700,1707 ----
  |:version|    :ve[rsion]      print version number and other info
  |:verbose|    :verb[ose]      execute command with 'verbose' set
  |:vertical|   :vert[ical]     make following command split vertically
! |:vim9cmd|    :vim9[cmd]      make following command use Vim9 script syntax
! |:vim9script| :vim9s[cript]   indicates Vim9 script file
  |:vimgrep|    :vim[grep]      search for pattern in files
  |:vimgrepadd| :vimgrepa[dd]   like :vimgrep, but append to current list
  |:visual|     :vi[sual]       same as ":edit", but turns off "Ex" mode
*** ../vim-8.2.2637/src/ex_cmds.h       2021-02-26 22:21:19.082675454 +0100
--- src/ex_cmds.h       2021-03-22 15:59:55.276254778 +0100
***************
*** 530,535 ****
--- 530,538 ----
  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),
*** ../vim-8.2.2637/src/ex_cmdidxs.h    2021-02-14 12:57:32.552655477 +0100
--- src/ex_cmdidxs.h    2021-03-22 16:07:50.611028087 +0100
***************
*** 10,36 ****
    /* 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
  };
  
  /*
--- 10,36 ----
    /* c */ 43,
    /* d */ 109,
    /* e */ 134,
!   /* 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,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, 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 },
    /* 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, 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,  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,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 = 575;
--- 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 = 576;
*** ../vim-8.2.2637/src/eval.c  2021-03-21 22:12:31.448826619 +0100
--- src/eval.c  2021-03-22 16:14:07.146154166 +0100
***************
*** 6117,6122 ****
--- 6117,6123 ----
   * ":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,6199 ****
--- 6195,6205 ----
            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;
*** ../vim-8.2.2637/src/ui.c    2021-01-14 19:19:14.927885317 +0100
--- src/ui.c    2021-03-22 16:13:57.562177008 +0100
***************
*** 18,27 ****
  #include "vim.h"
  
      void
! ui_write(char_u *s, int len)
  {
  #ifdef FEAT_GUI
!     if (gui.in_use && !gui.dying && !gui.starting)
      {
        gui_write(s, len);
        if (p_wd)
--- 18,31 ----
  #include "vim.h"
  
      void
! ui_write(char_u *s, int len, int console UNUSED)
  {
  #ifdef FEAT_GUI
!     if (gui.in_use && !gui.dying && !gui.starting
! # ifndef NO_CONSOLE
!           && !console
! # endif
!           )
      {
        gui_write(s, len);
        if (p_wd)
***************
*** 33,39 ****
      // Don't output anything in silent mode ("ex -s") unless 'verbose' set
      if (!(silent_mode && p_verbose == 0))
      {
! #if !defined(MSWIN)
        char_u  *tofree = NULL;
  
        if (output_conv.vc_type != CONV_NONE)
--- 37,43 ----
      // Don't output anything in silent mode ("ex -s") unless 'verbose' set
      if (!(silent_mode && p_verbose == 0))
      {
! # if !defined(MSWIN)
        char_u  *tofree = NULL;
  
        if (output_conv.vc_type != CONV_NONE)
***************
*** 43,51 ****
            if (tofree != NULL)
                s = tofree;
        }
! #endif
  
        mch_write(s, len);
  
  # if !defined(MSWIN)
        if (output_conv.vc_type != CONV_NONE)
--- 47,57 ----
            if (tofree != NULL)
                s = tofree;
        }
! # endif
  
        mch_write(s, len);
+       if (console && s[len - 1] == '\n')
+           fsync(1);
  
  # if !defined(MSWIN)
        if (output_conv.vc_type != CONV_NONE)
*** ../vim-8.2.2637/src/proto/ui.pro    2020-03-24 21:41:38.027535418 +0100
--- src/proto/ui.pro    2021-03-22 16:07:04.167134793 +0100
***************
*** 1,11 ****
  /* ui.c */
! void ui_write(char_u *s, int len);
  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_suspend(void);
  void suspend_shell(void);
  int ui_get_shellsize(void);
--- 1,11 ----
  /* ui.c */
! 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_arg, int ignoreinput);
  void ui_suspend(void);
  void suspend_shell(void);
  int ui_get_shellsize(void);
*** ../vim-8.2.2637/src/term.c  2021-03-03 15:24:18.938864642 +0100
--- src/term.c  2021-03-22 16:05:51.391324041 +0100
***************
*** 2545,2551 ****
        // set out_pos to 0 before ui_write, to avoid recursiveness
        len = out_pos;
        out_pos = 0;
!       ui_write(out_buf, len);
  #ifdef FEAT_JOB_CHANNEL
        if (ch_log_output)
        {
--- 2545,2551 ----
        // set out_pos to 0 before ui_write, to avoid recursiveness
        len = out_pos;
        out_pos = 0;
!       ui_write(out_buf, len, FALSE);
  #ifdef FEAT_JOB_CHANNEL
        if (ch_log_output)
        {
*** ../vim-8.2.2637/src/testdir/runtest.vim     2021-03-10 22:27:44.597737046 
+0100
--- src/testdir/runtest.vim     2021-03-22 16:18:22.693537215 +0100
***************
*** 162,168 ****
  endfunc
  
  func RunTheTest(test)
!   echo 'Executing ' . a:test
    if has('reltime')
      let func_start = reltime()
    endif
--- 162,168 ----
  endfunc
  
  func RunTheTest(test)
!   echoconsole 'Executing ' . a:test
    if has('reltime')
      let func_start = reltime()
    endif
*** ../vim-8.2.2637/src/version.c       2021-03-21 22:29:47.210542590 +0100
--- src/version.c       2021-03-22 15:58:08.132536921 +0100
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     2638,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
13. You refer to going to the bathroom as downloading.

 /// Bram Moolenaar -- [email protected] -- 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    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202103221533.12MFXlc52353981%40masaka.moolenaar.net.

Raspunde prin e-mail lui