patch 8.2.2638: cannot write a message to the terminal from the GUI

Problem:    Cannot write a message to the terminal from the GUI.
Solution:   Add :echoconsole and use it in the test runner. (issue #7975)
diff --git a/src/ui.c b/src/ui.c
index 3f4304f..6c1c1de 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 @@
     // 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 @@
 	    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)