aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThiago de Arruda <tpadilha84@gmail.com>2015-02-16 23:42:25 -0300
committerThiago de Arruda <tpadilha84@gmail.com>2015-02-16 23:42:25 -0300
commit0429857689ba98356bc80d01ebd540fe861e8db2 (patch)
treeb4d039dba9e18a041b00cfe31d954931a97241dd /src
parentaf46564dd6e7e709f269f041f749dc312d9c3773 (diff)
parent40b7990553997d9eabb21b746346356016b373c5 (diff)
downloadrneovim-0429857689ba98356bc80d01ebd540fe861e8db2.tar.gz
rneovim-0429857689ba98356bc80d01ebd540fe861e8db2.tar.bz2
rneovim-0429857689ba98356bc80d01ebd540fe861e8db2.zip
Merge PR #1820 'Reimplement builtin terminal UI with termkey/unibilium'
Diffstat (limited to 'src')
-rw-r--r--src/nvim/CMakeLists.txt24
-rw-r--r--src/nvim/charset.c19
-rw-r--r--src/nvim/eval.c28
-rw-r--r--src/nvim/ex_cmds.c5
-rw-r--r--src/nvim/ex_cmds.lua2
-rw-r--r--src/nvim/ex_cmds2.c4
-rw-r--r--src/nvim/ex_docmd.c37
-rw-r--r--src/nvim/ex_getln.c29
-rw-r--r--src/nvim/fileio.c7
-rw-r--r--src/nvim/garray.c20
-rw-r--r--src/nvim/getchar.c69
-rw-r--r--src/nvim/globals.h9
-rw-r--r--src/nvim/hardcopy.c5
-rw-r--r--src/nvim/keymap.c23
-rw-r--r--src/nvim/main.c139
-rw-r--r--src/nvim/map.c2
-rw-r--r--src/nvim/message.c68
-rw-r--r--src/nvim/misc1.c30
-rw-r--r--src/nvim/mouse.c6
-rw-r--r--src/nvim/msgpack_rpc/channel.c16
-rw-r--r--src/nvim/msgpack_rpc/helpers.c16
-rw-r--r--src/nvim/normal.c19
-rw-r--r--src/nvim/option.c62
-rw-r--r--src/nvim/os/event.c5
-rw-r--r--src/nvim/os/input.c168
-rw-r--r--src/nvim/os/rstream.c9
-rw-r--r--src/nvim/os/signal.c24
-rw-r--r--src/nvim/os_unix.c410
-rw-r--r--src/nvim/screen.c411
-rw-r--r--src/nvim/sha256.c37
-rw-r--r--src/nvim/strings.c11
-rw-r--r--src/nvim/syntax.c494
-rw-r--r--src/nvim/syntax.h1
-rw-r--r--src/nvim/syntax_defs.h20
-rw-r--r--src/nvim/term.c2771
-rw-r--r--src/nvim/tui/term_input.inl246
-rw-r--r--src/nvim/tui/tui.c752
-rw-r--r--src/nvim/tui/tui.h8
-rw-r--r--src/nvim/ui.c201
-rw-r--r--src/nvim/ui.h1
-rw-r--r--src/nvim/version.c28
-rw-r--r--src/nvim/vim.h3
42 files changed, 1439 insertions, 4800 deletions
diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt
index 6fc5022d48..922b8b85a1 100644
--- a/src/nvim/CMakeLists.txt
+++ b/src/nvim/CMakeLists.txt
@@ -26,13 +26,16 @@ file(MAKE_DIRECTORY ${GENERATED_DIR}/os)
file(MAKE_DIRECTORY ${GENERATED_DIR}/api)
file(MAKE_DIRECTORY ${GENERATED_DIR}/api/private)
file(MAKE_DIRECTORY ${GENERATED_DIR}/msgpack_rpc)
+file(MAKE_DIRECTORY ${GENERATED_DIR}/tui)
file(MAKE_DIRECTORY ${GENERATED_INCLUDES_DIR})
file(MAKE_DIRECTORY ${GENERATED_INCLUDES_DIR}/os)
file(MAKE_DIRECTORY ${GENERATED_INCLUDES_DIR}/api)
file(MAKE_DIRECTORY ${GENERATED_INCLUDES_DIR}/api/private)
file(MAKE_DIRECTORY ${GENERATED_INCLUDES_DIR}/msgpack_rpc)
+file(MAKE_DIRECTORY ${GENERATED_INCLUDES_DIR}/tui)
-file(GLOB NEOVIM_SOURCES *.c os/*.c api/*.c api/private/*.c msgpack_rpc/*.c)
+file(GLOB NEOVIM_SOURCES *.c os/*.c api/*.c api/private/*.c msgpack_rpc/*.c
+ tui/*.c)
file(GLOB_RECURSE NEOVIM_HEADERS *.h)
foreach(sfile ${NEOVIM_SOURCES})
@@ -164,19 +167,6 @@ if (LibIntl_FOUND)
list(APPEND NVIM_LINK_LIBRARIES ${LibIntl_LIBRARY})
endif()
-check_library_exists(curses tgetent "" HAVE_LIBCURSES)
-if (HAVE_LIBCURSES)
- list(APPEND NVIM_LINK_LIBRARIES curses)
-else()
- check_library_exists(tinfo tgetent "" HAVE_LIBTINFO)
- if (HAVE_LIBTINFO)
- list(APPEND NVIM_LINK_LIBRARIES tinfo)
- else()
- find_package(Curses REQUIRED)
- list(APPEND NVIM_LINK_LIBRARIES ${CURSES_LIBRARY})
- endif()
-endif()
-
if(Iconv_LIBRARIES)
list(APPEND NVIM_LINK_LIBRARIES ${Iconv_LIBRARIES})
endif()
@@ -186,8 +176,12 @@ list(APPEND NVIM_LINK_LIBRARIES
${LIBUV_LIBRARIES}
${MSGPACK_LIBRARIES}
${LUAJIT_LIBRARIES}
+ ${LIBTICKIT_LIBRARIES}
+ ${LIBTERMKEY_LIBRARIES}
+ ${LIBUNIBILIUM_LIBRARIES}
m
- ${CMAKE_THREAD_LIBS_INIT})
+ ${CMAKE_THREAD_LIBS_INIT}
+ )
add_executable(nvim ${NEOVIM_GENERATED_SOURCES} ${NEOVIM_SOURCES}
${NEOVIM_HEADERS})
diff --git a/src/nvim/charset.c b/src/nvim/charset.c
index 6fb5ebf3e4..b8fcd2de09 100644
--- a/src/nvim/charset.c
+++ b/src/nvim/charset.c
@@ -1849,25 +1849,6 @@ int hex2nr(int c)
return c - '0';
}
-#if defined(FEAT_TERMRESPONSE) || defined(FEAT_GUI_GTK)
-
-/// Convert two hex characters to a byte.
-/// Return -1 if one of the characters is not hex.
-///
-/// @param p
-///
-/// @return The two hex characters converted to a byte or -1 if one of the
-/// character is not hex.
-int hexhex2nr(char_u *p)
-{
- if (!vim_isxdigit(p[0]) || !vim_isxdigit(p[1])) {
- return -1;
- }
- return (hex2nr(p[0]) << 4) + hex2nr(p[1]);
-}
-
-#endif // if defined(FEAT_TERMRESPONSE) || defined(FEAT_GUI_GTK)
-
/// Return true if "str" starts with a backslash that should be removed.
/// For WIN32 this is only done when the character after the
/// backslash is not a normal file name character.
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index a4bd4d89ef..97993eb651 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -9955,14 +9955,8 @@ static void f_has(typval_T *argvars, typval_T *rettv)
#endif
"tag_binary",
"tag_old_static",
-#ifdef TERMINFO
- "terminfo",
-#endif
"termresponse",
"textobjects",
-#ifdef HAVE_TGETENT
- "tgetent",
-#endif
"title",
"user-commands", /* was accidentally included in 5.4 */
"user_commands",
@@ -14424,13 +14418,10 @@ static void f_synIDattr(typval_T *argvars, typval_T *rettv)
if (argvars[2].v_type != VAR_UNKNOWN) {
mode = get_tv_string_buf(&argvars[2], modebuf);
modec = TOLOWER_ASC(mode[0]);
- if (modec != 't' && modec != 'c' && modec != 'g')
+ if (modec != 'c' && modec != 'g')
modec = 0; /* replace invalid with current */
} else {
- if (abstract_ui || t_colors > 1)
- modec = 'c';
- else
- modec = 't';
+ modec = 'c';
}
@@ -18080,21 +18071,6 @@ static int function_exists(char_u *name)
return n;
}
-char_u *get_expanded_name(char_u *name, int check)
-{
- char_u *nm = name;
- char_u *p;
-
- p = trans_function_name(&nm, FALSE, TFN_INT|TFN_QUIET, NULL);
-
- if (p != NULL && *nm == NUL)
- if (!check || translated_function_exists(p))
- return p;
-
- free(p);
- return NULL;
-}
-
/// Return TRUE if "name" looks like a builtin function name: starts with a
/// lower case letter and doesn't contain AUTOLOAD_CHAR.
/// "len" is the length of "name", or -1 for NUL terminated.
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index b03c25a098..49f33c5017 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -1232,9 +1232,6 @@ do_shell (
* avoid having to type return below.
*/
msg_putchar('\r'); /* put cursor at start of line */
- if (!autocmd_busy) {
- stoptermcap();
- }
msg_putchar('\n'); /* may shift screen one line up */
/* warning message before calling the shell */
@@ -1292,8 +1289,6 @@ do_shell (
wait_return(msg_silent == 0);
no_wait_return = save_nwr;
}
-
- starttermcap(); /* start termcap if not done by wait_return() */
}
/* display any error messages now */
diff --git a/src/nvim/ex_cmds.lua b/src/nvim/ex_cmds.lua
index aade4d736d..98a2b2814d 100644
--- a/src/nvim/ex_cmds.lua
+++ b/src/nvim/ex_cmds.lua
@@ -2483,7 +2483,7 @@ return {
{
command='winpos',
flags=bit.bor(EXTRA, TRLBAR, CMDWIN),
- func='ex_winpos',
+ func='ex_ni',
},
{
command='wnext',
diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c
index 7de47cb296..9bcbfa2f26 100644
--- a/src/nvim/ex_cmds2.c
+++ b/src/nvim/ex_cmds2.c
@@ -155,10 +155,6 @@ void do_debug(char_u *cmd)
#define CMD_INTERRUPT 6
- /* Make sure we are in raw mode and start termcap mode. Might have side
- * effects... */
- starttermcap();
-
++RedrawingDisabled; /* don't redisplay the window */
++no_wait_return; /* don't wait for return */
did_emsg = FALSE; /* don't use error from debugged stuff */
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 9b48398d96..7ff69a3d41 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -146,10 +146,6 @@ struct dbg_stuff {
# define gui_mch_find_dialog ex_ni
# define gui_mch_replace_dialog ex_ni
# define ex_helpfind ex_ni
-#if defined(FEAT_GUI) || defined(UNIX) || defined(MSWIN)
-#else
-# define ex_winpos ex_ni
-#endif
static int did_lcd; /* whether ":lcd" was produced for a session */
#ifndef HAVE_WORKING_LIBINTL
# define ex_language ex_ni
@@ -5397,13 +5393,11 @@ static void ex_stop(exarg_T *eap)
windgoto((int)Rows - 1, 0);
out_char('\n');
out_flush();
- stoptermcap();
out_flush(); /* needed for SUN to restore xterm buffer */
mch_restore_title(3); /* restore window titles */
ui_suspend(); /* call machine specific function */
maketitle();
resettitle(); /* force updating the title */
- starttermcap();
scroll_start(); /* scroll screen before redrawing */
redraw_later_clear();
shell_resized(); /* may have resized window */
@@ -6438,7 +6432,7 @@ static void ex_winsize(exarg_T *eap)
p = arg;
h = getdigits_int(&arg);
if (*p != NUL && *arg == NUL)
- screen_resize(w, h, TRUE);
+ screen_resize(w, h);
else
EMSG(_("E465: :winsize requires two number arguments"));
}
@@ -6473,35 +6467,6 @@ static void ex_wincmd(exarg_T *eap)
}
}
-#if defined(FEAT_GUI) || defined(UNIX) || defined(MSWIN)
-/*
- * ":winpos".
- */
-static void ex_winpos(exarg_T *eap)
-{
- int x, y;
- char_u *arg = eap->arg;
- char_u *p;
-
- if (*arg == NUL) {
- EMSG(_("E188: Obtaining window position not implemented for this platform"));
- } else {
- x = getdigits_int(&arg);
- arg = skipwhite(arg);
- p = arg;
- y = getdigits_int(&arg);
- if (*p == NUL || *arg != NUL) {
- EMSG(_("E466: :winpos requires two number arguments"));
- return;
- }
-# ifdef HAVE_TGETENT
- if (*T_CWP)
- term_set_winpos(x, y);
-# endif
- }
-}
-#endif
-
/*
* Handle command that work like operators: ":delete", ":yank", ":>" and ":<".
*/
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index 2855f0cc12..6a3bd16feb 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -4618,35 +4618,6 @@ int del_history_idx(int histype, int idx)
return TRUE;
}
-
-/*
- * Very specific function to remove the value in ":set key=val" from the
- * history.
- */
-void remove_key_from_history(void)
-{
- char_u *p;
- int i;
-
- i = hisidx[HIST_CMD];
- if (i < 0)
- return;
- p = history[HIST_CMD][i].hisstr;
- if (p != NULL)
- for (; *p; ++p)
- if (STRNCMP(p, "key", 3) == 0 && !isalpha(p[3])) {
- p = vim_strchr(p + 3, '=');
- if (p == NULL)
- break;
- ++p;
- for (i = 0; p[i] && !vim_iswhite(p[i]); ++i)
- if (p[i] == '\\' && p[i + 1])
- ++i;
- STRMOVE(p, p + i);
- --p;
- }
-}
-
/*
* Get indices "num1,num2" that specify a range within a list (not a range of
* text lines in a buffer!) from a string. Used for ":history" and ":clist".
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index a4728b245b..dd6e5ace3f 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -1813,7 +1813,6 @@ failed:
* Switch on raw mode now and clear the screen.
*/
if (read_stdin) {
- starttermcap();
screenclear();
}
@@ -6471,12 +6470,6 @@ int has_cmdundefined(void)
return first_autopat[(int)EVENT_CMDUNDEFINED] != NULL;
}
-/// @returns true when there is an FuncUndefined autocommand defined.
-int has_funcundefined(void)
-{
- return first_autopat[(int)EVENT_FUNCUNDEFINED] != NULL;
-}
-
static int
apply_autocmds_group (
event_T event,
diff --git a/src/nvim/garray.c b/src/nvim/garray.c
index c3a3426e87..31a79db209 100644
--- a/src/nvim/garray.c
+++ b/src/nvim/garray.c
@@ -198,23 +198,3 @@ void ga_append(garray_T *gap, char c)
{
GA_APPEND(char, gap, c);
}
-
-#if defined(UNIX) || defined(WIN3264)
-
-/// Append the text in "gap" below the cursor line and clear "gap".
-///
-/// @param gap
-void append_ga_line(garray_T *gap)
-{
- // Remove trailing CR.
- if (!GA_EMPTY(gap)
- && !curbuf->b_p_bin
- && (((char_u *)gap->ga_data)[gap->ga_len - 1] == CAR)) {
- gap->ga_len--;
- }
- ga_append(gap, NUL);
- ml_append(curwin->w_cursor.lnum++, gap->ga_data, 0, FALSE);
- gap->ga_len = 0;
-}
-
-#endif // if defined(UNIX) || defined(WIN3264)
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c
index d97c983133..b8a145483f 100644
--- a/src/nvim/getchar.c
+++ b/src/nvim/getchar.c
@@ -1203,7 +1203,6 @@ void save_typeahead(tasave_T *tp)
readbuf1.bh_first.b_next = NULL;
tp->save_readbuf2 = readbuf2;
readbuf2.bh_first.b_next = NULL;
- tp->save_inputbuf = input_buffer_save();
}
/*
@@ -1224,7 +1223,6 @@ void restore_typeahead(tasave_T *tp)
readbuf1 = tp->save_readbuf1;
free_buff(&readbuf2);
readbuf2 = tp->save_readbuf2;
- input_buffer_restore(tp->save_inputbuf);
}
/*
@@ -1546,22 +1544,6 @@ int vpeekc(void)
}
/*
- * Like vpeekc(), but don't allow mapping. Do allow checking for terminal
- * codes.
- */
-int vpeekc_nomap(void)
-{
- int c;
-
- ++no_mapping;
- ++allow_keys;
- c = vpeekc();
- --no_mapping;
- --allow_keys;
- return c;
-}
-
-/*
* Check if any character is available, also half an escape sequence.
* Trick: when no typeahead found, but there is something in the typeahead
* buffer, it must be an ESC that is recognized as the start of a key code.
@@ -1929,8 +1911,6 @@ static int vgetorpeek(int advance)
if ((mp == NULL || max_mlen >= mp_match_len)
&& keylen != KEYLEN_PART_MAP) {
- int save_keylen = keylen;
-
/*
* When no matching mapping found or found a
* non-matching mapping that matches at least what the
@@ -1947,25 +1927,7 @@ static int vgetorpeek(int advance)
|| (p_remap && typebuf.tb_noremap[
typebuf.tb_off] == RM_YES))
&& !timedout) {
- keylen = check_termcode(max_mlen + 1,
- NULL, 0, NULL);
-
- /* If no termcode matched but 'pastetoggle'
- * matched partially it's like an incomplete key
- * sequence. */
- if (keylen == 0 && save_keylen == KEYLEN_PART_KEY)
- keylen = KEYLEN_PART_KEY;
-
- /*
- * When getting a partial match, but the last
- * characters were not typed, don't wait for a
- * typed character to complete the termcode.
- * This helps a lot when a ":normal" command ends
- * in an ESC.
- */
- if (keylen < 0
- && typebuf.tb_len == typebuf.tb_maplen)
- keylen = 0;
+ keylen = 0;
} else
keylen = 0;
if (keylen == 0) { /* no matching terminal code */
@@ -2515,29 +2477,27 @@ fix_input_buffer (
int script /* TRUE when reading from a script */
)
{
- if (abstract_ui) {
- // Should not escape K_SPECIAL/CSI while in embedded mode because vim key
- // codes keys are processed in input.c/input_enqueue.
+ if (!using_script()) {
+ // Should not escape K_SPECIAL/CSI reading input from the user because vim
+ // key codes keys are processed in input.c/input_enqueue.
buf[len] = NUL;
return len;
}
+ // Reading from script, need to process special bytes
int i;
char_u *p = buf;
- /*
- * Two characters are special: NUL and K_SPECIAL.
- * When compiled With the GUI CSI is also special.
- * Replace NUL by K_SPECIAL KS_ZERO KE_FILLER
- * Replace K_SPECIAL by K_SPECIAL KS_SPECIAL KE_FILLER
- * Replace CSI by K_SPECIAL KS_EXTRA KE_CSI
- * Don't replace K_SPECIAL when reading a script file.
- */
+ // Two characters are special: NUL and K_SPECIAL.
+ // Replace NUL by K_SPECIAL KS_ZERO KE_FILLER
+ // Replace K_SPECIAL by K_SPECIAL KS_SPECIAL KE_FILLER
+ // Replace CSI by K_SPECIAL KS_EXTRA KE_CSI
+ // Don't replace K_SPECIAL when reading a script file.
for (i = len; --i >= 0; ++p) {
if (p[0] == NUL
|| (p[0] == K_SPECIAL
&& !script
- && (i < 2 || p[1] != KS_EXTRA || is_user_input(p[2])))) {
+ && (i < 2 || p[1] != KS_EXTRA))) {
memmove(p + 3, p + 1, (size_t)i);
p[2] = K_THIRD(p[0]);
p[1] = K_SECOND(p[0]);
@@ -2546,7 +2506,7 @@ fix_input_buffer (
len += 2;
}
}
- *p = NUL; /* add trailing NUL */
+ *p = NUL; // add trailing NUL
return len;
}
@@ -3772,11 +3732,6 @@ eval_map_expr (
return res;
}
-static bool is_user_input(int k)
-{
- return k != (int)KE_EVENT && k != (int)KE_CURSORHOLD;
-}
-
/*
* Copy "p" to allocated memory, escaping K_SPECIAL and CSI so that the result
* can be put in the typeahead buffer.
diff --git a/src/nvim/globals.h b/src/nvim/globals.h
index 1aa90777fa..86c28e823a 100644
--- a/src/nvim/globals.h
+++ b/src/nvim/globals.h
@@ -904,13 +904,10 @@ EXTERN char_u *use_viminfo INIT(= NULL); /* name of viminfo file to use */
EXTERN FILE *scriptin[NSCRIPT]; /* streams to read script from */
EXTERN int curscript INIT(= 0); /* index in scriptin[] */
EXTERN FILE *scriptout INIT(= NULL); /* stream to write script to */
-EXTERN int read_cmd_fd INIT(= 0); /* fd to read commands from */
/* volatile because it is used in signal handler catch_sigint(). */
EXTERN volatile int got_int INIT(= FALSE); /* set to TRUE when interrupt
signal occurred */
-EXTERN int termcap_active INIT(= FALSE); /* set by starttermcap() */
-EXTERN int cur_tmode INIT(= TMODE_COOK); /* input terminal mode */
EXTERN int bangredo INIT(= FALSE); /* set to TRUE with ! command */
EXTERN int searchcmdlen; /* length of previous search cmd */
EXTERN int reg_do_extmatch INIT(= 0); /* Used when compiling regexp:
@@ -1237,14 +1234,8 @@ EXTERN FILE *time_fd INIT(= NULL); /* where to write startup timing */
EXTERN int ignored;
EXTERN char *ignoredp;
-/* Temporarily moved these static variables to assist in migrating from
- * os_unix.c */
-EXTERN int curr_tmode INIT(= TMODE_COOK); /* contains current terminal mode */
-
// If a msgpack-rpc channel should be started over stdin/stdout
EXTERN bool embedded_mode INIT(= false);
-// Using the "abstract_ui" termcap
-EXTERN bool abstract_ui INIT(= false);
/// Used to track the status of external functions.
/// Currently only used for iconv().
diff --git a/src/nvim/hardcopy.c b/src/nvim/hardcopy.c
index c01f763d20..2dbe33d6e2 100644
--- a/src/nvim/hardcopy.c
+++ b/src/nvim/hardcopy.c
@@ -617,10 +617,7 @@ void ex_hardcopy(exarg_T *eap)
eap->forceit) == FAIL)
return;
- if (t_colors > 1)
- settings.modec = 'c';
- else
- settings.modec = 't';
+ settings.modec = 'c';
if (!syntax_present(curwin))
settings.do_syntax = FALSE;
diff --git a/src/nvim/keymap.c b/src/nvim/keymap.c
index 251926c01a..8d98a0a95d 100644
--- a/src/nvim/keymap.c
+++ b/src/nvim/keymap.c
@@ -752,26 +752,3 @@ int get_mouse_button(int code, bool *is_click, bool *is_drag)
}
return 0; /* Shouldn't get here */
}
-
-/*
- * Return the appropriate pseudo mouse event token (KE_LEFTMOUSE etc) based on
- * the given information about which mouse button is down, and whether the
- * mouse was clicked, dragged or released.
- */
-int
-get_pseudo_mouse_code (
- int button, /* eg MOUSE_LEFT */
- int is_click,
- int is_drag
-)
-{
- int i;
-
- for (i = 0; mouse_table[i].pseudo_code; i++)
- if (button == mouse_table[i].button
- && is_click == mouse_table[i].is_click
- && is_drag == mouse_table[i].is_drag) {
- return mouse_table[i].pseudo_code;
- }
- return (int)KE_IGNORE; /* not recognized, ignore it */
-}
diff --git a/src/nvim/main.c b/src/nvim/main.c
index 6e24806c56..f2891f0979 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -95,7 +95,12 @@ typedef struct {
char_u *use_ef; /* 'errorfile' from -q argument */
int want_full_screen;
- bool stdout_isatty; /* is stdout a terminal? */
+ bool input_isatty; // stdin is a terminal
+ bool output_isatty; // stdout is a terminal
+ bool err_isatty; // stderr is a terminal
+ bool headless; // Dont try to start an user interface
+ // or read/write to stdio(unless
+ // embedding)
char_u *term; /* specified terminal name */
int no_swap_file; /* "-n" argument used */
int use_debug_break_level;
@@ -197,9 +202,7 @@ int main(int argc, char **argv)
early_init();
- /*
- * Check if we have an interactive window.
- */
+ // Check if we have an interactive window.
check_and_set_isatty(&params);
/*
@@ -242,34 +245,20 @@ int main(int argc, char **argv)
printf(_("%d files to edit\n"), GARGCOUNT);
if (params.want_full_screen && !silent_mode) {
- if (embedded_mode) {
- // embedded mode implies abstract_ui
- termcapinit((uint8_t *)"abstract_ui");
- } else {
- // set terminal name and get terminal capabilities (will set full_screen)
- // Do some initialization of the screen
- termcapinit(params.term);
- }
+ termcapinit((uint8_t *)"abstract_ui");
screen_start(); /* don't know where cursor is now */
TIME_MSG("Termcap init");
}
event_init();
-
- if (abstract_ui) {
- full_screen = true;
- t_colors = 256;
- T_CCO = (uint8_t *)"256";
- } else {
- // Print a warning if stdout is not a terminal TODO(tarruda): Remove this
- // check once the new terminal UI is implemented
- check_tty(&params);
- }
+ full_screen = true;
+ t_colors = 256;
+ T_CCO = (uint8_t *)"256";
+ check_tty(&params);
/*
* Set the default values for the options that use Rows and Columns.
*/
- ui_get_shellsize(); /* inits Rows and Columns */
win_init_size();
/* Set the 'diff' option now, so that it can be checked for in a .vimrc
* file. There is no buffer yet though. */
@@ -382,25 +371,22 @@ int main(int argc, char **argv)
newline_on_exit = TRUE;
#endif
- /*
- * When done something that is not allowed or error message call
- * wait_return. This must be done before starttermcap(), because it may
- * switch to another screen. It must be done after settmode(TMODE_RAW),
- * because we want to react on a single key stroke.
- * Call settmode and starttermcap here, so the T_KS and T_TI may be
- * defined by termcapinit and redefined in .exrc.
- */
- settmode(TMODE_RAW);
- TIME_MSG("setting raw mode");
+ if (!params.headless && (params.output_isatty || params.err_isatty)) {
+ if (params.input_isatty && (need_wait_return || msg_didany)) {
+ // Since at this point there's no UI instance running yet, error messages
+ // would have been printed to stdout. Before starting (which can result
+ // in a alternate screen buffer being shown) we need confirmation that
+ // the user has seen the messages and that is done with a call to
+ // wait_return. For that to work, stdin must be openend temporarily.
+ input_start_stdin();
+ wait_return(TRUE);
+ TIME_MSG("waiting for return");
+ input_stop_stdin();
+ }
- if (need_wait_return || msg_didany) {
- wait_return(TRUE);
- TIME_MSG("waiting for return");
+ ui_builtin_start();
}
- starttermcap(); // start termcap if not done by wait_return()
- TIME_MSG("start termcap");
- may_req_ambiguous_char_width();
setmouse(); // may start using the mouse
if (scroll_region) {
@@ -480,10 +466,6 @@ int main(int argc, char **argv)
no_wait_return = FALSE;
starting = 0;
- /* Requesting the termresponse is postponed until here, so that a "-c q"
- * argument doesn't make it appear in the shell Vim was started from. */
- may_req_termresponse();
-
/* start in insert mode */
if (p_im)
need_start_insertmode = TRUE;
@@ -965,14 +947,14 @@ static void command_line_scan(mparm_T *parmp)
c = argv[0][argv_idx++];
switch (c) {
case NUL: /* "vim -" read from stdin */
- /* "ex -" silent mode */
- if (exmode_active)
+ if (exmode_active) {
+ // "ex -" silent mode
silent_mode = TRUE;
- else {
- if (parmp->edit_type != EDIT_NONE)
+ } else {
+ if (parmp->edit_type != EDIT_NONE) {
mainerr(ME_TOO_MANY_ARGS, argv[0]);
+ }
parmp->