aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-04-27 09:03:09 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-04-29 15:51:04 +0800
commitf6afc7c3246db6e5bd8feab717b3c0dbf0226803 (patch)
tree533dc9a6727f66e9a64fd4a129ea87c0c7e0cc5b
parentd531ef6813919dd6df8ca6927cd99ec3c0a65635 (diff)
downloadrneovim-f6afc7c3246db6e5bd8feab717b3c0dbf0226803.tar.gz
rneovim-f6afc7c3246db6e5bd8feab717b3c0dbf0226803.tar.bz2
rneovim-f6afc7c3246db6e5bd8feab717b3c0dbf0226803.zip
revert: "refactor: Remove allow_keys global (#6346)"
-rw-r--r--src/nvim/digraph.c4
-rw-r--r--src/nvim/edit.c6
-rw-r--r--src/nvim/eval/funcs.c2
-rw-r--r--src/nvim/ex_cmds.c2
-rw-r--r--src/nvim/ex_getln.c2
-rw-r--r--src/nvim/getchar.c5
-rw-r--r--src/nvim/globals.h1
-rw-r--r--src/nvim/input.c4
-rw-r--r--src/nvim/message.c2
-rw-r--r--src/nvim/normal.c12
-rw-r--r--src/nvim/window.c2
11 files changed, 42 insertions, 0 deletions
diff --git a/src/nvim/digraph.c b/src/nvim/digraph.c
index 0e148543aa..2a6ccce79e 100644
--- a/src/nvim/digraph.c
+++ b/src/nvim/digraph.c
@@ -1513,8 +1513,10 @@ char_u *get_digraph_for_char(int val_arg)
int get_digraph(bool cmdline)
{
no_mapping++;
+ allow_keys++;
int c = plain_vgetc();
no_mapping--;
+ allow_keys--;
if (c != ESC) {
// ESC cancels CTRL-K
@@ -1531,8 +1533,10 @@ int get_digraph(bool cmdline)
add_to_showcmd(c);
}
no_mapping++;
+ allow_keys++;
int cc = plain_vgetc();
no_mapping--;
+ allow_keys--;
if (cc != ESC) {
// ESC cancels CTRL-K
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index 3e3648e61f..b8f88895a4 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -762,8 +762,10 @@ static int insert_execute(VimState *state, int key)
// may need to redraw when no more chars available now
ins_redraw(false);
no_mapping++;
+ allow_keys++;
s->c = plain_vgetc();
no_mapping--;
+ allow_keys--;
if (s->c != Ctrl_N && s->c != Ctrl_G && s->c != Ctrl_O) {
// it's something else
vungetc(s->c);
@@ -9237,8 +9239,10 @@ static int ins_digraph(void)
// don't map the digraph chars. This also prevents the
// mode message to be deleted when ESC is hit
no_mapping++;
+ allow_keys++;
c = plain_vgetc();
no_mapping--;
+ allow_keys--;
if (did_putchar) {
// when the line fits in 'columns' the '?' is at the start of the next
// line and will not be removed by the redraw
@@ -9264,8 +9268,10 @@ static int ins_digraph(void)
add_to_showcmd_c(c);
}
no_mapping++;
+ allow_keys++;
cc = plain_vgetc();
no_mapping--;
+ allow_keys--;
if (did_putchar) {
// when the line fits in 'columns' the '?' is at the start of the
// next line and will not be removed by a redraw
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c
index 00d725d393..dfdabd511e 100644
--- a/src/nvim/eval/funcs.c
+++ b/src/nvim/eval/funcs.c
@@ -2975,6 +2975,7 @@ static void getchar_common(typval_T *argvars, typval_T *rettv)
bool error = false;
no_mapping++;
+ allow_keys++;
for (;;) {
// Position the cursor. Needed after a message that ends in a space,
// or if event processing caused a redraw.
@@ -3012,6 +3013,7 @@ static void getchar_common(typval_T *argvars, typval_T *rettv)
break;
}
no_mapping--;
+ allow_keys--;
set_vim_var_nr(VV_MOUSE_WIN, 0);
set_vim_var_nr(VV_MOUSE_WINID, 0);
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index 7564b9326b..f059175c88 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -3951,8 +3951,10 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout, bool do_buf_event, handle
RedrawingDisabled = temp;
no_mapping++; // don't map this key
+ allow_keys++; // allow special keys
typed = plain_vgetc();
no_mapping--;
+ allow_keys--;
// clear the question
msg_didout = false; // don't scroll up
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index ea5bfc9a36..f9ce156eb2 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -1335,8 +1335,10 @@ static int command_line_execute(VimState *state, int key)
// mode when 'insertmode' is set, CTRL-\ e prompts for an expression.
if (s->c == Ctrl_BSL) {
no_mapping++;
+ allow_keys++;
s->c = plain_vgetc();
no_mapping--;
+ allow_keys--;
// CTRL-\ e doesn't work when obtaining an expression, unless it
// is in a mapping.
if (s->c != Ctrl_N
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c
index 9a89170a10..63e26fd0a4 100644
--- a/src/nvim/getchar.c
+++ b/src/nvim/getchar.c
@@ -1511,19 +1511,24 @@ int vgetc(void)
bool did_inc = false;
if (mod_mask) { // no mapping after modifier has been read
no_mapping++;
+ allow_keys++;
did_inc = true; // mod_mask may change value
}
c = vgetorpeek(true);
if (did_inc) {
no_mapping--;
+ allow_keys--;
}
// Get two extra bytes for special keys
if (c == K_SPECIAL) {
+ int save_allow_keys = allow_keys;
no_mapping++;
+ allow_keys = 0; // make sure BS is not found
c2 = vgetorpeek(true); // no mapping for these chars
c = vgetorpeek(true);
no_mapping--;
+ allow_keys = save_allow_keys;
if (c2 == KS_MODIFIER) {
mod_mask = c;
continue;
diff --git a/src/nvim/globals.h b/src/nvim/globals.h
index 6e0b445656..5983f18bb5 100644
--- a/src/nvim/globals.h
+++ b/src/nvim/globals.h
@@ -652,6 +652,7 @@ EXTERN int reg_recorded INIT(= 0); // last recorded register or zero
EXTERN int no_mapping INIT(= false); // currently no mapping allowed
EXTERN int no_zero_mapping INIT(= 0); // mapping zero not allowed
+EXTERN int allow_keys INIT(= false); // allow key codes when no_mapping is set
EXTERN int no_u_sync INIT(= 0); // Don't call u_sync()
EXTERN int u_sync_once INIT(= 0); // Call u_sync() once when evaluating
// an expression.
diff --git a/src/nvim/input.c b/src/nvim/input.c
index ff6b559710..6827dcae87 100644
--- a/src/nvim/input.c
+++ b/src/nvim/input.c
@@ -42,6 +42,7 @@ int ask_yesno(const char *const str, const bool direct)
State = CONFIRM; // Mouse behaves like with :confirm.
setmouse(); // Disable mouse in xterm.
no_mapping++;
+ allow_keys++; // no mapping here, but recognize keys
int r = ' ';
while (r != 'y' && r != 'n') {
@@ -62,6 +63,7 @@ int ask_yesno(const char *const str, const bool direct)
State = save_State;
setmouse();
no_mapping--;
+ allow_keys--;
return r;
}
@@ -172,6 +174,7 @@ int get_number(int colon, int *mouse_used)
}
no_mapping++;
+ allow_keys++; // no mapping here, but recognize keys
for (;;) {
ui_cursor_goto(msg_row, msg_col);
c = safe_vgetc();
@@ -205,6 +208,7 @@ int get_number(int colon, int *mouse_used)
}
}
no_mapping--;
+ allow_keys--;
return n;
}
diff --git a/src/nvim/message.c b/src/nvim/message.c
index 90af920396..3660dc20af 100644
--- a/src/nvim/message.c
+++ b/src/nvim/message.c
@@ -1146,6 +1146,7 @@ void wait_return(int redraw)
// Don't do mappings here, we put the character back in the
// typeahead buffer.
no_mapping++;
+ allow_keys++;
// Temporarily disable Recording. If Recording is active, the
// character will be recorded later, since it will be added to the
@@ -1159,6 +1160,7 @@ void wait_return(int redraw)
got_int = false;
}
no_mapping--;
+ allow_keys--;
reg_recording = save_reg_recording;
scriptout = save_scriptout;
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
index a04316f5e4..c5d7e603cd 100644
--- a/src/nvim/normal.c
+++ b/src/nvim/normal.c
@@ -638,6 +638,7 @@ static void normal_get_additional_char(NormalState *s)
int lang; // getting a text character
no_mapping++;
+ allow_keys++; // no mapping for nchar, but allow key codes
// Don't generate a CursorHold event here, most commands can't handle
// it, e.g., nv_replace(), nv_csearch().
did_cursorhold = true;
@@ -676,6 +677,7 @@ static void normal_get_additional_char(NormalState *s)
if (lang && curbuf->b_p_iminsert == B_IMODE_LMAP) {
// Allow mappings defined with ":lmap".
no_mapping--;
+ allow_keys--;
if (repl) {
State = LREPLACE;
} else {
@@ -689,6 +691,7 @@ static void normal_get_additional_char(NormalState *s)
if (langmap_active) {
// Undo the decrement done above
no_mapping++;
+ allow_keys++;
}
State = NORMAL_BUSY;
s->need_flushbuf |= add_to_showcmd(*cp);
@@ -769,6 +772,7 @@ static void normal_get_additional_char(NormalState *s)
no_mapping++;
}
no_mapping--;
+ allow_keys--;
}
static void normal_invert_horizontal(NormalState *s)
@@ -826,6 +830,7 @@ static bool normal_get_command_count(NormalState *s)
if (s->ctrl_w) {
no_mapping++;
+ allow_keys++; // no mapping for nchar, but keys
}
no_zero_mapping++; // don't map zero here
@@ -834,6 +839,7 @@ static bool normal_get_command_count(NormalState *s)
no_zero_mapping--;
if (s->ctrl_w) {
no_mapping--;
+ allow_keys--;
}
s->need_flushbuf |= add_to_showcmd(s->c);
}
@@ -844,9 +850,11 @@ static bool normal_get_command_count(NormalState *s)
s->ca.opcount = s->ca.count0; // remember first count
s->ca.count0 = 0;
no_mapping++;
+ allow_keys++; // no mapping for nchar, but keys
s->c = plain_vgetc(); // get next character
LANGMAP_ADJUST(s->c, true);
no_mapping--;
+ allow_keys--;
s->need_flushbuf |= add_to_showcmd(s->c);
return true;
}
@@ -3407,9 +3415,11 @@ static void nv_zet(cmdarg_T *cap)
n = nchar - '0';
for (;;) {
no_mapping++;
+ allow_keys++; // no mapping for nchar, but allow key codes
nchar = plain_vgetc();
LANGMAP_ADJUST(nchar, true);
no_mapping--;
+ allow_keys--;
(void)add_to_showcmd(nchar);
if (nchar == K_DEL || nchar == K_KDEL) {
n /= 10;
@@ -3785,9 +3795,11 @@ dozet:
case 'u': // "zug" and "zuw": undo "zg" and "zw"
no_mapping++;
+ allow_keys++; // no mapping for nchar, but allow key codes
nchar = plain_vgetc();
LANGMAP_ADJUST(nchar, true);
no_mapping--;
+ allow_keys--;
(void)add_to_showcmd(nchar);
if (vim_strchr((char_u *)"gGwW", nchar) == NULL) {
clearopbeep(cap->oap);
diff --git a/src/nvim/window.c b/src/nvim/window.c
index f68cfe4c9c..50921c8302 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -534,11 +534,13 @@ wingotofile:
case Ctrl_G:
CHECK_CMDWIN;
no_mapping++;
+ allow_keys++; // no mapping for xchar, but allow key codes
if (xchar == NUL) {
xchar = plain_vgetc();
}
LANGMAP_ADJUST(xchar, true);
no_mapping--;
+ allow_keys--;
(void)add_to_showcmd(xchar);
switch (xchar) {
case '}':