mirror of
https://github.com/neovim/neovim.git
synced 2025-09-30 15:08:35 +00:00
refactor: Remove allow_keys global (#6346)
* The allow_keys global is unused in nvim, remove it * clint
This commit is contained in:

committed by
Justin M. Keyes

parent
0cd829161a
commit
098e91400e
@@ -1448,10 +1448,8 @@ int get_digraph(int cmdline)
|
||||
{
|
||||
int cc;
|
||||
no_mapping++;
|
||||
allow_keys++;
|
||||
int c = plain_vgetc();
|
||||
no_mapping--;
|
||||
allow_keys--;
|
||||
|
||||
if (c != ESC) {
|
||||
// ESC cancels CTRL-K
|
||||
@@ -1468,10 +1466,8 @@ int get_digraph(int cmdline)
|
||||
add_to_showcmd(c);
|
||||
}
|
||||
no_mapping++;
|
||||
allow_keys++;
|
||||
cc = plain_vgetc();
|
||||
no_mapping--;
|
||||
allow_keys--;
|
||||
|
||||
if (cc != ESC) {
|
||||
// ESC cancels CTRL-K
|
||||
|
@@ -689,11 +689,9 @@ static int insert_execute(VimState *state, int key)
|
||||
if (s->c == Ctrl_BSL) {
|
||||
// may need to redraw when no more chars available now
|
||||
ins_redraw(false);
|
||||
++no_mapping;
|
||||
++allow_keys;
|
||||
no_mapping++;
|
||||
s->c = plain_vgetc();
|
||||
--no_mapping;
|
||||
--allow_keys;
|
||||
no_mapping--;
|
||||
if (s->c != Ctrl_N && s->c != Ctrl_G && s->c != Ctrl_O) {
|
||||
// it's something else
|
||||
vungetc(s->c);
|
||||
@@ -8303,17 +8301,16 @@ 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;
|
||||
// don't map the digraph chars. This also prevents the
|
||||
// mode message to be deleted when ESC is hit
|
||||
no_mapping++;
|
||||
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 */
|
||||
no_mapping--;
|
||||
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
|
||||
edit_unputchar();
|
||||
}
|
||||
|
||||
if (IS_SPECIAL(c) || mod_mask) { /* special key */
|
||||
clear_showcmd();
|
||||
@@ -8333,15 +8330,14 @@ static int ins_digraph(void)
|
||||
}
|
||||
add_to_showcmd_c(c);
|
||||
}
|
||||
++no_mapping;
|
||||
++allow_keys;
|
||||
no_mapping++;
|
||||
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 */
|
||||
no_mapping--;
|
||||
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
|
||||
edit_unputchar();
|
||||
}
|
||||
if (cc != ESC) {
|
||||
AppendToRedobuff((char_u *)CTRL_V_STR);
|
||||
c = getdigraph(c, cc, TRUE);
|
||||
|
@@ -10596,8 +10596,7 @@ static void f_getchar(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
varnumber_T n;
|
||||
int error = FALSE;
|
||||
|
||||
++no_mapping;
|
||||
++allow_keys;
|
||||
no_mapping++;
|
||||
for (;; ) {
|
||||
// Position the cursor. Needed after a message that ends in a space,
|
||||
// or if event processing caused a redraw.
|
||||
@@ -10630,8 +10629,7 @@ static void f_getchar(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
--no_mapping;
|
||||
--allow_keys;
|
||||
no_mapping--;
|
||||
|
||||
vimvars[VV_MOUSE_WIN].vv_nr = 0;
|
||||
vimvars[VV_MOUSE_WINID].vv_nr = 0;
|
||||
|
@@ -3577,11 +3577,9 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout)
|
||||
ui_cursor_goto(msg_row, msg_col);
|
||||
RedrawingDisabled = temp;
|
||||
|
||||
++no_mapping; /* don't map this key */
|
||||
++allow_keys; /* allow special keys */
|
||||
no_mapping++; // don't map this key
|
||||
typed = plain_vgetc();
|
||||
--allow_keys;
|
||||
--no_mapping;
|
||||
no_mapping--;
|
||||
|
||||
/* clear the question */
|
||||
msg_didout = FALSE; /* don't scroll up */
|
||||
|
@@ -621,11 +621,9 @@ static int command_line_execute(VimState *state, int key)
|
||||
// CTRL-\ CTRL-N goes to Normal mode, CTRL-\ CTRL-G goes to Insert
|
||||
// mode when 'insertmode' is set, CTRL-\ e prompts for an expression.
|
||||
if (s->c == Ctrl_BSL) {
|
||||
++no_mapping;
|
||||
++allow_keys;
|
||||
no_mapping++;
|
||||
s->c = plain_vgetc();
|
||||
--no_mapping;
|
||||
--allow_keys;
|
||||
no_mapping--;
|
||||
// CTRL-\ e doesn't work when obtaining an expression, unless it
|
||||
// is in a mapping.
|
||||
if (s->c != Ctrl_N && s->c != Ctrl_G && (s->c != 'e'
|
||||
@@ -1887,8 +1885,7 @@ getexmodeline (
|
||||
msg_putchar(' ');
|
||||
}
|
||||
}
|
||||
++no_mapping;
|
||||
++allow_keys;
|
||||
no_mapping++;
|
||||
|
||||
/*
|
||||
* Get the line, one character at a time.
|
||||
@@ -2078,8 +2075,7 @@ redraw:
|
||||
}
|
||||
}
|
||||
|
||||
--no_mapping;
|
||||
--allow_keys;
|
||||
no_mapping--;
|
||||
|
||||
/* make following messages go to the next line */
|
||||
msg_didout = FALSE;
|
||||
|
@@ -1389,27 +1389,20 @@ int vgetc(void)
|
||||
for (;; ) { // this is done twice if there are modifiers
|
||||
bool did_inc = false;
|
||||
if (mod_mask) { // no mapping after modifier has been read
|
||||
++no_mapping;
|
||||
++allow_keys;
|
||||
no_mapping++;
|
||||
did_inc = true; // mod_mask may change value
|
||||
}
|
||||
c = vgetorpeek(true);
|
||||
if (did_inc) {
|
||||
--no_mapping;
|
||||
--allow_keys;
|
||||
no_mapping--;
|
||||
}
|
||||
|
||||
/* 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;
|
||||
// Get two extra bytes for special keys
|
||||
if (c == K_SPECIAL) {
|
||||
no_mapping++;
|
||||
c2 = vgetorpeek(true); // no mapping for these chars
|
||||
c = vgetorpeek(true);
|
||||
no_mapping--;
|
||||
if (c2 == KS_MODIFIER) {
|
||||
mod_mask = c;
|
||||
continue;
|
||||
@@ -1487,7 +1480,7 @@ int vgetc(void)
|
||||
buf[i] = CSI;
|
||||
}
|
||||
}
|
||||
--no_mapping;
|
||||
no_mapping--;
|
||||
c = (*mb_ptr2char)(buf);
|
||||
}
|
||||
|
||||
@@ -1570,7 +1563,7 @@ int char_avail(void)
|
||||
|
||||
no_mapping++;
|
||||
retval = vpeekc();
|
||||
--no_mapping;
|
||||
no_mapping--;
|
||||
return retval != NUL;
|
||||
}
|
||||
|
||||
|
@@ -832,13 +832,11 @@ EXTERN int ex_no_reprint INIT(= FALSE); /* no need to print after z or p */
|
||||
EXTERN int Recording INIT(= FALSE); /* TRUE when recording into a reg. */
|
||||
EXTERN int Exec_reg INIT(= FALSE); /* TRUE when executing a register */
|
||||
|
||||
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. */
|
||||
EXTERN int no_mapping INIT(= false); // currently no mapping allowed
|
||||
EXTERN int no_zero_mapping INIT(= 0); // mapping zero not allowed
|
||||
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.
|
||||
|
||||
EXTERN bool force_restart_edit INIT(= false); // force restart_edit after
|
||||
// ex_normal returns
|
||||
|
@@ -847,23 +847,22 @@ void wait_return(int redraw)
|
||||
* CTRL-C, but we need to loop then. */
|
||||
had_got_int = got_int;
|
||||
|
||||
/* Don't do mappings here, we put the character back in the
|
||||
* typeahead buffer. */
|
||||
++no_mapping;
|
||||
++allow_keys;
|
||||
// Don't do mappings here, we put the character back in the
|
||||
// typeahead buffer.
|
||||
no_mapping++;
|
||||
|
||||
/* Temporarily disable Recording. If Recording is active, the
|
||||
* character will be recorded later, since it will be added to the
|
||||
* typebuf after the loop */
|
||||
// Temporarily disable Recording. If Recording is active, the
|
||||
// character will be recorded later, since it will be added to the
|
||||
// typebuf after the loop
|
||||
save_Recording = Recording;
|
||||
save_scriptout = scriptout;
|
||||
Recording = FALSE;
|
||||
scriptout = NULL;
|
||||
c = safe_vgetc();
|
||||
if (had_got_int && !global_busy)
|
||||
got_int = FALSE;
|
||||
--no_mapping;
|
||||
--allow_keys;
|
||||
if (had_got_int && !global_busy) {
|
||||
got_int = false;
|
||||
}
|
||||
no_mapping--;
|
||||
Recording = save_Recording;
|
||||
scriptout = save_scriptout;
|
||||
|
||||
|
@@ -2225,11 +2225,10 @@ int ask_yesno(const char *str, bool direct)
|
||||
int r = ' ';
|
||||
int save_State = State;
|
||||
|
||||
++no_wait_return;
|
||||
State = CONFIRM; /* mouse behaves like with :confirm */
|
||||
setmouse(); /* disables mouse for xterm */
|
||||
++no_mapping;
|
||||
++allow_keys; /* no mapping here, but recognize keys */
|
||||
no_wait_return++;
|
||||
State = CONFIRM; // mouse behaves like with :confirm
|
||||
setmouse(); // disables mouse for xterm
|
||||
no_mapping++;
|
||||
|
||||
while (r != 'y' && r != 'n') {
|
||||
/* same highlighting as for wait_return */
|
||||
@@ -2247,8 +2246,7 @@ int ask_yesno(const char *str, bool direct)
|
||||
--no_wait_return;
|
||||
State = save_State;
|
||||
setmouse();
|
||||
--no_mapping;
|
||||
--allow_keys;
|
||||
no_mapping--;
|
||||
|
||||
return r;
|
||||
}
|
||||
@@ -2398,8 +2396,7 @@ get_number (
|
||||
if (msg_silent != 0)
|
||||
return 0;
|
||||
|
||||
++no_mapping;
|
||||
++allow_keys; /* no mapping here, but recognize keys */
|
||||
no_mapping++;
|
||||
for (;; ) {
|
||||
ui_cursor_goto(msg_row, msg_col);
|
||||
c = safe_vgetc();
|
||||
@@ -2427,8 +2424,7 @@ get_number (
|
||||
} else if (c == CAR || c == NL || c == Ctrl_C || c == ESC)
|
||||
break;
|
||||
}
|
||||
--no_mapping;
|
||||
--allow_keys;
|
||||
no_mapping--;
|
||||
return n;
|
||||
}
|
||||
|
||||
|
@@ -642,8 +642,7 @@ static void normal_get_additional_char(NormalState *s)
|
||||
bool langmap_active = false; // using :lmap mappings
|
||||
int lang; // getting a text character
|
||||
|
||||
++no_mapping;
|
||||
++allow_keys; // no mapping for nchar, but allow key codes
|
||||
no_mapping++;
|
||||
// Don't generate a CursorHold event here, most commands can't handle
|
||||
// it, e.g., nv_replace(), nv_csearch().
|
||||
did_cursorhold = true;
|
||||
@@ -681,8 +680,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;
|
||||
no_mapping--;
|
||||
if (repl) {
|
||||
State = LREPLACE;
|
||||
} else {
|
||||
@@ -695,8 +693,7 @@ static void normal_get_additional_char(NormalState *s)
|
||||
|
||||
if (langmap_active) {
|
||||
// Undo the decrement done above
|
||||
++no_mapping;
|
||||
++allow_keys;
|
||||
no_mapping++;
|
||||
State = NORMAL_BUSY;
|
||||
}
|
||||
State = NORMAL_BUSY;
|
||||
@@ -781,8 +778,7 @@ static void normal_get_additional_char(NormalState *s)
|
||||
}
|
||||
no_mapping++;
|
||||
}
|
||||
--no_mapping;
|
||||
--allow_keys;
|
||||
no_mapping--;
|
||||
}
|
||||
|
||||
static void normal_invert_horizontal(NormalState *s)
|
||||
@@ -832,8 +828,7 @@ static bool normal_get_command_count(NormalState *s)
|
||||
}
|
||||
|
||||
if (s->ctrl_w) {
|
||||
++no_mapping;
|
||||
++allow_keys; // no mapping for nchar, but keys
|
||||
no_mapping++;
|
||||
}
|
||||
|
||||
++no_zero_mapping; // don't map zero here
|
||||
@@ -841,8 +836,7 @@ static bool normal_get_command_count(NormalState *s)
|
||||
LANGMAP_ADJUST(s->c, true);
|
||||
--no_zero_mapping;
|
||||
if (s->ctrl_w) {
|
||||
--no_mapping;
|
||||
--allow_keys;
|
||||
no_mapping--;
|
||||
}
|
||||
s->need_flushbuf |= add_to_showcmd(s->c);
|
||||
}
|
||||
@@ -852,12 +846,10 @@ static bool normal_get_command_count(NormalState *s)
|
||||
s->ctrl_w = true;
|
||||
s->ca.opcount = s->ca.count0; // remember first count
|
||||
s->ca.count0 = 0;
|
||||
++no_mapping;
|
||||
++allow_keys; // no mapping for nchar, but keys
|
||||
no_mapping++;
|
||||
s->c = plain_vgetc(); // get next character
|
||||
LANGMAP_ADJUST(s->c, true);
|
||||
--no_mapping;
|
||||
--allow_keys;
|
||||
no_mapping--;
|
||||
s->need_flushbuf |= add_to_showcmd(s->c);
|
||||
return true;
|
||||
}
|
||||
@@ -4043,12 +4035,10 @@ static void nv_zet(cmdarg_T *cap)
|
||||
return;
|
||||
n = nchar - '0';
|
||||
for (;; ) {
|
||||
++no_mapping;
|
||||
++allow_keys; /* no mapping for nchar, but allow key codes */
|
||||
no_mapping++;
|
||||
nchar = plain_vgetc();
|
||||
LANGMAP_ADJUST(nchar, true);
|
||||
--no_mapping;
|
||||
--allow_keys;
|
||||
no_mapping--;
|
||||
(void)add_to_showcmd(nchar);
|
||||
if (nchar == K_DEL || nchar == K_KDEL)
|
||||
n /= 10;
|
||||
@@ -4376,13 +4366,11 @@ dozet:
|
||||
break;
|
||||
|
||||
|
||||
case 'u': /* "zug" and "zuw": undo "zg" and "zw" */
|
||||
++no_mapping;
|
||||
++allow_keys; /* no mapping for nchar, but allow key codes */
|
||||
case 'u': // "zug" and "zuw": undo "zg" and "zw"
|
||||
no_mapping++;
|
||||
nchar = plain_vgetc();
|
||||
LANGMAP_ADJUST(nchar, true);
|
||||
--no_mapping;
|
||||
--allow_keys;
|
||||
no_mapping--;
|
||||
(void)add_to_showcmd(nchar);
|
||||
if (vim_strchr((char_u *)"gGwW", nchar) == NULL) {
|
||||
clearopbeep(cap->oap);
|
||||
|
@@ -447,13 +447,12 @@ wingotofile:
|
||||
case 'g':
|
||||
case Ctrl_G:
|
||||
CHECK_CMDWIN
|
||||
++ no_mapping;
|
||||
++allow_keys; /* no mapping for xchar, but allow key codes */
|
||||
if (xchar == NUL)
|
||||
no_mapping++;
|
||||
if (xchar == NUL) {
|
||||
xchar = plain_vgetc();
|
||||
LANGMAP_ADJUST(xchar, TRUE);
|
||||
--no_mapping;
|
||||
--allow_keys;
|
||||
}
|
||||
LANGMAP_ADJUST(xchar, true);
|
||||
no_mapping--;
|
||||
(void)add_to_showcmd(xchar);
|
||||
switch (xchar) {
|
||||
case '}':
|
||||
|
Reference in New Issue
Block a user