aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/term.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/term.c')
-rw-r--r--src/nvim/term.c61
1 files changed, 55 insertions, 6 deletions
diff --git a/src/nvim/term.c b/src/nvim/term.c
index 263b81fc3a..9da7e11b96 100644
--- a/src/nvim/term.c
+++ b/src/nvim/term.c
@@ -54,6 +54,7 @@
#include "nvim/window.h"
#include "nvim/os/os.h"
#include "nvim/os/time.h"
+#include "nvim/os/input.h"
#ifdef HAVE_TGETENT
# ifdef HAVE_TERMIOS_H
@@ -638,7 +639,7 @@ static struct builtin_term builtin_termcaps[] =
{K_BS, "\x7f"}, /* for some reason 0177 doesn't work */
# endif
-# if defined(ALL_BUILTIN_TCAPS) || defined(__MINT__)
+# if defined(ALL_BUILTIN_TCAPS)
/*
* Ordinary vt52
*/
@@ -997,7 +998,7 @@ static struct builtin_term builtin_termcaps[] =
-#if defined(UNIX) && !defined(__MINT__)
+#if defined(UNIX)
# define DEFAULT_TERM (char_u *)"ansi"
#endif
@@ -1009,6 +1010,30 @@ static struct builtin_term builtin_termcaps[] =
# define DEFAULT_TERM (char_u *)"dumb"
#endif
+/// Sets up the terminal window for use.
+///
+/// This must be done after resetting full_screen, otherwise it may move the
+/// cursor.
+///
+/// @remark We may call mch_exit() before calling this.
+void term_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
+ mac_conv_init();
+#endif
+}
+
/*
* Term_strings contains currently used terminal output strings.
* It is initialized with the default values by parse_builtin_tcap().
@@ -1330,7 +1355,7 @@ int set_termname(char_u *term)
if (emsg_silent == 0) {
screen_start(); /* don't know where cursor is now */
out_flush();
- ui_delay(2000L, true);
+ os_delay(2000L, true);
}
set_string_option_direct((char_u *)"term", -1, term,
OPT_FREE, 0);
@@ -1821,11 +1846,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 */
@@ -2302,7 +2351,7 @@ void set_shellsize(int width, int height, int mustset)
Rows = height;
Columns = width;
check_shellsize();
- ui_set_shellsize(mustset);
+ mch_set_shellsize();
} else
check_shellsize();
@@ -4111,7 +4160,7 @@ void show_termcodes(void)
col += INC3;
}
out_flush();
- ui_breakcheck();
+ os_breakcheck();
}
}
free(items);