aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiago de Arruda <tpadilha84@gmail.com>2014-12-01 21:31:40 -0300
committerThiago de Arruda <tpadilha84@gmail.com>2014-12-02 07:15:07 -0300
commit8a5a8dbf0f8dfec0b0494a0215891469753961a1 (patch)
tree1f22a425eb77401b524a93292bfc5eb2f7e61d06
parent05f8d261fe305741ea99c6da2096d890b1005bf7 (diff)
downloadrneovim-8a5a8dbf0f8dfec0b0494a0215891469753961a1.tar.gz
rneovim-8a5a8dbf0f8dfec0b0494a0215891469753961a1.tar.bz2
rneovim-8a5a8dbf0f8dfec0b0494a0215891469753961a1.zip
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.
-rw-r--r--src/nvim/ex_cmds2.c1
-rw-r--r--src/nvim/ex_docmd.c4
-rw-r--r--src/nvim/ex_getln.c4
-rw-r--r--src/nvim/fileio.c4
-rw-r--r--src/nvim/misc1.c2
-rw-r--r--src/nvim/os/shell.c10
-rw-r--r--src/nvim/os/time.c30
-rw-r--r--src/nvim/term.c2
8 files changed, 13 insertions, 44 deletions
diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c
index 24a1ccf85d..794e9930b9 100644
--- a/src/nvim/ex_cmds2.c
+++ b/src/nvim/ex_cmds2.c
@@ -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 */
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index db95399285..e180be4421 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -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;
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index 70db2dc479..db12cf1b2e 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -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);
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index 3be9d89d87..021b12208e 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -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 */
/*
diff --git a/src/nvim/misc1.c b/src/nvim/misc1.c
index 230e198121..5c6963b2b7 100644
--- a/src/nvim/misc1.c
+++ b/src/nvim/misc1.c
@@ -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 */
diff --git a/src/nvim/os/shell.c b/src/nvim/os/shell.c
index 1b279f18f5..cdd85e4e96 100644
--- a/src/nvim/os/shell.c
+++ b/src/nvim/os/shell.c
@@ -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();
diff --git a/src/nvim/os/time.c b/src/nvim/os/time.c
index a4871ef499..3794e813d2 100644
--- a/src/nvim/os/time.c
+++ b/src/nvim/os/time.c
@@ -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()
diff --git a/src/nvim/term.c b/src/nvim/term.c
index 47f7fa8af3..26f0785849 100644
--- a/src/nvim/term.c
+++ b/src/nvim/term.c
@@ -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
}