mirror of
https://github.com/neovim/neovim.git
synced 2025-09-26 21:18:34 +00:00
revert: "refactor: Remove allow_keys global (#6346)"
This commit is contained in:
@@ -1513,8 +1513,10 @@ char_u *get_digraph_for_char(int val_arg)
|
|||||||
int get_digraph(bool cmdline)
|
int get_digraph(bool cmdline)
|
||||||
{
|
{
|
||||||
no_mapping++;
|
no_mapping++;
|
||||||
|
allow_keys++;
|
||||||
int c = plain_vgetc();
|
int c = plain_vgetc();
|
||||||
no_mapping--;
|
no_mapping--;
|
||||||
|
allow_keys--;
|
||||||
|
|
||||||
if (c != ESC) {
|
if (c != ESC) {
|
||||||
// ESC cancels CTRL-K
|
// ESC cancels CTRL-K
|
||||||
@@ -1531,8 +1533,10 @@ int get_digraph(bool cmdline)
|
|||||||
add_to_showcmd(c);
|
add_to_showcmd(c);
|
||||||
}
|
}
|
||||||
no_mapping++;
|
no_mapping++;
|
||||||
|
allow_keys++;
|
||||||
int cc = plain_vgetc();
|
int cc = plain_vgetc();
|
||||||
no_mapping--;
|
no_mapping--;
|
||||||
|
allow_keys--;
|
||||||
|
|
||||||
if (cc != ESC) {
|
if (cc != ESC) {
|
||||||
// ESC cancels CTRL-K
|
// ESC cancels CTRL-K
|
||||||
|
@@ -762,8 +762,10 @@ static int insert_execute(VimState *state, int key)
|
|||||||
// may need to redraw when no more chars available now
|
// may need to redraw when no more chars available now
|
||||||
ins_redraw(false);
|
ins_redraw(false);
|
||||||
no_mapping++;
|
no_mapping++;
|
||||||
|
allow_keys++;
|
||||||
s->c = plain_vgetc();
|
s->c = plain_vgetc();
|
||||||
no_mapping--;
|
no_mapping--;
|
||||||
|
allow_keys--;
|
||||||
if (s->c != Ctrl_N && s->c != Ctrl_G && s->c != Ctrl_O) {
|
if (s->c != Ctrl_N && s->c != Ctrl_G && s->c != Ctrl_O) {
|
||||||
// it's something else
|
// it's something else
|
||||||
vungetc(s->c);
|
vungetc(s->c);
|
||||||
@@ -9237,8 +9239,10 @@ static int ins_digraph(void)
|
|||||||
// don't map the digraph chars. This also prevents the
|
// don't map the digraph chars. This also prevents the
|
||||||
// mode message to be deleted when ESC is hit
|
// mode message to be deleted when ESC is hit
|
||||||
no_mapping++;
|
no_mapping++;
|
||||||
|
allow_keys++;
|
||||||
c = plain_vgetc();
|
c = plain_vgetc();
|
||||||
no_mapping--;
|
no_mapping--;
|
||||||
|
allow_keys--;
|
||||||
if (did_putchar) {
|
if (did_putchar) {
|
||||||
// when the line fits in 'columns' the '?' is at the start of the next
|
// when the line fits in 'columns' the '?' is at the start of the next
|
||||||
// line and will not be removed by the redraw
|
// line and will not be removed by the redraw
|
||||||
@@ -9264,8 +9268,10 @@ static int ins_digraph(void)
|
|||||||
add_to_showcmd_c(c);
|
add_to_showcmd_c(c);
|
||||||
}
|
}
|
||||||
no_mapping++;
|
no_mapping++;
|
||||||
|
allow_keys++;
|
||||||
cc = plain_vgetc();
|
cc = plain_vgetc();
|
||||||
no_mapping--;
|
no_mapping--;
|
||||||
|
allow_keys--;
|
||||||
if (did_putchar) {
|
if (did_putchar) {
|
||||||
// when the line fits in 'columns' the '?' is at the start of the
|
// when the line fits in 'columns' the '?' is at the start of the
|
||||||
// next line and will not be removed by a redraw
|
// next line and will not be removed by a redraw
|
||||||
|
@@ -2975,6 +2975,7 @@ static void getchar_common(typval_T *argvars, typval_T *rettv)
|
|||||||
bool error = false;
|
bool error = false;
|
||||||
|
|
||||||
no_mapping++;
|
no_mapping++;
|
||||||
|
allow_keys++;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
// Position the cursor. Needed after a message that ends in a space,
|
// Position the cursor. Needed after a message that ends in a space,
|
||||||
// or if event processing caused a redraw.
|
// or if event processing caused a redraw.
|
||||||
@@ -3012,6 +3013,7 @@ static void getchar_common(typval_T *argvars, typval_T *rettv)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
no_mapping--;
|
no_mapping--;
|
||||||
|
allow_keys--;
|
||||||
|
|
||||||
set_vim_var_nr(VV_MOUSE_WIN, 0);
|
set_vim_var_nr(VV_MOUSE_WIN, 0);
|
||||||
set_vim_var_nr(VV_MOUSE_WINID, 0);
|
set_vim_var_nr(VV_MOUSE_WINID, 0);
|
||||||
|
@@ -3951,8 +3951,10 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout, bool do_buf_event, handle
|
|||||||
RedrawingDisabled = temp;
|
RedrawingDisabled = temp;
|
||||||
|
|
||||||
no_mapping++; // don't map this key
|
no_mapping++; // don't map this key
|
||||||
|
allow_keys++; // allow special keys
|
||||||
typed = plain_vgetc();
|
typed = plain_vgetc();
|
||||||
no_mapping--;
|
no_mapping--;
|
||||||
|
allow_keys--;
|
||||||
|
|
||||||
// clear the question
|
// clear the question
|
||||||
msg_didout = false; // don't scroll up
|
msg_didout = false; // don't scroll up
|
||||||
|
@@ -1335,8 +1335,10 @@ static int command_line_execute(VimState *state, int key)
|
|||||||
// mode when 'insertmode' is set, CTRL-\ e prompts for an expression.
|
// mode when 'insertmode' is set, CTRL-\ e prompts for an expression.
|
||||||
if (s->c == Ctrl_BSL) {
|
if (s->c == Ctrl_BSL) {
|
||||||
no_mapping++;
|
no_mapping++;
|
||||||
|
allow_keys++;
|
||||||
s->c = plain_vgetc();
|
s->c = plain_vgetc();
|
||||||
no_mapping--;
|
no_mapping--;
|
||||||
|
allow_keys--;
|
||||||
// CTRL-\ e doesn't work when obtaining an expression, unless it
|
// CTRL-\ e doesn't work when obtaining an expression, unless it
|
||||||
// is in a mapping.
|
// is in a mapping.
|
||||||
if (s->c != Ctrl_N
|
if (s->c != Ctrl_N
|
||||||
|
@@ -1511,19 +1511,24 @@ int vgetc(void)
|
|||||||
bool did_inc = false;
|
bool did_inc = false;
|
||||||
if (mod_mask) { // no mapping after modifier has been read
|
if (mod_mask) { // no mapping after modifier has been read
|
||||||
no_mapping++;
|
no_mapping++;
|
||||||
|
allow_keys++;
|
||||||
did_inc = true; // mod_mask may change value
|
did_inc = true; // mod_mask may change value
|
||||||
}
|
}
|
||||||
c = vgetorpeek(true);
|
c = vgetorpeek(true);
|
||||||
if (did_inc) {
|
if (did_inc) {
|
||||||
no_mapping--;
|
no_mapping--;
|
||||||
|
allow_keys--;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get two extra bytes for special keys
|
// Get two extra bytes for special keys
|
||||||
if (c == K_SPECIAL) {
|
if (c == K_SPECIAL) {
|
||||||
|
int save_allow_keys = allow_keys;
|
||||||
no_mapping++;
|
no_mapping++;
|
||||||
|
allow_keys = 0; // make sure BS is not found
|
||||||
c2 = vgetorpeek(true); // no mapping for these chars
|
c2 = vgetorpeek(true); // no mapping for these chars
|
||||||
c = vgetorpeek(true);
|
c = vgetorpeek(true);
|
||||||
no_mapping--;
|
no_mapping--;
|
||||||
|
allow_keys = save_allow_keys;
|
||||||
if (c2 == KS_MODIFIER) {
|
if (c2 == KS_MODIFIER) {
|
||||||
mod_mask = c;
|
mod_mask = c;
|
||||||
continue;
|
continue;
|
||||||
|
@@ -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_mapping INIT(= false); // currently no mapping allowed
|
||||||
EXTERN int no_zero_mapping INIT(= 0); // mapping zero not 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 no_u_sync INIT(= 0); // Don't call u_sync()
|
||||||
EXTERN int u_sync_once INIT(= 0); // Call u_sync() once when evaluating
|
EXTERN int u_sync_once INIT(= 0); // Call u_sync() once when evaluating
|
||||||
// an expression.
|
// an expression.
|
||||||
|
@@ -42,6 +42,7 @@ int ask_yesno(const char *const str, const bool direct)
|
|||||||
State = CONFIRM; // Mouse behaves like with :confirm.
|
State = CONFIRM; // Mouse behaves like with :confirm.
|
||||||
setmouse(); // Disable mouse in xterm.
|
setmouse(); // Disable mouse in xterm.
|
||||||
no_mapping++;
|
no_mapping++;
|
||||||
|
allow_keys++; // no mapping here, but recognize keys
|
||||||
|
|
||||||
int r = ' ';
|
int r = ' ';
|
||||||
while (r != 'y' && r != 'n') {
|
while (r != 'y' && r != 'n') {
|
||||||
@@ -62,6 +63,7 @@ int ask_yesno(const char *const str, const bool direct)
|
|||||||
State = save_State;
|
State = save_State;
|
||||||
setmouse();
|
setmouse();
|
||||||
no_mapping--;
|
no_mapping--;
|
||||||
|
allow_keys--;
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
@@ -172,6 +174,7 @@ int get_number(int colon, int *mouse_used)
|
|||||||
}
|
}
|
||||||
|
|
||||||
no_mapping++;
|
no_mapping++;
|
||||||
|
allow_keys++; // no mapping here, but recognize keys
|
||||||
for (;;) {
|
for (;;) {
|
||||||
ui_cursor_goto(msg_row, msg_col);
|
ui_cursor_goto(msg_row, msg_col);
|
||||||
c = safe_vgetc();
|
c = safe_vgetc();
|
||||||
@@ -205,6 +208,7 @@ int get_number(int colon, int *mouse_used)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
no_mapping--;
|
no_mapping--;
|
||||||
|
allow_keys--;
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1146,6 +1146,7 @@ void wait_return(int redraw)
|
|||||||
// Don't do mappings here, we put the character back in the
|
// Don't do mappings here, we put the character back in the
|
||||||
// typeahead buffer.
|
// typeahead buffer.
|
||||||
no_mapping++;
|
no_mapping++;
|
||||||
|
allow_keys++;
|
||||||
|
|
||||||
// Temporarily disable Recording. If Recording is active, the
|
// Temporarily disable Recording. If Recording is active, the
|
||||||
// character will be recorded later, since it will be added to 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;
|
got_int = false;
|
||||||
}
|
}
|
||||||
no_mapping--;
|
no_mapping--;
|
||||||
|
allow_keys--;
|
||||||
reg_recording = save_reg_recording;
|
reg_recording = save_reg_recording;
|
||||||
scriptout = save_scriptout;
|
scriptout = save_scriptout;
|
||||||
|
|
||||||
|
@@ -638,6 +638,7 @@ static void normal_get_additional_char(NormalState *s)
|
|||||||
int lang; // getting a text character
|
int lang; // getting a text character
|
||||||
|
|
||||||
no_mapping++;
|
no_mapping++;
|
||||||
|
allow_keys++; // no mapping for nchar, but allow key codes
|
||||||
// Don't generate a CursorHold event here, most commands can't handle
|
// Don't generate a CursorHold event here, most commands can't handle
|
||||||
// it, e.g., nv_replace(), nv_csearch().
|
// it, e.g., nv_replace(), nv_csearch().
|
||||||
did_cursorhold = true;
|
did_cursorhold = true;
|
||||||
@@ -676,6 +677,7 @@ static void normal_get_additional_char(NormalState *s)
|
|||||||
if (lang && curbuf->b_p_iminsert == B_IMODE_LMAP) {
|
if (lang && curbuf->b_p_iminsert == B_IMODE_LMAP) {
|
||||||
// Allow mappings defined with ":lmap".
|
// Allow mappings defined with ":lmap".
|
||||||
no_mapping--;
|
no_mapping--;
|
||||||
|
allow_keys--;
|
||||||
if (repl) {
|
if (repl) {
|
||||||
State = LREPLACE;
|
State = LREPLACE;
|
||||||
} else {
|
} else {
|
||||||
@@ -689,6 +691,7 @@ static void normal_get_additional_char(NormalState *s)
|
|||||||
if (langmap_active) {
|
if (langmap_active) {
|
||||||
// Undo the decrement done above
|
// Undo the decrement done above
|
||||||
no_mapping++;
|
no_mapping++;
|
||||||
|
allow_keys++;
|
||||||
}
|
}
|
||||||
State = NORMAL_BUSY;
|
State = NORMAL_BUSY;
|
||||||
s->need_flushbuf |= add_to_showcmd(*cp);
|
s->need_flushbuf |= add_to_showcmd(*cp);
|
||||||
@@ -769,6 +772,7 @@ static void normal_get_additional_char(NormalState *s)
|
|||||||
no_mapping++;
|
no_mapping++;
|
||||||
}
|
}
|
||||||
no_mapping--;
|
no_mapping--;
|
||||||
|
allow_keys--;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void normal_invert_horizontal(NormalState *s)
|
static void normal_invert_horizontal(NormalState *s)
|
||||||
@@ -826,6 +830,7 @@ static bool normal_get_command_count(NormalState *s)
|
|||||||
|
|
||||||
if (s->ctrl_w) {
|
if (s->ctrl_w) {
|
||||||
no_mapping++;
|
no_mapping++;
|
||||||
|
allow_keys++; // no mapping for nchar, but keys
|
||||||
}
|
}
|
||||||
|
|
||||||
no_zero_mapping++; // don't map zero here
|
no_zero_mapping++; // don't map zero here
|
||||||
@@ -834,6 +839,7 @@ static bool normal_get_command_count(NormalState *s)
|
|||||||
no_zero_mapping--;
|
no_zero_mapping--;
|
||||||
if (s->ctrl_w) {
|
if (s->ctrl_w) {
|
||||||
no_mapping--;
|
no_mapping--;
|
||||||
|
allow_keys--;
|
||||||
}
|
}
|
||||||
s->need_flushbuf |= add_to_showcmd(s->c);
|
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.opcount = s->ca.count0; // remember first count
|
||||||
s->ca.count0 = 0;
|
s->ca.count0 = 0;
|
||||||
no_mapping++;
|
no_mapping++;
|
||||||
|
allow_keys++; // no mapping for nchar, but keys
|
||||||
s->c = plain_vgetc(); // get next character
|
s->c = plain_vgetc(); // get next character
|
||||||
LANGMAP_ADJUST(s->c, true);
|
LANGMAP_ADJUST(s->c, true);
|
||||||
no_mapping--;
|
no_mapping--;
|
||||||
|
allow_keys--;
|
||||||
s->need_flushbuf |= add_to_showcmd(s->c);
|
s->need_flushbuf |= add_to_showcmd(s->c);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -3407,9 +3415,11 @@ static void nv_zet(cmdarg_T *cap)
|
|||||||
n = nchar - '0';
|
n = nchar - '0';
|
||||||
for (;;) {
|
for (;;) {
|
||||||
no_mapping++;
|
no_mapping++;
|
||||||
|
allow_keys++; // no mapping for nchar, but allow key codes
|
||||||
nchar = plain_vgetc();
|
nchar = plain_vgetc();
|
||||||
LANGMAP_ADJUST(nchar, true);
|
LANGMAP_ADJUST(nchar, true);
|
||||||
no_mapping--;
|
no_mapping--;
|
||||||
|
allow_keys--;
|
||||||
(void)add_to_showcmd(nchar);
|
(void)add_to_showcmd(nchar);
|
||||||
if (nchar == K_DEL || nchar == K_KDEL) {
|
if (nchar == K_DEL || nchar == K_KDEL) {
|
||||||
n /= 10;
|
n /= 10;
|
||||||
@@ -3785,9 +3795,11 @@ dozet:
|
|||||||
|
|
||||||
case 'u': // "zug" and "zuw": undo "zg" and "zw"
|
case 'u': // "zug" and "zuw": undo "zg" and "zw"
|
||||||
no_mapping++;
|
no_mapping++;
|
||||||
|
allow_keys++; // no mapping for nchar, but allow key codes
|
||||||
nchar = plain_vgetc();
|
nchar = plain_vgetc();
|
||||||
LANGMAP_ADJUST(nchar, true);
|
LANGMAP_ADJUST(nchar, true);
|
||||||
no_mapping--;
|
no_mapping--;
|
||||||
|
allow_keys--;
|
||||||
(void)add_to_showcmd(nchar);
|
(void)add_to_showcmd(nchar);
|
||||||
if (vim_strchr((char_u *)"gGwW", nchar) == NULL) {
|
if (vim_strchr((char_u *)"gGwW", nchar) == NULL) {
|
||||||
clearopbeep(cap->oap);
|
clearopbeep(cap->oap);
|
||||||
|
@@ -534,11 +534,13 @@ wingotofile:
|
|||||||
case Ctrl_G:
|
case Ctrl_G:
|
||||||
CHECK_CMDWIN;
|
CHECK_CMDWIN;
|
||||||
no_mapping++;
|
no_mapping++;
|
||||||
|
allow_keys++; // no mapping for xchar, but allow key codes
|
||||||
if (xchar == NUL) {
|
if (xchar == NUL) {
|
||||||
xchar = plain_vgetc();
|
xchar = plain_vgetc();
|
||||||
}
|
}
|
||||||
LANGMAP_ADJUST(xchar, true);
|
LANGMAP_ADJUST(xchar, true);
|
||||||
no_mapping--;
|
no_mapping--;
|
||||||
|
allow_keys--;
|
||||||
(void)add_to_showcmd(xchar);
|
(void)add_to_showcmd(xchar);
|
||||||
switch (xchar) {
|
switch (xchar) {
|
||||||
case '}':
|
case '}':
|
||||||
|
Reference in New Issue
Block a user