1
0
forked from aniani/vim

patch 8.1.1943: more code can be moved to evalvars.c

Problem:    More code can be moved to evalvars.c.
Solution:   Move it, clean up comments.  Also move some window related
            functions to window.c. (Yegappan Lakshmanan, closes #4874)
This commit is contained in:
Bram Moolenaar
2019-08-30 15:46:30 +02:00
parent 58a297b28d
commit 8d71b54409
8 changed files with 246 additions and 245 deletions

View File

@@ -6513,109 +6513,6 @@ ex_execute(exarg_T *eap)
eap->nextcmd = check_nextcmd(arg);
}
/*
* Find window specified by "vp" in tabpage "tp".
*/
win_T *
find_win_by_nr(
typval_T *vp,
tabpage_T *tp) /* NULL for current tab page */
{
win_T *wp;
int nr = (int)tv_get_number_chk(vp, NULL);
if (nr < 0)
return NULL;
if (nr == 0)
return curwin;
FOR_ALL_WINDOWS_IN_TAB(tp, wp)
{
if (nr >= LOWEST_WIN_ID)
{
if (wp->w_id == nr)
return wp;
}
else if (--nr <= 0)
break;
}
if (nr >= LOWEST_WIN_ID)
{
#ifdef FEAT_TEXT_PROP
// check tab-local popup windows
for (wp = tp->tp_first_popupwin; wp != NULL; wp = wp->w_next)
if (wp->w_id == nr)
return wp;
// check global popup windows
for (wp = first_popupwin; wp != NULL; wp = wp->w_next)
if (wp->w_id == nr)
return wp;
#endif
return NULL;
}
return wp;
}
/*
* Find a window: When using a Window ID in any tab page, when using a number
* in the current tab page.
*/
win_T *
find_win_by_nr_or_id(typval_T *vp)
{
int nr = (int)tv_get_number_chk(vp, NULL);
if (nr >= LOWEST_WIN_ID)
return win_id2wp(tv_get_number(vp));
return find_win_by_nr(vp, NULL);
}
/*
* Find window specified by "wvp" in tabpage "tvp".
* Returns the tab page in 'ptp'
*/
win_T *
find_tabwin(
typval_T *wvp, // VAR_UNKNOWN for current window
typval_T *tvp, // VAR_UNKNOWN for current tab page
tabpage_T **ptp)
{
win_T *wp = NULL;
tabpage_T *tp = NULL;
long n;
if (wvp->v_type != VAR_UNKNOWN)
{
if (tvp->v_type != VAR_UNKNOWN)
{
n = (long)tv_get_number(tvp);
if (n >= 0)
tp = find_tabpage(n);
}
else
tp = curtab;
if (tp != NULL)
{
wp = find_win_by_nr(wvp, tp);
if (wp == NULL && wvp->v_type == VAR_NUMBER
&& wvp->vval.v_number != -1)
// A window with the specified number is not found
tp = NULL;
}
}
else
{
wp = curwin;
tp = curtab;
}
if (ptp != NULL)
*ptp = tp;
return wp;
}
/*
* Skip over the name of an option: "&option", "&g:option" or "&l:option".
* "arg" points to the "&" or '+' when called, to "option" when returning.