aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/eval.c11
-rw-r--r--src/nvim/getchar.c4
-rw-r--r--src/nvim/globals.h1
-rw-r--r--src/nvim/memfile.c3
-rw-r--r--src/nvim/memline.c3
-rw-r--r--src/nvim/message.c2
-rw-r--r--src/nvim/misc1.c3
-rw-r--r--src/nvim/os/input.c12
-rw-r--r--src/nvim/ui.c98
9 files changed, 19 insertions, 118 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 4a77bcd3c5..0a57b4ceb2 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -10273,12 +10273,6 @@ static void get_user_input(typval_T *argvars, typval_T *rettv, int inputdialog)
rettv->v_type = VAR_STRING;
rettv->vval.v_string = NULL;
-#ifdef NO_CONSOLE_INPUT
- /* While starting up, there is no place to enter text. */
- if (no_console_input())
- return;
-#endif
-
cmd_silent = FALSE; /* Want to see the prompt. */
if (prompt != NULL) {
/* Only the part of the message after the last NL is considered as
@@ -10373,11 +10367,6 @@ static void f_inputlist(typval_T *argvars, typval_T *rettv)
int selected;
int mouse_used;
-#ifdef NO_CONSOLE_INPUT
- /* While starting up, there is no place to enter text. */
- if (no_console_input())
- return;
-#endif
if (argvars[0].v_type != VAR_LIST || argvars[0].vval.v_list == NULL) {
EMSG2(_(e_listarg), "inputlist()");
return;
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c
index 1bec0fa1bb..a3c87806b2 100644
--- a/src/nvim/getchar.c
+++ b/src/nvim/getchar.c
@@ -2481,7 +2481,7 @@ inchar (
char_u dum[DUM_LEN + 1];
for (;; ) {
- len = ui_inchar(dum, DUM_LEN, 0L, 0);
+ len = os_inchar(dum, DUM_LEN, 0L, 0);
if (len == 0 || (len == 1 && dum[0] == 3))
break;
}
@@ -2498,7 +2498,7 @@ inchar (
* Fill up to a third of the buffer, because each character may be
* tripled below.
*/
- len = ui_inchar(buf, maxlen / 3, wait_time, tb_change_cnt);
+ len = os_inchar(buf, maxlen / 3, wait_time, tb_change_cnt);
}
if (typebuf_changed(tb_change_cnt))
diff --git a/src/nvim/globals.h b/src/nvim/globals.h
index cd9f7a648f..2d8e511ade 100644
--- a/src/nvim/globals.h
+++ b/src/nvim/globals.h
@@ -855,7 +855,6 @@ EXTERN char_u *exe_name; /* the name of the executable */
EXTERN int dont_scroll INIT(= FALSE); /* don't use scrollbars when TRUE */
#endif
EXTERN int mapped_ctrl_c INIT(= FALSE); /* CTRL-C is mapped */
-EXTERN bool ctrl_c_interrupts INIT(= true); /* CTRL-C sets got_int */
EXTERN cmdmod_T cmdmod; /* Ex command modifiers */
diff --git a/src/nvim/memfile.c b/src/nvim/memfile.c
index 1656acb689..bcb7c22a21 100644
--- a/src/nvim/memfile.c
+++ b/src/nvim/memfile.c
@@ -63,6 +63,7 @@
#include "nvim/path.h"
#include "nvim/ui.h"
#include "nvim/os/os.h"
+#include "nvim/os/input.h"
#define MEMFILE_PAGE_SIZE 4096 /// default page size
@@ -455,7 +456,7 @@ int mf_sync(memfile_T *mfp, int flags)
status = FAIL;
}
if (flags & MFS_STOP) { // Stop when char available now.
- if (ui_char_avail())
+ if (os_char_avail())
break;
} else {
ui_breakcheck();
diff --git a/src/nvim/memline.c b/src/nvim/memline.c
index e9edeb842f..469601d37a 100644
--- a/src/nvim/memline.c
+++ b/src/nvim/memline.c
@@ -75,6 +75,7 @@
#include "nvim/undo.h"
#include "nvim/window.h"
#include "nvim/os/os.h"
+#include "nvim/os/input.h"
#ifndef UNIX /* it's in os_unix_defs.h for Unix */
# include <time.h>
@@ -1642,7 +1643,7 @@ void ml_sync_all(int check_file, int check_char)
if (buf->b_ml.ml_mfp->mf_dirty) {
(void)mf_sync(buf->b_ml.ml_mfp, (check_char ? MFS_STOP : 0)
| (bufIsChanged(buf) ? MFS_FLUSH : 0));
- if (check_char && ui_char_avail()) /* character available now */
+ if (check_char && os_char_avail()) /* character available now */
break;
}
}
diff --git a/src/nvim/message.c b/src/nvim/message.c
index 23feeab173..6b17c00417 100644
--- a/src/nvim/message.c
+++ b/src/nvim/message.c
@@ -2702,11 +2702,9 @@ do_dialog (
int c;
int i;
-#ifndef NO_CONSOLE
/* Don't output anything in silent mode ("ex -s") */
if (silent_mode)
return dfltbutton; /* return default option */
-#endif
oldState = State;
diff --git a/src/nvim/misc1.c b/src/nvim/misc1.c
index 310cb6faac..cef7ea0627 100644
--- a/src/nvim/misc1.c
+++ b/src/nvim/misc1.c
@@ -58,6 +58,7 @@
#include "nvim/window.h"
#include "nvim/os/os.h"
#include "nvim/os/shell.h"
+#include "nvim/os/input.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "misc1.c.generated.h"
@@ -2383,7 +2384,7 @@ int get_keystroke(void)
/* First time: blocking wait. Second time: wait up to 100ms for a
* terminal code to complete. */
- n = ui_inchar(buf + len, maxlen, len == 0 ? -1L : 100L, 0);
+ n = os_inchar(buf + len, maxlen, len == 0 ? -1L : 100L, 0);
if (n > 0) {
/* Replace zero and CSI by a special key code. */
n = fix_input_buffer(buf + len, n, FALSE);
diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c
index d10d20b20e..d413921a5f 100644
--- a/src/nvim/os/input.c
+++ b/src/nvim/os/input.c
@@ -17,6 +17,7 @@
#include "nvim/keymap.h"
#include "nvim/mbyte.h"
#include "nvim/fileio.h"
+#include "nvim/ex_cmds2.h"
#include "nvim/getchar.h"
#include "nvim/term.h"
@@ -184,7 +185,16 @@ size_t input_enqueue(String keys)
static bool input_poll(int ms)
{
+ if (do_profiling == PROF_YES && ms) {
+ prof_inchar_enter();
+ }
+
event_poll_until(ms, input_ready());
+
+ if (do_profiling == PROF_YES && ms) {
+ prof_inchar_exit();
+ }
+
return input_ready();
}
@@ -282,7 +292,7 @@ static void convert_input(void)
static void process_interrupts(void)
{
- if (!ctrl_c_interrupts) {
+ if (mapped_ctrl_c) {
return;
}
diff --git a/src/nvim/ui.c b/src/nvim/ui.c
index d6269897d7..8495744ec2 100644
--- a/src/nvim/ui.c
+++ b/src/nvim/ui.c
@@ -44,7 +44,6 @@
void ui_write(char_u *s, int len)
{
-#ifndef NO_CONSOLE
/* Don't output anything in silent mode ("ex -s") unless 'verbose' set */
if (!(silent_mode && p_verbose == 0)) {
char_u *tofree = NULL;
@@ -61,103 +60,6 @@ void ui_write(char_u *s, int len)
if (output_conv.vc_type != CONV_NONE)
free(tofree);
}
-#endif
-}
-
-/*
- * ui_inchar(): low level input function.
- * Get characters from the keyboard.
- * Return the number of characters that are available.
- * If "wtime" == 0 do not wait for characters.
- * If "wtime" == -1 wait forever for characters.
- * If "wtime" > 0 wait "wtime" milliseconds for a character.
- *
- * "tb_change_cnt" is the value of typebuf.tb_change_cnt if "buf" points into
- * it. When typebuf.tb_change_cnt changes (e.g., when a message is received
- * from a remote client) "buf" can no longer be used. "tb_change_cnt" is NULL
- * otherwise.
- */
-int
-ui_inchar (
- char_u *buf,
- int maxlen,
- long wtime, /* don't use "time", MIPS cannot handle it */
- int tb_change_cnt
-)
-{
- int retval = 0;
-
-
- if (do_profiling == PROF_YES && wtime != 0)
- prof_inchar_enter();
-
-#ifdef NO_CONSOLE_INPUT
- /* Don't wait for character input when the window hasn't been opened yet.
- * Do try reading, this works when redirecting stdin from a file.
- * Must return something, otherwise we'll loop forever. If we run into
- * this very often we probably got stuck, exit Vim. */
- if (no_console_input()) {
- static int count = 0;
-
-# ifndef NO_CONSOLE
- retval = os_inchar(buf, maxlen, (wtime >= 0 && wtime < 10)
- ? 10L : wtime, tb_change_cnt);
- if (retval > 0 || typebuf_changed(tb_change_cnt) || wtime >= 0)
- goto theend;
-# endif
- if (wtime == -1 && ++count == 1000)
- read_error_exit();
- buf[0] = CAR;
- retval = 1;
- goto theend;
- }
-#endif
-
- /* If we are going to wait for some time or block... */
- if (wtime == -1 || wtime > 100L) {
- /* ... allow signals to kill us. */
- signal_accept_deadly();
-
- /* ... there is no need for CTRL-C to interrupt something, don't let
- * it set got_int when it was mapped. */
- if (mapped_ctrl_c)
- ctrl_c_interrupts = false;
- }
-
-#ifndef NO_CONSOLE
- {
- retval = os_inchar(buf, maxlen, wtime, tb_change_cnt);
- }
-#endif
-
- if (wtime == -1 || wtime > 100L)
- /* block SIGHUP et al. */
- signal_reject_deadly();
-
- ctrl_c_interrupts = true;
-
-#ifdef NO_CONSOLE_INPUT
-theend:
-#endif
- if (do_profiling == PROF_YES && wtime != 0)
- prof_inchar_exit();
- return retval;
-}
-
-/*
- * return non-zero if a character is available
- */
-int ui_char_avail(void)
-{
-#ifndef NO_CONSOLE
-# ifdef NO_CONSOLE_INPUT
- if (no_console_input())
- return 0;
-# endif
- return os_char_avail();
-#else
- return 0;
-#endif
}
/*