]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
updated for version 7.3.938 v7.3.938
authorBram Moolenaar <Bram@vim.org>
Sun, 12 May 2013 17:00:41 +0000 (19:00 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 12 May 2013 17:00:41 +0000 (19:00 +0200)
Problem:    Python: not easy to get to window number.
Solution:   Add vim.window.number. (ZyX)

runtime/doc/if_pyth.txt
src/if_py_both.h
src/proto/window.pro
src/version.c
src/window.c

index a6bb55c82bcb9957eeeb1adbf49e90d4fe6188d3..bf21f8cc49f1d67a6240b951f89395992c8e0f62 100644 (file)
@@ -396,6 +396,10 @@ Window attributes are:
                                |python-options|. If option is |global-local| 
                                and local value is missing getting it will 
                                return None.
+       number (read-only)      Window number.  The first window has number 1.
+                               This is zero in case it cannot be determined
+                               (e.g. when the window object belongs to other
+                               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.
 
index cf0f50b05392d32f902ddbdde98b099b130e04fb..f8b51b7a3285f9c35e86a7726282611ffbb018a1 100644 (file)
@@ -1848,9 +1848,11 @@ WindowAttr(WindowObject *this, char *name)
     else if (strcmp(name, "options") == 0)
        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));
     else if (strcmp(name,"__members__") == 0)
        return Py_BuildValue("[ssssss]", "buffer", "cursor", "height", "vars",
-               "options");
+               "options", "number");
     else
        return NULL;
 }
@@ -1974,17 +1976,13 @@ WindowRepr(PyObject *self)
     }
     else
     {
-       int     i = 0;
-       win_T   *w;
-
-       for (w = firstwin; w != NULL && w != this->win; w = W_NEXT(w))
-           ++i;
+       int     w = get_win_number(this->win);
 
-       if (w == NULL)
+       if (w == 0)
            vim_snprintf(repr, 100, _("<window object (unknown) at %p>"),
                                                                      (self));
        else
-           vim_snprintf(repr, 100, _("<window %d>"), i);
+           vim_snprintf(repr, 100, _("<window %d>"), w - 1);
 
        return PyString_FromString(repr);
     }
index 0a7448927a9371ecb97b088461f96c0ef9231fdf..a77da59c25cd153991dc9b33ef109cc684569678 100644 (file)
@@ -74,4 +74,5 @@ int match_add __ARGS((win_T *wp, char_u *grp, char_u *pat, int prio, int id));
 int match_delete __ARGS((win_T *wp, int id, int perr));
 void clear_matches __ARGS((win_T *wp));
 matchitem_T *get_match __ARGS((win_T *wp, int id));
+int get_win_number __ARGS((win_T *wp));
 /* vim: set ft=c : */
index 884b5c6c503b9f54af658dfac80f70a84f4256be..f6d3840d849d0747c01b3ebdf785e3bb4ef39fd8 100644 (file)
@@ -728,6 +728,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    938,
 /**/
     937,
 /**/
index 4616c803d4491b14f0273fa680e384ef7dc44524..035471490b86eebd51543f515869c90ee16069b6 100644 (file)
@@ -6731,3 +6731,20 @@ get_match(wp, id)
     return cur;
 }
 #endif
+
+#if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO)
+    int
+get_win_number(win_T *wp)
+{
+    int                i = 1;
+    win_T      *w;
+
+    for (w = firstwin; w != NULL && w != wp; w = W_NEXT(w))
+       ++i;
+
+    if (w == NULL)
+       return 0;
+    else
+       return i;
+}
+#endif