aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/os_unix.c30
-rw-r--r--src/nvim/term.c26
-rw-r--r--src/nvim/ui.c2
3 files changed, 32 insertions, 26 deletions
diff --git a/src/nvim/os_unix.c b/src/nvim/os_unix.c
index 3bf1198b46..bcb35e297b 100644
--- a/src/nvim/os_unix.c
+++ b/src/nvim/os_unix.c
@@ -82,30 +82,6 @@ static int did_set_title = FALSE;
static char_u *oldicon = NULL;
static int did_set_icon = FALSE;
-
-
-/*
- * Write s[len] to the screen.
- */
-void mch_write(char_u *s, int len)
-{
- if (embedded_mode) {
- // TODO(tarruda): This is a temporary hack to stop Neovim from writing
- // messages to stdout in embedded mode. In the future, embedded mode will
- // be the only possibility(GUIs will always start neovim with a msgpack-rpc
- // over stdio) and this function won't exist.
- //
- // The reason for this is because before Neovim fully migrates to a
- // msgpack-rpc-driven architecture, we must have a fully functional
- // UI working
- return;
- }
-
- ignored = (int)write(1, (char *)s, len);
- if (p_wd) /* Unix is too fast, slow down a bit more */
- os_microdelay(p_wd, false);
-}
-
/*
* If the machine has job control, use it to suspend the program,
* otherwise fake it by starting a new shell.
@@ -159,6 +135,12 @@ void mch_init(void)
Columns = 80;
Rows = 24;
+ // Prevent buffering output.
+ // Output gets explicitly buffered and flushed by out_flush() at times like,
+ // for example, when the user presses a key. Without this line, vim will not
+ // render the screen correctly.
+ setbuf(stdout, NULL);
+
out_flush();
#ifdef MACOS_CONVERT
diff --git a/src/nvim/term.c b/src/nvim/term.c
index 3d1053bd2f..18620ea766 100644
--- a/src/nvim/term.c
+++ b/src/nvim/term.c
@@ -1822,11 +1822,35 @@ void termcapinit(char_u *name)
set_termname(T_NAME != NULL ? T_NAME : term);
}
+/// Write s[len] to the screen.
+void term_write(char_u *s, size_t len)
+{
+ if (embedded_mode) {
+ // TODO(tarruda): This is a temporary hack to stop Neovim from writing
+ // messages to stdout in embedded mode. In the future, embedded mode will
+ // be the only possibility(GUIs will always start neovim with a msgpack-rpc
+ // over stdio) and this function won't exist.
+ //
+ // The reason for this is because before Neovim fully migrates to a
+ // msgpack-rpc-driven architecture, we must have a fully functional
+ // UI working
+ return;
+ }
+
+ (void) fwrite(s, len, 1, stdout);
+
+#ifdef UNIX
+ if (p_wd) { // Unix is too fast, slow down a bit more
+ os_microdelay(p_wd, false);
+ }
+#endif
+}
+
/*
* the number of calls to ui_write is reduced by using the buffer "out_buf"
*/
# define OUT_SIZE 2047
-/* Add one to allow mch_write() in os_win32.c to append a NUL */
+// Add one to allow term_write() in os_win32.c to append a NUL
static char_u out_buf[OUT_SIZE + 1];
static int out_pos = 0; /* number of chars in out_buf */
diff --git a/src/nvim/ui.c b/src/nvim/ui.c
index 803e7fab50..0b68eb3051 100644
--- a/src/nvim/ui.c
+++ b/src/nvim/ui.c
@@ -55,7 +55,7 @@ void ui_write(char_u *s, int len)
s = tofree;
}
- mch_write(s, len);
+ term_write(s, len);
if (output_conv.vc_type != CONV_NONE)
free(tofree);