aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/CMakeLists.txt72
-rw-r--r--src/nvim/api/vim.c20
-rw-r--r--src/nvim/buffer.c13
-rw-r--r--src/nvim/buffer_defs.h5
-rw-r--r--src/nvim/cursor_shape.c6
-rw-r--r--src/nvim/digraph.c17
-rw-r--r--src/nvim/edit.c54
-rw-r--r--src/nvim/eval.c93
-rw-r--r--src/nvim/ex_cmds.c6
-rw-r--r--src/nvim/ex_docmd.c16
-rw-r--r--src/nvim/ex_getln.c48
-rw-r--r--src/nvim/file_search.c4
-rw-r--r--src/nvim/fileio.c11
-rw-r--r--src/nvim/getchar.c15
-rw-r--r--src/nvim/globals.h5
-rw-r--r--src/nvim/hardcopy.c4
-rw-r--r--src/nvim/if_cscope.c4
-rw-r--r--src/nvim/main.c7
-rw-r--r--src/nvim/mark.c6
-rw-r--r--src/nvim/mbyte.c21
-rw-r--r--src/nvim/memfile.c6
-rw-r--r--src/nvim/memline.c4
-rw-r--r--src/nvim/memory.c18
-rw-r--r--src/nvim/message.c14
-rw-r--r--src/nvim/misc1.c16
-rw-r--r--src/nvim/misc2.c1
-rw-r--r--src/nvim/mouse.c438
-rw-r--r--src/nvim/mouse.h32
-rw-r--r--src/nvim/normal.c37
-rw-r--r--src/nvim/ops.c13
-rw-r--r--src/nvim/option.c24
-rw-r--r--src/nvim/option_defs.h4
-rw-r--r--src/nvim/os/event.c20
-rw-r--r--src/nvim/os/input.c60
-rw-r--r--src/nvim/os_unix.c1
-rw-r--r--src/nvim/path.c8
-rw-r--r--src/nvim/quickfix.c4
-rw-r--r--src/nvim/screen.c28
-rw-r--r--src/nvim/search.c5
-rw-r--r--src/nvim/spell.c6
-rw-r--r--src/nvim/strings.c1
-rw-r--r--src/nvim/syntax.c4
-rw-r--r--src/nvim/tag.c22
-rw-r--r--src/nvim/term.c7
-rw-r--r--src/nvim/testdir/Makefile14
-rw-r--r--src/nvim/testdir/sautest/autoload/Test104.vim1
-rw-r--r--src/nvim/testdir/test101.in45
-rw-r--r--src/nvim/testdir/test101.ok11
-rw-r--r--src/nvim/testdir/test104.in30
-rw-r--r--src/nvim/testdir/test104.ok13
-rw-r--r--src/nvim/testdir/test105.in45
-rw-r--r--src/nvim/testdir/test105.ok29
-rw-r--r--src/nvim/testdir/test21.in19
-rw-r--r--src/nvim/testdir/test21.ok2
-rw-r--r--src/nvim/testdir/test25.in31
-rw-r--r--src/nvim/testdir/test25.ok1
-rw-r--r--src/nvim/testdir/test26.in44
-rw-r--r--src/nvim/testdir/test26.ok10
-rw-r--r--src/nvim/testdir/test33.in34
-rw-r--r--src/nvim/testdir/test33.ok23
-rw-r--r--src/nvim/testdir/test43.in34
-rw-r--r--src/nvim/testdir/test43.ok11
-rw-r--r--src/nvim/testdir/test5.in29
-rw-r--r--src/nvim/testdir/test5.ok9
-rw-r--r--src/nvim/testdir/test51.in36
-rw-r--r--src/nvim/testdir/test51.ok20
-rw-r--r--src/nvim/testdir/test66.in33
-rw-r--r--src/nvim/testdir/test66.ok16
-rw-r--r--src/nvim/testdir/test67.in33
-rw-r--r--src/nvim/testdir/test67.ok10
-rw-r--r--src/nvim/testdir/test75.in41
-rw-r--r--src/nvim/testdir/test75.ok7
-rw-r--r--src/nvim/ui.c612
-rw-r--r--src/nvim/ui.h21
-rw-r--r--src/nvim/window.c6
75 files changed, 861 insertions, 1609 deletions
diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt
index b06b4fa547..a2d052c4ec 100644
--- a/src/nvim/CMakeLists.txt
+++ b/src/nvim/CMakeLists.txt
@@ -38,34 +38,66 @@ endforeach()
list(REMOVE_ITEM NEOVIM_SOURCES ${to_remove})
+# Handle legacy files that don't yet pass -Wconversion.
set(CONV_SOURCES
- arabic.c
- cursor.c
- garray.c
- hashtab.c
- log.c
- map.c
- memfile.c
- memory.c
- misc2.c
- profile.c
- tempfile.c
- )
+ buffer.c
+ charset.c
+ diff.c
+ edit.c
+ eval.c
+ ex_cmds2.c
+ ex_cmds.c
+ ex_docmd.c
+ ex_eval.c
+ ex_getln.c
+ farsi.c
+ fileio.c
+ file_search.c
+ fold.c
+ getchar.c
+ hardcopy.c
+ if_cscope.c
+ indent.c
+ indent_c.c
+ keymap.c
+ main.c
+ mark.c
+ mbyte.c
+ memline.c
+ menu.c
+ message.c
+ misc1.c
+ move.c
+ normal.c
+ ops.c
+ option.c
+ os_unix.c
+ path.c
+ popupmnu.c
+ quickfix.c
+ regexp.c
+ regexp_nfa.c
+ screen.c
+ search.c
+ sha256.c
+ spell.c
+ strings.c
+ syntax.c
+ tag.c
+ term.c
+ ui.c
+ undo.c
+ version.c
+ window.c)
foreach(sfile ${CONV_SOURCES})
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/src/nvim/${sfile}")
- message(FATAL_ERROR "${sfile} doesn't exist(it was added to CONV_SOURCES)")
+ message(FATAL_ERROR "${sfile} doesn't exist (it was added to CONV_SOURCES)")
endif()
endforeach()
-file(GLOB_RECURSE EXTRA_CONV_SOURCES os/*.c api/*.c msgpack_rpc/*.c)
-foreach(sfile ${EXTRA_CONV_SOURCES})
- file(RELATIVE_PATH f "${PROJECT_SOURCE_DIR}/src/nvim" "${sfile}")
- list(APPEND CONV_SOURCES ${f})
-endforeach()
-
set_source_files_properties(
- ${CONV_SOURCES} PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS} -Wconversion")
+ ${CONV_SOURCES} PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS} -Wno-conversion")
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
if(DEFINED ENV{SANITIZE})
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index addcbf62e9..fc1307090d 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -49,8 +49,10 @@ void vim_command(String str, Error *err)
///
/// @param keys to be typed
/// @param mode specifies the mapping options
+/// @param escape_csi the string needs escaping for K_SPECIAL/CSI bytes
/// @see feedkeys()
-void vim_feedkeys(String keys, String mode)
+/// @see vim_strsave_escape_csi
+void vim_feedkeys(String keys, String mode, Boolean escape_csi)
FUNC_ATTR_DEFERRED
{
bool remap = true;
@@ -68,12 +70,20 @@ void vim_feedkeys(String keys, String mode)
}
}
- /* Need to escape K_SPECIAL and CSI before putting the string in the
- * typeahead buffer. */
- char *keys_esc = (char *)vim_strsave_escape_csi((char_u *)keys.data);
+ char *keys_esc;
+ if (escape_csi) {
+ // Need to escape K_SPECIAL and CSI before putting the string in the
+ // typeahead buffer.
+ keys_esc = (char *)vim_strsave_escape_csi((char_u *)keys.data);
+ } else {
+ keys_esc = keys.data;
+ }
ins_typebuf((char_u *)keys_esc, (remap ? REMAP_YES : REMAP_NONE),
typebuf.tb_len, !typed, false);
- free(keys_esc);
+
+ if (escape_csi) {
+ free(keys_esc);
+ }
if (vgetc_busy)
typebuf_was_filled = true;
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index 6b5b97fe67..ec10a826c7 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -69,10 +69,11 @@
#include "nvim/strings.h"
#include "nvim/syntax.h"
#include "nvim/term.h"
-#include "nvim/ui.h"
#include "nvim/undo.h"
#include "nvim/window.h"
#include "nvim/os/os.h"
+#include "nvim/os/time.h"
+#include "nvim/os/input.h"
#define HAVE_BUFLIST_MATCH
@@ -716,7 +717,7 @@ do_bufdel (
} else /* addr_count == 1 */
bnr = end_bnr;
- for (; !got_int; ui_breakcheck()) {
+ for (; !got_int; os_breakcheck()) {
/*
* delete the current buffer last, otherwise when the
* current buffer is deleted, the next buffer becomes
@@ -1422,7 +1423,7 @@ buflist_new (
EMSG(_("W14: Warning: List of file names overflow"));
if (emsg_silent == 0) {
out_flush();
- ui_delay(3000L, true); /* make sure it is noticed */
+ os_delay(3000L, true); /* make sure it is noticed */
}
top_file_num = 1;
}
@@ -2162,7 +2163,7 @@ void buflist_list(exarg_T *eap)
: (int64_t)buflist_findlnum(buf));
msg_outtrans(IObuff);
out_flush(); /* output one line at a time */
- ui_breakcheck();
+ os_breakcheck();
}
}
@@ -3801,7 +3802,7 @@ do_arg_all (
++autocmd_no_leave;
use_firstwin = FALSE;
}
- ui_breakcheck();
+ os_breakcheck();
/* When ":tab" was used open a new tab for a new window repeatedly. */
if (had_tab > 0 && tabpage_index(NULL) <= p_tpm)
@@ -3965,7 +3966,7 @@ void ex_buffer_all(exarg_T *eap)
#endif
}
- ui_breakcheck();
+ os_breakcheck();
if (got_int) {
(void)vgetc(); /* only break the file loading, not the rest */
break;
diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h
index 196b975d2a..23f20c3c75 100644
--- a/src/nvim/buffer_defs.h
+++ b/src/nvim/buffer_defs.h
@@ -578,12 +578,7 @@ struct file_buffer {
#define B_IMODE_USE_INSERT -1 /* Use b_p_iminsert value for search */
#define B_IMODE_NONE 0 /* Input via none */
#define B_IMODE_LMAP 1 /* Input via langmap */
-#ifndef USE_IM_CONTROL
# define B_IMODE_LAST 1
-#else
-# define B_IMODE_IM 2 /* Input via input method */
-# define B_IMODE_LAST 2
-#endif
short b_kmap_state; /* using "lmap" mappings */
# define KEYMAP_INIT 1 /* 'keymap' was set, call keymap_init() */
diff --git a/src/nvim/cursor_shape.c b/src/nvim/cursor_shape.c
index 328b751693..06c8186bf9 100644
--- a/src/nvim/cursor_shape.c
+++ b/src/nvim/cursor_shape.c
@@ -1,4 +1,5 @@
#include <assert.h>
+#include <stdint.h>
#include "nvim/vim.h"
#include "nvim/ascii.h"
#include "nvim/cursor_shape.h"
@@ -52,7 +53,6 @@ char_u *parse_shape_opt(int what)
int all_idx;
int len;
int i;
- long n;
int found_ve = FALSE; /* found "ve" flag */
int round;
@@ -135,7 +135,9 @@ char_u *parse_shape_opt(int what)
p += len;
if (!VIM_ISDIGIT(*p))
return (char_u *)N_("E548: digit expected");
- n = getdigits(&p);
+ long digits = getdigits(&p);
+ assert(digits <= INT_MAX);
+ int n = (int)digits;
if (len == 3) { /* "ver" or "hor" */
if (n == 0)
return (char_u *)N_("E549: Illegal percentage");
diff --git a/src/nvim/digraph.c b/src/nvim/digraph.c
index f41a16bc1b..440d07aab0 100644
--- a/src/nvim/digraph.c
+++ b/src/nvim/digraph.c
@@ -2,7 +2,9 @@
///
/// code for digraphs
+#include <assert.h>
#include <stdbool.h>
+#include <stdint.h>
#include <inttypes.h>
#include "nvim/vim.h"
@@ -21,7 +23,7 @@
#include "nvim/normal.h"
#include "nvim/screen.h"
#include "nvim/strings.h"
-#include "nvim/ui.h"
+#include "nvim/os/input.h"
typedef int result_T;
@@ -1582,7 +1584,7 @@ int getdigraph(int char1, int char2, int meta_char)
/// @param str
void putdigraph(char_u *str)
{
- int char1, char2, n;
+ char_u char1, char2;
digr_T *dp;
while (*str != NUL) {
@@ -1609,7 +1611,9 @@ void putdigraph(char_u *str)
EMSG(_(e_number_exp));
return;
}
- n = getdigits(&str);
+ long digits = getdigits(&str);
+ assert(digits <= INT_MAX);
+ int n = (int)digits;
// If the digraph already exists, replace the result.
dp = (digr_T *)user_digraphs.ga_data;
@@ -1655,13 +1659,13 @@ void listdigraphs(void)
printdigraph(&tmp);
}
dp++;
- ui_breakcheck();
+ os_breakcheck();
}
dp = (digr_T *)user_digraphs.ga_data;
for (int i = 0; i < user_digraphs.ga_len && !got_int; ++i) {
printdigraph(dp);
- ui_breakcheck();
+ os_breakcheck();
dp++;
}
// clear screen, because some digraphs may be wrong, in which case we messed
@@ -1711,7 +1715,8 @@ static void printdigraph(digr_T *dp)
if (char2cells(dp->result) == 1) {
*p++ = ' ';
}
- vim_snprintf((char *)p, sizeof(buf) - (p - buf), " %3d", dp->result);
+ assert(p >= buf);
+ vim_snprintf((char *)p, sizeof(buf) - (size_t)(p - buf), " %3d", dp->result);
msg_outtrans(buf);
}
}
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index 8bf5170ae7..c7f20783a9 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -56,9 +56,12 @@
#include "nvim/tag.h"
#include "nvim/term.h"
#include "nvim/ui.h"
+#include "nvim/mouse.h"
#include "nvim/undo.h"
#include "nvim/window.h"
#include "nvim/os/event.h"
+#include "nvim/os/input.h"
+#include "nvim/os/time.h"
/*
* definitions used for CTRL-X submode
@@ -388,9 +391,6 @@ edit (
*/
if (curbuf->b_p_iminsert == B_IMODE_LMAP)
State |= LANGMAP;
-#ifdef USE_IM_CONTROL
- im_set_active(curbuf->b_p_iminsert == B_IMODE_IM);
-#endif
setmouse();
clear_showcmd();
@@ -593,9 +593,17 @@ edit (
* Get a character for Insert mode. Ignore K_IGNORE.
*/
lastc = c; /* remember previous char for CTRL-D */
+ event_enable_deferred();
do {
c = safe_vgetc();
} while (c == K_IGNORE);
+ event_disable_deferred();
+
+ if (c == K_EVENT) {
+ c = lastc;
+ event_process();
+ continue;
+ }
/* Don't want K_CURSORHOLD for the second key, e.g., after CTRL-V. */
did_cursorhold = TRUE;
@@ -943,10 +951,6 @@ doESCkey:
did_cursorhold = TRUE;
break;
- case K_EVENT:
- event_process();
- break;
-
case K_HOME: /* <Home> */
case K_KHOME:
case K_S_HOME:
@@ -1757,7 +1761,7 @@ static int has_compl_option(int dict_opt)
vim_beep();
setcursor();
out_flush();
- ui_delay(2000L, false);
+ os_delay(2000L, false);
}
return FALSE;
}
@@ -2001,7 +2005,7 @@ ins_compl_add (
compl_T *match;
int dir = (cdir == 0 ? compl_direction : cdir);
- ui_breakcheck();
+ os_breakcheck();
if (got_int)
return FAIL;
if (len < 0)
@@ -6757,19 +6761,11 @@ static void ins_reg(void)
* message for it. Only call it explicitly. */
++no_u_sync;
if (regname == '=') {
-# ifdef USE_IM_CONTROL
- int im_on = im_get_status();
-# endif
/* Sync undo when evaluating the expression calls setline() or
* append(), so that it can be undone separately. */
u_sync_once = 2;
regname = get_expr_register();
-# ifdef USE_IM_CONTROL
- /* Restore the Input Method. */
- if (im_on)
- im_set_active(TRUE);
-# endif
}
if (regname == NUL || !valid_yank_reg(regname, FALSE)) {
vim_beep();
@@ -6866,24 +6862,8 @@ static void ins_ctrl_hat(void)
} else {
curbuf->b_p_iminsert = B_IMODE_LMAP;
State |= LANGMAP;
-#ifdef USE_IM_CONTROL
- im_set_active(FALSE);
-#endif
}
}
-#ifdef USE_IM_CONTROL
- else {
- /* There are no ":lmap" mappings, toggle IM */
- if (im_get_status()) {
- curbuf->b_p_iminsert = B_IMODE_NONE;
- im_set_active(FALSE);
- } else {
- curbuf->b_p_iminsert = B_IMODE_IM;
- State &= ~LANGMAP;
- im_set_active(TRUE);
- }
- }
-#endif
set_iminsert_global();
showmode();
/* Show/unshow value of 'keymap' in status lines. */
@@ -6983,14 +6963,6 @@ ins_esc (
}
}
-#ifdef USE_IM_CONTROL
- /* Disable IM to allow typing English directly for Normal mode commands.
- * When ":lmap" is enabled don't change 'iminsert' (IM can be enabled as
- * well). */
- if (!(State & LANGMAP))
- im_save_status(&curbuf->b_p_iminsert);
- im_set_active(FALSE);
-#endif
State = NORMAL;
/* need to position cursor again (e.g. when on a TAB ) */
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 498795dc38..34990a62e0 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -76,7 +76,7 @@
#include "nvim/tag.h"
#include "nvim/tempfile.h"
#include "nvim/term.h"
-#include "nvim/ui.h"
+#include "nvim/mouse.h"
#include "nvim/undo.h"
#include "nvim/version.h"
#include "nvim/window.h"
@@ -90,6 +90,7 @@
#include "nvim/api/vim.h"
#include "nvim/os/dl.h"
#include "nvim/os/event.h"
+#include "nvim/os/input.h"
#define DICT_MAXNEST 100 /* maximum nesting of lists and dicts */
@@ -178,6 +179,8 @@ static char *e_nofunc = N_("E130: Unknown function: %s");
static char *e_illvar = N_("E461: Illegal variable name: %s");
static char *e_float_as_string = N_("E806: using Float as a String");
+static char_u * const empty_string = (char_u *)"";
+
static dictitem_T globvars_var; /* variable used for g: */
#define globvarht globvardict.dv_hashtab
@@ -2272,6 +2275,7 @@ static void set_var_lval(lval_T *lp, char_u *endp, typval_T *rettv, int copy, ch
if (lp->ll_li->li_next == NULL) {
/* Need to add an empty item. */
list_append_number(lp->ll_list, 0);
+ assert(lp->ll_li->li_next);
}
lp->ll_li = lp->ll_li->li_next;
++lp->ll_n1;
@@ -4123,7 +4127,7 @@ eval7 (
* get_func_tv, but it's needed in handle_subscript() to parse
* what follows. So set it here. */
if (rettv->v_type == VAR_UNKNOWN && !evaluate && **arg == '(') {
- rettv->vval.v_string = (char_u *)"";
+ rettv->vval.v_string = empty_string;
rettv->v_type = VAR_FUNC;
}
@@ -5733,7 +5737,9 @@ dict_free (
dictitem_T *dictitem_alloc(char_u *key) FUNC_ATTR_NONNULL_RET
{
dictitem_T *di = xmalloc(sizeof(dictitem_T) + STRLEN(key));
+#ifndef __clang_analyzer__
STRCPY(di->di_key, key);
+#endif
di->di_flags = 0;
return di;
}
@@ -8409,7 +8415,7 @@ static void f_feedkeys(typval_T *argvars, typval_T *rettv)
}
vim_feedkeys(cstr_as_string((char *)keys),
- cstr_as_string((char *)flags));
+ cstr_as_string((char *)flags), true);
}
}
@@ -10268,12 +10274,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
@@ -10368,11 +10368,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;
@@ -12518,6 +12513,7 @@ static void f_rpcrequest(typval_T *argvars, typval_T *rettv)
{
rettv->v_type = VAR_NUMBER;
rettv->vval.v_number = 0;
+ const int l_provider_call_nesting = provider_call_nesting;
if (check_restricted() || check_secure()) {
return;
@@ -12545,7 +12541,7 @@ static void f_rpcrequest(typval_T *argvars, typval_T *rettv)
int save_autocmd_fname_full, save_autocmd_bufnr;
void *save_funccalp;
- if (provider_call_nesting) {
+ if (l_provider_call_nesting) {
// If this is called from a provider function, restore the scope
// information of the caller.
save_current_SID = current_SID;
@@ -12574,7 +12570,7 @@ static void f_rpcrequest(typval_T *argvars, typval_T *rettv)
args,
&err);
- if (provider_call_nesting) {
+ if (l_provider_call_nesting) {
current_SID = save_current_SID;
sourcing_name = save_sourcing_name;
sourcing_lnum = save_sourcing_lnum;
@@ -13542,13 +13538,12 @@ static bool item_compare_numeric;
static char_u *item_compare_func;
static dict_T *item_compare_selfdict;
static int item_compare_func_err;
-static bool item_compare_keep_zero;
#define ITEM_COMPARE_FAIL 999
/*
* Compare functions for f_sort() and f_uniq() below.
*/
-static int item_compare(const void *s1, const void *s2)
+static int item_compare(const void *s1, const void *s2, bool keep_zero)
{
sortItem_T *si1, *si2;
char_u *p1, *p2;
@@ -13601,7 +13596,7 @@ static int item_compare(const void *s1, const void *s2)
// When the result would be zero, compare the item indexes. Makes the
// sort stable.
- if (res == 0 && !item_compare_keep_zero) {
+ if (res == 0 && !keep_zero) {
res = si1->idx > si2->idx ? 1 : -1;
}
@@ -13610,7 +13605,17 @@ static int item_compare(const void *s1, const void *s2)
return res;
}
-static int item_compare2(const void *s1, const void *s2)
+static int item_compare_keeping_zero(const void *s1, const void *s2)
+{
+ return item_compare(s1, s2, true);
+}
+
+static int item_compare_not_keeping_zero(const void *s1, const void *s2)
+{
+ return item_compare(s1, s2, false);
+}
+
+static int item_compare2(const void *s1, const void *s2, bool keep_zero)
{
sortItem_T *si1, *si2;
int res;
@@ -13647,13 +13652,23 @@ static int item_compare2(const void *s1, const void *s2)
// When the result would be zero, compare the pointers themselves. Makes
// the sort stable.
- if (res == 0 && !item_compare_keep_zero) {
+ if (res == 0 && !keep_zero) {
res = si1->idx > si2->idx ? 1 : -1;
}
return res;
}
+static int item_compare2_keeping_zero(const void *s1, const void *s2)
+{
+ return item_compare2(s1, s2, true);
+}
+
+static int item_compare2_not_keeping_zero(const void *s1, const void *s2)
+{
+ return item_compare2(s1, s2, false);
+}
+
/*
* "sort({list})" function
*/
@@ -13734,15 +13749,16 @@ static void do_sort_uniq(typval_T *argvars, typval_T *rettv, bool sort)
}
item_compare_func_err = FALSE;
- item_compare_keep_zero = false;
// Test the compare function.
if (item_compare_func != NULL
- && item_compare2(&ptrs[0], &ptrs[1]) == ITEM_COMPARE_FAIL) {
+ && item_compare2_not_keeping_zero(&ptrs[0], &ptrs[1])
+ == ITEM_COMPARE_FAIL) {
EMSG(_("E702: Sort compare function failed"));
} else {
// Sort the array with item pointers.
qsort(ptrs, (size_t)len, sizeof (sortItem_T),
- item_compare_func == NULL ? item_compare : item_compare2);
+ item_compare_func == NULL ? item_compare_not_keeping_zero :
+ item_compare2_not_keeping_zero);
if (!item_compare_func_err) {
// Clear the list and append the items in the sorted order.
@@ -13761,8 +13777,8 @@ static void do_sort_uniq(typval_T *argvars, typval_T *rettv, bool sort)
// f_uniq(): ptrs will be a stack of items to remove.
item_compare_func_err = FALSE;
- item_compare_keep_zero = true;
- item_compare_func_ptr = item_compare_func ? item_compare2 : item_compare;
+ item_compare_func_ptr = item_compare_func ? item_compare2_keeping_zero :
+ item_compare_keeping_zero;
for (li = l->lv_first; li != NULL && li->li_next != NULL; li = li->li_next) {
if (item_compare_func_ptr(&li, &li->li_next) == 0) {
@@ -13776,6 +13792,7 @@ static void do_sort_uniq(typval_T *argvars, typval_T *rettv, bool sort)
if (!item_compare_func_err) {
while (--i >= 0) {
+ assert(ptrs[i].item->li_next);
li = ptrs[i].item->li_next;
ptrs[i].item->li_next = li->li_next;
if (li->li_next != NULL) {
@@ -14561,8 +14578,7 @@ static void get_system_output_as_rettv(typval_T *argvars, typval_T *rettv,
if (res == NULL) {
if (retlist) {
// return an empty list when there's no output
- rettv->v_type = VAR_LIST;
- rettv->vval.v_list = list_alloc();
+ rettv_list_alloc(rettv);
}
return;
}
@@ -16111,7 +16127,11 @@ void clear_tv(typval_T *varp)
switch (varp->v_type) {
case VAR_FUNC:
func_unref(varp->vval.v_string);
- /*FALLTHROUGH*/
+ if (varp->vval.v_string != empty_string) {
+ free(varp->vval.v_string);
+ }
+ varp->vval.v_string = NULL;
+ break;
case VAR_STRING:
free(varp->vval.v_string);
varp->vval.v_string = NULL;
@@ -17251,7 +17271,7 @@ void ex_function(exarg_T *eap)
msg_putchar(' ');
msg_prt_line(FUNCLINE(fp, j), FALSE);
out_flush(); /* show a line at a time */
- ui_breakcheck();
+ os_breakcheck();
}
if (!got_int) {
msg_putchar('\n');
@@ -18250,6 +18270,7 @@ char_u *get_user_func_name(expand_T *xp, int idx)
done = 0;
hi = func_hashtab.ht_array;
}
+ assert(hi);
if (done < func_hashtab.ht_used) {
if (done++ > 0)
++hi;
@@ -18465,8 +18486,10 @@ call_user_func (
/* Set l:self to "selfdict". Use "name" to avoid a warning from
* some compiler that checks the destination size. */
v = &fc->fixvar[fixvar_idx++].var;
+#ifndef __clang_analyzer__
name = v->di_key;
STRCPY(name, "self");
+#endif
v->di_flags = DI_FLAGS_RO + DI_FLAGS_FIX;
hash_add(&fc->l_vars.dv_hashtab, DI2HIKEY(v));
v->di_tv.v_type = VAR_DICT;
@@ -18486,8 +18509,10 @@ call_user_func (
/* Use "name" to avoid a warning from some compiler that checks the
* destination size. */
v = &fc->fixvar[fixvar_idx++].var;
+#ifndef __clang_analyzer__
name = v->di_key;
STRCPY(name, "000");
+#endif
v->di_flags = DI_FLAGS_RO | DI_FLAGS_FIX;
hash_add(&fc->l_avars.dv_hashtab, DI2HIKEY(v));
v->di_tv.v_type = VAR_LIST;
@@ -18774,7 +18799,9 @@ free_funccal (
*/
static void add_nr_var(dict_T *dp, dictitem_T *v, char *name, varnumber_T nr)
{
+#ifndef __clang_analyzer__
STRCPY(v->di_key, name);
+#endif
v->di_flags = DI_FLAGS_RO | DI_FLAGS_FIX;
hash_add(&dp->dv_hashtab, DI2HIKEY(v));
v->di_tv.v_type = VAR_NUMBER;
@@ -18864,8 +18891,10 @@ int do_return(exarg_T *eap, int reanimate, int is_cmd, void *rettv)
else {
/* When undoing a return in order to make it pending, get the stored
* return rettv. */
- if (reanimate)
+ if (reanimate) {
+ assert(current_funccal->rettv);
rettv = current_funccal->rettv;
+ }
if (rettv != NULL) {
/* Store the value of the pending return. */
@@ -19267,7 +19296,7 @@ void ex_oldfiles(exarg_T *eap)
msg_outtrans(get_tv_string(&li->li_tv));
msg_putchar('\n');
out_flush(); /* output one line at a time */
- ui_breakcheck();
+ os_breakcheck();
}
/* Assume "got_int" was set to truncate the listing. */
got_int = FALSE;
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index f33a96cc50..556e0c01e3 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -62,11 +62,11 @@
#include "nvim/tag.h"
#include "nvim/tempfile.h"
#include "nvim/term.h"
-#include "nvim/ui.h"
#include "nvim/undo.h"
#include "nvim/window.h"
#include "nvim/os/os.h"
#include "nvim/os/shell.h"
+#include "nvim/os/input.h"
/*
* Struct to hold the sign properties.
@@ -1110,7 +1110,7 @@ do_filter (
/* When interrupting the shell command, it may still have produced some
* useful output. Reset got_int here, so that readfile() won't cancel
* reading. */
- ui_breakcheck();
+ os_breakcheck();
got_int = FALSE;
if (do_out) {
@@ -4560,7 +4560,7 @@ void global_exe(char_u *cmd)
do_cmdline((char_u *)"p", NULL, NULL, DOCMD_NOWAIT);
else
do_cmdline(cmd, NULL, NULL, DOCMD_NOWAIT);
- ui_breakcheck();
+ os_breakcheck();
}
global_busy = 0;
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 3e9b889253..3967c916bb 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -67,6 +67,8 @@
#include "nvim/version.h"
#include "nvim/window.h"
#include "nvim/os/os.h"
+#include "nvim/os/input.h"
+#include "nvim/os/time.h"
#include "nvim/ex_cmds_defs.h"
static int quitmore = 0;
@@ -4337,7 +4339,7 @@ static void uc_list(char_u *name, size_t name_len)
if (p_verbose > 0)
last_set_msg(cmd->uc_scriptID);
out_flush();
- ui_breakcheck();
+ os_breakcheck();
if (got_int)
break;
}
@@ -5459,7 +5461,7 @@ static void ex_print(exarg_T *eap)
if (curbuf->b_ml.ml_flags & ML_EMPTY)
EMSG(_(e_emptybuf));
else {
- for (; !got_int; ui_breakcheck()) {
+ for (; !got_int; os_breakcheck()) {
print_line(eap->line1,
(eap->cmdidx == CMD_number || eap->cmdidx == CMD_pound
|| (eap->flags & EXFLAG_NR)),
@@ -5586,7 +5588,7 @@ void alist_set(alist_T *al, int count, char_u **files, int use_curbuf, int *fnum
buf_set_name(fnum_list[i], files[i]);
alist_add(al, files[i], use_curbuf ? 2 : 1);
- ui_breakcheck();
+ os_breakcheck();
}
free(files);
}
@@ -5842,7 +5844,7 @@ static void ex_tabs(exarg_T *eap)
vim_snprintf((char *)IObuff, IOSIZE, _("Tab page %d"), tabcount++);
msg_outtrans_attr(IObuff, hl_attr(HLF_T));
out_flush(); /* output one line at a time */
- ui_breakcheck();
+ os_breakcheck();
FOR_ALL_WINDOWS_IN_TAB(wp, tp) {
if (got_int) {
@@ -5861,7 +5863,7 @@ static void ex_tabs(exarg_T *eap)
IObuff, IOSIZE, TRUE);
msg_outtrans(IObuff);
out_flush(); /* output one line at a time */
- ui_breakcheck();
+ os_breakcheck();
}
}
}
@@ -6408,8 +6410,8 @@ void do_sleep(long msec)
cursor_on();
out_flush();
for (done = 0; !got_int && done < msec; done += 1000L) {
- ui_delay(msec - done > 1000L ? 1000L : msec - done, true);
- ui_breakcheck();
+ os_delay(msec - done > 1000L ? 1000L : msec - done, true);
+ os_breakcheck();
}
}
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index 5feff4d456..70db2dc479 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -265,14 +265,7 @@ getcmdline (
b_im_ptr = &curbuf->b_p_imsearch;
if (*b_im_ptr == B_IMODE_LMAP)
State |= LANGMAP;
-#ifdef USE_IM_CONTROL
- im_set_active(*b_im_ptr == B_IMODE_IM);
-#endif
}
-#ifdef USE_IM_CONTROL
- else if (p_imcmdline)
- im_set_active(TRUE);
-#endif
setmouse();
ui_cursor_shape(); /* may show different cursor shape */
@@ -311,9 +304,16 @@ getcmdline (
/* Get a character. Ignore K_IGNORE, it should not do anything, such
* as stop completion. */
+ event_enable_deferred();
do {
c = safe_vgetc();
} while (c == K_IGNORE);
+ event_disable_deferred();
+
+ if (c == K_EVENT) {
+ event_process();
+ continue;
+ }
if (KeyTyped) {
some_key_typed = TRUE;
@@ -769,11 +769,6 @@ getcmdline (
* Big switch for a typed command line character.
*/
switch (c) {
- case K_EVENT:
- event_process();
- // Force a redraw even though the command line didn't change
- shell_resized();
- goto cmdline_not_changed;
case K_BS:
case Ctrl_H:
case K_DEL:
@@ -865,9 +860,6 @@ getcmdline (
if (map_to_exists_mode((char_u *)"", LANGMAP, FALSE)) {
/* ":lmap" mappings exists, toggle use of mappings. */
State ^= LANGMAP;
-#ifdef USE_IM_CONTROL
- im_set_active(FALSE); /* Disable input method */
-#endif
if (b_im_ptr != NULL) {
if (State & LANGMAP)
*b_im_ptr = B_IMODE_LMAP;
@@ -875,23 +867,6 @@ getcmdline (
*b_im_ptr = B_IMODE_NONE;
}
}
-#ifdef USE_IM_CONTROL
- else {
- /* There are no ":lmap" mappings, toggle IM. When
- * 'imdisable' is set don't try getting the status, it's
- * always off. */
- if ((p_imdisable && b_im_ptr != NULL)
- ? *b_im_ptr == B_IMODE_IM : im_get_status()) {
- im_set_active(FALSE); /* Disable input method */
- if (b_im_ptr != NULL)
- *b_im_ptr = B_IMODE_NONE;
- } else {
- im_set_active(TRUE); /* Enable input method */
- if (b_im_ptr != NULL)
- *b_im_ptr = B_IMODE_IM;
- }
- }
-#endif
if (b_im_ptr != NULL) {
if (b_im_ptr == &curbuf->b_p_iminsert)
set_iminsert_global();
@@ -1540,11 +1515,6 @@ returncmd:
need_wait_return = FALSE;
State = save_State;
-#ifdef USE_IM_CONTROL
- if (b_im_ptr != NULL && *b_im_ptr != B_IMODE_LMAP)
- im_save_status(b_im_ptr);
- im_set_active(FALSE);
-#endif
setmouse();
ui_cursor_shape(); /* may show different cursor shape */
@@ -1885,8 +1855,6 @@ redraw:
}
if (IS_SPECIAL(c1)) {
- // Process deferred events
- event_process();
// Ignore other special key codes
continue;
}
@@ -1946,7 +1914,7 @@ redraw:
msg_col = 0;
if (msg_row < Rows - 1)
++msg_row;
- emsg_on_display = FALSE; /* don't want ui_delay() */
+ emsg_on_display = FALSE; /* don't want os_delay() */
if (got_int)
ga_clear(&line_ga);
diff --git a/src/nvim/file_search.c b/src/nvim/file_search.c
index 955b0b0a68..1cb9e1e8f7 100644
--- a/src/nvim/file_search.c
+++ b/src/nvim/file_search.c
@@ -62,9 +62,9 @@
#include "nvim/path.h"
#include "nvim/strings.h"
#include "nvim/tag.h"
-#include "nvim/ui.h"
#include "nvim/window.h"
#include "nvim/os/os.h"
+#include "nvim/os/input.h"
#include "nvim/os/fs_defs.h"
static char_u *ff_expand_buffer = NULL; /* used for expanding filenames */
@@ -607,7 +607,7 @@ char_u *vim_findfile(void *search_ctx_arg)
/* downward search loop */
for (;; ) {
/* check if user user wants to stop the search*/
- ui_breakcheck();
+ os_breakcheck();
if (got_int)
break;
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index 97a357bff7..3be9d89d87 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -53,10 +53,11 @@
#include "nvim/tempfile.h"
#include "nvim/term.h"
#include "nvim/types.h"
-#include "nvim/ui.h"
#include "nvim/undo.h"
#include "nvim/window.h"
#include "nvim/os/os.h"
+#include "nvim/os/time.h"
+#include "nvim/os/input.h"
#if defined(HAVE_UTIME) && defined(HAVE_UTIME_H)
# include <utime.h> /* for struct utimbuf */
@@ -1704,7 +1705,7 @@ rewind_retry:
}
}
linerest = (long)(ptr - line_start);
- ui_breakcheck();
+ os_breakcheck();
}
failed:
@@ -2927,7 +2928,7 @@ buf_write (
"E506: Can't write to backup file (add ! to override)");
break;
}
- ui_breakcheck();
+ os_breakcheck();
if (got_int) {
errmsg = (char_u *)_(e_interr);
break;
@@ -3377,7 +3378,7 @@ restore_backup:
s = buffer;
len = 0;
- ui_breakcheck();
+ os_breakcheck();
if (got_int) {
end = 0; /* Interrupted, break loop */
break;
@@ -4958,7 +4959,7 @@ buf_check_timestamp (
if (emsg_silent == 0) {
out_flush();
/* give the user some time to think about it */
- ui_delay(1000L, true);
+ os_delay(1000L, true);
/* don't redraw and erase the message */
redraw_cmdline = FALSE;
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c
index fd60664b7b..d0bdcde9e8 100644
--- a/src/nvim/getchar.c
+++ b/src/nvim/getchar.c
@@ -47,7 +47,6 @@
#include "nvim/screen.h"
#include "nvim/strings.h"
#include "nvim/term.h"
-#include "nvim/ui.h"
#include "nvim/undo.h"
#include "nvim/os/event.h"
#include "nvim/os/input.h"
@@ -1702,14 +1701,14 @@ static int vgetorpeek(int advance)
*/
for (;; ) {
/*
- * ui_breakcheck() is slow, don't use it too often when
+ * os_breakcheck() is slow, don't use it too often when
* inside a mapping. But call it each time for typed
* characters.
*/
if (typebuf.tb_maplen)
line_breakcheck();
else
- ui_breakcheck(); /* check for CTRL-C */
+ os_breakcheck(); /* check for CTRL-C */
keylen = 0;
if (got_int) {
/* flush all input */
@@ -2350,11 +2349,6 @@ static int vgetorpeek(int advance)
+ typebuf.tb_len] != NUL)
typebuf.tb_noremap[typebuf.tb_off
+ typebuf.tb_len++] = RM_YES;
-#ifdef USE_IM_CONTROL
- /* Get IM status right after getting keys, not after the
- * timeout for a mapping (focus may be lost by then). */
- vgetc_im_active = im_get_status();
-#endif
}
} /* for (;;) */
} /* if (!character from stuffbuf) */
@@ -2481,8 +2475,7 @@ inchar (
char_u dum[DUM_LEN + 1];
for (;; ) {
- event_process();
- 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;
}
@@ -2499,7 +2492,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..ea91135194 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 */
@@ -898,10 +897,6 @@ EXTERN int stop_insert_mode; /* for ":stopinsert" and 'insertmode' */
EXTERN int KeyTyped; /* TRUE if user typed current char */
EXTERN int KeyStuffed; /* TRUE if current char from stuffbuf */
-#ifdef USE_IM_CONTROL
-EXTERN int vgetc_im_active; /* Input Method was active for last
- character obtained from vgetc() */
-#endif
EXTERN int maptick INIT(= 0); /* tick for each non-mapped char */
EXTERN char_u chartab[256]; /* table used in charset.c; See
diff --git a/src/nvim/hardcopy.c b/src/nvim/hardcopy.c
index 1d15e30921..5d9d353fc8 100644
--- a/src/nvim/hardcopy.c
+++ b/src/nvim/hardcopy.c
@@ -41,8 +41,8 @@
#include "nvim/syntax.h"
#include "nvim/term.h"
#include "nvim/tempfile.h"
-#include "nvim/ui.h"
#include "nvim/os/os.h"
+#include "nvim/os/input.h"
/*
* To implement printing on a platform, the following functions must be
@@ -724,7 +724,7 @@ void ex_hardcopy(exarg_T *eap)
*/
/* Check for interrupt character every page. */
- ui_breakcheck();
+ os_breakcheck();
if (got_int || settings.user_abort)
goto print_fail;
diff --git a/src/nvim/if_cscope.c b/src/nvim/if_cscope.c
index 667e6512f3..bb41db6168 100644
--- a/src/nvim/if_cscope.c
+++ b/src/nvim/if_cscope.c
@@ -29,9 +29,9 @@
#include "nvim/strings.h"
#include "nvim/tag.h"
#include "nvim/tempfile.h"
-#include "nvim/ui.h"
#include "nvim/window.h"
#include "nvim/os/os.h"
+#include "nvim/os/input.h"
#include <sys/types.h>
#include <sys/stat.h>
@@ -1735,7 +1735,7 @@ static void cs_print_tags_priv(char **matches, char **cntxts, int num_matches)
if (msg_col)
msg_putchar('\n');
- ui_breakcheck();
+ os_breakcheck();
if (got_int) {
got_int = FALSE; /* don't print any more matches */
break;
diff --git a/src/nvim/main.c b/src/nvim/main.c
index 4447c404d5..68ae000c35 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -57,6 +57,7 @@
#include "nvim/ui.h"
#include "nvim/version.h"
#include "nvim/window.h"
+#include "nvim/os/time.h"
#include "nvim/os/input.h"
#include "nvim/os/os.h"
#include "nvim/os/signal.h"
@@ -1608,7 +1609,7 @@ static void check_tty(mparm_T *parmp)
mch_errmsg(_("Vim: Warning: Input is not from a terminal\n"));
out_flush();
if (scriptin[0] == NULL)
- ui_delay(2000L, true);
+ os_delay(2000L, true);
TIME_MSG("Warning delay");
}
}
@@ -1742,7 +1743,7 @@ static void create_windows(mparm_T *parmp)
#endif
dorewind = TRUE; /* start again */
}
- ui_breakcheck();
+ os_breakcheck();
if (got_int) {
(void)vgetc(); /* only break the file loading, not the rest */
break;
@@ -1832,7 +1833,7 @@ static void edit_buffers(mparm_T *parmp)
arg_had_last = TRUE;
++arg_idx;
}
- ui_breakcheck();
+ os_breakcheck();
if (got_int) {
(void)vgetc(); /* only break the file loading, not the rest */
break;
diff --git a/src/nvim/mark.c b/src/nvim/mark.c
index 120645cfe6..4ded438f52 100644
--- a/src/nvim/mark.c
+++ b/src/nvim/mark.c
@@ -38,8 +38,8 @@
#include "nvim/search.h"
#include "nvim/strings.h"
#include "nvim/term.h"
-#include "nvim/ui.h"
#include "nvim/os/os.h"
+#include "nvim/os/input.h"
/*
* This file contains routines to maintain and manipulate marks.
@@ -811,7 +811,7 @@ void ex_jumps(exarg_T *eap)
curwin->w_jumplist[i].fmark.fnum == curbuf->b_fnum
? hl_attr(HLF_D) : 0);
free(name);
- ui_breakcheck();
+ os_breakcheck();
}
out_flush();
}
@@ -845,7 +845,7 @@ void ex_changes(exarg_T *eap)
name = mark_line(&curbuf->b_changelist[i], 17);
msg_outtrans_attr(name, hl_attr(HLF_D));
free(name);
- ui_breakcheck();
+ os_breakcheck();
}
out_flush();
}
diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c
index 2240c1fe83..d79a46ceaa 100644
--- a/src/nvim/mbyte.c
+++ b/src/nvim/mbyte.c
@@ -103,7 +103,6 @@
#include "nvim/screen.h"
#include "nvim/spell.h"
#include "nvim/strings.h"
-#include "nvim/ui.h"
#include "nvim/os/os.h"
#include "nvim/arabic.h"
@@ -3972,3 +3971,23 @@ char_u * string_convert_ext(vimconv_T *vcp, char_u *ptr, int *lenp,
return retval;
}
+
+// Check bounds for column number
+static int check_col(int col)
+{
+ if (col < 0)
+ return 0;
+ if (col >= (int)screen_Columns)
+ return (int)screen_Columns - 1;
+ return col;
+}
+
+// Check bounds for row number
+static int check_row(int row)
+{
+ if (row < 0)
+ return 0;
+ if (row >= (int)screen_Rows)
+ return (int)screen_Rows - 1;
+ return row;
+}
diff --git a/src/nvim/memfile.c b/src/nvim/memfile.c
index 1656acb689..d8d59474a2 100644
--- a/src/nvim/memfile.c
+++ b/src/nvim/memfile.c
@@ -61,8 +61,8 @@
#include "nvim/memory.h"
#include "nvim/os_unix.h"
#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,10 +455,10 @@ 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();
+ os_breakcheck();
}
if (got_int)
break;
diff --git a/src/nvim/memline.c b/src/nvim/memline.c
index e9edeb842f..f6246c8b57 100644
--- a/src/nvim/memline.c
+++ b/src/nvim/memline.c
@@ -71,10 +71,10 @@
#include "nvim/strings.h"
#include "nvim/term.h"
#include "nvim/tempfile.h"
-#include "nvim/ui.h"
#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 +1642,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/memory.c b/src/nvim/memory.c
index c2c406a235..4c5a45b8b6 100644
--- a/src/nvim/memory.c
+++ b/src/nvim/memory.c
@@ -49,11 +49,11 @@ static void try_to_free_memory(void)
/// @return pointer to allocated space. NULL if out of memory
void *try_malloc(size_t size) FUNC_ATTR_MALLOC FUNC_ATTR_ALLOC_SIZE(1)
{
- size = size ? size : 1;
- void *ret = malloc(size);
+ size_t allocated_size = size ? size : 1;
+ void *ret = malloc(allocated_size);
if (!ret) {
try_to_free_memory();
- ret = malloc(size);
+ ret = malloc(allocated_size);
}
return ret;
}
@@ -102,10 +102,12 @@ void *xmalloc(size_t size)
void *xcalloc(size_t count, size_t size)
FUNC_ATTR_MALLOC FUNC_ATTR_ALLOC_SIZE_PROD(1, 2) FUNC_ATTR_NONNULL_RET
{
- void *ret = count && size ? calloc(count, size) : calloc(1, 1);
+ size_t allocated_count = count && size ? count : 1;
+ size_t allocated_size = count && size ? size : 1;
+ void *ret = calloc(allocated_count, allocated_size);
if (!ret) {
try_to_free_memory();
- ret = count && size ? calloc(count, size) : calloc(1, 1);
+ ret = calloc(allocated_count, allocated_size);
if (!ret) {
OUT_STR(e_outofmem);
out_char('\n');
@@ -123,10 +125,11 @@ void *xcalloc(size_t count, size_t size)
void *xrealloc(void *ptr, size_t size)
FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_ALLOC_SIZE(2) FUNC_ATTR_NONNULL_RET
{
- void *ret = size ? realloc(ptr, size) : realloc(ptr, 1);
+ size_t allocated_size = size ? size : 1;
+ void *ret = realloc(ptr, allocated_size);
if (!ret) {
try_to_free_memory();
- ret = size ? realloc(ptr, size) : realloc(ptr, 1);
+ ret = realloc(ptr, allocated_size);
if (!ret) {
OUT_STR(e_outofmem);
out_char('\n');
@@ -427,7 +430,6 @@ void do_outofmem_msg(size_t size)
#include "nvim/spell.h"
#include "nvim/syntax.h"
#include "nvim/tag.h"
-#include "nvim/ui.h"
#include "nvim/window.h"
#include "nvim/os/os.h"
diff --git a/src/nvim/message.c b/src/nvim/message.c
index ee83fd371e..cd0c548fb4 100644
--- a/src/nvim/message.c
+++ b/src/nvim/message.c
@@ -42,9 +42,10 @@
#include "nvim/screen.h"
#include "nvim/strings.h"
#include "nvim/term.h"
-#include "nvim/ui.h"
+#include "nvim/mouse.h"
#include "nvim/os/os.h"
-#include "nvim/os/event.h"
+#include "nvim/os/input.h"
+#include "nvim/os/time.h"
/*
* To be able to scroll back at the "more" and "hit-enter" prompts we need to
@@ -878,7 +879,7 @@ void wait_return(int redraw)
|| c == K_X1MOUSE
|| c == K_X2MOUSE))
);
- ui_breakcheck();
+ os_breakcheck();
/*
* Avoid that the mouse-up event causes visual mode to start.
*/
@@ -2076,9 +2077,6 @@ static int do_more_prompt(int typed_char)
toscroll = 0;
switch (c) {
- case K_EVENT:
- event_process();
- break;
case BS: /* scroll one line back */
case K_BS:
case 'k':
@@ -2706,11 +2704,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;
@@ -2738,8 +2734,6 @@ do_dialog (
break;
default: /* Could be a hotkey? */
if (c < 0) { /* special keys are ignored here */
- // drain event queue to prevent infinite loop
- event_process();
continue;
}
if (c == ':' && ex_cmd) {
diff --git a/src/nvim/misc1.c b/src/nvim/misc1.c
index 310cb6faac..230e198121 100644
--- a/src/nvim/misc1.c
+++ b/src/nvim/misc1.c
@@ -58,6 +58,8 @@
#include "nvim/window.h"
#include "nvim/os/os.h"
#include "nvim/os/shell.h"
+#include "nvim/os/input.h"
+#include "nvim/os/time.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "misc1.c.generated.h"
@@ -1840,7 +1842,7 @@ void changed(void)
* and don't let the emsg() set msg_scroll. */
if (need_wait_return && emsg_silent == 0) {
out_flush();
- ui_delay(2000L, true);
+ os_delay(2000L, true);
wait_return(TRUE);
msg_scroll = save_msg_scroll;
}
@@ -2261,7 +2263,7 @@ change_warning (
(void)msg_end();
if (msg_silent == 0 && !silent_mode) {
out_flush();
- ui_delay(1000L, true); /* give the user time to think about it */
+ os_delay(1000L, true); /* give the user time to think about it */
}
curbuf->b_did_warn = true;
redraw_cmdline = FALSE; /* don't redraw and erase the message */
@@ -2383,7 +2385,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);
@@ -3362,8 +3364,8 @@ void preserve_exit(void)
/*
* Check for CTRL-C pressed, but only once in a while.
- * Should be used instead of ui_breakcheck() for functions that check for
- * each line in the file. Calling ui_breakcheck() each time takes too much
+ * 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.
*/
@@ -3377,7 +3379,7 @@ void line_breakcheck(void)
{
if (++breakcheck_count >= BREAKCHECK_SKIP) {
breakcheck_count = 0;
- ui_breakcheck();
+ os_breakcheck();
}
}
@@ -3388,7 +3390,7 @@ void fast_breakcheck(void)
{
if (++breakcheck_count >= BREAKCHECK_SKIP * 10) {
breakcheck_count = 0;
- ui_breakcheck();
+ os_breakcheck();
}
}
diff --git a/src/nvim/misc2.c b/src/nvim/misc2.c
index 3fe5f1a0ed..acf243b349 100644
--- a/src/nvim/misc2.c
+++ b/src/nvim/misc2.c
@@ -50,7 +50,6 @@
#include "nvim/syntax.h"
#include "nvim/tag.h"
#include "nvim/term.h"
-#include "nvim/ui.h"
#include "nvim/window.h"
#include "nvim/os/os.h"
#include "nvim/os/shell.h"
diff --git a/src/nvim/mouse.c b/src/nvim/mouse.c
new file mode 100644
index 0000000000..7fc581a7c0
--- /dev/null
+++ b/src/nvim/mouse.c
@@ -0,0 +1,438 @@
+#include <stdbool.h>
+
+#include "nvim/mouse.h"
+#include "nvim/vim.h"
+#include "nvim/screen.h"
+#include "nvim/window.h"
+#include "nvim/term.h"
+#include "nvim/fold.h"
+#include "nvim/diff.h"
+#include "nvim/move.h"
+#include "nvim/misc1.h"
+#include "nvim/cursor.h"
+#include "nvim/buffer_defs.h"
+
+#ifdef INCLUDE_GENERATED_DECLARATIONS
+# include "mouse.c.generated.h"
+#endif
+
+// Move the cursor to the specified row and column on the screen.
+// Change current window if necessary. Returns an integer with the
+// CURSOR_MOVED bit set if the cursor has moved or unset otherwise.
+//
+// The MOUSE_FOLD_CLOSE bit is set when clicked on the '-' in a fold column.
+// The MOUSE_FOLD_OPEN bit is set when clicked on the '+' in a fold column.
+//
+// If flags has MOUSE_FOCUS, then the current window will not be changed, and
+// if the mouse is outside the window then the text will scroll, or if the
+// mouse was previously on a status line, then the status line may be dragged.
+//
+// If flags has MOUSE_MAY_VIS, then VIsual mode will be started before the
+// cursor is moved unless the cursor was on a status line.
+// This function returns one of IN_UNKNOWN, IN_BUFFER, IN_STATUS_LINE or
+// IN_SEP_LINE depending on where the cursor was clicked.
+//
+// If flags has MOUSE_MAY_STOP_VIS, then Visual mode will be stopped, unless
+// the mouse is on the status line of the same window.
+//
+// If flags has MOUSE_DID_MOVE, nothing is done if the mouse didn't move since
+// the last call.
+//
+// If flags has MOUSE_SETPOS, nothing is done, only the current position is
+// remembered.
+int jump_to_mouse(int flags,
+ bool *inclusive, // used for inclusive operator, can be NULL
+ int which_button) // MOUSE_LEFT, MOUSE_RIGHT, MOUSE_MIDDLE
+{
+ static int on_status_line = 0; // #lines below bottom of window
+ static int on_sep_line = 0; // on separator right of window
+ static int prev_row = -1;
+ static int prev_col = -1;
+ static win_T *dragwin = NULL; // window being dragged
+ static int did_drag = false; // drag was noticed
+
+ win_T *wp, *old_curwin;
+ pos_T old_cursor;
+ int count;
+ bool first;
+ int row = mouse_row;
+ int col = mouse_col;
+ int mouse_char;
+
+ mouse_past_bottom = false;
+ mouse_past_eol = false;
+
+ if (flags & MOUSE_RELEASED) {
+ // On button release we may change window focus if positioned on a
+ // status line and no dragging happened.
+ if (dragwin != NULL && !did_drag)
+ flags &= ~(MOUSE_FOCUS | MOUSE_DID_MOVE);
+ dragwin = NULL;
+ did_drag = false;
+ }
+
+ if ((flags & MOUSE_DID_MOVE)
+ && prev_row == mouse_row
+ && prev_col == mouse_col) {
+retnomove:
+ // before moving the cursor for a left click which is NOT in a status
+ // line, stop Visual mode
+ if (on_status_line)
+ return IN_STATUS_LINE;
+ if (on_sep_line)
+ return IN_SEP_LINE;
+ if (flags & MOUSE_MAY_STOP_VIS) {
+ end_visual_mode();
+ redraw_curbuf_later(INVERTED); // delete the inversion
+ }
+ return IN_BUFFER;
+ }
+
+ prev_row = mouse_row;
+ prev_col = mouse_col;
+
+ if (flags & MOUSE_SETPOS)
+ goto retnomove; // ugly goto...
+
+ // Remember the character under the mouse, it might be a '-' or '+' in the
+ // fold column.
+ if (row >= 0 && row < Rows && col >= 0 && col <= Columns
+ && ScreenLines != NULL)
+ mouse_char = ScreenLines[LineOffset[row] + (unsigned)col];
+ else
+ mouse_char = ' ';
+
+ old_curwin = curwin;
+ old_cursor = curwin->w_cursor;
+
+ if (!(flags & MOUSE_FOCUS)) {
+ if (row < 0 || col < 0) // check if it makes sense
+ return IN_UNKNOWN;
+
+ // find the window where the row is in
+ wp = mouse_find_win(&row, &col);
+ dragwin = NULL;
+ // winpos and height may change in win_enter()!
+ if (row >= wp->w_height) { // In (or below) status line
+ on_status_line = row - wp->w_height + 1;
+ dragwin = wp;
+ } else {
+ on_status_line = 0;
+ }
+
+ if (col >= wp->w_width) { // In separator line
+ on_sep_line = col - wp->w_width + 1;
+ dragwin = wp;
+ } else {
+ on_sep_line = 0;
+ }
+
+ // The rightmost character of the status line might be a vertical
+ // separator character if there is no connecting window to the right.
+ if (on_status_line && on_sep_line) {
+ if (stl_connected(wp))
+ on_sep_line = 0;
+ else
+ on_status_line = 0;
+ }
+
+ // Before jumping to another buffer, or moving the cursor for a left
+ // click, stop Visual mode.
+ if (VIsual_active
+ && (wp->w_buffer != curwin->w_buffer
+ || (!on_status_line
+ && !on_sep_line
+ && (
+ wp->w_p_rl ? col < wp->w_width - wp->w_p_fdc :
+ col >= wp->w_p_fdc
+ + (cmdwin_type == 0 && wp ==
+ curwin ? 0 : 1)
+ )
+ && (flags & MOUSE_MAY_STOP_VIS)))) {
+ end_visual_mode();
+ redraw_curbuf_later(INVERTED); // delete the inversion
+ }
+ if (cmdwin_type != 0 && wp != curwin) {
+ // A click outside the command-line window: Use modeless
+ // selection if possible. Allow dragging the status lines.
+ on_sep_line = 0;
+ row = 0;
+ col += wp->w_wincol;
+ wp = curwin;
+ }
+ // Only change window focus when not clicking on or dragging the
+ // status line. Do change focus when releasing the mouse button
+ // (MOUSE_FOCUS was set above if we dragged first).
+ if (dragwin == NULL || (flags & MOUSE_RELEASED))
+ win_enter(wp, true); // can make wp invalid!
+# ifdef CHECK_DOUBLE_CLICK
+ // set topline, to be able to check for double click ourselves
+ if (curwin != old_curwin)
+ set_mouse_topline(curwin);
+# endif
+ if (on_status_line) { // In (or below) status line
+ // Don't use start_arrow() if we're in the same window
+ if (curwin == old_curwin)
+ return IN_STATUS_LINE;
+ else
+ return IN_STATUS_LINE | CURSOR_MOVED;
+ }
+ if (on_sep_line) { // In (or below) status line
+ // Don't use start_arrow() if we're in the same window
+ if (curwin == old_curwin)
+ return IN_SEP_LINE;
+ else
+ return IN_SEP_LINE | CURSOR_MOVED;
+ }
+
+ curwin->w_cursor.lnum = curwin->w_topline;
+ } else if (on_status_line && which_button == MOUSE_LEFT) {
+ if (dragwin != NULL) {
+ // Drag the status line
+ count = row - dragwin->w_winrow - dragwin->w_height + 1
+ - on_status_line;
+ win_drag_status_line(dragwin, count);
+ did_drag |= count;
+ }
+ return IN_STATUS_LINE; // Cursor didn't move
+ } else if (on_sep_line && which_button == MOUSE_LEFT) {
+ if (dragwin != NULL) {
+ // Drag the separator column
+ count = col - dragwin->w_wincol - dragwin->w_width + 1
+ - on_sep_line;
+ win_drag_vsep_line(dragwin, count);
+ did_drag |= count;
+ }
+ return IN_SEP_LINE; // Cursor didn't move
+ } else {
+ // keep_window_focus must be true
+ // before moving the cursor for a left click, stop Visual mode
+ if (flags & MOUSE_MAY_STOP_VIS) {
+ end_visual_mode();
+ redraw_curbuf_later(INVERTED); // delete the inversion
+ }
+
+
+ row -= curwin->w_winrow;
+ col -= curwin->w_wincol;
+
+ // When clicking beyond the end of the window, scroll the screen.
+ // Scroll by however many rows outside the window we are.
+ if (row < 0) {
+ count = 0;
+ for (first = true; curwin->w_topline > 1; ) {
+ if (curwin->w_topfill < diff_check(curwin, curwin->w_topline))
+ ++count;
+ else
+ count += plines(curwin->w_topline - 1);
+ if (!first && count > -row)
+ break;
+ first = false;
+ hasFolding(curwin->w_topline, &curwin->w_topline, NULL);
+ if (curwin->w_topfill < diff_check(curwin, curwin->w_topline)) {
+ ++curwin->w_topfill;
+ } else {
+ --curwin->w_topline;
+ curwin->w_topfill = 0;
+ }
+ }
+ check_topfill(curwin, false);
+ curwin->w_valid &=
+ ~(VALID_WROW|VALID_CROW|VALID_BOTLINE|VALID_BOTLINE_AP);
+ redraw_later(VALID);
+ row = 0;
+ } else if (row >= curwin->w_height) {
+ count = 0;
+ for (first = true; curwin->w_topline < curbuf->b_ml.ml_line_count; ) {
+ if (curwin->w_topfill > 0) {
+ ++count;
+ } else {
+ count += plines(curwin->w_topline);
+ }
+
+ if (!first && count > row - curwin->w_height + 1) {
+ break;
+ }
+ first = false;
+
+ if (hasFolding(curwin->w_topline, NULL, &curwin->w_topline)
+ && curwin->w_topline == curbuf->b_ml.ml_line_count) {
+ break;
+ }
+
+ if (curwin->w_topfill > 0) {
+ --curwin->w_topfill;
+ } else {
+ ++curwin->w_topline;
+ curwin->w_topfill =
+ diff_check_fill(curwin, curwin->w_topline);
+ }
+ }
+ check_topfill(curwin, false);
+ redraw_later(VALID);
+ curwin->w_valid &=
+ ~(VALID_WROW|VALID_CROW|VALID_BOTLINE|VALID_BOTLINE_AP);
+ row = curwin->w_height - 1;
+ } else if (row == 0) {
+ // When dragging the mouse, while the text has been scrolled up as
+ // far as it goes, moving the mouse in the top line should scroll
+ // the text down (done later when recomputing w_topline).
+ if (mouse_dragging > 0
+ && curwin->w_cursor.lnum
+ == curwin->w_buffer->b_ml.ml_line_count
+ && curwin->w_cursor.lnum == curwin->w_topline) {
+ curwin->w_valid &= ~(VALID_TOPLINE);
+ }
+ }
+ }
+
+ // Check for position outside of the fold column.
+ if (curwin->w_p_rl ? col < curwin->w_width - curwin->w_p_fdc :
+ col >= curwin->w_p_fdc + (cmdwin_type == 0 ? 0 : 1)) {
+ mouse_char = ' ';
+ }
+
+ // compute the position in the buffer line from the posn on the screen
+ if (mouse_comp_pos(curwin, &row, &col, &curwin->w_cursor.lnum)) {
+ mouse_past_bottom = true;
+ }
+
+ // Start Visual mode before coladvance(), for when 'sel' != "old"
+ if ((flags & MOUSE_MAY_VIS) && !VIsual_active) {
+ check_visual_highlight();
+ VIsual = old_cursor;
+ VIsual_active = true;
+ VIsual_reselect = true;
+ // if 'selectmode' contains "mouse", start Select mode
+ may_start_select('o');
+ setmouse();
+
+ if (p_smd && msg_silent == 0) {
+ redraw_cmdline = true; // show visual mode later
+ }
+ }
+
+ curwin->w_curswant = col;
+ curwin->w_set_curswant = false; // May still have been true
+ if (coladvance(col) == FAIL) { // Mouse click beyond end of line
+ if (inclusive != NULL) {
+ *inclusive = true;
+ }
+ mouse_past_eol = true;
+ } else if (inclusive != NULL) {
+ *inclusive = false;
+ }
+
+ count = IN_BUFFER;
+ if (curwin != old_curwin || curwin->w_cursor.lnum != old_cursor.lnum
+ || curwin->w_cursor.col != old_cursor.col) {
+ count |= CURSOR_MOVED; // Cursor has moved
+ }
+
+ if (mouse_char == '+') {
+ count |= MOUSE_FOLD_OPEN;
+ } else if (mouse_char != ' ') {
+ count |= MOUSE_FOLD_CLOSE;
+ }
+
+ return count;
+}
+
+// Compute the position in the buffer line from the posn on the screen in
+// window "win".
+// Returns true if the position is below the last line.
+bool mouse_comp_pos(win_T *win, int *rowp, int *colp, linenr_T *lnump)
+{
+ int col = *colp;
+ int row = *rowp;
+ linenr_T lnum;
+ bool retval = false;
+ int off;
+ int count;
+
+ if (win->w_p_rl)
+ col = win->w_width - 1 - col;
+
+ lnum = win->w_topline;
+
+ while (row > 0) {
+ // Don't include filler lines in "count"
+ if (win->w_p_diff
+ && !hasFoldingWin(win, lnum, NULL, NULL, true, NULL)) {
+ if (lnum == win->w_topline) {
+ row -= win->w_topfill;
+ } else {
+ row -= diff_check_fill(win, lnum);
+ }
+ count = plines_win_nofill(win, lnum, true);
+ } else {
+ count = plines_win(win, lnum, true);
+ }
+
+ if (count > row) {
+ break; // Position is in this buffer line.
+ }
+
+ (void)hasFoldingWin(win, lnum, NULL, &lnum, true, NULL);
+
+ if (lnum == win->w_buffer->b_ml.ml_line_count) {
+ retval = true;
+ break; // past end of file
+ }
+ row -= count;
+ ++lnum;
+ }
+
+ if (!retval) {
+ // Compute the column without wrapping.
+ off = win_col_off(win) - win_col_off2(win);
+ if (col < off)
+ col = off;
+ col += row * (win->w_width - off);
+ // add skip column (for long wrapping line)
+ col += win->w_skipcol;
+ }
+
+ if (!win->w_p_wrap) {
+ col += win->w_leftcol;
+ }
+
+ // skip line number and fold column in front of the line
+ col -= win_col_off(win);
+ if (col < 0) {
+ col = 0;
+ }
+
+ *colp = col;
+ *rowp = row;
+ *lnump = lnum;
+ return retval;
+}
+
+// Find the window at screen position "*rowp" and "*colp". The positions are
+// updated to become relative to the top-left of the window.
+win_T *mouse_find_win(int *rowp, int *colp)
+{
+ frame_T *fp;
+
+ fp = topframe;
+ *rowp -= firstwin->w_winrow;
+ for (;; ) {
+ if (fp->fr_layout == FR_LEAF)
+ break;
+ if (fp->fr_layout == FR_ROW) {
+ for (fp = fp->fr_child; fp->fr_next != NULL; fp = fp->fr_next) {
+ if (*colp < fp->fr_width)
+ break;
+ *colp -= fp->fr_width;
+ }
+ } else { // fr_layout == FR_COL
+ for (fp = fp->fr_child; fp->fr_next != NULL; fp = fp->fr_next) {
+ if (*rowp < fp->fr_height)
+ break;
+ *rowp -= fp->fr_height;
+ }
+ }
+ }
+ return fp->fr_win;
+}
diff --git a/src/nvim/mouse.h b/src/nvim/mouse.h
new file mode 100644
index 0000000000..4f797c7480
--- /dev/null
+++ b/src/nvim/mouse.h
@@ -0,0 +1,32 @@
+#ifndef NVIM_MOUSE_H
+#define NVIM_MOUSE_H
+
+#include <stdbool.h>
+
+#include "nvim/vim.h"
+#include "nvim/buffer_defs.h"
+
+// jump_to_mouse() returns one of first four these values, possibly with
+// some of the other three added.
+#define IN_UNKNOWN 0
+#define IN_BUFFER 1
+#define IN_STATUS_LINE 2 // on status or command line
+#define IN_SEP_LINE 4 // on vertical separator line
+#define IN_OTHER_WIN 8 // in other window but can't go there
+#define CURSOR_MOVED 0x100
+#define MOUSE_FOLD_CLOSE 0x200 // clicked on '-' in fold column
+#define MOUSE_FOLD_OPEN 0x400 // clicked on '+' in fold column
+
+// flags for jump_to_mouse()
+#define MOUSE_FOCUS 0x01 // need to stay in this window
+#define MOUSE_MAY_VIS 0x02 // may start Visual mode
+#define MOUSE_DID_MOVE 0x04 // only act when mouse has moved
+#define MOUSE_SETPOS 0x08 // only set current mouse position
+#define MOUSE_MAY_STOP_VIS 0x10 // may stop Visual mode
+#define MOUSE_RELEASED 0x20 // button was released
+
+#ifdef INCLUDE_GENERATED_DECLARATIONS
+# include "mouse.h.generated.h"
+#endif
+
+#endif // NVIM_MOUSE_H
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
index 9ec97bd320..0a43d59607 100644
--- a/src/nvim/normal.c
+++ b/src/nvim/normal.c
@@ -57,9 +57,11 @@
#include "nvim/tag.h"
#include "nvim/term.h"
#include "nvim/ui.h"
+#include "nvim/mouse.h"
#include "nvim/undo.h"
#include "nvim/window.h"
#include "nvim/os/event.h"
+#include "nvim/os/time.h"
/*
* The Visual area is remembered for reselection.
@@ -312,7 +314,6 @@ static const struct nv_cmd {
{K_F8, farsi_fkey, 0, 0},
{K_F9, farsi_fkey, 0, 0},
{K_CURSORHOLD, nv_cursorhold, NV_KEEPREG, 0},
- {K_EVENT, nv_event, NV_KEEPREG, 0},
};
/* Number of commands in nv_cmds[]. */
@@ -483,7 +484,15 @@ normal_cmd (
/*
* Get the command character from the user.
*/
+ event_enable_deferred();
c = safe_vgetc();
+ event_disable_deferred();
+
+ if (c == K_EVENT) {
+ event_process();
+ return;
+ }
+
LANGMAP_ADJUST(c, true);
/*
@@ -708,9 +717,6 @@ getcount:
bool lit = false; /* get extra character literally */
bool langmap_active = false; /* using :lmap mappings */
int lang; /* getting a text character */
-#ifdef USE_IM_CONTROL
- bool save_smd; /* saved value of p_smd */
-#endif
++no_mapping;
++allow_keys; /* no mapping for nchar, but allow key codes */
@@ -759,12 +765,6 @@ getcount:
State = LANGMAP;
langmap_active = true;
}
-#ifdef USE_IM_CONTROL
- save_smd = p_smd;
- p_smd = false; /* Don't let the IM code show the mode here */
- if (lang && curbuf->b_p_iminsert == B_IMODE_IM)
- im_set_active(true);
-#endif
*cp = plain_vgetc();
@@ -774,14 +774,6 @@ getcount:
++allow_keys;
State = NORMAL_BUSY;
}
-#ifdef USE_IM_CONTROL
- if (lang) {
- if (curbuf->b_p_iminsert != B_IMODE_LMAP)
- im_save_status(&curbuf->b_p_iminsert);
- im_set_active(false);
- }
- p_smd = save_smd;
-#endif
State = NORMAL_BUSY;
need_flushbuf |= add_to_showcmd(*cp);
@@ -1001,8 +993,8 @@ getcount:
cursor_on();
out_flush();
if (msg_scroll || emsg_on_display)
- ui_delay(1000L, true); /* wait at least one second */
- ui_delay(3000L, false); /* wait up to three seconds */
+ os_delay(1000L, true); /* wait at least one second */
+ os_delay(3000L, false); /* wait up to three seconds */
State = save_State;
msg_scroll = false;
@@ -7382,8 +7374,3 @@ static void nv_cursorhold(cmdarg_T *cap)
did_cursorhold = true;
cap->retval |= CA_COMMAND_BUSY; /* don't call edit() now */
}
-
-static void nv_event(cmdarg_T *cap)
-{
- event_process();
-}
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index 5ef605bb3b..6bf3f6036f 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -45,10 +45,9 @@
#include "nvim/search.h"
#include "nvim/strings.h"
#include "nvim/term.h"
-#include "nvim/ui.h"
#include "nvim/undo.h"
#include "nvim/window.h"
-#include "nvim/api/private/helpers.h"
+#include "nvim/os/input.h"
/*
* Registers:
@@ -1112,7 +1111,7 @@ insert_reg (
* register a and then, in insert mode, doing CTRL-R a.
* If you hit CTRL-C, the loop will be broken here.
*/
- ui_breakcheck();
+ os_breakcheck();
if (got_int)
return FAIL;
@@ -1296,7 +1295,7 @@ cmdline_paste_reg (
/* Check for CTRL-C, in case someone tries to paste a few thousand
* lines and gets bored. */
- ui_breakcheck();
+ os_breakcheck();
if (got_int)
return FAIL;
}
@@ -3254,7 +3253,7 @@ void ex_display(exarg_T *eap)
MSG_PUTS_ATTR("^J", attr);
out_flush(); /* show one line at a time */
}
- ui_breakcheck();
+ os_breakcheck();
}
/*
@@ -3339,7 +3338,7 @@ dis_msg (
} else
msg_outtrans_len(p++, 1);
}
- ui_breakcheck();
+ os_breakcheck();
}
/*
@@ -5079,7 +5078,7 @@ void cursor_pos_info(void)
for (lnum = 1; lnum <= curbuf->b_ml.ml_line_count; ++lnum) {
/* Check for a CTRL-C every 100000 characters. */
if (byte_count > last_check) {
- ui_breakcheck();
+ os_breakcheck();
if (got_int)
return;
last_check = byte_count + 100000L;
diff --git a/src/nvim/option.c b/src/nvim/option.c
index 830a30204b..ee70b5bf8a 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -75,10 +75,10 @@
#include "nvim/strings.h"
#include "nvim/syntax.h"
#include "nvim/term.h"
-#include "nvim/ui.h"
#include "nvim/undo.h"
#include "nvim/window.h"
#include "nvim/os/os.h"
+#include "nvim/os/input.h"
/*
* The options that are local to a window or buffer have "indir" set to one of
@@ -912,18 +912,10 @@ static struct vimoption
(char_u *)NULL, PV_NONE,
{(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
{"imcmdline", "imc", P_BOOL|P_VI_DEF,
-#ifdef USE_IM_CONTROL
- (char_u *)&p_imcmdline, PV_NONE,
-#else
(char_u *)NULL, PV_NONE,
-#endif
{(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
{"imdisable", "imd", P_BOOL|P_VI_DEF,
-#ifdef USE_IM_CONTROL
- (char_u *)&p_imdisable, PV_NONE,
-#else
(char_u *)NULL, PV_NONE,
-#endif
{(char_u *)FALSE, (char_u *)0L}
SCRIPTID_INIT},
{"iminsert", "imi", P_NUM|P_VI_DEF,
@@ -5134,18 +5126,6 @@ set_bool_option (
foldUpdateAll(curwin);
}
-#ifdef USE_IM_CONTROL
- /* 'imdisable' */
- else if ((int *)varp == &p_imdisable) {
- /* Only de-activate it here, it will be enabled when changing mode. */
- if (p_imdisable)
- im_set_active(FALSE);
- else if (State & INSERT)
- /* When the option is set from an autocommand, it may need to take
- * effect right away. */
- im_set_active(curbuf->b_p_iminsert == B_IMODE_IM);
- }
-#endif
/* 'spell' */
else if ((int *)varp == &curwin->w_p_spell) {
@@ -6123,7 +6103,7 @@ showoptions (
col += INC;
}
out_flush();
- ui_breakcheck();
+ os_breakcheck();
}
}
free(items);
diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h
index cd61b6427c..89264f8982 100644
--- a/src/nvim/option_defs.h
+++ b/src/nvim/option_defs.h
@@ -416,10 +416,6 @@ EXTERN int p_arshape; /* 'arabicshape' */
EXTERN int p_icon; /* 'icon' */
EXTERN char_u *p_iconstring; /* 'iconstring' */
EXTERN int p_ic; /* 'ignorecase' */
-#ifdef USE_IM_CONTROL
-EXTERN int p_imcmdline; /* 'imcmdline' */
-EXTERN int p_imdisable; /* 'imdisable' */
-#endif
EXTERN int p_is; /* 'incsearch' */
EXTERN int p_im; /* 'insertmode' */
EXTERN char_u *p_isf; /* 'isfname' */
diff --git a/src/nvim/os/event.c b/src/nvim/os/event.c
index 1477072f4f..34560610bd 100644
--- a/src/nvim/os/event.c
+++ b/src/nvim/os/event.c
@@ -18,6 +18,8 @@
#include "nvim/vim.h"
#include "nvim/memory.h"
#include "nvim/misc2.h"
+#include "nvim/term.h"
+#include "nvim/screen.h"
#include "nvim/lib/klist.h"
@@ -39,6 +41,7 @@ typedef struct {
// loop(to avoid recursion), but before returning from
// `event_poll`
static klist_t(Event) *deferred_events = NULL, *immediate_events = NULL;
+static int deferred_events_allowed = 0;
void event_init(void)
{
@@ -134,7 +137,17 @@ void event_poll(int ms)
bool event_has_deferred(void)
{
- return !kl_empty(deferred_events);
+ return deferred_events_allowed && !kl_empty(deferred_events);
+}
+
+void event_enable_deferred(void)
+{
+ ++deferred_events_allowed;
+}
+
+void event_disable_deferred(void)
+{
+ --deferred_events_allowed;
}
// Queue an event
@@ -146,6 +159,11 @@ void event_push(Event event, bool deferred)
void event_process(void)
{
process_events_from(deferred_events);
+
+ if (must_redraw) {
+ update_screen(0);
+ out_flush();
+ }
}
static void process_events_from(klist_t(Event) *queue)
diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c
index 3ebfb3f12b..686fe1f06d 100644
--- a/src/nvim/os/input.c
+++ b/src/nvim/os/input.c
@@ -17,8 +17,11 @@
#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"
+#include "nvim/main.h"
+#include "nvim/misc1.h"
#define READ_BUFFER_SIZE 0xfff
#define INPUT_BUFFER_SIZE (READ_BUFFER_SIZE * 4)
@@ -84,13 +87,11 @@ void input_stop(void)
// Low level input function.
int os_inchar(uint8_t *buf, int maxlen, int ms, int tb_change_cnt)
{
- InbufPollResult result;
-
- if (event_has_deferred()) {
- // Return pending event bytes
- return push_event_key(buf, maxlen);
+ if (rbuffer_pending(input_buffer)) {
+ return (int)rbuffer_read(input_buffer, (char *)buf, (size_t)maxlen);
}
+ InbufPollResult result;
if (ms >= 0) {
if ((result = inbuf_poll(ms)) == kInputNone) {
return 0;
@@ -110,24 +111,27 @@ int os_inchar(uint8_t *buf, int maxlen, int ms, int tb_change_cnt)
}
}
- // If there are deferred events, return the keys directly
- if (event_has_deferred()) {
- return push_event_key(buf, maxlen);
- }
-
// If input was put directly in typeahead buffer bail out here.
if (typebuf_changed(tb_change_cnt)) {
return 0;
}
+ if (rbuffer_pending(input_buffer)) {
+ // Safe to convert rbuffer_read to int, it will never overflow since we use
+ // relatively small buffers.
+ return (int)rbuffer_read(input_buffer, (char *)buf, (size_t)maxlen);
+ }
+
+ // If there are deferred events, return the keys directly
+ if (event_has_deferred()) {
+ return push_event_key(buf, maxlen);
+ }
+
if (result == kInputEof) {
read_error_exit();
- return 0;
}
- // Safe to convert rbuffer_read to int, it will never overflow since
- // we use relatively small buffers.
- return (int)rbuffer_read(input_buffer, (char *)buf, (size_t)maxlen);
+ return 0;
}
// Check if a character is available for reading
@@ -183,7 +187,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();
}
@@ -281,7 +294,7 @@ static void convert_input(void)
static void process_interrupts(void)
{
- if (!ctrl_c_interrupts) {
+ if (mapped_ctrl_c) {
return;
}
@@ -319,10 +332,17 @@ static int push_event_key(uint8_t *buf, int maxlen)
// Check if there's pending input
static bool input_ready(void)
{
- return typebuf_was_filled || // API call filled typeahead
- event_has_deferred() || // Events must be processed
- (!embedded_mode && (
- rbuffer_pending(input_buffer) > 0 || // Stdin input
- eof)); // Stdin closed
+ return typebuf_was_filled || // API call filled typeahead
+ rbuffer_pending(input_buffer) > 0 || // Stdin input
+ event_has_deferred() || // Events must be processed
+ (!embedded_mode && eof); // Stdin closed
}
+// Exit because of an input read error.
+static void read_error_exit(void)
+{
+ if (silent_mode) /* Normal way to exit for "ex -s" */
+ getout(0);
+ STRCPY(IObuff, _("Vim: Error reading input, exiting...\n"));
+ preserve_exit();
+}
diff --git a/src/nvim/os_unix.c b/src/nvim/os_unix.c
index 8ab61045dc..3bf1198b46 100644
--- a/src/nvim/os_unix.c
+++ b/src/nvim/os_unix.c
@@ -46,7 +46,6 @@
#include "nvim/tempfile.h"
#include "nvim/term.h"
#include "nvim/types.h"
-#include "nvim/ui.h"
#include "nvim/os/os.h"
#include "nvim/os/time.h"
#include "nvim/os/event.h"
diff --git a/src/nvim/path.c b/src/nvim/path.c
index ff97b7774a..e8d31f3f73 100644
--- a/src/nvim/path.c
+++ b/src/nvim/path.c
@@ -31,7 +31,7 @@
#include "nvim/strings.h"
#include "nvim/tag.h"
#include "nvim/types.h"
-#include "nvim/ui.h"
+#include "nvim/os/input.h"
#include "nvim/window.h"
#define URL_SLASH 1 /* path_is_url() has found "://" */
@@ -449,7 +449,7 @@ unix_expandpath (
/* Expanding "**" may take a long time, check for CTRL-C. */
if (stardepth > 0) {
- ui_breakcheck();
+ os_breakcheck();
if (got_int)
return 0;
}
@@ -850,7 +850,7 @@ static void uniquefy_paths(garray_T *gap, char_u *pattern)
STRMOVE(path + STRLEN(path), short_name);
}
}
- ui_breakcheck();
+ os_breakcheck();
}
/* Shorten filenames in /in/current/directory/{filename} */
@@ -879,7 +879,7 @@ static void uniquefy_paths(garray_T *gap, char_u *pattern)
free(fnames[i]);
fnames[i] = rel_path;
sort_again = TRUE;
- ui_breakcheck();
+ os_breakcheck();
}
free(curdir);
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c
index 3de7f73339..4baba00ccf 100644
--- a/src/nvim/quickfix.c
+++ b/src/nvim/quickfix.c
@@ -49,9 +49,9 @@
#include "nvim/strings.h"
#include "nvim/term.h"
#include "nvim/tempfile.h"
-#include "nvim/ui.h"
#include "nvim/window.h"
#include "nvim/os/os.h"
+#include "nvim/os/input.h"
struct dir_stack_T {
@@ -1791,7 +1791,7 @@ void qf_list(exarg_T *eap)
qfp = qfp->qf_next;
++i;
- ui_breakcheck();
+ os_breakcheck();
}
}
diff --git a/src/nvim/screen.c b/src/nvim/screen.c
index 73df08aac9..2dbf3f8888 100644
--- a/src/nvim/screen.c
+++ b/src/nvim/screen.c
@@ -129,10 +129,10 @@
#include "nvim/strings.h"
#include "nvim/syntax.h"
#include "nvim/term.h"
-#include "nvim/ui.h"
#include "nvim/undo.h"
#include "nvim/version.h"
#include "nvim/window.h"
+#include "nvim/os/time.h"
#define MB_FILLER_CHAR '<' /* character used when a double-width character
* doesn't fit. */
@@ -6261,7 +6261,7 @@ void check_for_delay(int check_msg_scroll)
&& !did_wait_return
&& emsg_silent == 0) {
out_flush();
- ui_delay(1000L, true);
+ os_delay(1000L, true);
emsg_on_display = FALSE;
if (check_msg_scroll)
msg_scroll = FALSE;
@@ -6307,6 +6307,8 @@ void screenalloc(bool doclear)
static int entered = FALSE; /* avoid recursiveness */
static int done_outofmem_msg = FALSE; /* did outofmem message */
int retry_count = 0;
+ const bool l_enc_utf8 = enc_utf8;
+ const int l_enc_dbcs = enc_dbcs;
retry:
/*
@@ -6317,8 +6319,8 @@ retry:
if ((ScreenLines != NULL
&& Rows == screen_Rows
&& Columns == screen_Columns
- && enc_utf8 == (ScreenLinesUC != NULL)
- && (enc_dbcs == DBCS_JPNU) == (ScreenLines2 != NULL)
+ && l_enc_utf8 == (ScreenLinesUC != NULL)
+ && (l_enc_dbcs == DBCS_JPNU) == (ScreenLines2 != NULL)
&& p_mco == Screen_mco
)
|| Rows == 0
@@ -6364,13 +6366,13 @@ retry:
new_ScreenLines = xmalloc((size_t)((Rows + 1) * Columns * sizeof(schar_T)));
memset(new_ScreenLinesC, 0, sizeof(u8char_T *) * MAX_MCO);
- if (enc_utf8) {
+ if (l_enc_utf8) {
new_ScreenLinesUC = xmalloc(
(size_t)((Rows + 1) * Columns * sizeof(u8char_T)));
for (i = 0; i < p_mco; ++i)
new_ScreenLinesC[i] = xcalloc((Rows + 1) * Columns, sizeof(u8char_T));
}
- if (enc_dbcs == DBCS_JPNU)
+ if (l_enc_dbcs == DBCS_JPNU)
new_ScreenLines2 = xmalloc(
(size_t)((Rows + 1) * Columns * sizeof(schar_T)));
new_ScreenAttrs = xmalloc((size_t)((Rows + 1) * Columns * sizeof(sattr_T)));
@@ -6389,8 +6391,8 @@ retry:
if (new_ScreenLinesC[i] == NULL)
break;
if (new_ScreenLines == NULL
- || (enc_utf8 && (new_ScreenLinesUC == NULL || i != p_mco))
- || (enc_dbcs == DBCS_JPNU && new_ScreenLines2 == NULL)
+ || (l_enc_utf8 && (new_ScreenLinesUC == NULL || i != p_mco))
+ || (l_enc_dbcs == DBCS_JPNU && new_ScreenLines2 == NULL)
|| new_ScreenAttrs == NULL
|| new_LineOffset == NULL
|| new_LineWraps == NULL
@@ -6438,7 +6440,7 @@ retry:
if (!doclear) {
(void)memset(new_ScreenLines + new_row * Columns,
' ', (size_t)Columns * sizeof(schar_T));
- if (enc_utf8) {
+ if (l_enc_utf8) {
(void)memset(new_ScreenLinesUC + new_row * Columns,
0, (size_t)Columns * sizeof(u8char_T));
for (i = 0; i < p_mco; ++i)
@@ -6446,7 +6448,7 @@ retry:
+ new_row * Columns,
0, (size_t)Columns * sizeof(u8char_T));
}
- if (enc_dbcs == DBCS_JPNU)
+ if (l_enc_dbcs == DBCS_JPNU)
(void)memset(new_ScreenLines2 + new_row * Columns,
0, (size_t)Columns * sizeof(schar_T));
(void)memset(new_ScreenAttrs + new_row * Columns,
@@ -6459,12 +6461,12 @@ retry:
len = Columns;
/* When switching to utf-8 don't copy characters, they
* may be invalid now. Also when p_mco changes. */
- if (!(enc_utf8 && ScreenLinesUC == NULL)
+ if (!(l_enc_utf8 && ScreenLinesUC == NULL)
&& p_mco == Screen_mco)
memmove(new_ScreenLines + new_LineOffset[new_row],
ScreenLines + LineOffset[old_row],
(size_t)len * sizeof(schar_T));
- if (enc_utf8 && ScreenLinesUC != NULL
+ if (l_enc_utf8 && ScreenLinesUC != NULL
&& p_mco == Screen_mco) {
memmove(new_ScreenLinesUC + new_LineOffset[new_row],
ScreenLinesUC + LineOffset[old_row],
@@ -6475,7 +6477,7 @@ retry:
ScreenLinesC[i] + LineOffset[old_row],
(size_t)len * sizeof(u8char_T));
}
- if (enc_dbcs == DBCS_JPNU && ScreenLines2 != NULL)
+ if (l_enc_dbcs == DBCS_JPNU && ScreenLines2 != NULL)
memmove(new_ScreenLines2 + new_LineOffset[new_row],
ScreenLines2 + LineOffset[old_row],
(size_t)len * sizeof(schar_T));
diff --git a/src/nvim/search.c b/src/nvim/search.c
index bd1811c7fb..78d9dcbccb 100644
--- a/src/nvim/search.c
+++ b/src/nvim/search.c
@@ -48,6 +48,7 @@
#include "nvim/term.h"
#include "nvim/ui.h"
#include "nvim/window.h"
+#include "nvim/os/time.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
@@ -2053,9 +2054,9 @@ showmatch (
* available.
*/
if (vim_strchr(p_cpo, CPO_SHOWMATCH) != NULL)
- ui_delay(p_mat * 100L, true);
+ os_delay(p_mat * 100L, true);
else if (!char_avail())
- ui_delay(p_mat * 100L, false);
+ os_delay(p_mat * 100L, false);
curwin->w_cursor = save_cursor; /* restore cursor position */
p_so = save_so;
p_siso = save_siso;
diff --git a/src/nvim/spell.c b/src/nvim/spell.c
index ea5ce7ee0d..fa786fdd74 100644
--- a/src/nvim/spell.c
+++ b/src/nvim/spell.c
@@ -325,9 +325,9 @@
#include "nvim/syntax.h"
#include "nvim/term.h"
#include "nvim/tempfile.h"
-#include "nvim/ui.h"
#include "nvim/undo.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> // for time_t
@@ -9018,7 +9018,7 @@ static void spell_suggest_intern(suginfo_T *su, bool interactive)
// When CTRL-C was hit while searching do show the results. Only clear
// got_int when using a command, not for spellsuggest().
- ui_breakcheck();
+ os_breakcheck();
if (interactive && got_int) {
(void)vgetc();
got_int = FALSE;
@@ -10616,7 +10616,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
// Don't check for CTRL-C too often, it takes time.
if (--breakcheckcount == 0) {
- ui_breakcheck();
+ os_breakcheck();
breakcheckcount = 1000;
}
}
diff --git a/src/nvim/strings.c b/src/nvim/strings.c
index d34014ac75..6c69b3b34a 100644
--- a/src/nvim/strings.c
+++ b/src/nvim/strings.c
@@ -42,7 +42,6 @@
#include "nvim/syntax.h"
#include "nvim/tag.h"
#include "nvim/term.h"
-#include "nvim/ui.h"
#include "nvim/window.h"
#include "nvim/os/os.h"
#include "nvim/os/shell.h"
diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c
index 6c5c0f37b1..69d6479cf3 100644
--- a/src/nvim/syntax.c
+++ b/src/nvim/syntax.c
@@ -44,8 +44,8 @@
#include "nvim/strings.h"
#include "nvim/syntax_defs.h"
#include "nvim/term.h"
-#include "nvim/ui.h"
#include "nvim/os/os.h"
+#include "nvim/os/time.h"
/*
* Structure that stores information about a highlight group.
@@ -7606,7 +7606,7 @@ static void highlight_list_two(int cnt, int attr)
msg_puts_attr((char_u *)&("N \bI \b! \b"[cnt / 11]), attr);
msg_clr_eos();
out_flush();
- ui_delay(cnt == 99 ? 40L : (long)cnt * 50L, false);
+ os_delay(cnt == 99 ? 40L : (long)cnt * 50L, false);
}
diff --git a/src/nvim/tag.c b/src/nvim/tag.c
index e267280bbd..fb39e069f0 100644
--- a/src/nvim/tag.c
+++ b/src/nvim/tag.c
@@ -10,6 +10,7 @@
* Code to handle tags and the tag stack
*/
+#include <assert.h>
#include <errno.h>
#include <inttypes.h>
#include <stdbool.h>
@@ -48,9 +49,10 @@
#include "nvim/search.h"
#include "nvim/strings.h"
#include "nvim/term.h"
-#include "nvim/ui.h"
#include "nvim/window.h"
#include "nvim/os/os.h"
+#include "nvim/os/time.h"
+#include "nvim/os/input.h"
/*
* Structure to hold pointers to various items in a tag line.
@@ -671,7 +673,7 @@ do_tag (
}
if (msg_col)
msg_putchar('\n');
- ui_breakcheck();
+ os_breakcheck();
}
if (got_int)
got_int = FALSE; /* only stop the listing */
@@ -880,7 +882,7 @@ do_tag (
give_warning(IObuff, ic);
if (ic && !msg_scrolled && msg_silent == 0) {
out_flush();
- ui_delay(1000L, true);
+ os_delay(1000L, true);
}
}
@@ -2307,6 +2309,7 @@ jumpto_tag (
win_T *curwin_save = NULL;
char_u *full_fname = NULL;
int old_KeyTyped = KeyTyped; /* getting the file may reset it */
+ const int l_g_do_tagpreview = g_do_tagpreview;
pbuf = xmalloc(LSIZE);
@@ -2363,7 +2366,7 @@ jumpto_tag (
++RedrawingDisabled;
- if (g_do_tagpreview != 0) {
+ if (l_g_do_tagpreview != 0) {
postponed_split = 0; /* don't split again below */
curwin_save = curwin; /* Save current window */
@@ -2395,7 +2398,7 @@ jumpto_tag (
if (keep_help) {
/* A :ta from a help file will keep the b_help flag set. For ":ptag"
* we need to use the flag from the window where we came from. */
- if (g_do_tagpreview != 0)
+ if (l_g_do_tagpreview != 0)
keep_help_flag = curwin_save->w_buffer->b_help;
else
keep_help_flag = curbuf->b_help;
@@ -2491,7 +2494,7 @@ jumpto_tag (
MSG(_("E435: Couldn't find tag, just guessing!"));
if (!msg_scrolled && msg_silent == 0) {
out_flush();
- ui_delay(1000L, true);
+ os_delay(1000L, true);
}
}
retval = OK;
@@ -2541,7 +2544,7 @@ jumpto_tag (
foldOpenCursor();
}
- if (g_do_tagpreview != 0
+ if (l_g_do_tagpreview != 0
&& curwin != curwin_save && win_valid(curwin_save)) {
/* Return cursor to where we were */
validate_cursor();
@@ -2779,7 +2782,8 @@ int get_tags(list_T *list, char_u *pat)
TAG_REGEXP | TAG_NOIC, (int)MAXCOL, NULL);
if (ret == OK && num_matches > 0) {
for (i = 0; i < num_matches; ++i) {
- parse_match(matches[i], &tp);
+ int parse_result = parse_match(matches[i], &tp);
+ assert(parse_result == OK);
is_static = test_for_static(&tp);
/* Skip pseudo-tag lines. */
@@ -2796,7 +2800,7 @@ int get_tags(list_T *list, char_u *pat)
|| add_tag_field(dict, "cmd", tp.command,
tp.command_end) == FAIL
|| add_tag_field(dict, "kind", tp.tagkind,
- tp.tagkind_end) == FAIL
+ tp.tagkind ? tp.tagkind_end : NULL) == FAIL
|| dict_add_nr_str(dict, "static", is_static, NULL) == FAIL)
ret = FAIL;
diff --git a/src/nvim/term.c b/src/nvim/term.c
index 263b81fc3a..3d1053bd2f 100644
--- a/src/nvim/term.c
+++ b/src/nvim/term.c
@@ -54,6 +54,7 @@
#include "nvim/window.h"
#include "nvim/os/os.h"
#include "nvim/os/time.h"
+#include "nvim/os/input.h"
#ifdef HAVE_TGETENT
# ifdef HAVE_TERMIOS_H
@@ -1330,7 +1331,7 @@ int set_termname(char_u *term)
if (emsg_silent == 0) {
screen_start(); /* don't know where cursor is now */
out_flush();
- ui_delay(2000L, true);
+ os_delay(2000L, true);
}
set_string_option_direct((char_u *)"term", -1, term,
OPT_FREE, 0);
@@ -2302,7 +2303,7 @@ void set_shellsize(int width, int height, int mustset)
Rows = height;
Columns = width;
check_shellsize();
- ui_set_shellsize(mustset);
+ mch_set_shellsize();
} else
check_shellsize();
@@ -4111,7 +4112,7 @@ void show_termcodes(void)
col += INC3;
}
out_flush();
- ui_breakcheck();
+ os_breakcheck();
}
}
free(items);
diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile
index 9ca2c9688a..6bacef9778 100644
--- a/src/nvim/testdir/Makefile
+++ b/src/nvim/testdir/Makefile
@@ -52,13 +52,13 @@ ifdef USE_VALGRIND
--leak-check=yes \
--track-origins=yes
# VALGRIND_TOOL := exp-sgcheck
- TOOL := valgrind -q \
- -q \
- $(VALGRIND_TOOL) \
- --suppressions=../../.valgrind.supp \
- --error-exitcode=123 \
- --log-file=valgrind.\%p.$* \
- $(VGDB) \
+ TOOL := valgrind -q \
+ -q \
+ $(VALGRIND_TOOL) \
+ --suppressions=../../../.valgrind.supp \
+ --error-exitcode=123 \
+ --log-file=valgrind.\%p.$* \
+ $(VGDB) \
--trace-children=yes
else
ifdef USE_GDB
diff --git a/src/nvim/testdir/sautest/autoload/Test104.vim b/src/nvim/testdir/sautest/autoload/Test104.vim
deleted file mode 100644
index d1e0e17a3b..0000000000
--- a/src/nvim/testdir/sautest/autoload/Test104.vim
+++ /dev/null
@@ -1 +0,0 @@
-let Test104#numvar = 123
diff --git a/src/nvim/testdir/test101.in b/src/nvim/testdir/test101.in
deleted file mode 100644
index 04c934f2c5..0000000000
--- a/src/nvim/testdir/test101.in
+++ /dev/null
@@ -1,45 +0,0 @@
-Test for v:hlsearch vim: set ft=vim :
-
-STARTTEST
-:" Last abc: Q
-:so small.vim
-:new
-:call setline(1, repeat(['aaa'], 10))
-:set hlsearch nolazyredraw
-:let r=[]
-:command -nargs=0 -bar AddR :call add(r, [screenattr(1, 1), v:hlsearch])
-/aaa
-:AddR
-:nohlsearch
-:AddR
-:let v:hlsearch=1
-:AddR
-:let v:hlsearch=0
-:AddR
-:set hlsearch
-:AddR
-:let v:hlsearch=0
-:AddR
-n:AddR
-:let v:hlsearch=0
-:AddR
-/
-:AddR
-:let r1=r[0][0]
-:" I guess it is not guaranteed that screenattr outputs always the same character
-:call map(r, 'v:val[1].":".(v:val[0]==r1?"highlighted":"not highlighted")')
-:try
-: let v:hlsearch=[]
-:catch
-: call add(r, matchstr(v:exception,'^Vim(let):E\d\+:'))
-:endtry
-:bwipeout!
-:$put=r
-:call garbagecollect(1)
-:"
-:/^start:/,$wq! test.out
-:" vim: et ts=4 isk-=\:
-:call getchar()
-ENDTEST
-
-start:
diff --git a/src/nvim/testdir/test101.ok b/src/nvim/testdir/test101.ok
deleted file mode 100644
index 3ed7436cf7..0000000000
--- a/src/nvim/testdir/test101.ok
+++ /dev/null
@@ -1,11 +0,0 @@
-start:
-1:highlighted
-0:not highlighted
-1:highlighted
-0:not highlighted
-1:highlighted
-0:not highlighted
-1:highlighted
-0:not highlighted
-1:highlighted
-Vim(let):E706:
diff --git a/src/nvim/testdir/test104.in b/src/nvim/testdir/test104.in
deleted file mode 100644
index fd847131e9..0000000000
--- a/src/nvim/testdir/test104.in
+++ /dev/null
@@ -1,30 +0,0 @@
-Tests for :let. vim: set ft=vim ts=8 :
-
-STARTTEST
-:so small.vim
-:set runtimepath+=./sautest
-:" Test to not autoload when assigning. It causes internal error.
-:try
-: let Test104#numvar = function('tr')
-: $put ='OK: ' . string(Test104#numvar)
-:catch
-: $put ='FAIL: ' . v:exception
-:endtry
-:let a = 1
-:let b = 2
-:for letargs in ['a b', '{0 == 1 ? "a" : "b"}', '{0 == 1 ? "a" : "b"} a', 'a {0 == 1 ? "a" : "b"}']
-: try
-: redir => messages
-: execute 'let' letargs
-: redir END
-: $put ='OK:'
-: $put =split(substitute(messages, '\n', '\0 ', 'g'), '\n')
-: catch
-: $put ='FAIL: ' . v:exception
-: redir END
-: endtry
-:endfor
-:/^Results/,$wq! test.out
-ENDTEST
-
-Results of test104:
diff --git a/src/nvim/testdir/test104.ok b/src/nvim/testdir/test104.ok
deleted file mode 100644
index 5fb20945c3..0000000000
--- a/src/nvim/testdir/test104.ok
+++ /dev/null
@@ -1,13 +0,0 @@
-Results of test104:
-OK: function('tr')
-OK:
- a #1
- b #2
-OK:
- b #2
-OK:
- b #2
- a #1
-OK:
- a #1
- b #2
diff --git a/src/nvim/testdir/test105.in b/src/nvim/testdir/test105.in
deleted file mode 100644
index bfb4b65fbb..0000000000
--- a/src/nvim/testdir/test105.in
+++ /dev/null
@@ -1,45 +0,0 @@
-Test filename modifiers vim: set ft=vim :
-
-STARTTEST
-:source small.vim
-:%delete _
-:set shell=sh
-:set shellslash
-:let tab="\t"
-:command -nargs=1 Put :let expr=<q-args> | $put =expr.tab.strtrans(string(eval(expr)))
-:let $HOME=fnamemodify('.', ':p:h:h:h')
-:Put fnamemodify('.', ':p' )[-1:]
-:Put fnamemodify('.', ':p:h' )[-1:]
-:Put fnamemodify('test.out', ':p' )[-1:]
-:Put fnamemodify('test.out', ':.' )
-:Put fnamemodify('../testdir/a', ':.' )
-:Put fnamemodify('test.out', ':~' )
-:Put fnamemodify('../testdir/a', ':~' )
-:Put fnamemodify('../testdir/a', ':t' )
-:Put fnamemodify('.', ':p:t' )
-:Put fnamemodify('test.out', ':p:t' )
-:Put fnamemodify('test.out', ':p:e' )
-:Put fnamemodify('test.out', ':p:t:e' )
-:Put fnamemodify('abc.fb2.tar.gz', ':r' )
-:Put fnamemodify('abc.fb2.tar.gz', ':r:r' )
-:Put fnamemodify('abc.fb2.tar.gz', ':r:r:r' )
-:Put substitute(fnamemodify('abc.fb2.tar.gz', ':p:r:r'), '.*\(nvim/testdir/.*\)', '\1', '')
-:Put fnamemodify('abc.fb2.tar.gz', ':e' )
-:Put fnamemodify('abc.fb2.tar.gz', ':e:e' )
-:Put fnamemodify('abc.fb2.tar.gz', ':e:e:e' )
-:Put fnamemodify('abc.fb2.tar.gz', ':e:e:e:e')
-:Put fnamemodify('abc.fb2.tar.gz', ':e:e:r' )
-:Put fnamemodify('abc def', ':S' )
-:Put fnamemodify('abc" "def', ':S' )
-:Put fnamemodify('abc"%"def', ':S' )
-:Put fnamemodify('abc'' ''def', ':S' )
-:Put fnamemodify('abc''%''def', ':S' )
-:Put fnamemodify("abc\ndef", ':S' )
-:set shell=tcsh
-:Put fnamemodify("abc\ndef", ':S' )
-:$put ='vim: ts=8'
-:1 delete _
-:w! test.out
-:qa!
-ENDTEST
-
diff --git a/src/nvim/testdir/test105.ok b/src/nvim/testdir/test105.ok
deleted file mode 100644
index 0b30ee4281..0000000000
--- a/src/nvim/testdir/test105.ok
+++ /dev/null
@@ -1,29 +0,0 @@
-fnamemodify('.', ':p' )[-1:] '/'
-fnamemodify('.', ':p:h' )[-1:] 'r'
-fnamemodify('test.out', ':p' )[-1:] 't'
-fnamemodify('test.out', ':.' ) 'test.out'
-fnamemodify('../testdir/a', ':.' ) 'a'
-fnamemodify('test.out', ':~' ) '~/nvim/testdir/test.out'
-fnamemodify('../testdir/a', ':~' ) '~/nvim/testdir/a'
-fnamemodify('../testdir/a', ':t' ) 'a'
-fnamemodify('.', ':p:t' ) ''
-fnamemodify('test.out', ':p:t' ) 'test.out'
-fnamemodify('test.out', ':p:e' ) 'out'
-fnamemodify('test.out', ':p:t:e' ) 'out'
-fnamemodify('abc.fb2.tar.gz', ':r' ) 'abc.fb2.tar'
-fnamemodify('abc.fb2.tar.gz', ':r:r' ) 'abc.fb2'
-fnamemodify('abc.fb2.tar.gz', ':r:r:r' ) 'abc'
-substitute(fnamemodify('abc.fb2.tar.gz', ':p:r:r'), '.*\(nvim/testdir/.*\)', '\1', '') 'nvim/testdir/abc.fb2'
-fnamemodify('abc.fb2.tar.gz', ':e' ) 'gz'
-fnamemodify('abc.fb2.tar.gz', ':e:e' ) 'tar.gz'
-fnamemodify('abc.fb2.tar.gz', ':e:e:e' ) 'fb2.tar.gz'
-fnamemodify('abc.fb2.tar.gz', ':e:e:e:e') 'fb2.tar.gz'
-fnamemodify('abc.fb2.tar.gz', ':e:e:r' ) 'tar'
-fnamemodify('abc def', ':S' ) '''abc def'''
-fnamemodify('abc" "def', ':S' ) '''abc" "def'''
-fnamemodify('abc"%"def', ':S' ) '''abc"%"def'''
-fnamemodify('abc'' ''def', ':S' ) '''abc''\'''' ''\''''def'''
-fnamemodify('abc''%''def', ':S' ) '''abc''\''''%''\''''def'''
-fnamemodify("abc\ndef", ':S' ) '''abc^@def'''
-fnamemodify("abc\ndef", ':S' ) '''abc\^@def'''
-vim: ts=8
diff --git a/src/nvim/testdir/test21.in b/src/nvim/testdir/test21.in
deleted file mode 100644
index 491b9f7404..0000000000
--- a/src/nvim/testdir/test21.in
+++ /dev/null
@@ -1,19 +0,0 @@
-Tests for [ CTRL-I with a count and CTRL-W CTRL-I with a count
-
-STARTTEST
-:so small.vim
-/start
-6[ :.w! test.out
-?start here
-6 :.w >>test.out
-:qa!
-ENDTEST
-
-#include test21.in
-
-/* test text test tex start here
- some text
- test text
- start OK if found this line
- start found wrong line
-test text
diff --git a/src/nvim/testdir/test21.ok b/src/nvim/testdir/test21.ok
deleted file mode 100644
index d9f1b759ce..0000000000
--- a/src/nvim/testdir/test21.ok
+++ /dev/null
@@ -1,2 +0,0 @@
- start OK if found this line
- start OK if found this line
diff --git a/src/nvim/testdir/test25.in b/src/nvim/testdir/test25.in
deleted file mode 100644
index 4139865daf..0000000000
--- a/src/nvim/testdir/test25.in
+++ /dev/null
@@ -1,31 +0,0 @@
-Test for jumping to a tag with 'hidden' set, with symbolic link in path of tag.
-This only works for Unix, because of the symbolic link.
-
-STARTTEST
-:so small.vim
-:set hidden
-:" Create a link from test25.dir to the current directory.
-:!rm -f test25.dir
-:!ln -s . test25.dir
-:" Create tags.text, with the current directory name inserted.
-/tags line
-:r !pwd
-d$/test
-hP:.w! tags.test
-:" Try jumping to a tag in the current file, but with a path that contains a
-:" symbolic link. When wrong, this will give the ATTENTION message. The next
-:" space will then be eaten by hit-return, instead of moving the cursor to 'd'.
-:set tags=tags.test
-G x:.w! test.out
-:!rm -f test25.dir tags.test
-:qa!
-ENDTEST
-
-tags line:
-SECTION_OFF /test25.dir/test25.in /^#define SECTION_OFF 3$/
-
-/*tx.c*/
-#define SECTION_OFF 3
-#define NUM_SECTIONS 3
-
-SECTION_OFF
diff --git a/src/nvim/testdir/test25.ok b/src/nvim/testdir/test25.ok
deleted file mode 100644
index 08fc070b7b..0000000000
--- a/src/nvim/testdir/test25.ok
+++ /dev/null
@@ -1 +0,0 @@
-#efine SECTION_OFF 3
diff --git a/src/nvim/testdir/test26.in b/src/nvim/testdir/test26.in
deleted file mode 100644
index e7cd757661..0000000000
--- a/src/nvim/testdir/test26.in
+++ /dev/null
@@ -1,44 +0,0 @@
-Test for :execute, :while and :if
-
-STARTTEST
-:so small.vim
-mt:let i = 0
-:while i < 12
-: let i = i + 1
-: if has("ebcdic")
-: execute "normal o" . i . "\047"
-: else
-: execute "normal o" . i . "\033"
-: endif
-: if i % 2
-: normal Ax
-: if i == 9
-: break
-: endif
-: if i == 5
-: continue
-: else
-: let j = 9
-: while j > 0
-: if has("ebcdic")
-: execute "normal" j . "a" . j . "\x27"
-: else
-: execute "normal" j . "a" . j . "\x1b"
-: endif
-: let j = j - 1
-: endwhile
-: endif
-: endif
-: if i == 9
-: if has("ebcdic")
-: execute "normal Az\047"
-: else
-: execute "normal Az\033"
-: endif
-: endif
-:endwhile
-:unlet i j
-:'t,$w! test.out
-:qa!
-ENDTEST
-
diff --git a/src/nvim/testdir/test26.ok b/src/nvim/testdir/test26.ok
deleted file mode 100644
index bc44761187..0000000000
--- a/src/nvim/testdir/test26.ok
+++ /dev/null
@@ -1,10 +0,0 @@
-
-1x999999999888888887777777666666555554444333221
-2
-3x999999999888888887777777666666555554444333221
-4
-5x
-6
-7x999999999888888887777777666666555554444333221
-8
-9x
diff --git a/src/nvim/testdir/test33.in b/src/nvim/testdir/test33.in
deleted file mode 100644
index 5644760402..0000000000
--- a/src/nvim/testdir/test33.in
+++ /dev/null
@@ -1,34 +0,0 @@
-Test for 'lisp'
-If the lisp feature is not enabled, this will fail!
-
-STARTTEST
-:so small.vim
-:set lisp
-/^(defun
-=G:/^(defun/,$w! test.out
-:q!
-ENDTEST
-
-(defun html-file (base)
-(format nil "~(~A~).html" base))
-
-(defmacro page (name title &rest body)
-(let ((ti (gensym)))
-`(with-open-file (*standard-output*
-(html-file ,name)
-:direction :output
-:if-exists :supersede)
-(let ((,ti ,title))
-(as title ,ti)
-(with center
-(as h2 (string-upcase ,ti)))
-(brs 3)
-,@body))))
-
-;;; Utilities for generating links
-
-(defmacro with-link (dest &rest body)
-`(progn
-(format t "<a href=\"~A\">" (html-file ,dest))
-,@body
-(princ "</a>")))
diff --git a/src/nvim/testdir/test33.ok b/src/nvim/testdir/test33.ok
deleted file mode 100644
index cd1d87a14b..0000000000
--- a/src/nvim/testdir/test33.ok
+++ /dev/null
@@ -1,23 +0,0 @@
-(defun html-file (base)
- (format nil "~(~A~).html" base))
-
-(defmacro page (name title &rest body)
- (let ((ti (gensym)))
- `(with-open-file (*standard-output*
- (html-file ,name)
- :direction :output
- :if-exists :supersede)
- (let ((,ti ,title))
- (as title ,ti)
- (with center
- (as h2 (string-upcase ,ti)))
- (brs 3)
- ,@body))))
-
-;;; Utilities for generating links
-
-(defmacro with-link (dest &rest body)
- `(progn
- (format t "<a href=\"~A\">" (html-file ,dest))
- ,@body
- (princ "</a>")))
diff --git a/src/nvim/testdir/test43.in b/src/nvim/testdir/test43.in
deleted file mode 100644
index 7c545073da..0000000000
--- a/src/nvim/testdir/test43.in
+++ /dev/null
@@ -1,34 +0,0 @@
-Tests for regexp with various magic settings.
-
-STARTTEST
-:so small.vim
-:set nocompatible viminfo+=nviminfo
-/^1
-/a*b\{2}c\+/e
-x/\Md\*e\{2}f\+/e
-x:set nomagic
-/g\*h\{2}i\+/e
-x/\mj*k\{2}l\+/e
-x/\vm*n{2}o+/e
-x/\V^aa$
-x:set magic
-/\v(a)(b)\2\1\1/e
-x/\V[ab]\(\[xy]\)\1
-x:$
-:set undolevels=100
-dv?bar?
-Yup:"
-:?^1?,$w! test.out
-:qa!
-ENDTEST
-
-1 a aa abb abbccc
-2 d dd dee deefff
-3 g gg ghh ghhiii
-4 j jj jkk jkklll
-5 m mm mnn mnnooo
-6 x ^aa$ x
-7 (a)(b) abbaa
-8 axx [ab]xx
-9 foobar
-
diff --git a/src/nvim/testdir/test43.ok b/src/nvim/testdir/test43.ok
deleted file mode 100644
index 0b37a6a61e..0000000000
--- a/src/nvim/testdir/test43.ok
+++ /dev/null
@@ -1,11 +0,0 @@
-1 a aa abb abbcc
-2 d dd dee deeff
-3 g gg ghh ghhii
-4 j jj jkk jkkll
-5 m mm mnn mnnoo
-6 x aa$ x
-7 (a)(b) abba
-8 axx ab]xx
-9 foobar
-9 foo
-
diff --git a/src/nvim/testdir/test5.in b/src/nvim/testdir/test5.in
deleted file mode 100644
index e19e20d59b..0000000000
--- a/src/nvim/testdir/test5.in
+++ /dev/null
@@ -1,29 +0,0 @@
-Test for autocommand that deletes the current buffer on BufLeave event.
-Also test deleting the last buffer, should give a new, empty buffer.
-
-STARTTEST
-:so small.vim
-:au BufLeave Xxx bwipe
-/start of
-:.,/end of/w! Xxx " write test file Xxx
-:sp Xxx " split to Xxx
-:bwipe " delete buffer Xxx, now we're back here
-G?this is a
-othis is some more text
-: " Append some text to this file
-:?start?,$w! test.out " Write current file contents
-:bwipe test.out " delete alternate buffer
-:au bufleave test5.in bwipe
-:bwipe! " delete current buffer, get an empty one
-ithis is another test line:w >>test.out
-: " append an extra line to the output file
-:qa!
-ENDTEST
-
-start of test file Xxx
-vim: set noai :
- this is a test
- this is a test
- this is a test
- this is a test
-end of test file Xxx
diff --git a/src/nvim/testdir/test5.ok b/src/nvim/testdir/test5.ok
deleted file mode 100644
index 6743060794..0000000000
--- a/src/nvim/testdir/test5.ok
+++ /dev/null
@@ -1,9 +0,0 @@
-start of test file Xxx
-vim: set noai :
- this is a test
- this is a test
- this is a test
- this is a test
-this is some more text
-end of test file Xxx
-this is another test line
diff --git a/src/nvim/testdir/test51.in b/src/nvim/testdir/test51.in
deleted file mode 100644
index b4f45d1f75..0000000000
--- a/src/nvim/testdir/test51.in
+++ /dev/null
@@ -1,36 +0,0 @@
-Tests for ":highlight". vim: set ft=vim :
-
-STARTTEST
-:so small.vim
-:" basic test if ":highlight" doesn't crash
-:highlight
-:hi Search
-:" test setting colors.
-:" test clearing one color and all doesn't generate error or warning
-:hi NewGroup term=bold cterm=italic ctermfg=DarkBlue ctermbg=Grey gui= guifg=#00ff00 guibg=Cyan
-:hi Group2 term= cterm=
-:hi Group3 term=underline cterm=bold
-:redir! >test.out
-:hi NewGroup
-:hi Group2
-:hi Group3
-:hi clear NewGroup
-:hi NewGroup
-:hi Group2
-:hi Group2 NONE
-:hi Group2
-:hi clear
-:hi Group3
-:hi Crash term='asdf
-:redir END
-:" filter ctermfg and ctermbg, the numbers depend on the terminal
-:e test.out
-:%s/ctermfg=\d*/ctermfg=2/
-:%s/ctermbg=\d*/ctermbg=3/
-:" filter out possibly translated error message
-:%s/E475: [^:]*:/E475:/
-:" fix the fileformat
-:set ff&
-:wq!
-ENDTEST
-
diff --git a/src/nvim/testdir/test51.ok b/src/nvim/testdir/test51.ok
deleted file mode 100644
index be9ff7862c..0000000000
--- a/src/nvim/testdir/test51.ok
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-NewGroup xxx term=bold cterm=italic ctermfg=2 ctermbg=3
-
-Group2 xxx cleared
-
-Group3 xxx term=underline cterm=bold
-
-
-NewGroup xxx cleared
-
-Group2 xxx cleared
-
-
-Group2 xxx cleared
-
-
-Group3 xxx cleared
-
-E475: term='asdf
diff --git a/src/nvim/testdir/test66.in b/src/nvim/testdir/test66.in
deleted file mode 100644
index f1fdce3792..0000000000
--- a/src/nvim/testdir/test66.in
+++ /dev/null
@@ -1,33 +0,0 @@
-
-Test for visual block shift and tab characters.
-
-STARTTEST
-:so small.vim
-/^one
-fe4jRugvr1:'<,'>w! test.out
-/^abcdefgh
-4jI j<<11|D
-7|a 
-7|a 
-7|a 4k13|4j<
-:$-5,$w >> test.out
-:$-4,$s/\s\+//g
-4kI j<<
-7|a 
-7|a 
-7|a 4k13|4j3<
-:$-4,$w >> test.out
-:qa!
-ENDTEST
-
-one two three
-one two three
-one two three
-one two three
-one two three
-
-abcdefghijklmnopqrstuvwxyz
-abcdefghijklmnopqrstuvwxyz
-abcdefghijklmnopqrstuvwxyz
-abcdefghijklmnopqrstuvwxyz
-abcdefghijklmnopqrstuvwxyz
diff --git a/src/nvim/testdir/test66.ok b/src/nvim/testdir/test66.ok
deleted file mode 100644
index 4c3ab0fb56..0000000000
--- a/src/nvim/testdir/test66.ok
+++ /dev/null
@@ -1,16 +0,0 @@
-on1 two three
-on1 two three
-on1 two three
-on1 two three
-on1 two three
-
- abcdefghijklmnopqrstuvwxyz
-abcdefghij
- abc defghijklmnopqrstuvwxyz
- abc defghijklmnopqrstuvwxyz
- abc defghijklmnopqrstuvwxyz
- abcdefghijklmnopqrstuvwxyz
-abcdefghij
- abc defghijklmnopqrstuvwxyz
- abc defghijklmnopqrstuvwxyz
- abc defghijklmnopqrstuvwxyz
diff --git a/src/nvim/testdir/test67.in b/src/nvim/testdir/test67.in
deleted file mode 100644
index 08b4e3701f..0000000000
--- a/src/nvim/testdir/test67.in
+++ /dev/null
@@ -1,33 +0,0 @@
-Test that groups and patterns are tested correctly when calling exists() for
-autocommands.
-
-STARTTEST
-:so small.vim
-:let results=[]
-:augroup auexists
-:augroup END
-:call add(results, "##BufEnter: " . exists("##BufEnter"))
-:call add(results, "#BufEnter: " . exists("#BufEnter"))
-:au BufEnter * let g:entered=1
-:call add(results, "#BufEnter: " . exists("#BufEnter"))
-:call add(results, "#auexists#BufEnter: " . exists("#auexists#BufEnter"))
-:augroup auexists
-:au BufEnter * let g:entered=1
-:augroup END
-:call add(results, "#auexists#BufEnter: " . exists("#auexists#BufEnter"))
-:call add(results, "#BufEnter#*.test: " . exists("#BufEnter#*.test"))
-:au BufEnter *.test let g:entered=1
-:call add(results, "#BufEnter#*.test: " . exists("#BufEnter#*.test"))
-:edit testfile.test
-:call add(results, "#BufEnter#<buffer>: " . exists("#BufEnter#<buffer>"))
-:au BufEnter <buffer> let g:entered=1
-:call add(results, "#BufEnter#<buffer>: " . exists("#BufEnter#<buffer>"))
-:edit testfile2.test
-:call add(results, "#BufEnter#<buffer>: " . exists("#BufEnter#<buffer>"))
-:e test.out
-:call append(0, results)
-:$d
-:w
-:qa!
-ENDTEST
-
diff --git a/src/nvim/testdir/test67.ok b/src/nvim/testdir/test67.ok
deleted file mode 100644
index 51188e5afd..0000000000
--- a/src/nvim/testdir/test67.ok
+++ /dev/null
@@ -1,10 +0,0 @@
-##BufEnter: 1
-#BufEnter: 0
-#BufEnter: 1
-#auexists#BufEnter: 0
-#auexists#BufEnter: 1
-#BufEnter#*.test: 0
-#BufEnter#*.test: 1
-#BufEnter#<buffer>: 0
-#BufEnter#<buffer>: 1
-#BufEnter#<buffer>: 0
diff --git a/src/nvim/testdir/test75.in b/src/nvim/testdir/test75.in
deleted file mode 100644
index 8fabccdf52..0000000000
--- a/src/nvim/testdir/test75.in
+++ /dev/null
@@ -1,41 +0,0 @@
-Tests for maparg().
-Also test utf8 map with a 0x80 byte.
-
-STARTTEST
-:so small.vim
-:so mbyte.vim
-:set cpo-=<
-:set encoding=utf8
-:" Test maparg() with a string result
-:map foo<C-V> is<F4>foo
-:vnoremap <script> <buffer> <expr> <silent> bar isbar
-:call append('$', maparg('foo<C-V>'))
-:call append('$', string(maparg('foo<C-V>', '', 0, 1)))
-:call append('$', string(maparg('bar', '', 0, 1)))
-:map <buffer> <nowait> foo bar
-:call append('$', string(maparg('foo', '', 0, 1)))
-:"
-:map abc x<char-114>x
-:call append('$', maparg('abc'))
-:map abc y<S-char-114>y
-:call append('$', maparg('abc'))
-:"
-Go:"
-:" Outside of the range, minimum
-:inoremap <Char-0x1040> a
-:execute "normal a\u1040\<Esc>"
-:" Inside of the range, minimum
-:inoremap <Char-0x103f> b
-:execute "normal a\u103f\<Esc>"
-:" Inside of the range, maximum
-:inoremap <Char-0xf03f> c
-:execute "normal a\uf03f\<Esc>"
-:" Outside of the range, maximum
-:inoremap <Char-0xf040> d
-:execute "normal a\uf040\<Esc>"
-:"
-:/^eof/+1,$w! test.out
-:qa!
-ENDTEST
-
-eof
diff --git a/src/nvim/testdir/test75.ok b/src/nvim/testdir/test75.ok
deleted file mode 100644
index a2c5c5ac3d..0000000000
--- a/src/nvim/testdir/test75.ok
+++ /dev/null
@@ -1,7 +0,0 @@
-is<F4>foo
-{'silent': 0, 'noremap': 0, 'lhs': 'foo<C-V>', 'mode': ' ', 'nowait': 0, 'expr': 0, 'sid': 0, 'rhs': 'is<F4>foo', 'buffer': 0}
-{'silent': 1, 'noremap': 1, 'lhs': 'bar', 'mode': 'v', 'nowait': 0, 'expr': 1, 'sid': 0, 'rhs': 'isbar', 'buffer': 1}
-{'silent': 0, 'noremap': 0, 'lhs': 'foo', 'mode': ' ', 'nowait': 1, 'expr': 0, 'sid': 0, 'rhs': 'bar', 'buffer': 1}
-xrx
-yRy
-abcd
diff --git a/src/nvim/ui.c b/src/nvim/ui.c
index d6269897d7..526cc3e47e 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,112 +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
-}
-
-/*
- * Delay for the given number of milliseconds. If ignoreinput is FALSE then we
- * cancel the delay if a key is hit.
- */
-void ui_delay(long msec, bool ignoreinput)
-{
- os_delay(msec, ignoreinput);
}
/*
@@ -201,516 +94,11 @@ int ui_get_shellsize(void)
}
/*
- * Set the size of the Vim shell according to Rows and Columns, if possible.
- * The gui_set_shellsize() or mch_set_shellsize() function will try to set the
- * new size. If this is not possible, it will adjust Rows and Columns.
- */
-void
-ui_set_shellsize(int mustset)
-{
- mch_set_shellsize();
-}
-
-void ui_breakcheck(void)
-{
- os_breakcheck();
-}
-
-/*****************************************************************************
- * Functions for copying and pasting text between applications.
- * This is always included in a GUI version, but may also be included when the
- * clipboard and mouse is available to a terminal version such as xterm.
- * Note: there are some more functions in ops.c that handle selection stuff.
- *
- * Also note that the majority of functions here deal with the X 'primary'
- * (visible - for Visual mode use) selection, and only that. There are no
- * versions of these for the 'clipboard' selection, as Visual mode has no use
- * for them.
- */
-
-/*
- * Exit because of an input read error.
- */
-void read_error_exit(void)
-{
- if (silent_mode) /* Normal way to exit for "ex -s" */
- getout(0);
- STRCPY(IObuff, _("Vim: Error reading input, exiting...\n"));
- preserve_exit();
-}
-
-/*
* May update the shape of the cursor.
*/
void ui_cursor_shape(void)
{
term_cursor_shape();
-
-
conceal_check_cursur_line();
}
-/*
- * Check bounds for column number
- */
-int check_col(int col)
-{
- if (col < 0)
- return 0;
- if (col >= (int)screen_Columns)
- return (int)screen_Columns - 1;
- return col;
-}
-
-/*
- * Check bounds for row number
- */
-int check_row(int row)
-{
- if (row < 0)
- return 0;
- if (row >= (int)screen_Rows)
- return (int)screen_Rows - 1;
- return row;
-}
-
-/*
- * Stuff for the X clipboard. Shared between VMS and Unix.
- */
-
-/*
- * Move the cursor to the specified row and column on the screen.
- * Change current window if necessary. Returns an integer with the
- * CURSOR_MOVED bit set if the cursor has moved or unset otherwise.
- *
- * The MOUSE_FOLD_CLOSE bit is set when clicked on the '-' in a fold column.
- * The MOUSE_FOLD_OPEN bit is set when clicked on the '+' in a fold column.
- *
- * If flags has MOUSE_FOCUS, then the current window will not be changed, and
- * if the mouse is outside the window then the text will scroll, or if the
- * mouse was previously on a status line, then the status line may be dragged.
- *
- * If flags has MOUSE_MAY_VIS, then VIsual mode will be started before the
- * cursor is moved unless the cursor was on a status line.
- * This function returns one of IN_UNKNOWN, IN_BUFFER, IN_STATUS_LINE or
- * IN_SEP_LINE depending on where the cursor was clicked.
- *
- * If flags has MOUSE_MAY_STOP_VIS, then Visual mode will be stopped, unless
- * the mouse is on the status line of the same window.
- *
- * If flags has MOUSE_DID_MOVE, nothing is done if the mouse didn't move since
- * the last call.
- *
- * If flags has MOUSE_SETPOS, nothing is done, only the current position is
- * remembered.
- */
-int
-jump_to_mouse (
- int flags,
- bool *inclusive, /* used for inclusive operator, can be NULL */
- int which_button /* MOUSE_LEFT, MOUSE_RIGHT, MOUSE_MIDDLE */
-)
-{
- static int on_status_line = 0; /* #lines below bottom of window */
- static int on_sep_line = 0; /* on separator right of window */
- static int prev_row = -1;
- static int prev_col = -1;
- static win_T *dragwin = NULL; /* window being dragged */
- static int did_drag = FALSE; /* drag was noticed */
-
- win_T *wp, *old_curwin;
- pos_T old_cursor;
- int count;
- bool first;
- int row = mouse_row;
- int col = mouse_col;
- int mouse_char;
-
- mouse_past_bottom = false;
- mouse_past_eol = false;
-
- if (flags & MOUSE_RELEASED) {
- /* On button release we may change window focus if positioned on a
- * status line and no dragging happened. */
- if (dragwin != NULL && !did_drag)
- flags &= ~(MOUSE_FOCUS | MOUSE_DID_MOVE);
- dragwin = NULL;
- did_drag = FALSE;
- }
-
- if ((flags & MOUSE_DID_MOVE)
- && prev_row == mouse_row
- && prev_col == mouse_col) {
-retnomove:
- /* before moving the cursor for a left click which is NOT in a status
- * line, stop Visual mode */
- if (on_status_line)
- return IN_STATUS_LINE;
- if (on_sep_line)
- return IN_SEP_LINE;
- if (flags & MOUSE_MAY_STOP_VIS) {
- end_visual_mode();
- redraw_curbuf_later(INVERTED); /* delete the inversion */
- }
- return IN_BUFFER;
- }
-
- prev_row = mouse_row;
- prev_col = mouse_col;
-
- if (flags & MOUSE_SETPOS)
- goto retnomove; /* ugly goto... */
-
- /* Remember the character under the mouse, it might be a '-' or '+' in the
- * fold column. */
- if (row >= 0 && row < Rows && col >= 0 && col <= Columns
- && ScreenLines != NULL)
- mouse_char = ScreenLines[LineOffset[row] + col];
- else
- mouse_char = ' ';
-
- old_curwin = curwin;
- old_cursor = curwin->w_cursor;
-
- if (!(flags & MOUSE_FOCUS)) {
- if (row < 0 || col < 0) /* check if it makes sense */
- return IN_UNKNOWN;
-
- /* find the window where the row is in */
- wp = mouse_find_win(&row, &col);
- dragwin = NULL;
- /*
- * winpos and height may change in win_enter()!
- */
- if (row >= wp->w_height) { /* In (or below) status line */
- on_status_line = row - wp->w_height + 1;
- dragwin = wp;
- } else
- on_status_line = 0;
- if (col >= wp->w_width) { /* In separator line */
- on_sep_line = col - wp->w_width + 1;
- dragwin = wp;
- } else
- on_sep_line = 0;
-
- /* The rightmost character of the status line might be a vertical
- * separator character if there is no connecting window to the right. */
- if (on_status_line && on_sep_line) {
- if (stl_connected(wp))
- on_sep_line = 0;
- else
- on_status_line = 0;
- }
-
- /* Before jumping to another buffer, or moving the cursor for a left
- * click, stop Visual mode. */
- if (VIsual_active
- && (wp->w_buffer != curwin->w_buffer
- || (!on_status_line
- && !on_sep_line
- && (
- wp->w_p_rl ? col < wp->w_width - wp->w_p_fdc :
- col >= wp->w_p_fdc
- + (cmdwin_type == 0 && wp ==
- curwin ? 0 : 1)
- )
- && (flags & MOUSE_MAY_STOP_VIS)))) {
- end_visual_mode();
- redraw_curbuf_later(INVERTED); /* delete the inversion */
- }
- if (cmdwin_type != 0 && wp != curwin) {
- /* A click outside the command-line window: Use modeless
- * selection if possible. Allow dragging the status lines. */
- on_sep_line = 0;
- row = 0;
- col += wp->w_wincol;
- wp = curwin;
- }
- /* Only change window focus when not clicking on or dragging the
- * status line. Do change focus when releasing the mouse button
- * (MOUSE_FOCUS was set above if we dragged first). */
- if (dragwin == NULL || (flags & MOUSE_RELEASED))
- win_enter(wp, true); /* can make wp invalid! */
-# ifdef CHECK_DOUBLE_CLICK
- /* set topline, to be able to check for double click ourselves */
- if (curwin != old_curwin)
- set_mouse_topline(curwin);
-# endif
- if (on_status_line) { /* In (or below) status line */
- /* Don't use start_arrow() if we're in the same window */
- if (curwin == old_curwin)
- return IN_STATUS_LINE;
- else
- return IN_STATUS_LINE | CURSOR_MOVED;
- }
- if (on_sep_line) { /* In (or below) status line */
- /* Don't use start_arrow() if we're in the same window */
- if (curwin == old_curwin)
- return IN_SEP_LINE;
- else
- return IN_SEP_LINE | CURSOR_MOVED;
- }
-
- curwin->w_cursor.lnum = curwin->w_topline;
- } else if (on_status_line && which_button == MOUSE_LEFT) {
- if (dragwin != NULL) {
- /* Drag the status line */
- count = row - dragwin->w_winrow - dragwin->w_height + 1
- - on_status_line;
- win_drag_status_line(dragwin, count);
- did_drag |= count;
- }
- return IN_STATUS_LINE; /* Cursor didn't move */
- } else if (on_sep_line && which_button == MOUSE_LEFT) {
- if (dragwin != NULL) {
- /* Drag the separator column */
- count = col - dragwin->w_wincol - dragwin->w_width + 1
- - on_sep_line;
- win_drag_vsep_line(dragwin, count);
- did_drag |= count;
- }
- return IN_SEP_LINE; /* Cursor didn't move */
- } else { /* keep_window_focus must be TRUE */
- /* before moving the cursor for a left click, stop Visual mode */
- if (flags & MOUSE_MAY_STOP_VIS) {
- end_visual_mode();
- redraw_curbuf_later(INVERTED); /* delete the inversion */
- }
-
-
- row -= curwin->w_winrow;
- col -= curwin->w_wincol;
-
- /*
- * When clicking beyond the end of the window, scroll the screen.
- * Scroll by however many rows outside the window we are.
- */
- if (row < 0) {
- count = 0;
- for (first = true; curwin->w_topline > 1; ) {
- if (curwin->w_topfill < diff_check(curwin, curwin->w_topline))
- ++count;
- else
- count += plines(curwin->w_topline - 1);
- if (!first && count > -row)
- break;
- first = false;
- hasFolding(curwin->w_topline, &curwin->w_topline, NULL);
- if (curwin->w_topfill < diff_check(curwin, curwin->w_topline))
- ++curwin->w_topfill;
- else {
- --curwin->w_topline;
- curwin->w_topfill = 0;
- }
- }
- check_topfill(curwin, false);
- curwin->w_valid &=
- ~(VALID_WROW|VALID_CROW|VALID_BOTLINE|VALID_BOTLINE_AP);
- redraw_later(VALID);
- row = 0;
- } else if (row >= curwin->w_height) {
- count = 0;
- for (first = true; curwin->w_topline < curbuf->b_ml.ml_line_count; ) {
- if (curwin->w_topfill > 0)
- ++count;
- else
- count += plines(curwin->w_topline);
- if (!first && count > row - curwin->w_height + 1)
- break;
- first = false;
- if (hasFolding(curwin->w_topline, NULL, &curwin->w_topline)
- && curwin->w_topline == curbuf->b_ml.ml_line_count)
- break;
- if (curwin->w_topfill > 0)
- --curwin->w_topfill;
- else {
- ++curwin->w_topline;
- curwin->w_topfill =
- diff_check_fill(curwin, curwin->w_topline);
- }
- }
- check_topfill(curwin, false);
- redraw_later(VALID);
- curwin->w_valid &=
- ~(VALID_WROW|VALID_CROW|VALID_BOTLINE|VALID_BOTLINE_AP);
- row = curwin->w_height - 1;
- } else if (row == 0) {
- /* When dragging the mouse, while the text has been scrolled up as
- * far as it goes, moving the mouse in the top line should scroll
- * the text down (done later when recomputing w_topline). */
- if (mouse_dragging > 0
- && curwin->w_cursor.lnum
- == curwin->w_buffer->b_ml.ml_line_count
- && curwin->w_cursor.lnum == curwin->w_topline)
- curwin->w_valid &= ~(VALID_TOPLINE);
- }
- }
-
- /* Check for position outside of the fold column. */
- if (
- curwin->w_p_rl ? col < curwin->w_width - curwin->w_p_fdc :
- col >= curwin->w_p_fdc
- + (cmdwin_type == 0 ? 0 : 1)
- )
- mouse_char = ' ';
-
- /* compute the position in the buffer line from the posn on the screen */
- if (mouse_comp_pos(curwin, &row, &col, &curwin->w_cursor.lnum))
- mouse_past_bottom = true;
-
- /* Start Visual mode before coladvance(), for when 'sel' != "old" */
- if ((flags & MOUSE_MAY_VIS) && !VIsual_active) {
- check_visual_highlight();
- VIsual = old_cursor;
- VIsual_active = TRUE;
- VIsual_reselect = TRUE;
- /* if 'selectmode' contains "mouse", start Select mode */
- may_start_select('o');
- setmouse();
- if (p_smd && msg_silent == 0)
- redraw_cmdline = TRUE; /* show visual mode later */
- }
-
- curwin->w_curswant = col;
- curwin->w_set_curswant = FALSE; /* May still have been TRUE */
- if (coladvance(col) == FAIL) { /* Mouse click beyond end of line */
- if (inclusive != NULL)
- *inclusive = true;
- mouse_past_eol = true;
- } else if (inclusive != NULL)
- *inclusive = false;
-
- count = IN_BUFFER;
- if (curwin != old_curwin || curwin->w_cursor.lnum != old_cursor.lnum
- || curwin->w_cursor.col != old_cursor.col)
- count |= CURSOR_MOVED; /* Cursor has moved */
-
- if (mouse_char == '+')
- count |= MOUSE_FOLD_OPEN;
- else if (mouse_char != ' ')
- count |= MOUSE_FOLD_CLOSE;
-
- return count;
-}
-
-/*
- * Compute the position in the buffer line from the posn on the screen in
- * window "win".
- * Returns TRUE if the position is below the last line.
- */
-bool mouse_comp_pos(win_T *win, int *rowp, int *colp, linenr_T *lnump)
-{
- int col = *colp;
- int row = *rowp;
- linenr_T lnum;
- bool retval = false;
- int off;
- int count;
-
- if (win->w_p_rl)
- col = win->w_width - 1 - col;
-
- lnum = win->w_topline;
-
- while (row > 0) {
- /* Don't include filler lines in "count" */
- if (win->w_p_diff
- && !hasFoldingWin(win, lnum, NULL, NULL, TRUE, NULL)
- ) {
- if (lnum == win->w_topline)
- row -= win->w_topfill;
- else
- row -= diff_check_fill(win, lnum);
- count = plines_win_nofill(win, lnum, TRUE);
- } else
- count = plines_win(win, lnum, TRUE);
- if (count > row)
- break; /* Position is in this buffer line. */
- (void)hasFoldingWin(win, lnum, NULL, &lnum, TRUE, NULL);
- if (lnum == win->w_buffer->b_ml.ml_line_count) {
- retval = true;
- break; /* past end of file */
- }
- row -= count;
- ++lnum;
- }
-
- if (!retval) {
- /* Compute the column without wrapping. */
- off = win_col_off(win) - win_col_off2(win);
- if (col < off)
- col = off;
- col += row * (win->w_width - off);
- /* add skip column (for long wrapping line) */
- col += win->w_skipcol;
- }
-
- if (!win->w_p_wrap)
- col += win->w_leftcol;
-
- /* skip line number and fold column in front of the line */
- col -= win_col_off(win);
- if (col < 0) {
- col = 0;
- }
-
- *colp = col;
- *rowp = row;
- *lnump = lnum;
- return retval;
-}
-
-/*
- * Find the window at screen position "*rowp" and "*colp". The positions are
- * updated to become relative to the top-left of the window.
- */
-win_T *mouse_find_win(int *rowp, int *colp)
-{
- frame_T *fp;
-
- fp = topframe;
- *rowp -= firstwin->w_winrow;
- for (;; ) {
- if (fp->fr_layout == FR_LEAF)
- break;
- if (fp->fr_layout == FR_ROW) {
- for (fp = fp->fr_child; fp->fr_next != NULL; fp = fp->fr_next) {
- if (*colp < fp->fr_width)
- break;
- *colp -= fp->fr_width;
- }
- } else { /* fr_layout == FR_COL */
- for (fp = fp->fr_child; fp->fr_next != NULL; fp = fp->fr_next) {
- if (*rowp < fp->fr_height)
- break;
- *rowp -= fp->fr_height;
- }
- }
- }
- return fp->fr_win;
-}
-
-#if defined(USE_IM_CONTROL) || defined(PROTO)
-/*
- * Save current Input Method status to specified place.
- */
-void im_save_status(long *psave)
-{
- /* Don't save when 'imdisable' is set or "xic" is NULL, IM is always
- * disabled then (but might start later).
- * Also don't save when inside a mapping, vgetc_im_active has not been set
- * then.
- * And don't save when the keys were stuffed (e.g., for a "." command).
- * And don't save when the GUI is running but our window doesn't have
- * input focus (e.g., when a find dialog is open). */
- if (!p_imdisable && KeyTyped && !KeyStuffed
- ) {
- /* Do save when IM is on, or IM is off and saved status is on. */
- if (vgetc_im_active)
- *psave = B_IMODE_IM;
- else if (*psave == B_IMODE_IM)
- *psave = B_IMODE_NONE;
- }
-}
-#endif
-
diff --git a/src/nvim/ui.h b/src/nvim/ui.h
index 2b1543a918..b174af9abe 100644
--- a/src/nvim/ui.h
+++ b/src/nvim/ui.h
@@ -3,27 +3,6 @@
#include <stdbool.h>
-/*
- * jump_to_mouse() returns one of first four these values, possibly with
- * some of the other three added.
- */
-#define IN_UNKNOWN 0
-#define IN_BUFFER 1
-#define IN_STATUS_LINE 2 /* on status or command line */
-#define IN_SEP_LINE 4 /* on vertical separator line */
-#define IN_OTHER_WIN 8 /* in other window but can't go there */
-#define CURSOR_MOVED 0x100
-#define MOUSE_FOLD_CLOSE 0x200 /* clicked on '-' in fold column */
-#define MOUSE_FOLD_OPEN 0x400 /* clicked on '+' in fold column */
-
-/* flags for jump_to_mouse() */
-#define MOUSE_FOCUS 0x01 /* need to stay in this window */
-#define MOUSE_MAY_VIS 0x02 /* may start Visual mode */
-#define MOUSE_DID_MOVE 0x04 /* only act when mouse has moved */
-#define MOUSE_SETPOS 0x08 /* only set current mouse position */
-#define MOUSE_MAY_STOP_VIS 0x10 /* may stop Visual mode */
-#define MOUSE_RELEASED 0x20 /* button was released */
-
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "ui.h.generated.h"
#endif
diff --git a/src/nvim/window.c b/src/nvim/window.c
index 9345d740d1..315d5f07de 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -1230,7 +1230,6 @@ static void win_rotate(int upwards, int count)
return;
}
-
/* Check if all frames in this row/col have one window. */
for (frp = curwin->w_frame->fr_parent->fr_child; frp != NULL;
frp = frp->fr_next)
@@ -1246,6 +1245,7 @@ static void win_rotate(int upwards, int count)
wp1 = frp->fr_win;
win_remove(wp1, NULL);
frame_remove(frp);
+ assert(frp->fr_parent->fr_child);
/* find last frame and append removed window/frame after it */
for (; frp->fr_next != NULL; frp = frp->fr_next)
@@ -1263,6 +1263,7 @@ static void win_rotate(int upwards, int count)
wp2 = wp1->w_prev; /* will become last window */
win_remove(wp1, NULL);
frame_remove(frp);
+ assert(frp->fr_parent->fr_child);
/* append the removed window/frame before the first in the list */
win_append(frp->fr_parent->fr_child->fr_win->w_prev, wp1);
@@ -2193,6 +2194,7 @@ winframe_remove (
* the frames into this list. */
if (frp2->fr_child == frp)
frp2->fr_child = frp->fr_child;
+ assert(frp->fr_child);
frp->fr_child->fr_prev = frp->fr_prev;
if (frp->fr_prev != NULL)
frp->fr_prev->fr_next = frp->fr_child;
@@ -4502,6 +4504,7 @@ void win_drag_vsep_line(win_T *dragwin, int offset)
room += fr->fr_width - frame_minwidth(fr, NULL);
fr = curfr; /* put fr at window that grows */
}
+ assert(fr);
if (room < offset) /* Not enough room */
offset = room; /* Move as far as we can */
@@ -4973,6 +4976,7 @@ static void last_status_rec(frame_T *fr, int statusline)
*/
int tabline_height(void)
{
+ assert(first_tabpage);
switch (p_stal) {
case 0: return 0;
case 1: return (first_tabpage->tp_next == NULL) ? 0 : 1;