diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2014-11-28 14:50:09 -0500 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2014-11-28 14:50:09 -0500 |
commit | ad848ced117ddf53481a9f0905b4d9826df71f90 (patch) | |
tree | bc18f0d0f9db0247196b7f2d389fe4c432da21df /src/nvim/term.c | |
parent | 68cee4c28d6c309e18ae35eeba9d5dffaf1078ca (diff) | |
parent | 275f6e3a6b5132f814ee947da49b8899f557f0a3 (diff) | |
download | rneovim-ad848ced117ddf53481a9f0905b4d9826df71f90.tar.gz rneovim-ad848ced117ddf53481a9f0905b4d9826df71f90.tar.bz2 rneovim-ad848ced117ddf53481a9f0905b4d9826df71f90.zip |
Merge pull request #1186 from splinterofchaos/write
Non-unix-specific os_unix function.
Diffstat (limited to 'src/nvim/term.c')
-rw-r--r-- | src/nvim/term.c | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/src/nvim/term.c b/src/nvim/term.c index 3d1053bd2f..fd2988c850 100644 --- a/src/nvim/term.c +++ b/src/nvim/term.c @@ -1010,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(). @@ -1822,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 */ |