0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

updated for version 7.3.938

Problem:    Python: not easy to get to window number.
Solution:   Add vim.window.number. (ZyX)
This commit is contained in:
Bram Moolenaar
2013-05-12 19:00:41 +02:00
parent 971db46799
commit 6d21645f46
5 changed files with 30 additions and 8 deletions

View 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;
int w = get_win_number(this->win);
for (w = firstwin; w != NULL && w != this->win; w = W_NEXT(w))
++i;
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);
}