home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / patches / 7.3 / 7.3.964 < prev    next >
Encoding:
Internet Message Format  |  2013-05-16  |  12.9 KB

  1. To: vim_dev@googlegroups.com
  2. Subject: Patch 7.3.964
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. Mime-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. ------------
  9.  
  10. Patch 7.3.964
  11. Problem:    Python: not so easy to access tab pages.
  12. Solution:   Add window.tabpage, make window.number work with non-current tab
  13.         pages. (ZyX)
  14. Files:        runtime/doc/if_pyth.txt, src/if_py_both.h, src/if_python3.c,
  15.         src/if_python.c, src/testdir/test86.ok, src/testdir/test87.ok
  16.  
  17.  
  18. *** ../vim-7.3.963/runtime/doc/if_pyth.txt    2013-05-15 18:28:08.000000000 +0200
  19. --- runtime/doc/if_pyth.txt    2013-05-17 16:07:16.000000000 +0200
  20. ***************
  21. *** 433,440 ****
  22.                   This is zero in case it cannot be determined
  23.                   (e.g. when the window object belongs to other
  24.                   tab page).
  25. !      row, col (read-only)    On-screen window position in display cells.
  26.                   First position is zero.
  27.   
  28.   The height attribute is writable only if the screen is split horizontally.
  29.   The width attribute is writable only if the screen is split vertically.
  30. --- 433,441 ----
  31.                   This is zero in case it cannot be determined
  32.                   (e.g. when the window object belongs to other
  33.                   tab page).
  34. !     row, col (read-only)    On-screen window position in display cells.
  35.                   First position is zero.
  36. +     tabpage (read-only)    Window tab page.
  37.   
  38.   The height attribute is writable only if the screen is split horizontally.
  39.   The width attribute is writable only if the screen is split vertically.
  40. ***************
  41. *** 490,496 ****
  42.   <                            *:py3file*
  43.   The |:py3file| command works similar to |:pyfile|.
  44.   
  45. !                             *:py3do*
  46.   :[range]py3do {body}    Execute Python function "def _vim_pydo(line, linenr):
  47.               {body}" for each line in the [range], with the
  48.               function arguments being set to the text of each line
  49. --- 491,497 ----
  50.   <                            *:py3file*
  51.   The |:py3file| command works similar to |:pyfile|.
  52.   
  53. !                             *:py3do* *E863*
  54.   :[range]py3do {body}    Execute Python function "def _vim_pydo(line, linenr):
  55.               {body}" for each line in the [range], with the
  56.               function arguments being set to the text of each line
  57. *** ../vim-7.3.963/src/if_py_both.h    2013-05-17 16:03:53.000000000 +0200
  58. --- src/if_py_both.h    2013-05-17 16:07:16.000000000 +0200
  59. ***************
  60. *** 31,36 ****
  61. --- 31,39 ----
  62.   
  63.   static int ConvertFromPyObject(PyObject *, typval_T *);
  64.   static int _ConvertFromPyObject(PyObject *, typval_T *, PyObject *);
  65. + static PyObject *WindowNew(win_T *, tabpage_T *);
  66. + static PyObject *BufferNew (buf_T *);
  67. + static PyObject *LineToString(const char *);
  68.   
  69.   static PyInt RangeStart;
  70.   static PyInt RangeEnd;
  71. ***************
  72. *** 1670,1678 ****
  73.       /* For current tab window.c does not bother to set or update tp_curwin
  74.        */
  75.       if (this->tab == curtab)
  76. !         return WindowNew(curwin);
  77.       else
  78. !         return WindowNew(this->tab->tp_curwin);
  79.       }
  80.       return NULL;
  81.   }
  82. --- 1673,1681 ----
  83.       /* For current tab window.c does not bother to set or update tp_curwin
  84.        */
  85.       if (this->tab == curtab)
  86. !         return WindowNew(curwin, curtab);
  87.       else
  88. !         return WindowNew(this->tab->tp_curwin, this->tab);
  89.       }
  90.       return NULL;
  91.   }
  92. ***************
  93. *** 1754,1759 ****
  94. --- 1757,1763 ----
  95.   {
  96.       PyObject_HEAD
  97.       win_T    *win;
  98. +     TabPageObject    *tabObject;
  99.   } WindowObject;
  100.   
  101.   static PyTypeObject WindowType;
  102. ***************
  103. *** 1771,1777 ****
  104.   }
  105.   
  106.       static PyObject *
  107. ! WindowNew(win_T *win)
  108.   {
  109.       /* We need to handle deletion of windows underneath us.
  110.        * If we add a "w_python*_ref" field to the win_T structure,
  111. --- 1775,1781 ----
  112.   }
  113.   
  114.       static PyObject *
  115. ! WindowNew(win_T *win, tabpage_T *tab)
  116.   {
  117.       /* We need to handle deletion of windows underneath us.
  118.        * If we add a "w_python*_ref" field to the win_T structure,
  119. ***************
  120. *** 1804,1809 ****
  121. --- 1808,1815 ----
  122.       WIN_PYTHON_REF(win) = self;
  123.       }
  124.   
  125. +     self->tabObject = ((TabPageObject *)(TabPageNew(tab)));
  126.       return (PyObject *)(self);
  127.   }
  128.   
  129. ***************
  130. *** 1815,1823 ****
  131. --- 1821,1849 ----
  132.       if (this->win && this->win != INVALID_WINDOW_VALUE)
  133.       WIN_PYTHON_REF(this->win) = NULL;
  134.   
  135. +     Py_DECREF(((PyObject *)(this->tabObject)));
  136.       DESTRUCTOR_FINISH(self);
  137.   }
  138.   
  139. +     static win_T *
  140. + get_firstwin(TabPageObject *tabObject)
  141. + {
  142. +     if (tabObject)
  143. +     {
  144. +     if (CheckTabPage(tabObject))
  145. +         return NULL;
  146. +     /* For current tab window.c does not bother to set or update tp_firstwin
  147. +      */
  148. +     else if (tabObject->tab == curtab)
  149. +         return firstwin;
  150. +     else
  151. +         return tabObject->tab->tp_firstwin;
  152. +     }
  153. +     else
  154. +     return firstwin;
  155. + }
  156.       static PyObject *
  157.   WindowAttr(WindowObject *this, char *name)
  158.   {
  159. ***************
  160. *** 1847,1856 ****
  161.       return OptionsNew(SREQ_WIN, this->win, (checkfun) CheckWindow,
  162.               (PyObject *) this);
  163.       else if (strcmp(name, "number") == 0)
  164. !     return PyLong_FromLong((long) get_win_number(this->win, firstwin));
  165.       else if (strcmp(name,"__members__") == 0)
  166. !     return Py_BuildValue("[ssssssss]", "buffer", "cursor", "height", "vars",
  167. !         "options", "number", "row", "col");
  168.       else
  169.       return NULL;
  170.   }
  171. --- 1873,1892 ----
  172.       return OptionsNew(SREQ_WIN, this->win, (checkfun) CheckWindow,
  173.               (PyObject *) this);
  174.       else if (strcmp(name, "number") == 0)
  175. !     {
  176. !     if (CheckTabPage(this->tabObject))
  177. !         return NULL;
  178. !     return PyLong_FromLong((long)
  179. !         get_win_number(this->win, get_firstwin(this->tabObject)));
  180. !     }
  181. !     else if (strcmp(name, "tabpage") == 0)
  182. !     {
  183. !     Py_INCREF(this->tabObject);
  184. !     return (PyObject *)(this->tabObject);
  185. !     }
  186.       else if (strcmp(name,"__members__") == 0)
  187. !     return Py_BuildValue("[sssssssss]", "buffer", "cursor", "height",
  188. !         "vars", "options", "number", "row", "col", "tabpage");
  189.       else
  190.       return NULL;
  191.   }
  192. ***************
  193. *** 2016,2046 ****
  194.       DESTRUCTOR_FINISH(self);
  195.   }
  196.   
  197. -     static win_T *
  198. - get_firstwin(WinListObject *this)
  199. - {
  200. -     if (this->tabObject)
  201. -     {
  202. -     if (CheckTabPage(this->tabObject))
  203. -         return NULL;
  204. -     /* For current tab window.c does not bother to set or update tp_firstwin
  205. -      */
  206. -     else if (this->tabObject->tab == curtab)
  207. -         return firstwin;
  208. -     else
  209. -         return this->tabObject->tab->tp_firstwin;
  210. -     }
  211. -     else
  212. -     return firstwin;
  213. - }
  214.       static PyInt
  215.   WinListLength(PyObject *self)
  216.   {
  217.       win_T    *w;
  218.       PyInt    n = 0;
  219.   
  220. !     if (!(w = get_firstwin((WinListObject *)(self))))
  221.       return -1;
  222.   
  223.       while (w != NULL)
  224. --- 2052,2064 ----
  225.       DESTRUCTOR_FINISH(self);
  226.   }
  227.   
  228.       static PyInt
  229.   WinListLength(PyObject *self)
  230.   {
  231.       win_T    *w;
  232.       PyInt    n = 0;
  233.   
  234. !     if (!(w = get_firstwin(((WinListObject *)(self))->tabObject)))
  235.       return -1;
  236.   
  237.       while (w != NULL)
  238. ***************
  239. *** 2055,2068 ****
  240.       static PyObject *
  241.   WinListItem(PyObject *self, PyInt n)
  242.   {
  243.       win_T *w;
  244.   
  245. !     if (!(w = get_firstwin((WinListObject *)(self))))
  246.       return NULL;
  247.   
  248.       for (; w != NULL; w = W_NEXT(w), --n)
  249.       if (n == 0)
  250. !         return WindowNew(w);
  251.   
  252.       PyErr_SetString(PyExc_IndexError, _("no such window"));
  253.       return NULL;
  254. --- 2073,2087 ----
  255.       static PyObject *
  256.   WinListItem(PyObject *self, PyInt n)
  257.   {
  258. +     WinListObject    *this = ((WinListObject *)(self));
  259.       win_T *w;
  260.   
  261. !     if (!(w = get_firstwin(this->tabObject)))
  262.       return NULL;
  263.   
  264.       for (; w != NULL; w = W_NEXT(w), --n)
  265.       if (n == 0)
  266. !         return WindowNew(w, this->tabObject? this->tabObject->tab: curtab);
  267.   
  268.       PyErr_SetString(PyExc_IndexError, _("no such window"));
  269.       return NULL;
  270. ***************
  271. *** 3227,3233 ****
  272.       if (strcmp(name, "buffer") == 0)
  273.       return (PyObject *)BufferNew(curbuf);
  274.       else if (strcmp(name, "window") == 0)
  275. !     return (PyObject *)WindowNew(curwin);
  276.       else if (strcmp(name, "tabpage") == 0)
  277.       return (PyObject *)TabPageNew(curtab);
  278.       else if (strcmp(name, "line") == 0)
  279. --- 3246,3252 ----
  280.       if (strcmp(name, "buffer") == 0)
  281.       return (PyObject *)BufferNew(curbuf);
  282.       else if (strcmp(name, "window") == 0)
  283. !     return (PyObject *)WindowNew(curwin, curtab);
  284.       else if (strcmp(name, "tabpage") == 0)
  285.       return (PyObject *)TabPageNew(curtab);
  286.       else if (strcmp(name, "line") == 0)
  287. *** ../vim-7.3.963/src/if_python3.c    2013-05-15 19:44:35.000000000 +0200
  288. --- src/if_python3.c    2013-05-17 16:07:16.000000000 +0200
  289. ***************
  290. *** 611,619 ****
  291.   }
  292.   #endif /* DYNAMIC_PYTHON3 */
  293.   
  294. - static PyObject *BufferNew (buf_T *);
  295. - static PyObject *WindowNew(win_T *);
  296. - static PyObject *LineToString(const char *);
  297.   static PyObject *BufferDir(PyObject *, PyObject *);
  298.   
  299.   static int py3initialised = 0;
  300. --- 611,616 ----
  301. *** ../vim-7.3.963/src/if_python.c    2013-05-15 17:49:00.000000000 +0200
  302. --- src/if_python.c    2013-05-17 16:07:16.000000000 +0200
  303. ***************
  304. *** 610,620 ****
  305.   }
  306.   #endif /* DYNAMIC_PYTHON */
  307.   
  308. - static PyObject *BufferNew (buf_T *);
  309. - static PyObject *WindowNew(win_T *);
  310. - static PyObject *DictionaryNew(dict_T *);
  311. - static PyObject *LineToString(const char *);
  312.   static int initialised = 0;
  313.   #define PYINITIALISED initialised
  314.   
  315. --- 610,615 ----
  316. *** ../vim-7.3.963/src/testdir/test86.ok    2013-05-17 16:03:53.000000000 +0200
  317. --- src/testdir/test86.ok    2013-05-17 16:10:26.000000000 +0200
  318. ***************
  319. *** 333,346 ****
  320.   Current tab pages:
  321.     <tabpage 0>(1): 1 windows, current is <window object (unknown)>
  322.     Windows:
  323. !     <window object (unknown)>(0): displays buffer <buffer test86.in>; cursor is at (954, 0)
  324.     <tabpage 1>(2): 1 windows, current is <window object (unknown)>
  325.     Windows:
  326. !     <window object (unknown)>(0): displays buffer <buffer 0>; cursor is at (1, 0)
  327.     <tabpage 2>(3): 2 windows, current is <window object (unknown)>
  328.     Windows:
  329. !     <window object (unknown)>(0): displays buffer <buffer a.1>; cursor is at (1, 0)
  330. !     <window object (unknown)>(0): displays buffer <buffer 1>; cursor is at (1, 0)
  331.     <tabpage 3>(4): 4 windows, current is <window 0>
  332.     Windows:
  333.       <window 0>(1): displays buffer <buffer c.2>; cursor is at (1, 0)
  334. --- 333,346 ----
  335.   Current tab pages:
  336.     <tabpage 0>(1): 1 windows, current is <window object (unknown)>
  337.     Windows:
  338. !     <window object (unknown)>(1): displays buffer <buffer test86.in>; cursor is at (954, 0)
  339.     <tabpage 1>(2): 1 windows, current is <window object (unknown)>
  340.     Windows:
  341. !     <window object (unknown)>(1): displays buffer <buffer 0>; cursor is at (1, 0)
  342.     <tabpage 2>(3): 2 windows, current is <window object (unknown)>
  343.     Windows:
  344. !     <window object (unknown)>(1): displays buffer <buffer a.1>; cursor is at (1, 0)
  345. !     <window object (unknown)>(2): displays buffer <buffer 1>; cursor is at (1, 0)
  346.     <tabpage 3>(4): 4 windows, current is <window 0>
  347.     Windows:
  348.       <window 0>(1): displays buffer <buffer c.2>; cursor is at (1, 0)
  349. *** ../vim-7.3.963/src/testdir/test87.ok    2013-05-17 13:37:57.000000000 +0200
  350. --- src/testdir/test87.ok    2013-05-17 16:07:16.000000000 +0200
  351. ***************
  352. *** 322,335 ****
  353.   Current tab pages:
  354.     <tabpage 0>(1): 1 windows, current is <window object (unknown)>
  355.     Windows:
  356. !     <window object (unknown)>(0): displays buffer <buffer test87.in>; cursor is at (930, 0)
  357.     <tabpage 1>(2): 1 windows, current is <window object (unknown)>
  358.     Windows:
  359. !     <window object (unknown)>(0): displays buffer <buffer 0>; cursor is at (1, 0)
  360.     <tabpage 2>(3): 2 windows, current is <window object (unknown)>
  361.     Windows:
  362. !     <window object (unknown)>(0): displays buffer <buffer a.1>; cursor is at (1, 0)
  363. !     <window object (unknown)>(0): displays buffer <buffer 1>; cursor is at (1, 0)
  364.     <tabpage 3>(4): 4 windows, current is <window 0>
  365.     Windows:
  366.       <window 0>(1): displays buffer <buffer c.2>; cursor is at (1, 0)
  367. --- 322,335 ----
  368.   Current tab pages:
  369.     <tabpage 0>(1): 1 windows, current is <window object (unknown)>
  370.     Windows:
  371. !     <window object (unknown)>(1): displays buffer <buffer test87.in>; cursor is at (930, 0)
  372.     <tabpage 1>(2): 1 windows, current is <window object (unknown)>
  373.     Windows:
  374. !     <window object (unknown)>(1): displays buffer <buffer 0>; cursor is at (1, 0)
  375.     <tabpage 2>(3): 2 windows, current is <window object (unknown)>
  376.     Windows:
  377. !     <window object (unknown)>(1): displays buffer <buffer a.1>; cursor is at (1, 0)
  378. !     <window object (unknown)>(2): displays buffer <buffer 1>; cursor is at (1, 0)
  379.     <tabpage 3>(4): 4 windows, current is <window 0>
  380.     Windows:
  381.       <window 0>(1): displays buffer <buffer c.2>; cursor is at (1, 0)
  382. *** ../vim-7.3.963/src/version.c    2013-05-17 16:03:53.000000000 +0200
  383. --- src/version.c    2013-05-17 16:11:15.000000000 +0200
  384. ***************
  385. *** 730,731 ****
  386. --- 730,733 ----
  387.   {   /* Add new patch number below this line */
  388. + /**/
  389. +     964,
  390.   /**/
  391.  
  392. -- 
  393. ARTHUR: Go on, Bors, chop its head off.
  394. BORS:   Right.  Silly little bleeder.  One rabbit stew coming up.
  395.                  "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
  396.  
  397.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  398. ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
  399. \\\  an exciting new programming language -- http://www.Zimbu.org        ///
  400.  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
  401.