mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 8.1.2001: some source files are too big
Problem: Some source files are too big. Solution: Move buffer and window related functions to evalbuffer.c and evalwindow.c. (Yegappan Lakshmanan, closes #4898)
This commit is contained in:
105
src/buffer.c
105
src/buffer.c
@@ -5450,66 +5450,6 @@ buf_spname(buf_T *buf)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#if defined(FEAT_JOB_CHANNEL) \
|
||||
|| defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) \
|
||||
|| defined(PROTO)
|
||||
/*
|
||||
* Find a window for buffer "buf".
|
||||
* If found OK is returned and "wp" and "tp" are set to the window and tabpage.
|
||||
* If not found FAIL is returned.
|
||||
*/
|
||||
static int
|
||||
find_win_for_buf(
|
||||
buf_T *buf,
|
||||
win_T **wp,
|
||||
tabpage_T **tp)
|
||||
{
|
||||
FOR_ALL_TAB_WINDOWS(*tp, *wp)
|
||||
if ((*wp)->w_buffer == buf)
|
||||
goto win_found;
|
||||
return FAIL;
|
||||
win_found:
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Find a window that contains "buf" and switch to it.
|
||||
* If there is no such window, use the current window and change "curbuf".
|
||||
* Caller must initialize save_curbuf to NULL.
|
||||
* restore_win_for_buf() MUST be called later!
|
||||
*/
|
||||
void
|
||||
switch_to_win_for_buf(
|
||||
buf_T *buf,
|
||||
win_T **save_curwinp,
|
||||
tabpage_T **save_curtabp,
|
||||
bufref_T *save_curbuf)
|
||||
{
|
||||
win_T *wp;
|
||||
tabpage_T *tp;
|
||||
|
||||
if (find_win_for_buf(buf, &wp, &tp) == FAIL)
|
||||
switch_buffer(save_curbuf, buf);
|
||||
else if (switch_win(save_curwinp, save_curtabp, wp, tp, TRUE) == FAIL)
|
||||
{
|
||||
restore_win(*save_curwinp, *save_curtabp, TRUE);
|
||||
switch_buffer(save_curbuf, buf);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
restore_win_for_buf(
|
||||
win_T *save_curwin,
|
||||
tabpage_T *save_curtab,
|
||||
bufref_T *save_curbuf)
|
||||
{
|
||||
if (save_curbuf->br_buf == NULL)
|
||||
restore_win(save_curwin, save_curtab, TRUE);
|
||||
else
|
||||
restore_buffer(save_curbuf);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Set 'buflisted' for curbuf to "on" and trigger autocommands if it changed.
|
||||
*/
|
||||
@@ -5603,48 +5543,3 @@ wipe_buffer(
|
||||
if (!aucmd)
|
||||
unblock_autocmds();
|
||||
}
|
||||
|
||||
#if defined(FEAT_EVAL) || defined(PROTO)
|
||||
/*
|
||||
* Mark references in functions of buffers.
|
||||
*/
|
||||
int
|
||||
set_ref_in_buffers(int copyID)
|
||||
{
|
||||
int abort = FALSE;
|
||||
buf_T *bp;
|
||||
|
||||
FOR_ALL_BUFFERS(bp)
|
||||
{
|
||||
listener_T *lnr;
|
||||
typval_T tv;
|
||||
|
||||
for (lnr = bp->b_listener; !abort && lnr != NULL; lnr = lnr->lr_next)
|
||||
{
|
||||
if (lnr->lr_callback.cb_partial != NULL)
|
||||
{
|
||||
tv.v_type = VAR_PARTIAL;
|
||||
tv.vval.v_partial = lnr->lr_callback.cb_partial;
|
||||
abort = abort || set_ref_in_item(&tv, copyID, NULL, NULL);
|
||||
}
|
||||
}
|
||||
# ifdef FEAT_JOB_CHANNEL
|
||||
if (!abort && bp->b_prompt_callback.cb_partial != NULL)
|
||||
{
|
||||
tv.v_type = VAR_PARTIAL;
|
||||
tv.vval.v_partial = bp->b_prompt_callback.cb_partial;
|
||||
abort = abort || set_ref_in_item(&tv, copyID, NULL, NULL);
|
||||
}
|
||||
if (!abort && bp->b_prompt_interrupt.cb_partial != NULL)
|
||||
{
|
||||
tv.v_type = VAR_PARTIAL;
|
||||
tv.vval.v_partial = bp->b_prompt_interrupt.cb_partial;
|
||||
abort = abort || set_ref_in_item(&tv, copyID, NULL, NULL);
|
||||
}
|
||||
# endif
|
||||
if (abort)
|
||||
break;
|
||||
}
|
||||
return abort;
|
||||
}
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user