forked from aniani/vim
updated for version 7.3.964
Problem: Python: not so easy to access tab pages. Solution: Add window.tabpage, make window.number work with non-current tab pages. (ZyX)
This commit is contained in:
parent
105bc355a6
commit
cabf80ff2f
@ -435,6 +435,7 @@ Window attributes are:
|
|||||||
tab page).
|
tab page).
|
||||||
row, col (read-only) On-screen window position in display cells.
|
row, col (read-only) On-screen window position in display cells.
|
||||||
First position is zero.
|
First position is zero.
|
||||||
|
tabpage (read-only) Window tab page.
|
||||||
|
|
||||||
The height attribute is writable only if the screen is split horizontally.
|
The height attribute is writable only if the screen is split horizontally.
|
||||||
The width attribute is writable only if the screen is split vertically.
|
The width attribute is writable only if the screen is split vertically.
|
||||||
@ -490,7 +491,7 @@ if the `:py3` command is working: >
|
|||||||
< *:py3file*
|
< *:py3file*
|
||||||
The |:py3file| command works similar to |:pyfile|.
|
The |:py3file| command works similar to |:pyfile|.
|
||||||
|
|
||||||
*:py3do*
|
*:py3do* *E863*
|
||||||
:[range]py3do {body} Execute Python function "def _vim_pydo(line, linenr):
|
:[range]py3do {body} Execute Python function "def _vim_pydo(line, linenr):
|
||||||
{body}" for each line in the [range], with the
|
{body}" for each line in the [range], with the
|
||||||
function arguments being set to the text of each line
|
function arguments being set to the text of each line
|
||||||
|
@ -31,6 +31,9 @@ typedef int Py_ssize_t; /* Python 2.4 and earlier don't have this type. */
|
|||||||
|
|
||||||
static int ConvertFromPyObject(PyObject *, typval_T *);
|
static int ConvertFromPyObject(PyObject *, typval_T *);
|
||||||
static int _ConvertFromPyObject(PyObject *, typval_T *, PyObject *);
|
static int _ConvertFromPyObject(PyObject *, typval_T *, PyObject *);
|
||||||
|
static PyObject *WindowNew(win_T *, tabpage_T *);
|
||||||
|
static PyObject *BufferNew (buf_T *);
|
||||||
|
static PyObject *LineToString(const char *);
|
||||||
|
|
||||||
static PyInt RangeStart;
|
static PyInt RangeStart;
|
||||||
static PyInt RangeEnd;
|
static PyInt RangeEnd;
|
||||||
@ -1670,9 +1673,9 @@ TabPageAttr(TabPageObject *this, char *name)
|
|||||||
/* For current tab window.c does not bother to set or update tp_curwin
|
/* For current tab window.c does not bother to set or update tp_curwin
|
||||||
*/
|
*/
|
||||||
if (this->tab == curtab)
|
if (this->tab == curtab)
|
||||||
return WindowNew(curwin);
|
return WindowNew(curwin, curtab);
|
||||||
else
|
else
|
||||||
return WindowNew(this->tab->tp_curwin);
|
return WindowNew(this->tab->tp_curwin, this->tab);
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -1754,6 +1757,7 @@ typedef struct
|
|||||||
{
|
{
|
||||||
PyObject_HEAD
|
PyObject_HEAD
|
||||||
win_T *win;
|
win_T *win;
|
||||||
|
TabPageObject *tabObject;
|
||||||
} WindowObject;
|
} WindowObject;
|
||||||
|
|
||||||
static PyTypeObject WindowType;
|
static PyTypeObject WindowType;
|
||||||
@ -1771,7 +1775,7 @@ CheckWindow(WindowObject *this)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
WindowNew(win_T *win)
|
WindowNew(win_T *win, tabpage_T *tab)
|
||||||
{
|
{
|
||||||
/* We need to handle deletion of windows underneath us.
|
/* We need to handle deletion of windows underneath us.
|
||||||
* If we add a "w_python*_ref" field to the win_T structure,
|
* If we add a "w_python*_ref" field to the win_T structure,
|
||||||
@ -1804,6 +1808,8 @@ WindowNew(win_T *win)
|
|||||||
WIN_PYTHON_REF(win) = self;
|
WIN_PYTHON_REF(win) = self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self->tabObject = ((TabPageObject *)(TabPageNew(tab)));
|
||||||
|
|
||||||
return (PyObject *)(self);
|
return (PyObject *)(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1815,9 +1821,29 @@ WindowDestructor(PyObject *self)
|
|||||||
if (this->win && this->win != INVALID_WINDOW_VALUE)
|
if (this->win && this->win != INVALID_WINDOW_VALUE)
|
||||||
WIN_PYTHON_REF(this->win) = NULL;
|
WIN_PYTHON_REF(this->win) = NULL;
|
||||||
|
|
||||||
|
Py_DECREF(((PyObject *)(this->tabObject)));
|
||||||
|
|
||||||
DESTRUCTOR_FINISH(self);
|
DESTRUCTOR_FINISH(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static win_T *
|
||||||
|
get_firstwin(TabPageObject *tabObject)
|
||||||
|
{
|
||||||
|
if (tabObject)
|
||||||
|
{
|
||||||
|
if (CheckTabPage(tabObject))
|
||||||
|
return NULL;
|
||||||
|
/* For current tab window.c does not bother to set or update tp_firstwin
|
||||||
|
*/
|
||||||
|
else if (tabObject->tab == curtab)
|
||||||
|
return firstwin;
|
||||||
|
else
|
||||||
|
return tabObject->tab->tp_firstwin;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return firstwin;
|
||||||
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
WindowAttr(WindowObject *this, char *name)
|
WindowAttr(WindowObject *this, char *name)
|
||||||
{
|
{
|
||||||
@ -1847,10 +1873,20 @@ WindowAttr(WindowObject *this, char *name)
|
|||||||
return OptionsNew(SREQ_WIN, this->win, (checkfun) CheckWindow,
|
return OptionsNew(SREQ_WIN, this->win, (checkfun) CheckWindow,
|
||||||
(PyObject *) this);
|
(PyObject *) this);
|
||||||
else if (strcmp(name, "number") == 0)
|
else if (strcmp(name, "number") == 0)
|
||||||
return PyLong_FromLong((long) get_win_number(this->win, firstwin));
|
{
|
||||||
|
if (CheckTabPage(this->tabObject))
|
||||||
|
return NULL;
|
||||||
|
return PyLong_FromLong((long)
|
||||||
|
get_win_number(this->win, get_firstwin(this->tabObject)));
|
||||||
|
}
|
||||||
|
else if (strcmp(name, "tabpage") == 0)
|
||||||
|
{
|
||||||
|
Py_INCREF(this->tabObject);
|
||||||
|
return (PyObject *)(this->tabObject);
|
||||||
|
}
|
||||||
else if (strcmp(name,"__members__") == 0)
|
else if (strcmp(name,"__members__") == 0)
|
||||||
return Py_BuildValue("[ssssssss]", "buffer", "cursor", "height", "vars",
|
return Py_BuildValue("[sssssssss]", "buffer", "cursor", "height",
|
||||||
"options", "number", "row", "col");
|
"vars", "options", "number", "row", "col", "tabpage");
|
||||||
else
|
else
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -2016,31 +2052,13 @@ WinListDestructor(PyObject *self)
|
|||||||
DESTRUCTOR_FINISH(self);
|
DESTRUCTOR_FINISH(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
static win_T *
|
|
||||||
get_firstwin(WinListObject *this)
|
|
||||||
{
|
|
||||||
if (this->tabObject)
|
|
||||||
{
|
|
||||||
if (CheckTabPage(this->tabObject))
|
|
||||||
return NULL;
|
|
||||||
/* For current tab window.c does not bother to set or update tp_firstwin
|
|
||||||
*/
|
|
||||||
else if (this->tabObject->tab == curtab)
|
|
||||||
return firstwin;
|
|
||||||
else
|
|
||||||
return this->tabObject->tab->tp_firstwin;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return firstwin;
|
|
||||||
}
|
|
||||||
|
|
||||||
static PyInt
|
static PyInt
|
||||||
WinListLength(PyObject *self)
|
WinListLength(PyObject *self)
|
||||||
{
|
{
|
||||||
win_T *w;
|
win_T *w;
|
||||||
PyInt n = 0;
|
PyInt n = 0;
|
||||||
|
|
||||||
if (!(w = get_firstwin((WinListObject *)(self))))
|
if (!(w = get_firstwin(((WinListObject *)(self))->tabObject)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
while (w != NULL)
|
while (w != NULL)
|
||||||
@ -2055,14 +2073,15 @@ WinListLength(PyObject *self)
|
|||||||
static PyObject *
|
static PyObject *
|
||||||
WinListItem(PyObject *self, PyInt n)
|
WinListItem(PyObject *self, PyInt n)
|
||||||
{
|
{
|
||||||
|
WinListObject *this = ((WinListObject *)(self));
|
||||||
win_T *w;
|
win_T *w;
|
||||||
|
|
||||||
if (!(w = get_firstwin((WinListObject *)(self))))
|
if (!(w = get_firstwin(this->tabObject)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
for (; w != NULL; w = W_NEXT(w), --n)
|
for (; w != NULL; w = W_NEXT(w), --n)
|
||||||
if (n == 0)
|
if (n == 0)
|
||||||
return WindowNew(w);
|
return WindowNew(w, this->tabObject? this->tabObject->tab: curtab);
|
||||||
|
|
||||||
PyErr_SetString(PyExc_IndexError, _("no such window"));
|
PyErr_SetString(PyExc_IndexError, _("no such window"));
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -3227,7 +3246,7 @@ CurrentGetattr(PyObject *self UNUSED, char *name)
|
|||||||
if (strcmp(name, "buffer") == 0)
|
if (strcmp(name, "buffer") == 0)
|
||||||
return (PyObject *)BufferNew(curbuf);
|
return (PyObject *)BufferNew(curbuf);
|
||||||
else if (strcmp(name, "window") == 0)
|
else if (strcmp(name, "window") == 0)
|
||||||
return (PyObject *)WindowNew(curwin);
|
return (PyObject *)WindowNew(curwin, curtab);
|
||||||
else if (strcmp(name, "tabpage") == 0)
|
else if (strcmp(name, "tabpage") == 0)
|
||||||
return (PyObject *)TabPageNew(curtab);
|
return (PyObject *)TabPageNew(curtab);
|
||||||
else if (strcmp(name, "line") == 0)
|
else if (strcmp(name, "line") == 0)
|
||||||
|
@ -610,11 +610,6 @@ get_exceptions(void)
|
|||||||
}
|
}
|
||||||
#endif /* DYNAMIC_PYTHON */
|
#endif /* DYNAMIC_PYTHON */
|
||||||
|
|
||||||
static PyObject *BufferNew (buf_T *);
|
|
||||||
static PyObject *WindowNew(win_T *);
|
|
||||||
static PyObject *DictionaryNew(dict_T *);
|
|
||||||
static PyObject *LineToString(const char *);
|
|
||||||
|
|
||||||
static int initialised = 0;
|
static int initialised = 0;
|
||||||
#define PYINITIALISED initialised
|
#define PYINITIALISED initialised
|
||||||
|
|
||||||
|
@ -611,9 +611,6 @@ get_py3_exceptions()
|
|||||||
}
|
}
|
||||||
#endif /* DYNAMIC_PYTHON3 */
|
#endif /* DYNAMIC_PYTHON3 */
|
||||||
|
|
||||||
static PyObject *BufferNew (buf_T *);
|
|
||||||
static PyObject *WindowNew(win_T *);
|
|
||||||
static PyObject *LineToString(const char *);
|
|
||||||
static PyObject *BufferDir(PyObject *, PyObject *);
|
static PyObject *BufferDir(PyObject *, PyObject *);
|
||||||
|
|
||||||
static int py3initialised = 0;
|
static int py3initialised = 0;
|
||||||
|
@ -333,14 +333,14 @@ 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 (954, 0)
|
<window object (unknown)>(1): 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)>(1): displays buffer <buffer 0>; cursor is at (1, 0)
|
||||||
<tabpage 2>(3): 2 windows, current is <window object (unknown)>
|
<tabpage 2>(3): 2 windows, current is <window object (unknown)>
|
||||||
Windows:
|
Windows:
|
||||||
<window object (unknown)>(0): displays buffer <buffer a.1>; cursor is at (1, 0)
|
<window object (unknown)>(1): displays buffer <buffer a.1>; cursor is at (1, 0)
|
||||||
<window object (unknown)>(0): displays buffer <buffer 1>; cursor is at (1, 0)
|
<window object (unknown)>(2): displays buffer <buffer 1>; cursor is at (1, 0)
|
||||||
<tabpage 3>(4): 4 windows, current is <window 0>
|
<tabpage 3>(4): 4 windows, current is <window 0>
|
||||||
Windows:
|
Windows:
|
||||||
<window 0>(1): displays buffer <buffer c.2>; cursor is at (1, 0)
|
<window 0>(1): displays buffer <buffer c.2>; cursor is at (1, 0)
|
||||||
|
@ -322,14 +322,14 @@ 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 test87.in>; cursor is at (930, 0)
|
<window object (unknown)>(1): displays buffer <buffer test87.in>; cursor is at (930, 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)>(1): displays buffer <buffer 0>; cursor is at (1, 0)
|
||||||
<tabpage 2>(3): 2 windows, current is <window object (unknown)>
|
<tabpage 2>(3): 2 windows, current is <window object (unknown)>
|
||||||
Windows:
|
Windows:
|
||||||
<window object (unknown)>(0): displays buffer <buffer a.1>; cursor is at (1, 0)
|
<window object (unknown)>(1): displays buffer <buffer a.1>; cursor is at (1, 0)
|
||||||
<window object (unknown)>(0): displays buffer <buffer 1>; cursor is at (1, 0)
|
<window object (unknown)>(2): displays buffer <buffer 1>; cursor is at (1, 0)
|
||||||
<tabpage 3>(4): 4 windows, current is <window 0>
|
<tabpage 3>(4): 4 windows, current is <window 0>
|
||||||
Windows:
|
Windows:
|
||||||
<window 0>(1): displays buffer <buffer c.2>; cursor is at (1, 0)
|
<window 0>(1): displays buffer <buffer c.2>; 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 */
|
||||||
|
/**/
|
||||||
|
964,
|
||||||
/**/
|
/**/
|
||||||
963,
|
963,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user