aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/buffer.c14
-rw-r--r--src/nvim/change.c2
-rw-r--r--src/nvim/digraph.c4
-rw-r--r--src/nvim/ex_cmds.c19
-rw-r--r--src/nvim/ex_docmd.c17
-rw-r--r--src/nvim/ex_docmd.h4
-rw-r--r--src/nvim/ex_getln.c264
-rw-r--r--src/nvim/getchar.c24
-rw-r--r--src/nvim/globals.h3
-rw-r--r--src/nvim/highlight.c2
-rw-r--r--src/nvim/indent.c14
-rw-r--r--src/nvim/keymap.c2
-rw-r--r--src/nvim/main.c27
-rw-r--r--src/nvim/main.h1
-rw-r--r--src/nvim/mbyte.c6
-rw-r--r--src/nvim/memfile_defs.h2
-rw-r--r--src/nvim/message.c5
-rw-r--r--src/nvim/misc1.c4
-rw-r--r--src/nvim/mouse.c5
-rw-r--r--src/nvim/normal.c19
-rw-r--r--src/nvim/option_defs.h1
-rw-r--r--src/nvim/options.lua2
-rw-r--r--src/nvim/search.h2
-rw-r--r--src/nvim/sign.c4
-rw-r--r--src/nvim/state.c6
-rw-r--r--src/nvim/tui/tui.c7
26 files changed, 89 insertions, 371 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index 3b4fc6c3df..587ef74b35 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -540,12 +540,10 @@ bool close_buffer(win_T *win, buf_T *buf, int action, bool abort_if_last)
del_buf = true;
}
- /*
- * Free all things allocated for this buffer.
- * Also calls the "BufDelete" autocommands when del_buf is TRUE.
- */
- /* Remember if we are closing the current buffer. Restore the number of
- * windows, so that autocommands in buf_freeall() don't get confused. */
+ // Free all things allocated for this buffer.
+ // Also calls the "BufDelete" autocommands when del_buf is true.
+ // Remember if we are closing the current buffer. Restore the number of
+ // windows, so that autocommands in buf_freeall() don't get confused.
bool is_curbuf = (buf == curbuf);
// When closing the current buffer stop Visual mode before freeing
@@ -5046,8 +5044,8 @@ do_arg_all(
xfree(opened);
}
-// Return TRUE if "buf" is a prompt buffer.
-int bt_prompt(buf_T *buf)
+/// @return true if "buf" is a prompt buffer.
+bool bt_prompt(buf_T *buf)
{
return buf != NULL && buf->b_p_bt[0] == 'p';
}
diff --git a/src/nvim/change.c b/src/nvim/change.c
index ca1ca756bb..b30490deca 100644
--- a/src/nvim/change.c
+++ b/src/nvim/change.c
@@ -779,7 +779,7 @@ int del_bytes(colnr_T count, bool fixpos_arg, bool use_delcombine)
int movelen = oldlen - col - count + 1; // includes trailing NUL
if (movelen <= 1) {
// If we just took off the last character of a non-blank line, and
- // fixpos is TRUE, we don't want to end up positioned at the NUL,
+ // fixpos is true, we don't want to end up positioned at the NUL,
// unless "restart_edit" is set or 'virtualedit' contains "onemore".
if (col > 0 && fixpos && restart_edit == 0
&& (ve_flags & VE_ONEMORE) == 0
diff --git a/src/nvim/digraph.c b/src/nvim/digraph.c
index dd32cef1e3..07e484c178 100644
--- a/src/nvim/digraph.c
+++ b/src/nvim/digraph.c
@@ -1502,10 +1502,10 @@ char_u *get_digraph_for_char(int val_arg)
/// Get a digraph. Used after typing CTRL-K on the command line or in normal
/// mode.
///
-/// @param cmdline TRUE when called from the cmdline
+/// @param cmdline true when called from the cmdline
///
/// @returns composed character, or NUL when ESC was used.
-int get_digraph(int cmdline)
+int get_digraph(bool cmdline)
{
int cc;
no_mapping++;
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index 0e7d7c2dc2..dc096bdb93 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -2887,7 +2887,6 @@ void ex_append(exarg_T *eap)
} else if (lnum > 0)
indent = get_indent_lnum(lnum);
}
- ex_keep_indent = FALSE;
if (eap->getline == NULL) {
/* No getline() function, use the lines that follow. This ends
* when there is no more. */
@@ -2915,10 +2914,6 @@ void ex_append(exarg_T *eap)
if (theline == NULL)
break;
- /* Using ^ CTRL-D in getexmodeline() makes us repeat the indent. */
- if (ex_keep_indent)
- append_indent = indent;
-
/* Look for the "." after automatic indent. */
vcol = 0;
for (p = theline; indent > vcol; ++p) {
@@ -3751,6 +3746,7 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout,
*/
while (subflags.do_ask) {
if (exmode_active) {
+ char *prompt;
char_u *resp;
colnr_T sc, ec;
@@ -3767,13 +3763,14 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout,
sc += numw;
ec += numw;
}
- msg_start();
- for (i = 0; i < (long)sc; ++i)
- msg_putchar(' ');
- for (; i <= (long)ec; ++i)
- msg_putchar('^');
- resp = getexmodeline('?', NULL, 0, true);
+ prompt = xmallocz(ec + 1);
+ memset(prompt, ' ', sc);
+ memset(prompt + sc, '^', ec - sc + 1);
+ resp = (char_u *)getcmdline_prompt(NUL, prompt, 0, EXPAND_NOTHING,
+ NULL, CALLBACK_NONE);
+ msg_putchar('\n');
+ xfree(prompt);
if (resp != NULL) {
typed = *resp;
xfree(resp);
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 83472fe146..cf604c2015 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -186,17 +186,14 @@ static void restore_dbg_stuff(struct dbg_stuff *dsp)
}
/// Repeatedly get commands for Ex mode, until the ":vi" command is given.
-void do_exmode(int improved)
+void do_exmode(void)
{
int save_msg_scroll;
int prev_msg_row;
linenr_T prev_line;
int changedtick;
- if (improved)
- exmode_active = EXMODE_VIM;
- else
- exmode_active = EXMODE_NORMAL;
+ exmode_active = true;
State = NORMAL;
/* When using ":global /pat/ visual" and then "Q" we return to continue
@@ -212,7 +209,7 @@ void do_exmode(int improved)
while (exmode_active) {
/* Check for a ":normal" command and no more characters left. */
if (ex_normal_busy > 0 && typebuf.tb_len == 0) {
- exmode_active = 0;
+ exmode_active = false;
break;
}
msg_scroll = true;
@@ -750,8 +747,7 @@ int do_cmdline(char_u *cmdline, LineGetter fgetline,
* the :endtry to be missed. */
&& (cstack.cs_trylevel == 0 || did_emsg_syntax)
&& used_getline
- && (getline_equal(fgetline, cookie, getexmodeline)
- || getline_equal(fgetline, cookie, getexline)))
+ && getline_equal(fgetline, cookie, getexline))
&& (next_cmdline != NULL
|| cstack.cs_idx >= 0
|| (flags & DOCMD_REPEAT)));
@@ -2056,8 +2052,7 @@ int parse_command_modifiers(exarg_T *eap, char_u **errormsg, bool skip_only)
// in ex mode, an empty line works like :+
if (*eap->cmd == NUL && exmode_active
- && (getline_equal(eap->getline, eap->cookie, getexmodeline)
- || getline_equal(eap->getline, eap->cookie, getexline))
+ && getline_equal(eap->getline, eap->cookie, getexline)
&& curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count) {
eap->cmd = (char_u *)"+";
if (!skip_only) {
@@ -7303,7 +7298,7 @@ do_exedit(
*/
if (exmode_active && (eap->cmdidx == CMD_visual
|| eap->cmdidx == CMD_view)) {
- exmode_active = 0;
+ exmode_active = false;
ex_pressedreturn = false;
if (*eap->arg == NUL) {
/* Special case: ":global/pat/visual\NLvi-commands" */
diff --git a/src/nvim/ex_docmd.h b/src/nvim/ex_docmd.h
index f6bd2adcd5..c8c5a0a3e2 100644
--- a/src/nvim/ex_docmd.h
+++ b/src/nvim/ex_docmd.h
@@ -16,10 +16,6 @@
#define VALID_PATH 1
#define VALID_HEAD 2
-/* Values for exmode_active (0 is no exmode) */
-#define EXMODE_NORMAL 1
-#define EXMODE_VIM 2
-
// Structure used to save the current state. Used when executing Normal mode
// commands while in any other mode.
typedef struct {
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index 4ebd384ae0..855f71ca28 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -2510,266 +2510,6 @@ getexline(
return getcmdline(c, 1L, indent, do_concat);
}
-/*
- * Get an Ex command line for Ex mode.
- * In Ex mode we only use the OS supplied line editing features and no
- * mappings or abbreviations.
- * Returns a string in allocated memory or NULL.
- */
-char_u *
-getexmodeline(
- int promptc, // normally ':', NUL for ":append" and '?'
- // for :s prompt
- void *cookie,
- int indent, // indent for inside conditionals
- bool do_concat
-)
-{
- garray_T line_ga;
- char_u *pend;
- int startcol = 0;
- int c1 = 0;
- int escaped = FALSE; /* CTRL-V typed */
- int vcol = 0;
- char_u *p;
- int prev_char;
- int len;
-
- /* always start in column 0; write a newline if necessary */
- compute_cmdrow();
- if ((msg_col || msg_didout) && promptc != '?')
- msg_putchar('\n');
- if (promptc == ':') {
- /* indent that is only displayed, not in the line itself */
- if (p_prompt)
- msg_putchar(':');
- while (indent-- > 0)
- msg_putchar(' ');
- startcol = msg_col;
- }
-
- ga_init(&line_ga, 1, 30);
-
- /* autoindent for :insert and :append is in the line itself */
- if (promptc <= 0) {
- vcol = indent;
- while (indent >= 8) {
- ga_append(&line_ga, TAB);
- msg_puts(" ");
- indent -= 8;
- }
- while (indent-- > 0) {
- ga_append(&line_ga, ' ');
- msg_putchar(' ');
- }
- }
- no_mapping++;
-
- /*
- * Get the line, one character at a time.
- */
- got_int = FALSE;
- while (!got_int) {
- ga_grow(&line_ga, 40);
-
- /* Get one character at a time. Don't use inchar(), it can't handle
- * special characters. */
- prev_char = c1;
-
- // Check for a ":normal" command and no more characters left.
- if (ex_normal_busy > 0 && typebuf.tb_len == 0) {
- c1 = '\n';
- } else {
- c1 = vgetc();
- }
-
- /*
- * Handle line editing.
- * Previously this was left to the system, putting the terminal in
- * cooked mode, but then CTRL-D and CTRL-T can't be used properly.
- */
- if (got_int) {
- msg_putchar('\n');
- break;
- }
-
- if (!escaped) {
- /* CR typed means "enter", which is NL */
- if (c1 == '\r')
- c1 = '\n';
-
- if (c1 == BS || c1 == K_BS || c1 == DEL || c1 == K_DEL || c1 == K_KDEL) {
- if (!GA_EMPTY(&line_ga)) {
- p = (char_u *)line_ga.ga_data;
- p[line_ga.ga_len] = NUL;
- len = utf_head_off(p, p + line_ga.ga_len - 1) + 1;
- line_ga.ga_len -= len;
- goto redraw;
- }
- continue;
- }
-
- if (c1 == Ctrl_U) {
- msg_col = startcol;
- msg_clr_eos();
- line_ga.ga_len = 0;
- goto redraw;
- }
-
- int num_spaces;
- if (c1 == Ctrl_T) {
- int sw = get_sw_value(curbuf);
-
- p = (char_u *)line_ga.ga_data;
- p[line_ga.ga_len] = NUL;
- indent = get_indent_str(p, 8, FALSE);
- num_spaces = sw - indent % sw;
-add_indent:
- if (num_spaces > 0) {
- ga_grow(&line_ga, num_spaces + 1);
- p = (char_u *)line_ga.ga_data;
- char_u *s = skipwhite(p);
-
- // Insert spaces after leading whitespaces.
- long move_len = line_ga.ga_len - (s - p) + 1;
- assert(move_len >= 0);
- memmove(s + num_spaces, s, (size_t)move_len);
- memset(s, ' ', (size_t)num_spaces);
-
- line_ga.ga_len += num_spaces;
- }
-redraw:
- /* redraw the line */
- msg_col = startcol;
- vcol = 0;
- p = (char_u *)line_ga.ga_data;
- p[line_ga.ga_len] = NUL;
- while (p < (char_u *)line_ga.ga_data + line_ga.ga_len) {
- if (*p == TAB) {
- do {
- msg_putchar(' ');
- } while (++vcol % 8);
- p++;
- } else {
- len = utfc_ptr2len(p);
- msg_outtrans_len(p, len);
- vcol += ptr2cells(p);
- p += len;
- }
- }
- msg_clr_eos();
- cmd_cursor_goto(msg_row, msg_col);
- continue;
- }
-
- if (c1 == Ctrl_D) {
- /* Delete one shiftwidth. */
- p = (char_u *)line_ga.ga_data;
- if (prev_char == '0' || prev_char == '^') {
- if (prev_char == '^')
- ex_keep_indent = TRUE;
- indent = 0;
- p[--line_ga.ga_len] = NUL;
- } else {
- p[line_ga.ga_len] = NUL;
- indent = get_indent_str(p, 8, FALSE);
- if (indent == 0) {
- continue;
- }
- --indent;
- indent -= indent % get_sw_value(curbuf);
- }
-
- // reduce the line's indentation
- char_u *from = skipwhite(p);
- char_u *to = from;
- int old_indent;
- while ((old_indent = get_indent_str(p, 8, FALSE)) > indent) {
- *--to = NUL;
- }
- long move_len = line_ga.ga_len - (from - p) + 1;
- assert(move_len > 0);
- memmove(to, from, (size_t)move_len);
- line_ga.ga_len -= (int)(from - to);
-
- // Removed to much indentation, fix it before redrawing.
- num_spaces = indent - old_indent;
- goto add_indent;
- }
-
- if (c1 == Ctrl_V || c1 == Ctrl_Q) {
- escaped = TRUE;
- continue;
- }
-
- if (IS_SPECIAL(c1)) {
- // Ignore other special key codes
- continue;
- }
- }
-
- if (IS_SPECIAL(c1)) {
- c1 = '?';
- }
- len = utf_char2bytes(c1, (char_u *)line_ga.ga_data + line_ga.ga_len);
- if (c1 == '\n') {
- msg_putchar('\n');
- } else if (c1 == TAB) {
- // Don't use chartabsize(), 'ts' can be different.
- do {
- msg_putchar(' ');
- } while (++vcol % 8);
- } else {
- msg_outtrans_len(((char_u *)line_ga.ga_data) + line_ga.ga_len, len);
- vcol += char2cells(c1);
- }
- line_ga.ga_len += len;
- escaped = FALSE;
-
- cmd_cursor_goto(msg_row, msg_col);
- pend = (char_u *)(line_ga.ga_data) + line_ga.ga_len;
-
- /* We are done when a NL is entered, but not when it comes after an
- * odd number of backslashes, that results in a NUL. */
- if (!GA_EMPTY(&line_ga) && pend[-1] == '\n') {
- int bcount = 0;
-
- while (line_ga.ga_len - 2 >= bcount && pend[-2 - bcount] == '\\')
- ++bcount;
-
- if (bcount > 0) {
- /* Halve the number of backslashes: "\NL" -> "NUL", "\\NL" ->
- * "\NL", etc. */
- line_ga.ga_len -= (bcount + 1) / 2;
- pend -= (bcount + 1) / 2;
- pend[-1] = '\n';
- }
-
- if ((bcount & 1) == 0) {
- --line_ga.ga_len;
- --pend;
- *pend = NUL;
- break;
- }
- }
- }
-
- no_mapping--;
-
- /* make following messages go to the next line */
- msg_didout = FALSE;
- msg_col = 0;
- if (msg_row < Rows - 1) {
- msg_row++;
- }
- emsg_on_display = false; // don't want os_delay()
-
- if (got_int)
- ga_clear(&line_ga);
-
- return (char_u *)line_ga.ga_data;
-}
-
bool cmdline_overstrike(void)
{
return ccline.overstrike;
@@ -6469,7 +6209,7 @@ static int open_cmdwin(void)
char_u typestr[2];
int save_restart_edit = restart_edit;
int save_State = State;
- int save_exmode = exmode_active;
+ bool save_exmode = exmode_active;
int save_cmdmsg_rl = cmdmsg_rl;
/* Can't do this recursively. Can't do it when typing a password. */
@@ -6563,7 +6303,7 @@ static int open_cmdwin(void)
save_cmdline(&save_ccline);
// No Ex mode here!
- exmode_active = 0;
+ exmode_active = false;
State = NORMAL;
setmouse();
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c
index 538ebf7978..b0d06b7a30 100644
--- a/src/nvim/getchar.c
+++ b/src/nvim/getchar.c
@@ -2230,20 +2230,22 @@ static int vgetorpeek(bool advance)
timedout = true;
continue;
}
- /* When 'insertmode' is set, ESC just beeps in Insert
- * mode. Use CTRL-L to make edit() return.
- * For the command line only CTRL-C always breaks it.
- * For the cmdline window: Alternate between ESC and
- * CTRL-C: ESC for most situations and CTRL-C to close the
- * cmdline window. */
- if (p_im && (State & INSERT))
+ // When 'insertmode' is set, ESC just beeps in Insert
+ // mode. Use CTRL-L to make edit() return.
+ // In Ex-mode \n is compatible with original Vim behaviour.
+ // For the command line only CTRL-C always breaks it.
+ // For the cmdline window: Alternate between ESC and
+ // CTRL-C: ESC for most situations and CTRL-C to close the
+ // cmdline window.
+ if (p_im && (State & INSERT)) {
c = Ctrl_L;
- else if ((State & CMDLINE)
- || (cmdwin_type > 0 && tc == ESC)
- )
+ } else if (exmode_active) {
+ c = '\n';
+ } else if ((State & CMDLINE) || (cmdwin_type > 0 && tc == ESC)) {
c = Ctrl_C;
- else
+ } else {
c = ESC;
+ }
tc = c;
break;
}
diff --git a/src/nvim/globals.h b/src/nvim/globals.h
index 9fd5ccf324..bbc936cf16 100644
--- a/src/nvim/globals.h
+++ b/src/nvim/globals.h
@@ -239,7 +239,6 @@ EXTERN int did_wait_return INIT(= false); // wait_return() was used and
EXTERN int need_maketitle INIT(= true); // call maketitle() soon
EXTERN int quit_more INIT(= false); // 'q' hit at "--more--" msg
-EXTERN int ex_keep_indent INIT(= false); // getexmodeline(): keep indent
EXTERN int vgetc_busy INIT(= 0); // when inside vgetc() then > 0
EXTERN int didset_vim INIT(= false); // did set $VIM ourselves
@@ -621,7 +620,7 @@ EXTERN long opcount INIT(= 0); // count for pending operator
EXTERN int motion_force INIT(=0); // motion force for pending operator
// Ex Mode (Q) state
-EXTERN int exmode_active INIT(= 0); // Zero, EXMODE_NORMAL or EXMODE_VIM.
+EXTERN bool exmode_active INIT(= false); // true if Ex mode is active
EXTERN int ex_no_reprint INIT(=false); // No need to print after z or p.
EXTERN int reg_recording INIT(= 0); // register for recording or zero
diff --git a/src/nvim/highlight.c b/src/nvim/highlight.c
index 79e474fa2e..29ee7aae56 100644
--- a/src/nvim/highlight.c
+++ b/src/nvim/highlight.c
@@ -46,7 +46,7 @@ void highlight_init(void)
.id1 = 0, .id2 = 0 }));
}
-/// @return TRUE if hl table was reset
+/// @return true if hl table was reset
bool highlight_use_hlstate(void)
{
if (hlstate_active) {
diff --git a/src/nvim/indent.c b/src/nvim/indent.c
index 8fa61515ef..c1f9c1e172 100644
--- a/src/nvim/indent.c
+++ b/src/nvim/indent.c
@@ -62,10 +62,10 @@ int get_indent_buf(buf_T *buf, linenr_T lnum)
}
-// Count the size (in window cells) of the indent in line "ptr", with
-// 'tabstop' at "ts".
-// If @param list is TRUE, count only screen size for tabs.
-int get_indent_str(const char_u *ptr, int ts, int list)
+/// Count the size (in window cells) of the indent in line "ptr", with
+/// 'tabstop' at "ts".
+/// If @param list is true, count only screen size for tabs.
+int get_indent_str(const char_u *ptr, int ts, bool list)
FUNC_ATTR_NONNULL_ALL
{
int count = 0;
@@ -91,9 +91,9 @@ int get_indent_str(const char_u *ptr, int ts, int list)
return count;
}
-// Count the size (in window cells) of the indent in line "ptr", using
-// variable tabstops.
-// if "list" is true, count only screen size for tabs.
+/// Count the size (in window cells) of the indent in line "ptr", using
+/// variable tabstops.
+/// if "list" is true, count only screen size for tabs.
int get_indent_str_vtab(const char_u *ptr, long ts, long *vts, bool list)
{
int count = 0;
diff --git a/src/nvim/keymap.c b/src/nvim/keymap.c
index 6dacace0a4..277b9ade89 100644
--- a/src/nvim/keymap.c
+++ b/src/nvim/keymap.c
@@ -543,7 +543,7 @@ unsigned int trans_special(const char_u **srcp, const size_t src_len,
/// Put the character sequence for "key" with "modifiers" into "dst" and return
/// the resulting length.
-/// When "keycode" is TRUE prefer key code, e.g. K_DEL instead of DEL.
+/// When "keycode" is true prefer key code, e.g. K_DEL instead of DEL.
/// The sequence is not NUL terminated.
/// This is how characters in a string are encoded.
unsigned int special_to_buf(int key, int modifiers, bool keycode, char_u *dst)
diff --git a/src/nvim/main.c b/src/nvim/main.c
index cf9cb9cfbd..ed40da5866 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -318,7 +318,8 @@ int main(int argc, char **argv)
debug_break_level = params.use_debug_break_level;
// Read ex-commands if invoked with "-es".
- if (!params.input_isatty && silent_mode && exmode_active == EXMODE_NORMAL) {
+ if (!params.input_isatty && !params.input_neverscript
+ && silent_mode && exmode_active) {
input_start(STDIN_FILENO);
}
@@ -366,19 +367,16 @@ int main(int argc, char **argv)
// Execute --cmd arguments.
exe_pre_commands(&params);
- // If using the runtime (-u is not NONE), enable syntax & filetype plugins.
- bool enable_syntax =
- (params.use_vimrc == NULL || !strequal(params.use_vimrc, "NONE"));
-
- // Source syncolor.vim to set up default UI highlights
- if (enable_syntax) {
- source_runtime((char_u *)"syntax/syncolor.vim", DIP_ALL);
- }
-
// Source startup scripts.
source_startup_scripts(&params);
- if (enable_syntax) {
+ // If using the runtime (-u is not NONE), enable syntax & filetype plugins.
+ if (params.use_vimrc == NULL || !strequal(params.use_vimrc, "NONE")) {
+ // Source syncolor.vim to set up default UI highlights if the user didn't
+ // already enable a colorscheme
+ if (!get_var_value("g:colors_name")) {
+ source_runtime((char_u *)"syntax/syncolor.vim", DIP_ALL);
+ }
// Does ":filetype plugin indent on".
filetype_maybe_enable();
// Sources syntax/syntax.vim, which calls `:filetype on`.
@@ -772,7 +770,7 @@ static bool edit_stdin(bool explicit, mparm_T *parmp)
{
bool implicit = !headless_mode
&& !embedded_mode
- && exmode_active != EXMODE_NORMAL // -E/-Es but not -e/-es.
+ && (!exmode_active || parmp->input_neverscript)
&& !parmp->input_isatty
&& scriptin[0] == NULL; // `-s -` was not given.
return explicit || implicit;
@@ -915,11 +913,12 @@ static void command_line_scan(mparm_T *parmp)
break;
}
case 'e': { // "-e" Ex mode
- exmode_active = EXMODE_NORMAL;
+ exmode_active = true;
break;
}
case 'E': { // "-E" Ex mode
- exmode_active = EXMODE_VIM;
+ exmode_active = true;
+ parmp->input_neverscript = true;
break;
}
case 'f': { // "-f" GUI: run in foreground.
diff --git a/src/nvim/main.h b/src/nvim/main.h
index 61252f2bce..d387e6d668 100644
--- a/src/nvim/main.h
+++ b/src/nvim/main.h
@@ -30,6 +30,7 @@ typedef struct {
bool input_isatty; // stdin is a terminal
bool output_isatty; // stdout is a terminal
bool err_isatty; // stderr is a terminal
+ bool input_neverscript; // never treat stdin as script (-E/-Es)
int no_swap_file; // "-n" argument used
int use_debug_break_level;
int window_count; // number of windows to use
diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c
index 73e3ba53a5..9cd57affb9 100644
--- a/src/nvim/mbyte.c
+++ b/src/nvim/mbyte.c
@@ -2354,10 +2354,8 @@ int convert_setup(vimconv_T *vcp, char_u *from, char_u *to)
return convert_setup_ext(vcp, from, true, to, true);
}
-/*
- * As convert_setup(), but only when from_unicode_is_utf8 is TRUE will all
- * "from" unicode charsets be considered utf-8. Same for "to".
- */
+/// As convert_setup(), but only when from_unicode_is_utf8 is true will all
+/// "from" unicode charsets be considered utf-8. Same for "to".
int convert_setup_ext(vimconv_T *vcp, char_u *from, bool from_unicode_is_utf8,
char_u *to, bool to_unicode_is_utf8)
{
diff --git a/src/nvim/memfile_defs.h b/src/nvim/memfile_defs.h
index 2402d2147d..3eaa7d83e0 100644
--- a/src/nvim/memfile_defs.h
+++ b/src/nvim/memfile_defs.h
@@ -101,7 +101,7 @@ typedef struct memfile {
blocknr_T mf_neg_count; /// number of negative blocks numbers
blocknr_T mf_infile_count; /// number of pages in the file
unsigned mf_page_size; /// number of bytes in a page
- bool mf_dirty; /// TRUE if there are dirty blocks
+ bool mf_dirty; /// true if there are dirty blocks
} memfile_T;
#endif // NVIM_MEMFILE_DEFS_H
diff --git a/src/nvim/message.c b/src/nvim/message.c
index ec5dabbbc0..3ab4ad5287 100644
--- a/src/nvim/message.c
+++ b/src/nvim/message.c
@@ -1324,9 +1324,8 @@ void msg_start(void)
0;
} else if (msg_didout) { // start message on next line
msg_putchar('\n');
- did_return = TRUE;
- if (exmode_active != EXMODE_NORMAL)
- cmdline_row = msg_row;
+ did_return = true;
+ cmdline_row = msg_row;
}
if (!msg_didany || lines_left < 0)
msg_starthere();
diff --git a/src/nvim/misc1.c b/src/nvim/misc1.c
index 38d0a7dadf..19239036fd 100644
--- a/src/nvim/misc1.c
+++ b/src/nvim/misc1.c
@@ -750,8 +750,8 @@ get_number (
stuffcharReadbuff(':');
if (!exmode_active)
cmdline_row = msg_row;
- skip_redraw = TRUE; /* skip redraw once */
- do_redraw = FALSE;
+ skip_redraw = true; // skip redraw once
+ do_redraw = false;
break;
} else if (c == Ctrl_C || c == ESC || c == 'q') {
n = 0;
diff --git a/src/nvim/mouse.c b/src/nvim/mouse.c
index 4c0339e5f4..f1ad0ed105 100644
--- a/src/nvim/mouse.c
+++ b/src/nvim/mouse.c
@@ -570,9 +570,8 @@ static linenr_T find_longest_lnum(void)
return ret;
}
-///
-/// Do a horizontal scroll. Return TRUE if the cursor moved, FALSE otherwise.
-///
+/// Do a horizontal scroll.
+/// @return true if the cursor moved, false otherwise.
bool mouse_scroll_horiz(int dir)
{
if (curwin->w_p_wrap) {
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
index 74a3d74860..4213e6f946 100644
--- a/src/nvim/normal.c
+++ b/src/nvim/normal.c
@@ -1188,7 +1188,7 @@ static void normal_check_interrupt(NormalState *s)
&& s->previous_got_int) {
// Typed two CTRL-C in a row: go back to ex mode as if "Q" was
// used and keep "got_int" set, so that it aborts ":g".
- exmode_active = EXMODE_NORMAL;
+ exmode_active = true;
State = NORMAL;
} else if (!global_busy || !exmode_active) {
if (!quit_more) {
@@ -1340,7 +1340,7 @@ static int normal_check(VimState *state)
quit_more = false;
// If skip redraw is set (for ":" in wait_return()), don't redraw now.
- // If there is nothing in the stuff_buffer or do_redraw is TRUE,
+ // If there is nothing in the stuff_buffer or do_redraw is true,
// update cursor and redraw.
if (skip_redraw || exmode_active) {
skip_redraw = false;
@@ -1398,7 +1398,7 @@ static int normal_check(VimState *state)
if (s->noexmode) {
return 0;
}
- do_exmode(exmode_active == EXMODE_VIM);
+ do_exmode();
return -1;
}
@@ -4652,7 +4652,7 @@ static void nv_exmode(cmdarg_T *cap)
if (VIsual_active) {
vim_beep(BO_EX);
} else if (!checkclearop(cap->oap)) {
- do_exmode(false);
+ do_exmode();
}
}
@@ -7101,8 +7101,9 @@ static void nv_g_cmd(cmdarg_T *cap)
break;
}
- if (!checkclearopq(oap))
- do_exmode(true);
+ if (!checkclearopq(oap)) {
+ do_exmode();
+ }
break;
case ',':
@@ -8146,10 +8147,8 @@ static void nv_event(cmdarg_T *cap)
}
}
-/*
- * Return TRUE when 'mousemodel' is set to "popup" or "popup_setpos".
- */
-static int mouse_model_popup(void)
+/// @return true when 'mousemodel' is set to "popup" or "popup_setpos".
+static bool mouse_model_popup(void)
{
return p_mousem[0] == 'p';
}
diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h
index 0a556390e7..5e40bdd6ef 100644
--- a/src/nvim/option_defs.h
+++ b/src/nvim/option_defs.h
@@ -459,7 +459,6 @@ EXTERN char_u *p_pmcs; // 'printmbcharset'
EXTERN char_u *p_pfn; // 'printfont'
EXTERN char_u *p_popt; // 'printoptions'
EXTERN char_u *p_header; // 'printheader'
-EXTERN int p_prompt; // 'prompt'
EXTERN char_u *p_guicursor; // 'guicursor'
EXTERN char_u *p_guifont; // 'guifont'
EXTERN char_u *p_guifontwide; // 'guifontwide'
diff --git a/src/nvim/options.lua b/src/nvim/options.lua
index 48e53c68f3..0830fb4638 100644
--- a/src/nvim/options.lua
+++ b/src/nvim/options.lua
@@ -1800,7 +1800,7 @@ return {
full_name='prompt',
short_desc=N_("enable prompt in Ex mode"),
type='bool', scope={'global'},
- varname='p_prompt',
+ varname='p_force_on',
defaults={if_true={vi=true}}
},
{
diff --git a/src/nvim/search.h b/src/nvim/search.h
index 98ddaa5eeb..0dbaf79c37 100644
--- a/src/nvim/search.h
+++ b/src/nvim/search.h
@@ -88,7 +88,7 @@ typedef struct searchstat
{
int cur; // current position of found words
int cnt; // total count of found words
- int exact_match; // TRUE if matched exactly on specified position
+ bool exact_match; // true if matched exactly on specified position
int incomplete; // 0: search was fully completed
// 1: recomputing was timed out
// 2: max count exceeded
diff --git a/src/nvim/sign.c b/src/nvim/sign.c
index d884ae62f4..c6f59b42b8 100644
--- a/src/nvim/sign.c
+++ b/src/nvim/sign.c
@@ -115,10 +115,10 @@ static void sign_group_unref(char_u *groupname)
}
}
-/// Returns TRUE if 'sign' is in 'group'.
+/// @return true if 'sign' is in 'group'.
/// A sign can either be in the global group (sign->group == NULL)
/// or in a named group. If 'group' is '*', then the sign is part of the group.
-int sign_in_group(sign_entry_T *sign, const char_u *group)
+bool sign_in_group(sign_entry_T *sign, const char_u *group)
{
return ((group != NULL && STRCMP(group, "*") == 0)
|| (group == NULL && sign->se_group == NULL)
diff --git a/src/nvim/state.c b/src/nvim/state.c
index a3c74789d1..437cb0db47 100644
--- a/src/nvim/state.c
+++ b/src/nvim/state.c
@@ -171,12 +171,10 @@ char *get_mode(void)
buf[1] = 'x';
}
}
- } else if ((State & CMDLINE) || exmode_active) {
+ } else if (State & CMDLINE) {
buf[0] = 'c';
- if (exmode_active == EXMODE_VIM) {
+ if (exmode_active) {
buf[1] = 'v';
- } else if (exmode_active == EXMODE_NORMAL) {
- buf[1] = 'e';
}
} else if (State & TERM_FOCUS) {
buf[0] = 't';
diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c
index 70d39339c3..dcc086a0cf 100644
--- a/src/nvim/tui/tui.c
+++ b/src/nvim/tui/tui.c
@@ -1123,10 +1123,9 @@ static void tui_mode_change(UI *ui, String mode, Integer mode_idx)
data->showing_mode = (ModeShape)mode_idx;
}
-static void tui_grid_scroll(UI *ui, Integer g, Integer startrow, Integer endrow,
- Integer startcol, Integer endcol,
- Integer rows,
- Integer cols FUNC_ATTR_UNUSED) // -V751
+static void tui_grid_scroll(UI *ui, Integer g, Integer startrow, // -V751
+ Integer endrow, Integer startcol, Integer endcol,
+ Integer rows, Integer cols FUNC_ATTR_UNUSED)
{
TUIData *data = ui->data;
UGrid *grid = &data->grid;