mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
updated for version 7.3.963
Problem: Setting curbuf without curwin causes trouble. Solution: Add switch_buffer() and restore_buffer(). Block autocommands to avoid trouble.
This commit is contained in:
parent
55b8ad3dab
commit
105bc355a6
51
src/eval.c
51
src/eval.c
@ -11894,7 +11894,7 @@ getwinvar(argvars, rettv, off)
|
|||||||
win_T *win, *oldcurwin;
|
win_T *win, *oldcurwin;
|
||||||
char_u *varname;
|
char_u *varname;
|
||||||
dictitem_T *v;
|
dictitem_T *v;
|
||||||
tabpage_T *tp;
|
tabpage_T *tp, *oldtabpage;
|
||||||
int done = FALSE;
|
int done = FALSE;
|
||||||
|
|
||||||
#ifdef FEAT_WINDOWS
|
#ifdef FEAT_WINDOWS
|
||||||
@ -11912,11 +11912,9 @@ getwinvar(argvars, rettv, off)
|
|||||||
|
|
||||||
if (win != NULL && varname != NULL)
|
if (win != NULL && varname != NULL)
|
||||||
{
|
{
|
||||||
/* Set curwin to be our win, temporarily. Also set curbuf, so
|
/* Set curwin to be our win, temporarily. Also set the tabpage,
|
||||||
* that we can get buffer-local options. */
|
* otherwise the window is not valid. */
|
||||||
oldcurwin = curwin;
|
switch_win(&oldcurwin, &oldtabpage, win, tp);
|
||||||
curwin = win;
|
|
||||||
curbuf = win->w_buffer;
|
|
||||||
|
|
||||||
if (*varname == '&') /* window-local-option */
|
if (*varname == '&') /* window-local-option */
|
||||||
{
|
{
|
||||||
@ -11936,8 +11934,7 @@ getwinvar(argvars, rettv, off)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* restore previous notion of curwin */
|
/* restore previous notion of curwin */
|
||||||
curwin = oldcurwin;
|
restore_win(oldcurwin, oldtabpage);
|
||||||
curbuf = curwin->w_buffer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!done && argvars[off + 2].v_type != VAR_UNKNOWN)
|
if (!done && argvars[off + 2].v_type != VAR_UNKNOWN)
|
||||||
@ -16641,44 +16638,6 @@ f_setwinvar(argvars, rettv)
|
|||||||
setwinvar(argvars, rettv, 0);
|
setwinvar(argvars, rettv, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
switch_win(save_curwin, save_curtab, win, tp)
|
|
||||||
win_T **save_curwin;
|
|
||||||
tabpage_T **save_curtab;
|
|
||||||
win_T *win;
|
|
||||||
tabpage_T *tp;
|
|
||||||
{
|
|
||||||
#ifdef FEAT_WINDOWS
|
|
||||||
/* set curwin to be our win, temporarily */
|
|
||||||
*save_curwin = curwin;
|
|
||||||
*save_curtab = curtab;
|
|
||||||
goto_tabpage_tp(tp, FALSE, FALSE);
|
|
||||||
if (!win_valid(win))
|
|
||||||
return FAIL;
|
|
||||||
curwin = win;
|
|
||||||
curbuf = curwin->w_buffer;
|
|
||||||
#endif
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
restore_win(save_curwin, save_curtab)
|
|
||||||
win_T *save_curwin;
|
|
||||||
tabpage_T *save_curtab;
|
|
||||||
{
|
|
||||||
#ifdef FEAT_WINDOWS
|
|
||||||
/* Restore current tabpage and window, if still valid (autocommands can
|
|
||||||
* make them invalid). */
|
|
||||||
if (valid_tabpage(save_curtab))
|
|
||||||
goto_tabpage_tp(save_curtab, FALSE, FALSE);
|
|
||||||
if (win_valid(save_curwin))
|
|
||||||
{
|
|
||||||
curwin = save_curwin;
|
|
||||||
curbuf = curwin->w_buffer;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* "setwinvar()" and "settabwinvar()" functions
|
* "setwinvar()" and "settabwinvar()" functions
|
||||||
*/
|
*/
|
||||||
|
@ -1413,14 +1413,14 @@ set_option_value_for(key, numval, stringval, opt_flags, opt_type, from)
|
|||||||
{
|
{
|
||||||
win_T *save_curwin;
|
win_T *save_curwin;
|
||||||
tabpage_T *save_curtab;
|
tabpage_T *save_curtab;
|
||||||
aco_save_T aco;
|
buf_T *save_curbuf;
|
||||||
int r = 0;
|
int r = 0;
|
||||||
|
|
||||||
switch (opt_type)
|
switch (opt_type)
|
||||||
{
|
{
|
||||||
case SREQ_WIN:
|
case SREQ_WIN:
|
||||||
if (switch_win(&save_curwin, &save_curtab, (win_T *) from, curtab)
|
if (switch_win(&save_curwin, &save_curtab, (win_T *)from,
|
||||||
== FAIL)
|
win_find_tabpage((win_T *)from)) == FAIL)
|
||||||
{
|
{
|
||||||
PyErr_SetVim("Problem while switching windows.");
|
PyErr_SetVim("Problem while switching windows.");
|
||||||
return -1;
|
return -1;
|
||||||
@ -1429,9 +1429,9 @@ set_option_value_for(key, numval, stringval, opt_flags, opt_type, from)
|
|||||||
restore_win(save_curwin, save_curtab);
|
restore_win(save_curwin, save_curtab);
|
||||||
break;
|
break;
|
||||||
case SREQ_BUF:
|
case SREQ_BUF:
|
||||||
aucmd_prepbuf(&aco, (buf_T *) from);
|
switch_buffer(&save_curbuf, (buf_T *)from);
|
||||||
set_option_value(key, numval, stringval, opt_flags);
|
set_option_value(key, numval, stringval, opt_flags);
|
||||||
aucmd_restbuf(&aco);
|
restore_buffer(save_curbuf);
|
||||||
break;
|
break;
|
||||||
case SREQ_GLOBAL:
|
case SREQ_GLOBAL:
|
||||||
set_option_value(key, numval, stringval, opt_flags);
|
set_option_value(key, numval, stringval, opt_flags);
|
||||||
@ -2240,10 +2240,10 @@ SetBufferLine(buf_T *buf, PyInt n, PyObject *line, PyInt *len_change)
|
|||||||
*/
|
*/
|
||||||
if (line == Py_None || line == NULL)
|
if (line == Py_None || line == NULL)
|
||||||
{
|
{
|
||||||
buf_T *savebuf = curbuf;
|
buf_T *savebuf;
|
||||||
|
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
curbuf = buf;
|
switch_buffer(&savebuf, buf);
|
||||||
|
|
||||||
if (u_savedel((linenr_T)n, 1L) == FAIL)
|
if (u_savedel((linenr_T)n, 1L) == FAIL)
|
||||||
PyErr_SetVim(_("cannot save undo information"));
|
PyErr_SetVim(_("cannot save undo information"));
|
||||||
@ -2251,12 +2251,12 @@ SetBufferLine(buf_T *buf, PyInt n, PyObject *line, PyInt *len_change)
|
|||||||
PyErr_SetVim(_("cannot delete line"));
|
PyErr_SetVim(_("cannot delete line"));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (buf == curwin->w_buffer)
|
if (buf == savebuf)
|
||||||
py_fix_cursor((linenr_T)n, (linenr_T)n + 1, (linenr_T)-1);
|
py_fix_cursor((linenr_T)n, (linenr_T)n + 1, (linenr_T)-1);
|
||||||
deleted_lines_mark((linenr_T)n, 1L);
|
deleted_lines_mark((linenr_T)n, 1L);
|
||||||
}
|
}
|
||||||
|
|
||||||
curbuf = savebuf;
|
restore_buffer(savebuf);
|
||||||
|
|
||||||
if (PyErr_Occurred() || VimErrorCheck())
|
if (PyErr_Occurred() || VimErrorCheck())
|
||||||
return FAIL;
|
return FAIL;
|
||||||
@ -2269,14 +2269,14 @@ SetBufferLine(buf_T *buf, PyInt n, PyObject *line, PyInt *len_change)
|
|||||||
else if (PyString_Check(line))
|
else if (PyString_Check(line))
|
||||||
{
|
{
|
||||||
char *save = StringToLine(line);
|
char *save = StringToLine(line);
|
||||||
buf_T *savebuf = curbuf;
|
buf_T *savebuf;
|
||||||
|
|
||||||
if (save == NULL)
|
if (save == NULL)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
|
||||||
/* We do not need to free "save" if ml_replace() consumes it. */
|
/* We do not need to free "save" if ml_replace() consumes it. */
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
curbuf = buf;
|
switch_buffer(&savebuf, buf);
|
||||||
|
|
||||||
if (u_savesub((linenr_T)n) == FAIL)
|
if (u_savesub((linenr_T)n) == FAIL)
|
||||||
{
|
{
|
||||||
@ -2291,10 +2291,10 @@ SetBufferLine(buf_T *buf, PyInt n, PyObject *line, PyInt *len_change)
|
|||||||
else
|
else
|
||||||
changed_bytes((linenr_T)n, 0);
|
changed_bytes((linenr_T)n, 0);
|
||||||
|
|
||||||
curbuf = savebuf;
|
restore_buffer(savebuf);
|
||||||
|
|
||||||
/* Check that the cursor is not beyond the end of the line now. */
|
/* Check that the cursor is not beyond the end of the line now. */
|
||||||
if (buf == curwin->w_buffer)
|
if (buf == savebuf)
|
||||||
check_cursor_col();
|
check_cursor_col();
|
||||||
|
|
||||||
if (PyErr_Occurred() || VimErrorCheck())
|
if (PyErr_Occurred() || VimErrorCheck())
|
||||||
@ -2333,10 +2333,10 @@ SetBufferLineList(buf_T *buf, PyInt lo, PyInt hi, PyObject *list, PyInt *len_cha
|
|||||||
{
|
{
|
||||||
PyInt i;
|
PyInt i;
|
||||||
PyInt n = (int)(hi - lo);
|
PyInt n = (int)(hi - lo);
|
||||||
buf_T *savebuf = curbuf;
|
buf_T *savebuf;
|
||||||
|
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
curbuf = buf;
|
switch_buffer(&savebuf, buf);
|
||||||
|
|
||||||
if (u_savedel((linenr_T)lo, (long)n) == FAIL)
|
if (u_savedel((linenr_T)lo, (long)n) == FAIL)
|
||||||
PyErr_SetVim(_("cannot save undo information"));
|
PyErr_SetVim(_("cannot save undo information"));
|
||||||
@ -2350,12 +2350,12 @@ SetBufferLineList(buf_T *buf, PyInt lo, PyInt hi, PyObject *list, PyInt *len_cha
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (buf == curwin->w_buffer)
|
if (buf == savebuf)
|
||||||
py_fix_cursor((linenr_T)lo, (linenr_T)hi, (linenr_T)-n);
|
py_fix_cursor((linenr_T)lo, (linenr_T)hi, (linenr_T)-n);
|
||||||
deleted_lines_mark((linenr_T)lo, (long)i);
|
deleted_lines_mark((linenr_T)lo, (long)i);
|
||||||
}
|
}
|
||||||
|
|
||||||
curbuf = savebuf;
|
restore_buffer(savebuf);
|
||||||
|
|
||||||
if (PyErr_Occurred() || VimErrorCheck())
|
if (PyErr_Occurred() || VimErrorCheck())
|
||||||
return FAIL;
|
return FAIL;
|
||||||
@ -2400,10 +2400,10 @@ SetBufferLineList(buf_T *buf, PyInt lo, PyInt hi, PyObject *list, PyInt *len_cha
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
savebuf = curbuf;
|
|
||||||
|
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
curbuf = buf;
|
|
||||||
|
// START of region without "return". Must call restore_buffer()!
|
||||||
|
switch_buffer(&savebuf, buf);
|
||||||
|
|
||||||
if (u_save((linenr_T)(lo-1), (linenr_T)hi) == FAIL)
|
if (u_save((linenr_T)(lo-1), (linenr_T)hi) == FAIL)
|
||||||
PyErr_SetVim(_("cannot save undo information"));
|
PyErr_SetVim(_("cannot save undo information"));
|
||||||
@ -2480,10 +2480,11 @@ SetBufferLineList(buf_T *buf, PyInt lo, PyInt hi, PyObject *list, PyInt *len_cha
|
|||||||
(long)MAXLNUM, (long)extra);
|
(long)MAXLNUM, (long)extra);
|
||||||
changed_lines((linenr_T)lo, 0, (linenr_T)hi, (long)extra);
|
changed_lines((linenr_T)lo, 0, (linenr_T)hi, (long)extra);
|
||||||
|
|
||||||
if (buf == curwin->w_buffer)
|
if (buf == savebuf)
|
||||||
py_fix_cursor((linenr_T)lo, (linenr_T)hi, (linenr_T)extra);
|
py_fix_cursor((linenr_T)lo, (linenr_T)hi, (linenr_T)extra);
|
||||||
|
|
||||||
curbuf = savebuf;
|
// END of region without "return".
|
||||||
|
restore_buffer(savebuf);
|
||||||
|
|
||||||
if (PyErr_Occurred() || VimErrorCheck())
|
if (PyErr_Occurred() || VimErrorCheck())
|
||||||
return FAIL;
|
return FAIL;
|
||||||
@ -2522,10 +2523,8 @@ InsertBufferLines(buf_T *buf, PyInt n, PyObject *lines, PyInt *len_change)
|
|||||||
if (str == NULL)
|
if (str == NULL)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
|
||||||
savebuf = curbuf;
|
|
||||||
|
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
curbuf = buf;
|
switch_buffer(&savebuf, buf);
|
||||||
|
|
||||||
if (u_save((linenr_T)n, (linenr_T)(n+1)) == FAIL)
|
if (u_save((linenr_T)n, (linenr_T)(n+1)) == FAIL)
|
||||||
PyErr_SetVim(_("cannot save undo information"));
|
PyErr_SetVim(_("cannot save undo information"));
|
||||||
@ -2535,7 +2534,7 @@ InsertBufferLines(buf_T *buf, PyInt n, PyObject *lines, PyInt *len_change)
|
|||||||
appended_lines_mark((linenr_T)n, 1L);
|
appended_lines_mark((linenr_T)n, 1L);
|
||||||
|
|
||||||
vim_free(str);
|
vim_free(str);
|
||||||
curbuf = savebuf;
|
restore_buffer(savebuf);
|
||||||
update_screen(VALID);
|
update_screen(VALID);
|
||||||
|
|
||||||
if (PyErr_Occurred() || VimErrorCheck())
|
if (PyErr_Occurred() || VimErrorCheck())
|
||||||
@ -2574,10 +2573,8 @@ InsertBufferLines(buf_T *buf, PyInt n, PyObject *lines, PyInt *len_change)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
savebuf = curbuf;
|
|
||||||
|
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
curbuf = buf;
|
switch_buffer(&savebuf, buf);
|
||||||
|
|
||||||
if (u_save((linenr_T)n, (linenr_T)(n + 1)) == FAIL)
|
if (u_save((linenr_T)n, (linenr_T)(n + 1)) == FAIL)
|
||||||
PyErr_SetVim(_("cannot save undo information"));
|
PyErr_SetVim(_("cannot save undo information"));
|
||||||
@ -2607,7 +2604,7 @@ InsertBufferLines(buf_T *buf, PyInt n, PyObject *lines, PyInt *len_change)
|
|||||||
*/
|
*/
|
||||||
vim_free(array);
|
vim_free(array);
|
||||||
|
|
||||||
curbuf = savebuf;
|
restore_buffer(savebuf);
|
||||||
update_screen(VALID);
|
update_screen(VALID);
|
||||||
|
|
||||||
if (PyErr_Occurred() || VimErrorCheck())
|
if (PyErr_Occurred() || VimErrorCheck())
|
||||||
@ -3023,7 +3020,7 @@ BufferMark(PyObject *self, PyObject *args)
|
|||||||
pos_T *posp;
|
pos_T *posp;
|
||||||
char *pmark;
|
char *pmark;
|
||||||
char mark;
|
char mark;
|
||||||
buf_T *curbuf_save;
|
buf_T *savebuf;
|
||||||
|
|
||||||
if (CheckBuffer((BufferObject *)(self)))
|
if (CheckBuffer((BufferObject *)(self)))
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -3032,10 +3029,9 @@ BufferMark(PyObject *self, PyObject *args)
|
|||||||
return NULL;
|
return NULL;
|
||||||
mark = *pmark;
|
mark = *pmark;
|
||||||
|
|
||||||
curbuf_save = curbuf;
|
switch_buffer(&savebuf, ((BufferObject *)(self))->buf);
|
||||||
curbuf = ((BufferObject *)(self))->buf;
|
|
||||||
posp = getmark(mark, FALSE);
|
posp = getmark(mark, FALSE);
|
||||||
curbuf = curbuf_save;
|
restore_buffer(savebuf);
|
||||||
|
|
||||||
if (posp == NULL)
|
if (posp == NULL)
|
||||||
{
|
{
|
||||||
|
@ -33,6 +33,8 @@ void prof_child_enter __ARGS((proftime_T *tm));
|
|||||||
void prof_child_exit __ARGS((proftime_T *tm));
|
void prof_child_exit __ARGS((proftime_T *tm));
|
||||||
int eval_foldexpr __ARGS((char_u *arg, int *cp));
|
int eval_foldexpr __ARGS((char_u *arg, int *cp));
|
||||||
void ex_let __ARGS((exarg_T *eap));
|
void ex_let __ARGS((exarg_T *eap));
|
||||||
|
void list_add_watch __ARGS((list_T *l, listwatch_T *lw));
|
||||||
|
void list_rem_watch __ARGS((list_T *l, listwatch_T *lwrem));
|
||||||
void *eval_for_line __ARGS((char_u *arg, int *errp, char_u **nextcmdp, int skip));
|
void *eval_for_line __ARGS((char_u *arg, int *errp, char_u **nextcmdp, int skip));
|
||||||
int next_for_item __ARGS((void *fi_void, char_u *arg));
|
int next_for_item __ARGS((void *fi_void, char_u *arg));
|
||||||
void free_for_info __ARGS((void *fi_void));
|
void free_for_info __ARGS((void *fi_void));
|
||||||
@ -125,8 +127,4 @@ void last_set_msg __ARGS((scid_T scriptID));
|
|||||||
void ex_oldfiles __ARGS((exarg_T *eap));
|
void ex_oldfiles __ARGS((exarg_T *eap));
|
||||||
int modify_fname __ARGS((char_u *src, int *usedlen, char_u **fnamep, char_u **bufp, int *fnamelen));
|
int modify_fname __ARGS((char_u *src, int *usedlen, char_u **fnamep, char_u **bufp, int *fnamelen));
|
||||||
char_u *do_string_sub __ARGS((char_u *str, char_u *pat, char_u *sub, char_u *flags));
|
char_u *do_string_sub __ARGS((char_u *str, char_u *pat, char_u *sub, char_u *flags));
|
||||||
int switch_win __ARGS((win_T **, tabpage_T **, win_T *, tabpage_T *));
|
|
||||||
void restore_win __ARGS((win_T *, tabpage_T *));
|
|
||||||
void list_add_watch __ARGS((list_T *l, listwatch_T *lw));
|
|
||||||
void list_rem_watch __ARGS((list_T *l, listwatch_T *lwrem));
|
|
||||||
/* vim: set ft=c : */
|
/* vim: set ft=c : */
|
||||||
|
@ -32,6 +32,7 @@ void goto_tabpage_win __ARGS((tabpage_T *tp, win_T *wp));
|
|||||||
void tabpage_move __ARGS((int nr));
|
void tabpage_move __ARGS((int nr));
|
||||||
void win_goto __ARGS((win_T *wp));
|
void win_goto __ARGS((win_T *wp));
|
||||||
win_T *win_find_nr __ARGS((int winnr));
|
win_T *win_find_nr __ARGS((int winnr));
|
||||||
|
tabpage_T *win_find_tabpage __ARGS((win_T *win));
|
||||||
void win_enter __ARGS((win_T *wp, int undo_sync));
|
void win_enter __ARGS((win_T *wp, int undo_sync));
|
||||||
win_T *buf_jump_open_win __ARGS((buf_T *buf));
|
win_T *buf_jump_open_win __ARGS((buf_T *buf));
|
||||||
win_T *buf_jump_open_tab __ARGS((buf_T *buf));
|
win_T *buf_jump_open_tab __ARGS((buf_T *buf));
|
||||||
@ -69,6 +70,10 @@ int only_one_window __ARGS((void));
|
|||||||
void check_lnums __ARGS((int do_curwin));
|
void check_lnums __ARGS((int do_curwin));
|
||||||
void make_snapshot __ARGS((int idx));
|
void make_snapshot __ARGS((int idx));
|
||||||
void restore_snapshot __ARGS((int idx, int close_curwin));
|
void restore_snapshot __ARGS((int idx, int close_curwin));
|
||||||
|
int switch_win __ARGS((win_T **save_curwin, tabpage_T **save_curtab, win_T *win, tabpage_T *tp));
|
||||||
|
void restore_win __ARGS((win_T *save_curwin, tabpage_T *save_curtab));
|
||||||
|
void switch_buffer __ARGS((buf_T **save_curbuf, buf_T *buf));
|
||||||
|
void restore_buffer __ARGS((buf_T *save_curbuf));
|
||||||
int win_hasvertsplit __ARGS((void));
|
int win_hasvertsplit __ARGS((void));
|
||||||
int match_add __ARGS((win_T *wp, char_u *grp, char_u *pat, int prio, int id));
|
int match_add __ARGS((win_T *wp, char_u *grp, char_u *pat, int prio, int id));
|
||||||
int match_delete __ARGS((win_T *wp, int id, int perr));
|
int match_delete __ARGS((win_T *wp, int id, int perr));
|
||||||
|
@ -333,7 +333,7 @@ Number of tabs: 4
|
|||||||
Current tab pages:
|
Current tab pages:
|
||||||
<tabpage 0>(1): 1 windows, current is <window object (unknown)>
|
<tabpage 0>(1): 1 windows, current is <window object (unknown)>
|
||||||
Windows:
|
Windows:
|
||||||
<window object (unknown)>(0): displays buffer <buffer test86.in>; cursor is at (955, 0)
|
<window object (unknown)>(0): displays buffer <buffer test86.in>; cursor is at (954, 0)
|
||||||
<tabpage 1>(2): 1 windows, current is <window object (unknown)>
|
<tabpage 1>(2): 1 windows, current is <window object (unknown)>
|
||||||
Windows:
|
Windows:
|
||||||
<window object (unknown)>(0): displays buffer <buffer 0>; cursor is at (1, 0)
|
<window object (unknown)>(0): displays buffer <buffer 0>; cursor is at (1, 0)
|
||||||
|
@ -728,6 +728,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
963,
|
||||||
/**/
|
/**/
|
||||||
962,
|
962,
|
||||||
/**/
|
/**/
|
||||||
|
118
src/window.c
118
src/window.c
@ -4058,6 +4058,25 @@ win_find_nr(winnr)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if (defined(FEAT_WINDOWS) && defined(FEAT_PYTHON)) || defined(PROTO)
|
||||||
|
/*
|
||||||
|
* Find the tabpage for window "win".
|
||||||
|
*/
|
||||||
|
tabpage_T *
|
||||||
|
win_find_tabpage(win)
|
||||||
|
win_T *win;
|
||||||
|
{
|
||||||
|
win_T *wp;
|
||||||
|
tabpage_T *tp;
|
||||||
|
|
||||||
|
for (tp = first_tabpage; tp != NULL; tp = tp->tp_next)
|
||||||
|
for (wp = tp->tp_firstwin; wp != NULL; wp = wp->w_next)
|
||||||
|
if (wp == win)
|
||||||
|
return tp;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef FEAT_VERTSPLIT
|
#ifdef FEAT_VERTSPLIT
|
||||||
/*
|
/*
|
||||||
* Move to window above or below "count" times.
|
* Move to window above or below "count" times.
|
||||||
@ -6550,6 +6569,105 @@ restore_snapshot_rec(sn, fr)
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(FEAT_EVAL) || defined(PROTO)
|
||||||
|
/*
|
||||||
|
* Set "win" to be the curwin and "tp" to be the current tab page.
|
||||||
|
* restore_win() MUST be called to undo.
|
||||||
|
* No autocommands will be executed.
|
||||||
|
* Returns FAIL if switching to "win" failed.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
switch_win(save_curwin, save_curtab, win, tp)
|
||||||
|
win_T **save_curwin;
|
||||||
|
tabpage_T **save_curtab;
|
||||||
|
win_T *win;
|
||||||
|
tabpage_T *tp;
|
||||||
|
{
|
||||||
|
# ifdef FEAT_AUTOCMD
|
||||||
|
block_autocmds();
|
||||||
|
# endif
|
||||||
|
# ifdef FEAT_WINDOWS
|
||||||
|
*save_curwin = curwin;
|
||||||
|
if (tp != NULL)
|
||||||
|
{
|
||||||
|
*save_curtab = curtab;
|
||||||
|
goto_tabpage_tp(tp, FALSE, FALSE);
|
||||||
|
}
|
||||||
|
if (!win_valid(win))
|
||||||
|
{
|
||||||
|
# ifdef FEAT_AUTOCMD
|
||||||
|
unblock_autocmds();
|
||||||
|
# endif
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
curwin = win;
|
||||||
|
curbuf = curwin->w_buffer;
|
||||||
|
# endif
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Restore current tabpage and window saved by switch_win(), if still valid.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
restore_win(save_curwin, save_curtab)
|
||||||
|
win_T *save_curwin;
|
||||||
|
tabpage_T *save_curtab;
|
||||||
|
{
|
||||||
|
# ifdef FEAT_WINDOWS
|
||||||
|
if (save_curtab != NULL && valid_tabpage(save_curtab))
|
||||||
|
goto_tabpage_tp(save_curtab, FALSE, FALSE);
|
||||||
|
if (win_valid(save_curwin))
|
||||||
|
{
|
||||||
|
curwin = save_curwin;
|
||||||
|
curbuf = curwin->w_buffer;
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
# ifdef FEAT_AUTOCMD
|
||||||
|
unblock_autocmds();
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Make "buf" the current buffer. restore_buffer() MUST be called to undo.
|
||||||
|
* No autocommands will be executed. Use aucmd_prepbuf() if there are any.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
switch_buffer(save_curbuf, buf)
|
||||||
|
buf_T *buf;
|
||||||
|
buf_T **save_curbuf;
|
||||||
|
{
|
||||||
|
# ifdef FEAT_AUTOCMD
|
||||||
|
block_autocmds();
|
||||||
|
# endif
|
||||||
|
*save_curbuf = curbuf;
|
||||||
|
--curbuf->b_nwindows;
|
||||||
|
curbuf = buf;
|
||||||
|
curwin->w_buffer = buf;
|
||||||
|
++curbuf->b_nwindows;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Restore the current buffer after using switch_buffer().
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
restore_buffer(save_curbuf)
|
||||||
|
buf_T *save_curbuf;
|
||||||
|
{
|
||||||
|
# ifdef FEAT_AUTOCMD
|
||||||
|
unblock_autocmds();
|
||||||
|
# endif
|
||||||
|
/* Check for valid buffer, just in case. */
|
||||||
|
if (buf_valid(save_curbuf))
|
||||||
|
{
|
||||||
|
--curbuf->b_nwindows;
|
||||||
|
curwin->w_buffer = save_curbuf;
|
||||||
|
curbuf = save_curbuf;
|
||||||
|
++curbuf->b_nwindows;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if (defined(FEAT_GUI) && defined(FEAT_VERTSPLIT)) || defined(PROTO)
|
#if (defined(FEAT_GUI) && defined(FEAT_VERTSPLIT)) || defined(PROTO)
|
||||||
/*
|
/*
|
||||||
* Return TRUE if there is any vertically split window.
|
* Return TRUE if there is any vertically split window.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user