# HG changeset patch
# User ZyX <[email protected]>
# Date 1368673074 -14400
# Branch python-extended-2
# Node ID 02c4f613343a69eeba16a8a4742f5a9dee269861
# Parent 9ea73172864c892283abb0735b427cba5485820c
Record tabpage in window
Needed to report correct window.number for non-current-tabpage windows
For backwards compatibility repr() result does not change.
diff -r 9ea73172864c -r 02c4f613343a runtime/doc/if_pyth.txt
--- a/runtime/doc/if_pyth.txt Thu May 16 05:49:26 2013 +0400
+++ b/runtime/doc/if_pyth.txt Thu May 16 06:57:54 2013 +0400
@@ -433,8 +433,9 @@
This is zero in case it cannot be determined
(e.g. when the window object belongs to other
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.
+ tabpage (read-only) Window tab page.
The height attribute is writable only if the screen is split horizontally.
The width attribute is writable only if the screen is split vertically.
diff -r 9ea73172864c -r 02c4f613343a src/if_py_both.h
--- a/src/if_py_both.h Thu May 16 05:49:26 2013 +0400
+++ b/src/if_py_both.h Thu May 16 06:57:54 2013 +0400
@@ -31,6 +31,9 @@
static int ConvertFromPyObject(PyObject *, typval_T *);
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 RangeEnd;
@@ -1670,9 +1673,9 @@
/* For current tab window.c does not bother to set or update tp_curwin
*/
if (this->tab == curtab)
- return WindowNew(curwin);
+ return WindowNew(curwin, curtab);
else
- return WindowNew(this->tab->tp_curwin);
+ return WindowNew(this->tab->tp_curwin, this->tab);
}
return NULL;
}
@@ -1754,6 +1757,7 @@
{
PyObject_HEAD
win_T *win;
+ TabPageObject *tabObject;
} WindowObject;
static PyTypeObject WindowType;
@@ -1771,7 +1775,7 @@
}
static PyObject *
-WindowNew(win_T *win)
+WindowNew(win_T *win, tabpage_T *tab)
{
/* We need to handle deletion of windows underneath us.
* If we add a "w_python*_ref" field to the win_T structure,
@@ -1804,6 +1808,8 @@
WIN_PYTHON_REF(win) = self;
}
+ self->tabObject = ((TabPageObject *)(TabPageNew(tab)));
+
return (PyObject *)(self);
}
@@ -1815,9 +1821,29 @@
if (this->win && this->win != INVALID_WINDOW_VALUE)
WIN_PYTHON_REF(this->win) = NULL;
+ Py_DECREF(((PyObject *)(this->tabObject)));
+
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 *
WindowAttr(WindowObject *this, char *name)
{
@@ -1847,10 +1873,20 @@
return OptionsNew(SREQ_WIN, this->win, (checkfun) CheckWindow,
(PyObject *) this);
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)
- return Py_BuildValue("[ssssssss]", "buffer", "cursor", "height", "vars",
- "options", "number", "row", "col");
+ return Py_BuildValue("[sssssssss]", "buffer", "cursor", "height",
+ "vars", "options", "number", "row", "col", "tabpage");
else
return NULL;
}
@@ -2016,31 +2052,13 @@
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
WinListLength(PyObject *self)
{
win_T *w;
PyInt n = 0;
- if (!(w = get_firstwin((WinListObject *)(self))))
+ if (!(w = get_firstwin(((WinListObject *)(self))->tabObject)))
return -1;
while (w != NULL)
@@ -2055,14 +2073,15 @@
static PyObject *
WinListItem(PyObject *self, PyInt n)
{
+ WinListObject *this = ((WinListObject *)(self));
win_T *w;
- if (!(w = get_firstwin((WinListObject *)(self))))
+ if (!(w = get_firstwin(this->tabObject)))
return NULL;
for (; w != NULL; w = W_NEXT(w), --n)
if (n == 0)
- return WindowNew(w);
+ return WindowNew(w, this->tabObject? this->tabObject->tab: curtab);
PyErr_SetString(PyExc_IndexError, _("no such window"));
return NULL;
@@ -3231,7 +3250,7 @@
if (strcmp(name, "buffer") == 0)
return (PyObject *)BufferNew(curbuf);
else if (strcmp(name, "window") == 0)
- return (PyObject *)WindowNew(curwin);
+ return (PyObject *)WindowNew(curwin, curtab);
else if (strcmp(name, "tabpage") == 0)
return (PyObject *)TabPageNew(curtab);
else if (strcmp(name, "line") == 0)
diff -r 9ea73172864c -r 02c4f613343a src/if_python.c
--- a/src/if_python.c Thu May 16 05:49:26 2013 +0400
+++ b/src/if_python.c Thu May 16 06:57:54 2013 +0400
@@ -610,11 +610,6 @@
}
#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;
#define PYINITIALISED initialised
diff -r 9ea73172864c -r 02c4f613343a src/if_python3.c
--- a/src/if_python3.c Thu May 16 05:49:26 2013 +0400
+++ b/src/if_python3.c Thu May 16 06:57:54 2013 +0400
@@ -611,9 +611,6 @@
}
#endif /* DYNAMIC_PYTHON3 */
-static PyObject *BufferNew (buf_T *);
-static PyObject *WindowNew(win_T *);
-static PyObject *LineToString(const char *);
static PyObject *BufferDir(PyObject *, PyObject *);
static int py3initialised = 0;
diff -r 9ea73172864c -r 02c4f613343a src/testdir/test86.ok
--- a/src/testdir/test86.ok Thu May 16 05:49:26 2013 +0400
+++ b/src/testdir/test86.ok Thu May 16 06:57:54 2013 +0400
@@ -333,14 +333,14 @@
Current tab pages:
<tabpage 0>(1): 1 windows, current is <window object (unknown)>
Windows:
- <window object (unknown)>(0): displays buffer <buffer test86.in>; cursor
is at (955, 0)
+ <window object (unknown)>(1): displays buffer <buffer test86.in>; cursor
is at (955, 0)
<tabpage 1>(2): 1 windows, current is <window object (unknown)>
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)>
Windows:
- <window object (unknown)>(0): 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)>(1): displays buffer <buffer a.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>
Windows:
<window 0>(1): displays buffer <buffer c.2>; cursor is at (1, 0)
diff -r 9ea73172864c -r 02c4f613343a src/testdir/test87.ok
--- a/src/testdir/test87.ok Thu May 16 05:49:26 2013 +0400
+++ b/src/testdir/test87.ok Thu May 16 06:57:54 2013 +0400
@@ -322,14 +322,14 @@
Current tab pages:
<tabpage 0>(1): 1 windows, current is <window object (unknown)>
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)>
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)>
Windows:
- <window object (unknown)>(0): 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)>(1): displays buffer <buffer a.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>
Windows:
<window 0>(1): displays buffer <buffer c.2>; cursor is at (1, 0)
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.
diff -cr vim.9ea73172864c/runtime/doc/if_pyth.txt vim.02c4f613343a/runtime/doc/if_pyth.txt
*** vim.9ea73172864c/runtime/doc/if_pyth.txt 2013-05-16 07:05:53.356022399 +0400
--- vim.02c4f613343a/runtime/doc/if_pyth.txt 2013-05-16 07:05:53.371022243 +0400
***************
*** 433,440 ****
This is zero in case it cannot be determined
(e.g. when the window object belongs to other
tab page).
! row, col (read-only) On-screen window position in display cells.
First position is zero.
The height attribute is writable only if the screen is split horizontally.
The width attribute is writable only if the screen is split vertically.
--- 433,441 ----
This is zero in case it cannot be determined
(e.g. when the window object belongs to other
tab page).
! row, col (read-only) On-screen window position in display cells.
First position is zero.
+ tabpage (read-only) Window tab page.
The height attribute is writable only if the screen is split horizontally.
The width attribute is writable only if the screen is split vertically.
diff -cr vim.9ea73172864c/src/if_py_both.h vim.02c4f613343a/src/if_py_both.h
*** vim.9ea73172864c/src/if_py_both.h 2013-05-16 07:05:53.351022450 +0400
--- vim.02c4f613343a/src/if_py_both.h 2013-05-16 07:05:53.365022306 +0400
***************
*** 31,36 ****
--- 31,39 ----
static int ConvertFromPyObject(PyObject *, typval_T *);
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 RangeEnd;
***************
*** 1670,1678 ****
/* For current tab window.c does not bother to set or update tp_curwin
*/
if (this->tab == curtab)
! return WindowNew(curwin);
else
! return WindowNew(this->tab->tp_curwin);
}
return NULL;
}
--- 1673,1681 ----
/* For current tab window.c does not bother to set or update tp_curwin
*/
if (this->tab == curtab)
! return WindowNew(curwin, curtab);
else
! return WindowNew(this->tab->tp_curwin, this->tab);
}
return NULL;
}
***************
*** 1754,1759 ****
--- 1757,1763 ----
{
PyObject_HEAD
win_T *win;
+ TabPageObject *tabObject;
} WindowObject;
static PyTypeObject WindowType;
***************
*** 1771,1777 ****
}
static PyObject *
! WindowNew(win_T *win)
{
/* We need to handle deletion of windows underneath us.
* If we add a "w_python*_ref" field to the win_T structure,
--- 1775,1781 ----
}
static PyObject *
! WindowNew(win_T *win, tabpage_T *tab)
{
/* We need to handle deletion of windows underneath us.
* If we add a "w_python*_ref" field to the win_T structure,
***************
*** 1804,1809 ****
--- 1808,1815 ----
WIN_PYTHON_REF(win) = self;
}
+ self->tabObject = ((TabPageObject *)(TabPageNew(tab)));
+
return (PyObject *)(self);
}
***************
*** 1815,1823 ****
--- 1821,1849 ----
if (this->win && this->win != INVALID_WINDOW_VALUE)
WIN_PYTHON_REF(this->win) = NULL;
+ Py_DECREF(((PyObject *)(this->tabObject)));
+
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 *
WindowAttr(WindowObject *this, char *name)
{
***************
*** 1847,1856 ****
return OptionsNew(SREQ_WIN, this->win, (checkfun) CheckWindow,
(PyObject *) this);
else if (strcmp(name, "number") == 0)
! return PyLong_FromLong((long) get_win_number(this->win, firstwin));
else if (strcmp(name,"__members__") == 0)
! return Py_BuildValue("[ssssssss]", "buffer", "cursor", "height", "vars",
! "options", "number", "row", "col");
else
return NULL;
}
--- 1873,1892 ----
return OptionsNew(SREQ_WIN, this->win, (checkfun) CheckWindow,
(PyObject *) this);
else if (strcmp(name, "number") == 0)
! {
! 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)
! return Py_BuildValue("[sssssssss]", "buffer", "cursor", "height",
! "vars", "options", "number", "row", "col", "tabpage");
else
return NULL;
}
***************
*** 2016,2046 ****
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
WinListLength(PyObject *self)
{
win_T *w;
PyInt n = 0;
! if (!(w = get_firstwin((WinListObject *)(self))))
return -1;
while (w != NULL)
--- 2052,2064 ----
DESTRUCTOR_FINISH(self);
}
static PyInt
WinListLength(PyObject *self)
{
win_T *w;
PyInt n = 0;
! if (!(w = get_firstwin(((WinListObject *)(self))->tabObject)))
return -1;
while (w != NULL)
***************
*** 2055,2068 ****
static PyObject *
WinListItem(PyObject *self, PyInt n)
{
win_T *w;
! if (!(w = get_firstwin((WinListObject *)(self))))
return NULL;
for (; w != NULL; w = W_NEXT(w), --n)
if (n == 0)
! return WindowNew(w);
PyErr_SetString(PyExc_IndexError, _("no such window"));
return NULL;
--- 2073,2087 ----
static PyObject *
WinListItem(PyObject *self, PyInt n)
{
+ WinListObject *this = ((WinListObject *)(self));
win_T *w;
! if (!(w = get_firstwin(this->tabObject)))
return NULL;
for (; w != NULL; w = W_NEXT(w), --n)
if (n == 0)
! return WindowNew(w, this->tabObject? this->tabObject->tab: curtab);
PyErr_SetString(PyExc_IndexError, _("no such window"));
return NULL;
***************
*** 3231,3237 ****
if (strcmp(name, "buffer") == 0)
return (PyObject *)BufferNew(curbuf);
else if (strcmp(name, "window") == 0)
! return (PyObject *)WindowNew(curwin);
else if (strcmp(name, "tabpage") == 0)
return (PyObject *)TabPageNew(curtab);
else if (strcmp(name, "line") == 0)
--- 3250,3256 ----
if (strcmp(name, "buffer") == 0)
return (PyObject *)BufferNew(curbuf);
else if (strcmp(name, "window") == 0)
! return (PyObject *)WindowNew(curwin, curtab);
else if (strcmp(name, "tabpage") == 0)
return (PyObject *)TabPageNew(curtab);
else if (strcmp(name, "line") == 0)
diff -cr vim.9ea73172864c/src/if_python3.c vim.02c4f613343a/src/if_python3.c
*** vim.9ea73172864c/src/if_python3.c 2013-05-16 07:05:53.354022419 +0400
--- vim.02c4f613343a/src/if_python3.c 2013-05-16 07:05:53.369022264 +0400
***************
*** 611,619 ****
}
#endif /* DYNAMIC_PYTHON3 */
- static PyObject *BufferNew (buf_T *);
- static PyObject *WindowNew(win_T *);
- static PyObject *LineToString(const char *);
static PyObject *BufferDir(PyObject *, PyObject *);
static int py3initialised = 0;
--- 611,616 ----
diff -cr vim.9ea73172864c/src/if_python.c vim.02c4f613343a/src/if_python.c
*** vim.9ea73172864c/src/if_python.c 2013-05-16 07:05:53.359022368 +0400
--- vim.02c4f613343a/src/if_python.c 2013-05-16 07:05:53.374022212 +0400
***************
*** 610,620 ****
}
#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;
#define PYINITIALISED initialised
--- 610,615 ----
diff -cr vim.9ea73172864c/src/testdir/test86.ok vim.02c4f613343a/src/testdir/test86.ok
*** vim.9ea73172864c/src/testdir/test86.ok 2013-05-16 07:05:53.352022440 +0400
--- vim.02c4f613343a/src/testdir/test86.ok 2013-05-16 07:05:53.366022295 +0400
***************
*** 333,346 ****
Current tab pages:
<tabpage 0>(1): 1 windows, current is <window object (unknown)>
Windows:
! <window object (unknown)>(0): displays buffer <buffer test86.in>; cursor is at (955, 0)
<tabpage 1>(2): 1 windows, current is <window object (unknown)>
Windows:
! <window object (unknown)>(0): displays buffer <buffer 0>; cursor is at (1, 0)
<tabpage 2>(3): 2 windows, current is <window object (unknown)>
Windows:
! <window object (unknown)>(0): displays buffer <buffer a.1>; cursor is at (1, 0)
! <window object (unknown)>(0): displays buffer <buffer 1>; cursor is at (1, 0)
<tabpage 3>(4): 4 windows, current is <window 0>
Windows:
<window 0>(1): displays buffer <buffer c.2>; cursor is at (1, 0)
--- 333,346 ----
Current tab pages:
<tabpage 0>(1): 1 windows, current is <window object (unknown)>
Windows:
! <window object (unknown)>(1): displays buffer <buffer test86.in>; cursor is at (955, 0)
<tabpage 1>(2): 1 windows, current is <window object (unknown)>
Windows:
! <window object (unknown)>(1): displays buffer <buffer 0>; cursor is at (1, 0)
<tabpage 2>(3): 2 windows, current is <window object (unknown)>
Windows:
! <window object (unknown)>(1): displays buffer <buffer a.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>
Windows:
<window 0>(1): displays buffer <buffer c.2>; cursor is at (1, 0)
diff -cr vim.9ea73172864c/src/testdir/test87.ok vim.02c4f613343a/src/testdir/test87.ok
*** vim.9ea73172864c/src/testdir/test87.ok 2013-05-16 07:05:53.348022482 +0400
--- vim.02c4f613343a/src/testdir/test87.ok 2013-05-16 07:05:53.362022337 +0400
***************
*** 322,335 ****
Current tab pages:
<tabpage 0>(1): 1 windows, current is <window object (unknown)>
Windows:
! <window object (unknown)>(0): displays buffer <buffer test87.in>; cursor is at (930, 0)
<tabpage 1>(2): 1 windows, current is <window object (unknown)>
Windows:
! <window object (unknown)>(0): displays buffer <buffer 0>; cursor is at (1, 0)
<tabpage 2>(3): 2 windows, current is <window object (unknown)>
Windows:
! <window object (unknown)>(0): displays buffer <buffer a.1>; cursor is at (1, 0)
! <window object (unknown)>(0): displays buffer <buffer 1>; cursor is at (1, 0)
<tabpage 3>(4): 4 windows, current is <window 0>
Windows:
<window 0>(1): displays buffer <buffer c.2>; cursor is at (1, 0)
--- 322,335 ----
Current tab pages:
<tabpage 0>(1): 1 windows, current is <window object (unknown)>
Windows:
! <window object (unknown)>(1): displays buffer <buffer test87.in>; cursor is at (930, 0)
<tabpage 1>(2): 1 windows, current is <window object (unknown)>
Windows:
! <window object (unknown)>(1): displays buffer <buffer 0>; cursor is at (1, 0)
<tabpage 2>(3): 2 windows, current is <window object (unknown)>
Windows:
! <window object (unknown)>(1): displays buffer <buffer a.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>
Windows:
<window 0>(1): displays buffer <buffer c.2>; cursor is at (1, 0)