0
0
mirror of https://github.com/vim/vim.git synced 2025-10-14 07:04:10 -04:00

patch 8.1.2042: the evalfunc.c file is too big

Problem:    The evalfunc.c file is too big.
Solution:   Move getchar() and parse_queued_messages() to getchar.c.
This commit is contained in:
Bram Moolenaar
2019-09-15 21:00:54 +02:00
parent 248fdb3332
commit 9c658c9eac
6 changed files with 204 additions and 199 deletions

View File

@@ -90,8 +90,6 @@ static void f_function(typval_T *argvars, typval_T *rettv);
static void f_garbagecollect(typval_T *argvars, typval_T *rettv);
static void f_get(typval_T *argvars, typval_T *rettv);
static void f_getchangelist(typval_T *argvars, typval_T *rettv);
static void f_getchar(typval_T *argvars, typval_T *rettv);
static void f_getcharmod(typval_T *argvars, typval_T *rettv);
static void f_getcharsearch(typval_T *argvars, typval_T *rettv);
static void f_getcmdwintype(typval_T *argvars, typval_T *rettv);
static void f_getenv(typval_T *argvars, typval_T *rettv);
@@ -2857,125 +2855,6 @@ f_getchangelist(typval_T *argvars, typval_T *rettv)
}
#endif
}
/*
* "getchar()" function
*/
static void
f_getchar(typval_T *argvars, typval_T *rettv)
{
varnumber_T n;
int error = FALSE;
#ifdef MESSAGE_QUEUE
// vpeekc() used to check for messages, but that caused problems, invoking
// a callback where it was not expected. Some plugins use getchar(1) in a
// loop to await a message, therefore make sure we check for messages here.
parse_queued_messages();
#endif
/* Position the cursor. Needed after a message that ends in a space. */
windgoto(msg_row, msg_col);
++no_mapping;
++allow_keys;
for (;;)
{
if (argvars[0].v_type == VAR_UNKNOWN)
/* getchar(): blocking wait. */
n = plain_vgetc();
else if (tv_get_number_chk(&argvars[0], &error) == 1)
/* getchar(1): only check if char avail */
n = vpeekc_any();
else if (error || vpeekc_any() == NUL)
/* illegal argument or getchar(0) and no char avail: return zero */
n = 0;
else
/* getchar(0) and char avail: return char */
n = plain_vgetc();
if (n == K_IGNORE)
continue;
break;
}
--no_mapping;
--allow_keys;
set_vim_var_nr(VV_MOUSE_WIN, 0);
set_vim_var_nr(VV_MOUSE_WINID, 0);
set_vim_var_nr(VV_MOUSE_LNUM, 0);
set_vim_var_nr(VV_MOUSE_COL, 0);
rettv->vval.v_number = n;
if (IS_SPECIAL(n) || mod_mask != 0)
{
char_u temp[10]; /* modifier: 3, mbyte-char: 6, NUL: 1 */
int i = 0;
/* Turn a special key into three bytes, plus modifier. */
if (mod_mask != 0)
{
temp[i++] = K_SPECIAL;
temp[i++] = KS_MODIFIER;
temp[i++] = mod_mask;
}
if (IS_SPECIAL(n))
{
temp[i++] = K_SPECIAL;
temp[i++] = K_SECOND(n);
temp[i++] = K_THIRD(n);
}
else if (has_mbyte)
i += (*mb_char2bytes)(n, temp + i);
else
temp[i++] = n;
temp[i++] = NUL;
rettv->v_type = VAR_STRING;
rettv->vval.v_string = vim_strsave(temp);
#ifdef FEAT_MOUSE
if (is_mouse_key(n))
{
int row = mouse_row;
int col = mouse_col;
win_T *win;
linenr_T lnum;
win_T *wp;
int winnr = 1;
if (row >= 0 && col >= 0)
{
/* Find the window at the mouse coordinates and compute the
* text position. */
win = mouse_find_win(&row, &col, FIND_POPUP);
if (win == NULL)
return;
(void)mouse_comp_pos(win, &row, &col, &lnum, NULL);
# ifdef FEAT_TEXT_PROP
if (WIN_IS_POPUP(win))
winnr = 0;
else
# endif
for (wp = firstwin; wp != win && wp != NULL;
wp = wp->w_next)
++winnr;
set_vim_var_nr(VV_MOUSE_WIN, winnr);
set_vim_var_nr(VV_MOUSE_WINID, win->w_id);
set_vim_var_nr(VV_MOUSE_LNUM, lnum);
set_vim_var_nr(VV_MOUSE_COL, col + 1);
}
}
#endif
}
}
/*
* "getcharmod()" function
*/
static void
f_getcharmod(typval_T *argvars UNUSED, typval_T *rettv)
{
rettv->vval.v_number = mod_mask;
}
/*
* "getcharsearch()" function