Karsten Hopp 88a91d
To: vim_dev@googlegroups.com
Karsten Hopp 88a91d
Subject: Patch 7.3.949
Karsten Hopp 88a91d
Fcc: outbox
Karsten Hopp 88a91d
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 88a91d
Mime-Version: 1.0
Karsten Hopp 88a91d
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 88a91d
Content-Transfer-Encoding: 8bit
Karsten Hopp 88a91d
------------
Karsten Hopp 88a91d
Karsten Hopp 88a91d
Patch 7.3.949
Karsten Hopp 88a91d
Problem:    Python: no easy access to tabpages.
Karsten Hopp 88a91d
Solution:   Add vim.tabpages and vim.current.tabpage. (ZyX)
Karsten Hopp 88a91d
Files:	    runtime/doc/if_pyth.txt, src/if_py_both.h, src/if_python3.c,
Karsten Hopp 88a91d
	    src/if_python.c, src/proto/if_python3.pro,
Karsten Hopp 88a91d
	    src/proto/if_python.pro, src/proto/window.pro, src/structs.h,
Karsten Hopp 88a91d
	    src/window.c
Karsten Hopp 88a91d
Karsten Hopp 88a91d
Karsten Hopp 88a91d
*** ../vim-7.3.948/runtime/doc/if_pyth.txt	2013-05-15 14:39:47.000000000 +0200
Karsten Hopp 88a91d
--- runtime/doc/if_pyth.txt	2013-05-15 15:05:04.000000000 +0200
Karsten Hopp 88a91d
***************
Karsten Hopp 88a91d
*** 223,228 ****
Karsten Hopp 88a91d
--- 223,242 ----
Karsten Hopp 88a91d
  	    :py w in vim.windows	# Membership test
Karsten Hopp 88a91d
  	    :py n = len(vim.windows)	# Number of elements
Karsten Hopp 88a91d
  	    :py for w in vim.windows:	# Sequential access
Karsten Hopp 88a91d
+ <	Note: vim.windows object always accesses current tab page,. 
Karsten Hopp 88a91d
+ 	|python-tabpage|.windows objects are bound to parent |python-tabpage| 
Karsten Hopp 88a91d
+ 	object and always use windows from that tab page (or throw vim.error 
Karsten Hopp 88a91d
+ 	in case tab page was deleted). You can keep a reference to both 
Karsten Hopp 88a91d
+ 	without keeping a reference to vim module object or |python-tabpage|, 
Karsten Hopp 88a91d
+ 	they will not loose their properties in this case.
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
+ vim.tabpages						*python-tabpages*
Karsten Hopp 88a91d
+ 	A sequence object providing access to the list of vim tab pages. The 
Karsten Hopp 88a91d
+ 	object supports the following operations: >
Karsten Hopp 88a91d
+ 	    :py t = vim.tabpages[i]	# Indexing (read-only)
Karsten Hopp 88a91d
+ 	    :py t in vim.tabpages	# Membership test
Karsten Hopp 88a91d
+ 	    :py n = len(vim.tabpages)	# Number of elements
Karsten Hopp 88a91d
+ 	    :py for t in vim.tabpages:	# Sequential access
Karsten Hopp 88a91d
  <
Karsten Hopp 88a91d
  vim.current						*python-current*
Karsten Hopp 88a91d
  	An object providing access (via specific attributes) to various
Karsten Hopp 88a91d
***************
Karsten Hopp 88a91d
*** 230,235 ****
Karsten Hopp 88a91d
--- 244,250 ----
Karsten Hopp 88a91d
  		vim.current.line	The current line (RW)		String
Karsten Hopp 88a91d
  		vim.current.buffer	The current buffer (RO)		Buffer
Karsten Hopp 88a91d
  		vim.current.window	The current window (RO)		Window
Karsten Hopp 88a91d
+ 		vim.current.tabpage	The current tab page (RO)	TabPage
Karsten Hopp 88a91d
  		vim.current.range	The current line range (RO)	Range
Karsten Hopp 88a91d
  
Karsten Hopp 88a91d
  	The last case deserves a little explanation.  When the :python or
Karsten Hopp 88a91d
***************
Karsten Hopp 88a91d
*** 375,380 ****
Karsten Hopp 88a91d
--- 390,397 ----
Karsten Hopp 88a91d
  Window objects represent vim windows.  You can obtain them in a number of ways:
Karsten Hopp 88a91d
  	- via vim.current.window (|python-current|)
Karsten Hopp 88a91d
  	- from indexing vim.windows (|python-windows|)
Karsten Hopp 88a91d
+ 	- from indexing "windows" attribute of a tab page (|python-tabpage|)
Karsten Hopp 88a91d
+ 	- from the "window" attribute of a tab page (|python-tabpage|)
Karsten Hopp 88a91d
  
Karsten Hopp 88a91d
  You can manipulate window objects only through their attributes.  They have no
Karsten Hopp 88a91d
  methods, and no sequence or other interface.
Karsten Hopp 88a91d
***************
Karsten Hopp 88a91d
*** 407,412 ****
Karsten Hopp 88a91d
--- 424,447 ----
Karsten Hopp 88a91d
  The width attribute is writable only if the screen is split vertically.
Karsten Hopp 88a91d
  
Karsten Hopp 88a91d
  ==============================================================================
Karsten Hopp 88a91d
+ 6. Tab page objects					*python-tabpage*
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
+ Tab page objects represent vim tab pages. You can obtain them in a number of 
Karsten Hopp 88a91d
+ ways:
Karsten Hopp 88a91d
+ 	- via vim.current.tabpage (|python-current|)
Karsten Hopp 88a91d
+ 	- from indexing vim.tabpages (|python-tabpages|)
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
+ You can use this object to access tab page windows. They have no methods and 
Karsten Hopp 88a91d
+ no sequence or other interfaces.
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
+ Tab page attributes are:
Karsten Hopp 88a91d
+ 	number		The tab page number like the one returned by 
Karsten Hopp 88a91d
+ 			|tabpagenr()|.
Karsten Hopp 88a91d
+ 	windows		Like |python-windows|, but for current tab page.
Karsten Hopp 88a91d
+ 	vars		The tab page |t:| variables.
Karsten Hopp 88a91d
+ 	window		Current tabpage window.
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
+ ==============================================================================
Karsten Hopp 88a91d
  6. pyeval() and py3eval() Vim functions			*python-pyeval*
Karsten Hopp 88a91d
  
Karsten Hopp 88a91d
  To facilitate bi-directional interface, you can use |pyeval()| and |py3eval()| 
Karsten Hopp 88a91d
*** ../vim-7.3.948/src/if_py_both.h	2013-05-15 14:51:31.000000000 +0200
Karsten Hopp 88a91d
--- src/if_py_both.h	2013-05-15 15:10:16.000000000 +0200
Karsten Hopp 88a91d
***************
Karsten Hopp 88a91d
*** 27,32 ****
Karsten Hopp 88a91d
--- 27,33 ----
Karsten Hopp 88a91d
  
Karsten Hopp 88a91d
  #define INVALID_BUFFER_VALUE ((buf_T *)(-1))
Karsten Hopp 88a91d
  #define INVALID_WINDOW_VALUE ((win_T *)(-1))
Karsten Hopp 88a91d
+ #define INVALID_TABPAGE_VALUE ((tabpage_T *)(-1))
Karsten Hopp 88a91d
  
Karsten Hopp 88a91d
  static int ConvertFromPyObject(PyObject *, typval_T *);
Karsten Hopp 88a91d
  static int _ConvertFromPyObject(PyObject *, typval_T *, PyObject *);
Karsten Hopp 88a91d
***************
Karsten Hopp 88a91d
*** 1579,1584 ****
Karsten Hopp 88a91d
--- 1580,1734 ----
Karsten Hopp 88a91d
      (objobjargproc) OptionsAssItem,
Karsten Hopp 88a91d
  };
Karsten Hopp 88a91d
  
Karsten Hopp 88a91d
+ /* Tabpage object
Karsten Hopp 88a91d
+  */
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
+ typedef struct
Karsten Hopp 88a91d
+ {
Karsten Hopp 88a91d
+     PyObject_HEAD
Karsten Hopp 88a91d
+     tabpage_T	*tab;
Karsten Hopp 88a91d
+ } TabPageObject;
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
+ static PyObject *WinListNew(TabPageObject *tabObject);
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
+ static PyTypeObject TabPageType;
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
+     static int
Karsten Hopp 88a91d
+ CheckTabPage(TabPageObject *this)
Karsten Hopp 88a91d
+ {
Karsten Hopp 88a91d
+     if (this->tab == INVALID_TABPAGE_VALUE)
Karsten Hopp 88a91d
+     {
Karsten Hopp 88a91d
+ 	PyErr_SetVim(_("attempt to refer to deleted tab page"));
Karsten Hopp 88a91d
+ 	return -1;
Karsten Hopp 88a91d
+     }
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
+     return 0;
Karsten Hopp 88a91d
+ }
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
+     static PyObject *
Karsten Hopp 88a91d
+ TabPageNew(tabpage_T *tab)
Karsten Hopp 88a91d
+ {
Karsten Hopp 88a91d
+     TabPageObject *self;
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
+     if (TAB_PYTHON_REF(tab))
Karsten Hopp 88a91d
+     {
Karsten Hopp 88a91d
+ 	self = TAB_PYTHON_REF(tab);
Karsten Hopp 88a91d
+ 	Py_INCREF(self);
Karsten Hopp 88a91d
+     }
Karsten Hopp 88a91d
+     else
Karsten Hopp 88a91d
+     {
Karsten Hopp 88a91d
+ 	self = PyObject_NEW(TabPageObject, &TabPageType);
Karsten Hopp 88a91d
+ 	if (self == NULL)
Karsten Hopp 88a91d
+ 	    return NULL;
Karsten Hopp 88a91d
+ 	self->tab = tab;
Karsten Hopp 88a91d
+ 	TAB_PYTHON_REF(tab) = self;
Karsten Hopp 88a91d
+     }
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
+     return (PyObject *)(self);
Karsten Hopp 88a91d
+ }
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
+     static void
Karsten Hopp 88a91d
+ TabPageDestructor(PyObject *self)
Karsten Hopp 88a91d
+ {
Karsten Hopp 88a91d
+     TabPageObject *this = (TabPageObject *)(self);
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
+     if (this->tab && this->tab != INVALID_TABPAGE_VALUE)
Karsten Hopp 88a91d
+ 	TAB_PYTHON_REF(this->tab) = NULL;
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
+     DESTRUCTOR_FINISH(self);
Karsten Hopp 88a91d
+ }
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
+     static PyObject *
Karsten Hopp 88a91d
+ TabPageAttr(TabPageObject *this, char *name)
Karsten Hopp 88a91d
+ {
Karsten Hopp 88a91d
+     if (strcmp(name, "windows") == 0)
Karsten Hopp 88a91d
+ 	return WinListNew(this);
Karsten Hopp 88a91d
+     else if (strcmp(name, "number") == 0)
Karsten Hopp 88a91d
+ 	return PyLong_FromLong((long) get_tab_number(this->tab));
Karsten Hopp 88a91d
+     else if (strcmp(name, "vars") == 0)
Karsten Hopp 88a91d
+ 	return DictionaryNew(this->tab->tp_vars);
Karsten Hopp 88a91d
+     else if (strcmp(name, "window") == 0)
Karsten Hopp 88a91d
+     {
Karsten Hopp 88a91d
+ 	/* For current tab window.c does not bother to set or update tp_curwin
Karsten Hopp 88a91d
+ 	 */
Karsten Hopp 88a91d
+ 	if (this->tab == curtab)
Karsten Hopp 88a91d
+ 	    return WindowNew(curwin);
Karsten Hopp 88a91d
+ 	else
Karsten Hopp 88a91d
+ 	    return WindowNew(this->tab->tp_curwin);
Karsten Hopp 88a91d
+     }
Karsten Hopp 88a91d
+     return NULL;
Karsten Hopp 88a91d
+ }
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
+     static PyObject *
Karsten Hopp 88a91d
+ TabPageRepr(PyObject *self)
Karsten Hopp 88a91d
+ {
Karsten Hopp 88a91d
+     static char repr[100];
Karsten Hopp 88a91d
+     TabPageObject *this = (TabPageObject *)(self);
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
+     if (this->tab == INVALID_TABPAGE_VALUE)
Karsten Hopp 88a91d
+     {
Karsten Hopp 88a91d
+ 	vim_snprintf(repr, 100, _("<tabpage object (deleted) at %p>"), (self));
Karsten Hopp 88a91d
+ 	return PyString_FromString(repr);
Karsten Hopp 88a91d
+     }
Karsten Hopp 88a91d
+     else
Karsten Hopp 88a91d
+     {
Karsten Hopp 88a91d
+ 	int	t = get_tab_number(this->tab);
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
+ 	if (t == 0)
Karsten Hopp 88a91d
+ 	    vim_snprintf(repr, 100, _("<tabpage object (unknown) at %p>"),
Karsten Hopp 88a91d
+ 								      (self));
Karsten Hopp 88a91d
+ 	else
Karsten Hopp 88a91d
+ 	    vim_snprintf(repr, 100, _("<tabpage %d>"), t - 1);
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
+ 	return PyString_FromString(repr);
Karsten Hopp 88a91d
+     }
Karsten Hopp 88a91d
+ }
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
+ static struct PyMethodDef TabPageMethods[] = {
Karsten Hopp 88a91d
+     /* name,	    function,		calling,    documentation */
Karsten Hopp 88a91d
+     { NULL,	    NULL,		0,	    NULL }
Karsten Hopp 88a91d
+ };
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
+ /*
Karsten Hopp 88a91d
+  * Window list object
Karsten Hopp 88a91d
+  */
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
+ static PyTypeObject TabListType;
Karsten Hopp 88a91d
+ static PySequenceMethods TabListAsSeq;
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
+ typedef struct
Karsten Hopp 88a91d
+ {
Karsten Hopp 88a91d
+     PyObject_HEAD
Karsten Hopp 88a91d
+ } TabListObject;
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
+     static PyInt
Karsten Hopp 88a91d
+ TabListLength(PyObject *self UNUSED)
Karsten Hopp 88a91d
+ {
Karsten Hopp 88a91d
+     tabpage_T	*tp = first_tabpage;
Karsten Hopp 88a91d
+     PyInt	n = 0;
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
+     while (tp != NULL)
Karsten Hopp 88a91d
+     {
Karsten Hopp 88a91d
+ 	++n;
Karsten Hopp 88a91d
+ 	tp = tp->tp_next;
Karsten Hopp 88a91d
+     }
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
+     return n;
Karsten Hopp 88a91d
+ }
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
+     static PyObject *
Karsten Hopp 88a91d
+ TabListItem(PyObject *self UNUSED, PyInt n)
Karsten Hopp 88a91d
+ {
Karsten Hopp 88a91d
+     tabpage_T	*tp;
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
+     for (tp = first_tabpage; tp != NULL; tp = tp->tp_next, --n)
Karsten Hopp 88a91d
+ 	if (n == 0)
Karsten Hopp 88a91d
+ 	    return TabPageNew(tp);
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
+     PyErr_SetString(PyExc_IndexError, _("no such tab page"));
Karsten Hopp 88a91d
+     return NULL;
Karsten Hopp 88a91d
+ }
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
  /* Window object
Karsten Hopp 88a91d
   */
Karsten Hopp 88a91d
  
Karsten Hopp 88a91d
***************
Karsten Hopp 88a91d
*** 1588,1595 ****
Karsten Hopp 88a91d
      win_T	*win;
Karsten Hopp 88a91d
  } WindowObject;
Karsten Hopp 88a91d
  
Karsten Hopp 88a91d
- static int WindowSetattr(PyObject *, char *, PyObject *);
Karsten Hopp 88a91d
- static PyObject *WindowRepr(PyObject *);
Karsten Hopp 88a91d
  static PyTypeObject WindowType;
Karsten Hopp 88a91d
  
Karsten Hopp 88a91d
      static int
Karsten Hopp 88a91d
--- 1738,1743 ----
Karsten Hopp 88a91d
***************
Karsten Hopp 88a91d
*** 1681,1687 ****
Karsten Hopp 88a91d
  	return OptionsNew(SREQ_WIN, this->win, (checkfun) CheckWindow,
Karsten Hopp 88a91d
  			(PyObject *) this);
Karsten Hopp 88a91d
      else if (strcmp(name, "number") == 0)
Karsten Hopp 88a91d
! 	return PyLong_FromLong((long) get_win_number(this->win));
Karsten Hopp 88a91d
      else if (strcmp(name,"__members__") == 0)
Karsten Hopp 88a91d
  	return Py_BuildValue("[ssssssss]", "buffer", "cursor", "height", "vars",
Karsten Hopp 88a91d
  		"options", "number", "row", "col");
Karsten Hopp 88a91d
--- 1829,1835 ----
Karsten Hopp 88a91d
  	return OptionsNew(SREQ_WIN, this->win, (checkfun) CheckWindow,
Karsten Hopp 88a91d
  			(PyObject *) this);
Karsten Hopp 88a91d
      else if (strcmp(name, "number") == 0)
Karsten Hopp 88a91d
! 	return PyLong_FromLong((long) get_win_number(this->win, firstwin));
Karsten Hopp 88a91d
      else if (strcmp(name,"__members__") == 0)
Karsten Hopp 88a91d
  	return Py_BuildValue("[ssssssss]", "buffer", "cursor", "height", "vars",
Karsten Hopp 88a91d
  		"options", "number", "row", "col");
Karsten Hopp 88a91d
***************
Karsten Hopp 88a91d
*** 1797,1803 ****
Karsten Hopp 88a91d
      }
Karsten Hopp 88a91d
      else
Karsten Hopp 88a91d
      {
Karsten Hopp 88a91d
! 	int	w = get_win_number(this->win);
Karsten Hopp 88a91d
  
Karsten Hopp 88a91d
  	if (w == 0)
Karsten Hopp 88a91d
  	    vim_snprintf(repr, 100, _("<window object (unknown) at %p>"),
Karsten Hopp 88a91d
--- 1945,1951 ----
Karsten Hopp 88a91d
      }
Karsten Hopp 88a91d
      else
Karsten Hopp 88a91d
      {
Karsten Hopp 88a91d
! 	int	w = get_win_number(this->win, firstwin);
Karsten Hopp 88a91d
  
Karsten Hopp 88a91d
  	if (w == 0)
Karsten Hopp 88a91d
  	    vim_snprintf(repr, 100, _("<window object (unknown) at %p>"),
Karsten Hopp 88a91d
***************
Karsten Hopp 88a91d
*** 1824,1837 ****
Karsten Hopp 88a91d
  typedef struct
Karsten Hopp 88a91d
  {
Karsten Hopp 88a91d
      PyObject_HEAD
Karsten Hopp 88a91d
  } WinListObject;
Karsten Hopp 88a91d
  
Karsten Hopp 88a91d
      static PyInt
Karsten Hopp 88a91d
! WinListLength(PyObject *self UNUSED)
Karsten Hopp 88a91d
  {
Karsten Hopp 88a91d
!     win_T	*w = firstwin;
Karsten Hopp 88a91d
      PyInt	n = 0;
Karsten Hopp 88a91d
  
Karsten Hopp 88a91d
      while (w != NULL)
Karsten Hopp 88a91d
      {
Karsten Hopp 88a91d
  	++n;
Karsten Hopp 88a91d
--- 1972,2030 ----
Karsten Hopp 88a91d
  typedef struct
Karsten Hopp 88a91d
  {
Karsten Hopp 88a91d
      PyObject_HEAD
Karsten Hopp 88a91d
+     TabPageObject	*tabObject;
Karsten Hopp 88a91d
  } WinListObject;
Karsten Hopp 88a91d
  
Karsten Hopp 88a91d
+     static PyObject *
Karsten Hopp 88a91d
+ WinListNew(TabPageObject *tabObject)
Karsten Hopp 88a91d
+ {
Karsten Hopp 88a91d
+     WinListObject	*self;
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
+     self = PyObject_NEW(WinListObject, &WinListType);
Karsten Hopp 88a91d
+     self->tabObject = tabObject;
Karsten Hopp 88a91d
+     Py_INCREF(tabObject);
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
+     return (PyObject *)(self);
Karsten Hopp 88a91d
+ }
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
+     static void
Karsten Hopp 88a91d
+ WinListDestructor(PyObject *self)
Karsten Hopp 88a91d
+ {
Karsten Hopp 88a91d
+     TabPageObject	*tabObject = ((WinListObject *)(self))->tabObject;
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
+     if (tabObject)
Karsten Hopp 88a91d
+ 	Py_DECREF((PyObject *)(tabObject));
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
+     DESTRUCTOR_FINISH(self);
Karsten Hopp 88a91d
+ }
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
+     static win_T *
Karsten Hopp 88a91d
+ get_firstwin(WinListObject *this)
Karsten Hopp 88a91d
+ {
Karsten Hopp 88a91d
+     if (this->tabObject)
Karsten Hopp 88a91d
+     {
Karsten Hopp 88a91d
+ 	if (CheckTabPage(this->tabObject))
Karsten Hopp 88a91d
+ 	    return NULL;
Karsten Hopp 88a91d
+ 	/* For current tab window.c does not bother to set or update tp_firstwin
Karsten Hopp 88a91d
+ 	 */
Karsten Hopp 88a91d
+ 	else if (this->tabObject->tab == curtab)
Karsten Hopp 88a91d
+ 	    return firstwin;
Karsten Hopp 88a91d
+ 	else
Karsten Hopp 88a91d
+ 	    return this->tabObject->tab->tp_firstwin;
Karsten Hopp 88a91d
+     }
Karsten Hopp 88a91d
+     else
Karsten Hopp 88a91d
+ 	return firstwin;
Karsten Hopp 88a91d
+ }
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
      static PyInt
Karsten Hopp 88a91d
! WinListLength(PyObject *self)
Karsten Hopp 88a91d
  {
Karsten Hopp 88a91d
!     win_T	*w;
Karsten Hopp 88a91d
      PyInt	n = 0;
Karsten Hopp 88a91d
  
Karsten Hopp 88a91d
+     if (!(w = get_firstwin((WinListObject *)(self))))
Karsten Hopp 88a91d
+ 	return -1;
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
      while (w != NULL)
Karsten Hopp 88a91d
      {
Karsten Hopp 88a91d
  	++n;
Karsten Hopp 88a91d
***************
Karsten Hopp 88a91d
*** 1842,1852 ****
Karsten Hopp 88a91d
  }
Karsten Hopp 88a91d
  
Karsten Hopp 88a91d
      static PyObject *
Karsten Hopp 88a91d
! WinListItem(PyObject *self UNUSED, PyInt n)
Karsten Hopp 88a91d
  {
Karsten Hopp 88a91d
      win_T *w;
Karsten Hopp 88a91d
  
Karsten Hopp 88a91d
!     for (w = firstwin; w != NULL; w = W_NEXT(w), --n)
Karsten Hopp 88a91d
  	if (n == 0)
Karsten Hopp 88a91d
  	    return WindowNew(w);
Karsten Hopp 88a91d
  
Karsten Hopp 88a91d
--- 2035,2048 ----
Karsten Hopp 88a91d
  }
Karsten Hopp 88a91d
  
Karsten Hopp 88a91d
      static PyObject *
Karsten Hopp 88a91d
! WinListItem(PyObject *self, PyInt n)
Karsten Hopp 88a91d
  {
Karsten Hopp 88a91d
      win_T *w;
Karsten Hopp 88a91d
  
Karsten Hopp 88a91d
!     if (!(w = get_firstwin((WinListObject *)(self))))
Karsten Hopp 88a91d
! 	return NULL;
Karsten Hopp 88a91d
! 
Karsten Hopp 88a91d
!     for (; w != NULL; w = W_NEXT(w), --n)
Karsten Hopp 88a91d
  	if (n == 0)
Karsten Hopp 88a91d
  	    return WindowNew(w);
Karsten Hopp 88a91d
  
Karsten Hopp 88a91d
***************
Karsten Hopp 88a91d
*** 3018,3029 ****
Karsten Hopp 88a91d
  	return (PyObject *)BufferNew(curbuf);
Karsten Hopp 88a91d
      else if (strcmp(name, "window") == 0)
Karsten Hopp 88a91d
  	return (PyObject *)WindowNew(curwin);
Karsten Hopp 88a91d
      else if (strcmp(name, "line") == 0)
Karsten Hopp 88a91d
  	return GetBufferLine(curbuf, (PyInt)curwin->w_cursor.lnum);
Karsten Hopp 88a91d
      else if (strcmp(name, "range") == 0)
Karsten Hopp 88a91d
  	return RangeNew(curbuf, RangeStart, RangeEnd);
Karsten Hopp 88a91d
      else if (strcmp(name,"__members__") == 0)
Karsten Hopp 88a91d
! 	return Py_BuildValue("[ssss]", "buffer", "window", "line", "range");
Karsten Hopp 88a91d
      else
Karsten Hopp 88a91d
      {
Karsten Hopp 88a91d
  	PyErr_SetString(PyExc_AttributeError, name);
Karsten Hopp 88a91d
--- 3214,3228 ----
Karsten Hopp 88a91d
  	return (PyObject *)BufferNew(curbuf);
Karsten Hopp 88a91d
      else if (strcmp(name, "window") == 0)
Karsten Hopp 88a91d
  	return (PyObject *)WindowNew(curwin);
Karsten Hopp 88a91d
+     else if (strcmp(name, "tabpage") == 0)
Karsten Hopp 88a91d
+ 	return (PyObject *)TabPageNew(curtab);
Karsten Hopp 88a91d
      else if (strcmp(name, "line") == 0)
Karsten Hopp 88a91d
  	return GetBufferLine(curbuf, (PyInt)curwin->w_cursor.lnum);
Karsten Hopp 88a91d
      else if (strcmp(name, "range") == 0)
Karsten Hopp 88a91d
  	return RangeNew(curbuf, RangeStart, RangeEnd);
Karsten Hopp 88a91d
      else if (strcmp(name,"__members__") == 0)
Karsten Hopp 88a91d
! 	return Py_BuildValue("[sssss]", "buffer", "window", "line", "range",
Karsten Hopp 88a91d
! 		"tabpage");
Karsten Hopp 88a91d
      else
Karsten Hopp 88a91d
      {
Karsten Hopp 88a91d
  	PyErr_SetString(PyExc_AttributeError, name);
Karsten Hopp 88a91d
***************
Karsten Hopp 88a91d
*** 3568,3573 ****
Karsten Hopp 88a91d
--- 3767,3789 ----
Karsten Hopp 88a91d
      WindowType.tp_setattr = WindowSetattr;
Karsten Hopp 88a91d
  #endif
Karsten Hopp 88a91d
  
Karsten Hopp 88a91d
+     vim_memset(&TabPageType, 0, sizeof(TabPageType));
Karsten Hopp 88a91d
+     TabPageType.tp_name = "vim.tabpage";
Karsten Hopp 88a91d
+     TabPageType.tp_basicsize = sizeof(TabPageObject);
Karsten Hopp 88a91d
+     TabPageType.tp_dealloc = TabPageDestructor;
Karsten Hopp 88a91d
+     TabPageType.tp_repr = TabPageRepr;
Karsten Hopp 88a91d
+     TabPageType.tp_flags = Py_TPFLAGS_DEFAULT;
Karsten Hopp 88a91d
+     TabPageType.tp_doc = "vim tab page object";
Karsten Hopp 88a91d
+     TabPageType.tp_methods = TabPageMethods;
Karsten Hopp 88a91d
+ #if PY_MAJOR_VERSION >= 3
Karsten Hopp 88a91d
+     TabPageType.tp_getattro = TabPageGetattro;
Karsten Hopp 88a91d
+     TabPageType.tp_alloc = call_PyType_GenericAlloc;
Karsten Hopp 88a91d
+     TabPageType.tp_new = call_PyType_GenericNew;
Karsten Hopp 88a91d
+     TabPageType.tp_free = call_PyObject_Free;
Karsten Hopp 88a91d
+ #else
Karsten Hopp 88a91d
+     TabPageType.tp_getattr = TabPageGetattr;
Karsten Hopp 88a91d
+ #endif
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
      vim_memset(&BufMapType, 0, sizeof(BufMapType));
Karsten Hopp 88a91d
      BufMapType.tp_name = "vim.bufferlist";
Karsten Hopp 88a91d
      BufMapType.tp_basicsize = sizeof(BufMapObject);
Karsten Hopp 88a91d
***************
Karsten Hopp 88a91d
*** 3582,3587 ****
Karsten Hopp 88a91d
--- 3798,3811 ----
Karsten Hopp 88a91d
      WinListType.tp_as_sequence = &WinListAsSeq;
Karsten Hopp 88a91d
      WinListType.tp_flags = Py_TPFLAGS_DEFAULT;
Karsten Hopp 88a91d
      WinListType.tp_doc = "vim window list";
Karsten Hopp 88a91d
+     WinListType.tp_dealloc = WinListDestructor;
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
+     vim_memset(&TabListType, 0, sizeof(TabListType));
Karsten Hopp 88a91d
+     TabListType.tp_name = "vim.tabpagelist";
Karsten Hopp 88a91d
+     TabListType.tp_basicsize = sizeof(TabListType);
Karsten Hopp 88a91d
+     TabListType.tp_as_sequence = &TabListAsSeq;
Karsten Hopp 88a91d
+     TabListType.tp_flags = Py_TPFLAGS_DEFAULT;
Karsten Hopp 88a91d
+     TabListType.tp_doc = "vim tab page list";
Karsten Hopp 88a91d
  
Karsten Hopp 88a91d
      vim_memset(&RangeType, 0, sizeof(RangeType));
Karsten Hopp 88a91d
      RangeType.tp_name = "vim.range";
Karsten Hopp 88a91d
*** ../vim-7.3.948/src/if_python3.c	2013-05-15 14:51:31.000000000 +0200
Karsten Hopp 88a91d
--- src/if_python3.c	2013-05-15 15:05:04.000000000 +0200
Karsten Hopp 88a91d
***************
Karsten Hopp 88a91d
*** 626,631 ****
Karsten Hopp 88a91d
--- 626,632 ----
Karsten Hopp 88a91d
  
Karsten Hopp 88a91d
  #define WIN_PYTHON_REF(win) win->w_python3_ref
Karsten Hopp 88a91d
  #define BUF_PYTHON_REF(buf) buf->b_python3_ref
Karsten Hopp 88a91d
+ #define TAB_PYTHON_REF(tab) tab->tp_python3_ref
Karsten Hopp 88a91d
  
Karsten Hopp 88a91d
      static void
Karsten Hopp 88a91d
  call_PyObject_Free(void *p)
Karsten Hopp 88a91d
***************
Karsten Hopp 88a91d
*** 652,657 ****
Karsten Hopp 88a91d
--- 653,659 ----
Karsten Hopp 88a91d
  static PyObject *OutputGetattro(PyObject *, PyObject *);
Karsten Hopp 88a91d
  static int OutputSetattro(PyObject *, PyObject *, PyObject *);
Karsten Hopp 88a91d
  static PyObject *BufferGetattro(PyObject *, PyObject *);
Karsten Hopp 88a91d
+ static PyObject *TabPageGetattro(PyObject *, PyObject *);
Karsten Hopp 88a91d
  static PyObject *WindowGetattro(PyObject *, PyObject *);
Karsten Hopp 88a91d
  static int WindowSetattro(PyObject *, PyObject *, PyObject *);
Karsten Hopp 88a91d
  static PyObject *RangeGetattro(PyObject *, PyObject *);
Karsten Hopp 88a91d
***************
Karsten Hopp 88a91d
*** 1275,1280 ****
Karsten Hopp 88a91d
--- 1277,1302 ----
Karsten Hopp 88a91d
      }
Karsten Hopp 88a91d
  }
Karsten Hopp 88a91d
  
Karsten Hopp 88a91d
+ /* TabPage object - Implementation
Karsten Hopp 88a91d
+  */
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
+     static PyObject *
Karsten Hopp 88a91d
+ TabPageGetattro(PyObject *self, PyObject *nameobj)
Karsten Hopp 88a91d
+ {
Karsten Hopp 88a91d
+     PyObject *r;
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
+     GET_ATTR_STRING(name, nameobj);
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
+     if (CheckTabPage((TabPageObject *)(self)))
Karsten Hopp 88a91d
+ 	return NULL;
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
+     r = TabPageAttr((TabPageObject *)(self), name);
Karsten Hopp 88a91d
+     if (r || PyErr_Occurred())
Karsten Hopp 88a91d
+ 	return r;
Karsten Hopp 88a91d
+     else
Karsten Hopp 88a91d
+ 	return PyObject_GenericGetAttr(self, nameobj);
Karsten Hopp 88a91d
+ }
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
  /* Window object - Implementation
Karsten Hopp 88a91d
   */
Karsten Hopp 88a91d
  
Karsten Hopp 88a91d
***************
Karsten Hopp 88a91d
*** 1303,1308 ****
Karsten Hopp 88a91d
--- 1325,1346 ----
Karsten Hopp 88a91d
      return WindowSetattr(self, name, val);
Karsten Hopp 88a91d
  }
Karsten Hopp 88a91d
  
Karsten Hopp 88a91d
+ /* Tab page list object - Definitions
Karsten Hopp 88a91d
+  */
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
+ static PySequenceMethods TabListAsSeq = {
Karsten Hopp 88a91d
+     (lenfunc)	     TabListLength,	    /* sq_length,    len(x)   */
Karsten Hopp 88a91d
+     (binaryfunc)     0,			    /* sq_concat,    x+y      */
Karsten Hopp 88a91d
+     (ssizeargfunc)   0,			    /* sq_repeat,    x*n      */
Karsten Hopp 88a91d
+     (ssizeargfunc)   TabListItem,	    /* sq_item,      x[i]     */
Karsten Hopp 88a91d
+     0,					    /* sq_slice,     x[i:j]   */
Karsten Hopp 88a91d
+     (ssizeobjargproc)0,			    /* sq_as_item,  x[i]=v   */
Karsten Hopp 88a91d
+     0,					    /* sq_ass_slice, x[i:j]=v */
Karsten Hopp 88a91d
+     0,					    /* sq_contains */
Karsten Hopp 88a91d
+     0,					    /* sq_inplace_concat */
Karsten Hopp 88a91d
+     0,					    /* sq_inplace_repeat */
Karsten Hopp 88a91d
+ };
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
  /* Window list object - Definitions
Karsten Hopp 88a91d
   */
Karsten Hopp 88a91d
  
Karsten Hopp 88a91d
***************
Karsten Hopp 88a91d
*** 1497,1502 ****
Karsten Hopp 88a91d
--- 1535,1551 ----
Karsten Hopp 88a91d
  	WIN_PYTHON_REF(win) = NULL;
Karsten Hopp 88a91d
      }
Karsten Hopp 88a91d
  }
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
+     void
Karsten Hopp 88a91d
+ python3_tabpage_free(tabpage_T *tab)
Karsten Hopp 88a91d
+ {
Karsten Hopp 88a91d
+     if (TAB_PYTHON_REF(tab) != NULL)
Karsten Hopp 88a91d
+     {
Karsten Hopp 88a91d
+ 	TabPageObject *tp = TAB_PYTHON_REF(tab);
Karsten Hopp 88a91d
+ 	tp->tab = INVALID_TABPAGE_VALUE;
Karsten Hopp 88a91d
+ 	TAB_PYTHON_REF(tab) = NULL;
Karsten Hopp 88a91d
+     }
Karsten Hopp 88a91d
+ }
Karsten Hopp 88a91d
  #endif
Karsten Hopp 88a91d
  
Karsten Hopp 88a91d
  static BufMapObject TheBufferMap =
Karsten Hopp 88a91d
***************
Karsten Hopp 88a91d
*** 1507,1512 ****
Karsten Hopp 88a91d
--- 1556,1562 ----
Karsten Hopp 88a91d
  static WinListObject TheWindowList =
Karsten Hopp 88a91d
  {
Karsten Hopp 88a91d
      PyObject_HEAD_INIT(&WinListType)
Karsten Hopp 88a91d
+     NULL
Karsten Hopp 88a91d
  };
Karsten Hopp 88a91d
  
Karsten Hopp 88a91d
  static CurrentObject TheCurrent =
Karsten Hopp 88a91d
***************
Karsten Hopp 88a91d
*** 1514,1519 ****
Karsten Hopp 88a91d
--- 1564,1574 ----
Karsten Hopp 88a91d
      PyObject_HEAD_INIT(&CurrentType)
Karsten Hopp 88a91d
  };
Karsten Hopp 88a91d
  
Karsten Hopp 88a91d
+ static TabListObject TheTabPageList =
Karsten Hopp 88a91d
+ {
Karsten Hopp 88a91d
+     PyObject_HEAD_INIT(&TabListType)
Karsten Hopp 88a91d
+ };
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
      static PyObject *
Karsten Hopp 88a91d
  Py3Init_vim(void)
Karsten Hopp 88a91d
  {
Karsten Hopp 88a91d
***************
Karsten Hopp 88a91d
*** 1526,1533 ****
Karsten Hopp 88a91d
--- 1581,1590 ----
Karsten Hopp 88a91d
      PyType_Ready(&BufferType);
Karsten Hopp 88a91d
      PyType_Ready(&RangeType);
Karsten Hopp 88a91d
      PyType_Ready(&WindowType);
Karsten Hopp 88a91d
+     PyType_Ready(&TabPageType);
Karsten Hopp 88a91d
      PyType_Ready(&BufMapType);
Karsten Hopp 88a91d
      PyType_Ready(&WinListType);
Karsten Hopp 88a91d
+     PyType_Ready(&TabListType);
Karsten Hopp 88a91d
      PyType_Ready(&CurrentType);
Karsten Hopp 88a91d
      PyType_Ready(&DictionaryType);
Karsten Hopp 88a91d
      PyType_Ready(&ListType);
Karsten Hopp 88a91d
***************
Karsten Hopp 88a91d
*** 1551,1556 ****
Karsten Hopp 88a91d
--- 1608,1615 ----
Karsten Hopp 88a91d
      PyModule_AddObject(mod, "current", (PyObject *)(void *)&TheCurrent);
Karsten Hopp 88a91d
      Py_INCREF((PyObject *)(void *)&TheWindowList);
Karsten Hopp 88a91d
      PyModule_AddObject(mod, "windows", (PyObject *)(void *)&TheWindowList);
Karsten Hopp 88a91d
+     Py_INCREF((PyObject *)(void *)&TheTabPageList);
Karsten Hopp 88a91d
+     PyModule_AddObject(mod, "tabpages", (PyObject *)(void *)&TheTabPageList);
Karsten Hopp 88a91d
  
Karsten Hopp 88a91d
      PyModule_AddObject(mod, "vars", DictionaryNew(&globvardict));
Karsten Hopp 88a91d
      PyModule_AddObject(mod, "vvars", DictionaryNew(&vimvardict));
Karsten Hopp 88a91d
*** ../vim-7.3.948/src/if_python.c	2013-05-15 14:51:31.000000000 +0200
Karsten Hopp 88a91d
--- src/if_python.c	2013-05-15 15:05:04.000000000 +0200
Karsten Hopp 88a91d
***************
Karsten Hopp 88a91d
*** 624,633 ****
Karsten Hopp 88a91d
--- 624,635 ----
Karsten Hopp 88a91d
  
Karsten Hopp 88a91d
  #define WIN_PYTHON_REF(win) win->w_python_ref
Karsten Hopp 88a91d
  #define BUF_PYTHON_REF(buf) buf->b_python_ref
Karsten Hopp 88a91d
+ #define TAB_PYTHON_REF(tab) tab->tp_python_ref
Karsten Hopp 88a91d
  
Karsten Hopp 88a91d
  static PyObject *OutputGetattr(PyObject *, char *);
Karsten Hopp 88a91d
  static PyObject *BufferGetattr(PyObject *, char *);
Karsten Hopp 88a91d
  static PyObject *WindowGetattr(PyObject *, char *);
Karsten Hopp 88a91d
+ static PyObject *TabPageGetattr(PyObject *, char *);
Karsten Hopp 88a91d
  static PyObject *RangeGetattr(PyObject *, char *);
Karsten Hopp 88a91d
  static PyObject *DictionaryGetattr(PyObject *, char*);
Karsten Hopp 88a91d
  static PyObject *ListGetattr(PyObject *, char *);
Karsten Hopp 88a91d
***************
Karsten Hopp 88a91d
*** 1137,1142 ****
Karsten Hopp 88a91d
--- 1139,1162 ----
Karsten Hopp 88a91d
  		      &((RangeObject *)(self))->end);
Karsten Hopp 88a91d
  }
Karsten Hopp 88a91d
  
Karsten Hopp 88a91d
+ /* TabPage object - Implementation
Karsten Hopp 88a91d
+  */
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
+     static PyObject *
Karsten Hopp 88a91d
+ TabPageGetattr(PyObject *self, char *name)
Karsten Hopp 88a91d
+ {
Karsten Hopp 88a91d
+     PyObject *r;
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
+     if (CheckTabPage((TabPageObject *)(self)))
Karsten Hopp 88a91d
+ 	return NULL;
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
+     r = TabPageAttr((TabPageObject *)(self), name);
Karsten Hopp 88a91d
+     if (r || PyErr_Occurred())
Karsten Hopp 88a91d
+ 	return r;
Karsten Hopp 88a91d
+     else
Karsten Hopp 88a91d
+ 	return Py_FindMethod(TabPageMethods, self, name);
Karsten Hopp 88a91d
+ }
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
  /* Window object - Implementation
Karsten Hopp 88a91d
   */
Karsten Hopp 88a91d
  
Karsten Hopp 88a91d
***************
Karsten Hopp 88a91d
*** 1155,1160 ****
Karsten Hopp 88a91d
--- 1175,1198 ----
Karsten Hopp 88a91d
  	return Py_FindMethod(WindowMethods, self, name);
Karsten Hopp 88a91d
  }
Karsten Hopp 88a91d
  
Karsten Hopp 88a91d
+ /* Tab page list object - Definitions
Karsten Hopp 88a91d
+  */
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
+ static PySequenceMethods TabListAsSeq = {
Karsten Hopp 88a91d
+     (PyInquiry)		TabListLength,	    /* sq_length,    len(x)   */
Karsten Hopp 88a91d
+     (binaryfunc)	0,		    /* sq_concat,    x+y      */
Karsten Hopp 88a91d
+     (PyIntArgFunc)	0,		    /* sq_repeat,    x*n      */
Karsten Hopp 88a91d
+     (PyIntArgFunc)	TabListItem,	    /* sq_item,      x[i]     */
Karsten Hopp 88a91d
+     (PyIntIntArgFunc)	0,		    /* sq_slice,     x[i:j]   */
Karsten Hopp 88a91d
+     (PyIntObjArgProc)	0,		    /* sq_ass_item,  x[i]=v   */
Karsten Hopp 88a91d
+     (PyIntIntObjArgProc) 0,		    /* sq_ass_slice, x[i:j]=v */
Karsten Hopp 88a91d
+     (objobjproc)	0,
Karsten Hopp 88a91d
+ #if PY_MAJOR_VERSION >= 2
Karsten Hopp 88a91d
+     (binaryfunc)	0,
Karsten Hopp 88a91d
+     0,
Karsten Hopp 88a91d
+ #endif
Karsten Hopp 88a91d
+ };
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
  /* Window list object - Definitions
Karsten Hopp 88a91d
   */
Karsten Hopp 88a91d
  
Karsten Hopp 88a91d
***************
Karsten Hopp 88a91d
*** 1198,1203 ****
Karsten Hopp 88a91d
--- 1236,1252 ----
Karsten Hopp 88a91d
  	WIN_PYTHON_REF(win) = NULL;
Karsten Hopp 88a91d
      }
Karsten Hopp 88a91d
  }
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
+     void
Karsten Hopp 88a91d
+ python_tabpage_free(tabpage_T *tab)
Karsten Hopp 88a91d
+ {
Karsten Hopp 88a91d
+     if (TAB_PYTHON_REF(tab) != NULL)
Karsten Hopp 88a91d
+     {
Karsten Hopp 88a91d
+ 	TabPageObject *tp = TAB_PYTHON_REF(tab);
Karsten Hopp 88a91d
+ 	tp->tab = INVALID_TABPAGE_VALUE;
Karsten Hopp 88a91d
+ 	TAB_PYTHON_REF(tab) = NULL;
Karsten Hopp 88a91d
+     }
Karsten Hopp 88a91d
+ }
Karsten Hopp 88a91d
  #endif
Karsten Hopp 88a91d
  
Karsten Hopp 88a91d
  static BufMapObject TheBufferMap =
Karsten Hopp 88a91d
***************
Karsten Hopp 88a91d
*** 1208,1213 ****
Karsten Hopp 88a91d
--- 1257,1263 ----
Karsten Hopp 88a91d
  static WinListObject TheWindowList =
Karsten Hopp 88a91d
  {
Karsten Hopp 88a91d
      PyObject_HEAD_INIT(&WinListType)
Karsten Hopp 88a91d
+     NULL
Karsten Hopp 88a91d
  };
Karsten Hopp 88a91d
  
Karsten Hopp 88a91d
  static CurrentObject TheCurrent =
Karsten Hopp 88a91d
***************
Karsten Hopp 88a91d
*** 1215,1220 ****
Karsten Hopp 88a91d
--- 1265,1275 ----
Karsten Hopp 88a91d
      PyObject_HEAD_INIT(&CurrentType)
Karsten Hopp 88a91d
  };
Karsten Hopp 88a91d
  
Karsten Hopp 88a91d
+ static TabListObject TheTabPageList =
Karsten Hopp 88a91d
+ {
Karsten Hopp 88a91d
+     PyObject_HEAD_INIT(&TabListType)
Karsten Hopp 88a91d
+ };
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
      static int
Karsten Hopp 88a91d
  PythonMod_Init(void)
Karsten Hopp 88a91d
  {
Karsten Hopp 88a91d
***************
Karsten Hopp 88a91d
*** 1229,1236 ****
Karsten Hopp 88a91d
--- 1284,1293 ----
Karsten Hopp 88a91d
      PyType_Ready(&BufferType);
Karsten Hopp 88a91d
      PyType_Ready(&RangeType);
Karsten Hopp 88a91d
      PyType_Ready(&WindowType);
Karsten Hopp 88a91d
+     PyType_Ready(&TabPageType);
Karsten Hopp 88a91d
      PyType_Ready(&BufMapType);
Karsten Hopp 88a91d
      PyType_Ready(&WinListType);
Karsten Hopp 88a91d
+     PyType_Ready(&TabListType);
Karsten Hopp 88a91d
      PyType_Ready(&CurrentType);
Karsten Hopp 88a91d
      PyType_Ready(&OptionsType);
Karsten Hopp 88a91d
  
Karsten Hopp 88a91d
***************
Karsten Hopp 88a91d
*** 1246,1251 ****
Karsten Hopp 88a91d
--- 1303,1309 ----
Karsten Hopp 88a91d
      PyDict_SetItemString(dict, "buffers", (PyObject *)(void *)&TheBufferMap);
Karsten Hopp 88a91d
      PyDict_SetItemString(dict, "current", (PyObject *)(void *)&TheCurrent);
Karsten Hopp 88a91d
      PyDict_SetItemString(dict, "windows", (PyObject *)(void *)&TheWindowList);
Karsten Hopp 88a91d
+     PyDict_SetItemString(dict, "tabpages", (PyObject *)(void *)&TheTabPageList);
Karsten Hopp 88a91d
      tmp = DictionaryNew(&globvardict);
Karsten Hopp 88a91d
      PyDict_SetItemString(dict, "vars",    tmp);
Karsten Hopp 88a91d
      Py_DECREF(tmp);
Karsten Hopp 88a91d
*** ../vim-7.3.948/src/proto/if_python3.pro	2012-06-29 12:54:32.000000000 +0200
Karsten Hopp 88a91d
--- src/proto/if_python3.pro	2013-05-15 15:05:04.000000000 +0200
Karsten Hopp 88a91d
***************
Karsten Hopp 88a91d
*** 6,11 ****
Karsten Hopp 88a91d
--- 6,12 ----
Karsten Hopp 88a91d
  void ex_py3file __ARGS((exarg_T *eap));
Karsten Hopp 88a91d
  void python3_buffer_free __ARGS((buf_T *buf));
Karsten Hopp 88a91d
  void python3_window_free __ARGS((win_T *win));
Karsten Hopp 88a91d
+ void python3_tabpage_free __ARGS((tabpage_T *tab));
Karsten Hopp 88a91d
  void do_py3eval __ARGS((char_u *str, typval_T *rettv));
Karsten Hopp 88a91d
  void set_ref_in_python3 __ARGS((int copyID));
Karsten Hopp 88a91d
  /* vim: set ft=c : */
Karsten Hopp 88a91d
*** ../vim-7.3.948/src/proto/if_python.pro	2012-06-29 12:54:32.000000000 +0200
Karsten Hopp 88a91d
--- src/proto/if_python.pro	2013-05-15 15:05:04.000000000 +0200
Karsten Hopp 88a91d
***************
Karsten Hopp 88a91d
*** 6,11 ****
Karsten Hopp 88a91d
--- 6,12 ----
Karsten Hopp 88a91d
  void ex_pyfile __ARGS((exarg_T *eap));
Karsten Hopp 88a91d
  void python_buffer_free __ARGS((buf_T *buf));
Karsten Hopp 88a91d
  void python_window_free __ARGS((win_T *win));
Karsten Hopp 88a91d
+ void python_tabpage_free __ARGS((tabpage_T *tab));
Karsten Hopp 88a91d
  void do_pyeval __ARGS((char_u *str, typval_T *rettv));
Karsten Hopp 88a91d
  void set_ref_in_python __ARGS((int copyID));
Karsten Hopp 88a91d
  /* vim: set ft=c : */
Karsten Hopp 88a91d
*** ../vim-7.3.948/src/proto/window.pro	2013-05-12 19:00:36.000000000 +0200
Karsten Hopp 88a91d
--- src/proto/window.pro	2013-05-15 15:05:04.000000000 +0200
Karsten Hopp 88a91d
***************
Karsten Hopp 88a91d
*** 74,78 ****
Karsten Hopp 88a91d
  int match_delete __ARGS((win_T *wp, int id, int perr));
Karsten Hopp 88a91d
  void clear_matches __ARGS((win_T *wp));
Karsten Hopp 88a91d
  matchitem_T *get_match __ARGS((win_T *wp, int id));
Karsten Hopp 88a91d
! int get_win_number __ARGS((win_T *wp));
Karsten Hopp 88a91d
  /* vim: set ft=c : */
Karsten Hopp 88a91d
--- 74,79 ----
Karsten Hopp 88a91d
  int match_delete __ARGS((win_T *wp, int id, int perr));
Karsten Hopp 88a91d
  void clear_matches __ARGS((win_T *wp));
Karsten Hopp 88a91d
  matchitem_T *get_match __ARGS((win_T *wp, int id));
Karsten Hopp 88a91d
! int get_win_number __ARGS((win_T *wp, win_T *first_win));
Karsten Hopp 88a91d
! int get_tab_number __ARGS((tabpage_T *tp));
Karsten Hopp 88a91d
  /* vim: set ft=c : */
Karsten Hopp 88a91d
*** ../vim-7.3.948/src/structs.h	2013-05-06 04:21:35.000000000 +0200
Karsten Hopp 88a91d
--- src/structs.h	2013-05-15 15:05:04.000000000 +0200
Karsten Hopp 88a91d
***************
Karsten Hopp 88a91d
*** 1759,1764 ****
Karsten Hopp 88a91d
--- 1759,1772 ----
Karsten Hopp 88a91d
      dictitem_T	    tp_winvar;	    /* variable for "t:" Dictionary */
Karsten Hopp 88a91d
      dict_T	    *tp_vars;	    /* internal variables, local to tab page */
Karsten Hopp 88a91d
  #endif
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
+ #ifdef FEAT_PYTHON
Karsten Hopp 88a91d
+     void	    *tp_python_ref;	/* The Python value for this tab page */
Karsten Hopp 88a91d
+ #endif
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
+ #ifdef FEAT_PYTHON3
Karsten Hopp 88a91d
+     void	    *tp_python3_ref;	/* The Python value for this tab page */
Karsten Hopp 88a91d
+ #endif
Karsten Hopp 88a91d
  };
Karsten Hopp 88a91d
  
Karsten Hopp 88a91d
  /*
Karsten Hopp 88a91d
*** ../vim-7.3.948/src/window.c	2013-05-12 19:00:36.000000000 +0200
Karsten Hopp 88a91d
--- src/window.c	2013-05-15 15:05:04.000000000 +0200
Karsten Hopp 88a91d
***************
Karsten Hopp 88a91d
*** 3510,3515 ****
Karsten Hopp 88a91d
--- 3510,3524 ----
Karsten Hopp 88a91d
      hash_init(&tp->tp_vars->dv_hashtab);
Karsten Hopp 88a91d
      unref_var_dict(tp->tp_vars);
Karsten Hopp 88a91d
  #endif
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
+ #ifdef FEAT_PYTHON
Karsten Hopp 88a91d
+     python_tabpage_free(tp);
Karsten Hopp 88a91d
+ #endif
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
+ #ifdef FEAT_PYTHON3
Karsten Hopp 88a91d
+     python3_tabpage_free(tp);
Karsten Hopp 88a91d
+ #endif
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
      vim_free(tp);
Karsten Hopp 88a91d
  }
Karsten Hopp 88a91d
  
Karsten Hopp 88a91d
***************
Karsten Hopp 88a91d
*** 6734,6750 ****
Karsten Hopp 88a91d
  
Karsten Hopp 88a91d
  #if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO)
Karsten Hopp 88a91d
      int
Karsten Hopp 88a91d
! get_win_number(win_T *wp)
Karsten Hopp 88a91d
  {
Karsten Hopp 88a91d
      int		i = 1;
Karsten Hopp 88a91d
      win_T	*w;
Karsten Hopp 88a91d
  
Karsten Hopp 88a91d
!     for (w = firstwin; w != NULL && w != wp; w = W_NEXT(w))
Karsten Hopp 88a91d
  	++i;
Karsten Hopp 88a91d
  
Karsten Hopp 88a91d
      if (w == NULL)
Karsten Hopp 88a91d
  	return 0;
Karsten Hopp 88a91d
      else
Karsten Hopp 88a91d
  	return i;
Karsten Hopp 88a91d
  }
Karsten Hopp 88a91d
  #endif
Karsten Hopp 88a91d
--- 6743,6774 ----
Karsten Hopp 88a91d
  
Karsten Hopp 88a91d
  #if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO)
Karsten Hopp 88a91d
      int
Karsten Hopp 88a91d
! get_win_number(win_T *wp, win_T *first_win)
Karsten Hopp 88a91d
  {
Karsten Hopp 88a91d
      int		i = 1;
Karsten Hopp 88a91d
      win_T	*w;
Karsten Hopp 88a91d
  
Karsten Hopp 88a91d
!     for (w = first_win; w != NULL && w != wp; w = W_NEXT(w))
Karsten Hopp 88a91d
  	++i;
Karsten Hopp 88a91d
  
Karsten Hopp 88a91d
      if (w == NULL)
Karsten Hopp 88a91d
  	return 0;
Karsten Hopp 88a91d
      else
Karsten Hopp 88a91d
  	return i;
Karsten Hopp 88a91d
+ }
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
+     int
Karsten Hopp 88a91d
+ get_tab_number(tabpage_T *tp)
Karsten Hopp 88a91d
+ {
Karsten Hopp 88a91d
+     int		i = 1;
Karsten Hopp 88a91d
+     tabpage_T	*t;
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
+     for (t = first_tabpage; t != NULL && t != tp; t = t->tp_next)
Karsten Hopp 88a91d
+ 	++i;
Karsten Hopp 88a91d
+ 
Karsten Hopp 88a91d
+     if (t == NULL)
Karsten Hopp 88a91d
+ 	return 0;
Karsten Hopp 88a91d
+     else
Karsten Hopp 88a91d
+ 	return i;
Karsten Hopp 88a91d
  }
Karsten Hopp 88a91d
  #endif
Karsten Hopp 88a91d
*** ../vim-7.3.948/src/version.c	2013-05-15 14:51:31.000000000 +0200
Karsten Hopp 88a91d
--- src/version.c	2013-05-15 15:06:37.000000000 +0200
Karsten Hopp 88a91d
***************
Karsten Hopp 88a91d
*** 730,731 ****
Karsten Hopp 88a91d
--- 730,733 ----
Karsten Hopp 88a91d
  {   /* Add new patch number below this line */
Karsten Hopp 88a91d
+ /**/
Karsten Hopp 88a91d
+     949,
Karsten Hopp 88a91d
  /**/
Karsten Hopp 88a91d
Karsten Hopp 88a91d
-- 
Karsten Hopp 88a91d
BLACK KNIGHT:  Come on you pansy!
Karsten Hopp 88a91d
    [hah] [parry thrust]
Karsten Hopp 88a91d
    [ARTHUR chops the BLACK KNIGHT's right arm off]
Karsten Hopp 88a91d
ARTHUR:        Victory is mine!  [kneeling]
Karsten Hopp 88a91d
               We thank thee Lord, that in thy merc-
Karsten Hopp 88a91d
    [Black Knight kicks Arthur in the head while he is praying]
Karsten Hopp 88a91d
                                  The Quest for the Holy Grail (Monty Python)
Karsten Hopp 88a91d
Karsten Hopp 88a91d
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 88a91d
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 88a91d
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 88a91d
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///