term: Remove most calls to settmode

Nvim now relies much less on setting terminal mode to cooked mode, remove most
calls to settmode, except for those that happen on startup or when suspending.
Eventually even those will be handled by the UI layer.
This commit is contained in:
Thiago de Arruda
2014-12-01 21:31:40 -03:00
parent 05f8d261fe
commit 8a5a8dbf0f
8 changed files with 13 additions and 44 deletions

View File

@@ -157,7 +157,6 @@ void do_debug(char_u *cmd)
/* Make sure we are in raw mode and start termcap mode. Might have side
* effects... */
settmode(TMODE_RAW);
starttermcap();
++RedrawingDisabled; /* don't redisplay the window */

View File

@@ -5107,7 +5107,6 @@ static void ex_highlight(exarg_T *eap)
void not_exiting(void)
{
exiting = FALSE;
settmode(TMODE_RAW);
}
/*
@@ -5994,7 +5993,6 @@ do_exedit (
{
int n;
int need_hide;
int exmode_was = exmode_active;
/*
* ":vi" command ends Ex mode.
@@ -6014,8 +6012,6 @@ do_exedit (
eap->nextcmd = NULL;
}
if (exmode_was != EXMODE_VIM)
settmode(TMODE_RAW);
RedrawingDisabled = 0;
no_wait_return = 0;
need_wait_return = FALSE;

View File

@@ -270,10 +270,6 @@ getcmdline (
setmouse();
ui_cursor_shape(); /* may show different cursor shape */
/* When inside an autocommand for writing "exiting" may be set and
* terminal mode set to cooked. Need to set raw mode here then. */
settmode(TMODE_RAW);
init_history();
hiscnt = hislen; /* set hiscnt to impossible history value */
histype = hist_char2type(firstc);

View File

@@ -1812,7 +1812,6 @@ failed:
* Switch on raw mode now and clear the screen.
*/
if (read_stdin) {
settmode(TMODE_RAW); /* set to raw mode */
starttermcap();
screenclear();
}
@@ -2387,9 +2386,6 @@ buf_write (
else
overwriting = FALSE;
if (exiting)
settmode(TMODE_COOK); /* when exiting allow typeahead now */
++no_wait_return; /* don't wait for return yet */
/*

View File

@@ -2286,8 +2286,6 @@ int ask_yesno(char_u *str, int direct)
int r = ' ';
int save_State = State;
if (exiting) /* put terminal in raw mode for this question */
settmode(TMODE_RAW);
++no_wait_return;
#ifdef USE_ON_FLY_SCROLL
dont_scroll = TRUE; /* disallow scrolling here */

View File

@@ -104,14 +104,10 @@ int os_call_shell(char_u *cmd, ShellOpts opts, char_u *extra_arg)
{
DynamicBuffer input = DYNAMIC_BUFFER_INIT;
char *output = NULL, **output_ptr = NULL;
int current_state = State, old_mode = cur_tmode;
int current_state = State;
bool forward_output = true;
out_flush();
if (opts & kShellOptCooked) {
settmode(TMODE_COOK);
}
// While the child is running, ignore terminating signals
signal_reject_deadly();
@@ -155,10 +151,6 @@ int os_call_shell(char_u *cmd, ShellOpts opts, char_u *extra_arg)
msg_putchar('\n');
}
if (old_mode == TMODE_RAW) {
// restore mode
settmode(TMODE_RAW);
}
State = current_state;
signal_accept_deadly();

View File

@@ -6,6 +6,7 @@
#include <uv.h>
#include "nvim/os/time.h"
#include "nvim/os/event.h"
#include "nvim/vim.h"
#include "nvim/term.h"
@@ -38,31 +39,22 @@ uint64_t os_hrtime(void)
/// @param ignoreinput If true, allow a SIGINT to interrupt us
void os_delay(uint64_t milliseconds, bool ignoreinput)
{
os_microdelay(milliseconds * 1000, ignoreinput);
if (ignoreinput) {
if (milliseconds > INT_MAX) {
milliseconds = INT_MAX;
}
event_poll_until((int)milliseconds, got_int);
} else {
os_microdelay(milliseconds * 1000);
}
}
/// Sleeps for a certain amount of microseconds
///
/// @param microseconds Number of microseconds to sleep
/// @param ignoreinput If true, allow a SIGINT to interrupt us
void os_microdelay(uint64_t microseconds, bool ignoreinput)
void os_microdelay(uint64_t microseconds)
{
int old_tmode;
if (ignoreinput) {
// Go to cooked mode without echo, to allow SIGINT interrupting us
// here
old_tmode = curr_tmode;
if (curr_tmode == TMODE_RAW)
settmode(TMODE_SLEEP);
microdelay(microseconds);
settmode(old_tmode);
} else {
microdelay(microseconds);
}
microdelay(microseconds);
}
/// Portable version of POSIX localtime_r()

View File

@@ -1865,7 +1865,7 @@ void term_write(char_u *s, size_t len)
#ifdef UNIX
if (p_wd) { // Unix is too fast, slow down a bit more
os_microdelay(p_wd, false);
os_microdelay(p_wd);
}
#endif
}