diff options
-rw-r--r-- | src/nvim/autocmd.c | 1 | ||||
-rw-r--r-- | src/nvim/eval/typval.c | 1 | ||||
-rw-r--r-- | src/nvim/ex_cmds2.c | 1 | ||||
-rw-r--r-- | src/nvim/fold.c | 1 | ||||
-rw-r--r-- | src/nvim/misc1.c | 41 | ||||
-rw-r--r-- | src/nvim/os/input.c | 34 | ||||
-rw-r--r-- | src/nvim/regexp.c | 1 | ||||
-rw-r--r-- | src/nvim/regexp_nfa.c | 1 | ||||
-rw-r--r-- | src/nvim/search.c | 1 | ||||
-rw-r--r-- | src/nvim/spellfile.c | 1 | ||||
-rw-r--r-- | src/nvim/syntax.c | 1 | ||||
-rw-r--r-- | src/nvim/undo.c | 1 |
12 files changed, 44 insertions, 41 deletions
diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c index 9044657358..0248230e15 100644 --- a/src/nvim/autocmd.c +++ b/src/nvim/autocmd.c @@ -17,6 +17,7 @@ #include "nvim/getchar.h" #include "nvim/misc1.h" #include "nvim/option.h" +#include "nvim/os/input.h" #include "nvim/regexp.h" #include "nvim/search.h" #include "nvim/state.h" diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c index 3e37e8cbb6..dfb2500b49 100644 --- a/src/nvim/eval/typval.c +++ b/src/nvim/eval/typval.c @@ -28,6 +28,7 @@ #include "nvim/mbyte.h" #include "nvim/memory.h" #include "nvim/message.h" +#include "nvim/os/input.h" #include "nvim/pos.h" #include "nvim/types.h" #include "nvim/vim.h" diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 449e6f7bf5..2dc098df8c 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -41,6 +41,7 @@ #include "nvim/ops.h" #include "nvim/option.h" #include "nvim/os/fs_defs.h" +#include "nvim/os/input.h" #include "nvim/os/shell.h" #include "nvim/os_unix.h" #include "nvim/path.h" diff --git a/src/nvim/fold.c b/src/nvim/fold.c index 4a8be7a31b..7806d3eada 100644 --- a/src/nvim/fold.c +++ b/src/nvim/fold.c @@ -32,6 +32,7 @@ #include "nvim/move.h" #include "nvim/ops.h" #include "nvim/option.h" +#include "nvim/os/input.h" #include "nvim/plines.h" #include "nvim/screen.h" #include "nvim/strings.h" diff --git a/src/nvim/misc1.c b/src/nvim/misc1.c index 872a2c58e3..dd753a2de6 100644 --- a/src/nvim/misc1.c +++ b/src/nvim/misc1.c @@ -858,47 +858,6 @@ void preserve_exit(void) getout(1); } -/* - * Check for CTRL-C pressed, but only once in a while. - * Should be used instead of os_breakcheck() for functions that check for - * each line in the file. Calling os_breakcheck() each time takes too much - * time, because it can be a system call. - */ - -#ifndef BREAKCHECK_SKIP -# define BREAKCHECK_SKIP 1000 -#endif - -static int breakcheck_count = 0; - -void line_breakcheck(void) -{ - if (++breakcheck_count >= BREAKCHECK_SKIP) { - breakcheck_count = 0; - os_breakcheck(); - } -} - -/* - * Like line_breakcheck() but check 10 times less often. - */ -void fast_breakcheck(void) -{ - if (++breakcheck_count >= BREAKCHECK_SKIP * 10) { - breakcheck_count = 0; - os_breakcheck(); - } -} - -// Like line_breakcheck() but check 100 times less often. -void veryfast_breakcheck(void) -{ - if (++breakcheck_count >= BREAKCHECK_SKIP * 100) { - breakcheck_count = 0; - os_breakcheck(); - } -} - /// os_call_shell() wrapper. Handles 'verbose', :profile, and v:shell_error. /// Invalidates cached tags. /// diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c index 5b231f205b..fc9bbbc8b0 100644 --- a/src/nvim/os/input.c +++ b/src/nvim/os/input.c @@ -183,6 +183,40 @@ void os_breakcheck(void) updating_screen = save_us; } +#define BREAKCHECK_SKIP 1000 +static int breakcheck_count = 0; + +/// Check for CTRL-C pressed, but only once in a while. +/// +/// Should be used instead of os_breakcheck() for functions that check for +/// each line in the file. Calling os_breakcheck() each time takes too much +/// time, because it will use system calls to check for input. +void line_breakcheck(void) +{ + if (++breakcheck_count >= BREAKCHECK_SKIP) { + breakcheck_count = 0; + os_breakcheck(); + } +} + +/// Like line_breakcheck() but check 10 times less often. +void fast_breakcheck(void) +{ + if (++breakcheck_count >= BREAKCHECK_SKIP * 10) { + breakcheck_count = 0; + os_breakcheck(); + } +} + +/// Like line_breakcheck() but check 100 times less often. +void veryfast_breakcheck(void) +{ + if (++breakcheck_count >= BREAKCHECK_SKIP * 100) { + breakcheck_count = 0; + os_breakcheck(); + } +} + /// Test whether a file descriptor refers to a terminal. /// diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index e67efb8ea0..aa8d1503fc 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -65,6 +65,7 @@ #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/misc1.h" +#include "nvim/os/input.h" #include "nvim/plines.h" #include "nvim/garray.h" #include "nvim/strings.h" diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c index 5df5cc5975..3e7306bad3 100644 --- a/src/nvim/regexp_nfa.c +++ b/src/nvim/regexp_nfa.c @@ -16,6 +16,7 @@ #include "nvim/ascii.h" #include "nvim/garray.h" +#include "nvim/os/input.h" /* * Logging of NFA engine. diff --git a/src/nvim/search.c b/src/nvim/search.c index f47315705c..f45d709b91 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -36,6 +36,7 @@ #include "nvim/move.h" #include "nvim/normal.h" #include "nvim/option.h" +#include "nvim/os/input.h" #include "nvim/os/time.h" #include "nvim/path.h" #include "nvim/regexp.h" diff --git a/src/nvim/spellfile.c b/src/nvim/spellfile.c index ae4514dd30..c65fcc1180 100644 --- a/src/nvim/spellfile.c +++ b/src/nvim/spellfile.c @@ -239,6 +239,7 @@ #include "nvim/memory.h" #include "nvim/misc1.h" #include "nvim/option.h" +#include "nvim/os/input.h" #include "nvim/os/os.h" #include "nvim/path.h" #include "nvim/regexp.h" diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index cb243668ce..fc445d80b6 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -34,6 +34,7 @@ #include "nvim/message.h" #include "nvim/misc1.h" #include "nvim/option.h" +#include "nvim/os/input.h" #include "nvim/os/os.h" #include "nvim/os/time.h" #include "nvim/os_unix.h" diff --git a/src/nvim/undo.c b/src/nvim/undo.c index 8161fce9f4..5274fb98c7 100644 --- a/src/nvim/undo.c +++ b/src/nvim/undo.c @@ -100,6 +100,7 @@ #include "nvim/message.h" #include "nvim/misc1.h" #include "nvim/option.h" +#include "nvim/os/input.h" #include "nvim/os/os.h" #include "nvim/os/time.h" #include "nvim/os_unix.h" |