mirror of
https://github.com/vim/vim.git
synced 2025-09-29 04:34:16 -04:00
updated for version 7.3.1044
Problem: Python: No {Buffer,TabPage,Window}.valid attributes. Solution: Python patch 5: add .valid (ZyX)
This commit is contained in:
@@ -1814,6 +1814,19 @@ TabPageDestructor(TabPageObject *self)
|
|||||||
DESTRUCTOR_FINISH(self);
|
DESTRUCTOR_FINISH(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
TabPageAttrValid(TabPageObject *self, char *name)
|
||||||
|
{
|
||||||
|
PyObject *r;
|
||||||
|
|
||||||
|
if (strcmp(name, "valid") != 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
r = ((self->tab == INVALID_TABPAGE_VALUE) ? Py_False : Py_True);
|
||||||
|
Py_INCREF(r);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
TabPageAttr(TabPageObject *self, char *name)
|
TabPageAttr(TabPageObject *self, char *name)
|
||||||
{
|
{
|
||||||
@@ -2009,6 +2022,19 @@ get_firstwin(TabPageObject *tabObject)
|
|||||||
return firstwin;
|
return firstwin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
WindowAttrValid(WindowObject *self, char *name)
|
||||||
|
{
|
||||||
|
PyObject *r;
|
||||||
|
|
||||||
|
if (strcmp(name, "valid") != 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
r = ((self->win == INVALID_WINDOW_VALUE) ? Py_False : Py_True);
|
||||||
|
Py_INCREF(r);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
WindowAttr(WindowObject *self, char *name)
|
WindowAttr(WindowObject *self, char *name)
|
||||||
{
|
{
|
||||||
@@ -2050,8 +2076,8 @@ WindowAttr(WindowObject *self, char *name)
|
|||||||
return (PyObject *)(self->tabObject);
|
return (PyObject *)(self->tabObject);
|
||||||
}
|
}
|
||||||
else if (strcmp(name,"__members__") == 0)
|
else if (strcmp(name,"__members__") == 0)
|
||||||
return Py_BuildValue("[sssssssss]", "buffer", "cursor", "height",
|
return Py_BuildValue("[ssssssssss]", "buffer", "cursor", "height",
|
||||||
"vars", "options", "number", "row", "col", "tabpage");
|
"vars", "options", "number", "row", "col", "tabpage", "valid");
|
||||||
else
|
else
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -3185,6 +3211,19 @@ BufferSlice(BufferObject *self, PyInt lo, PyInt hi)
|
|||||||
return RBSlice(self, lo, hi, 1, -1);
|
return RBSlice(self, lo, hi, 1, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
BufferAttrValid(BufferObject *self, char *name)
|
||||||
|
{
|
||||||
|
PyObject *r;
|
||||||
|
|
||||||
|
if (strcmp(name, "valid") != 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
r = ((self->buf == INVALID_BUFFER_VALUE) ? Py_False : Py_True);
|
||||||
|
Py_INCREF(r);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
BufferAttr(BufferObject *self, char *name)
|
BufferAttr(BufferObject *self, char *name)
|
||||||
{
|
{
|
||||||
@@ -3198,7 +3237,8 @@ BufferAttr(BufferObject *self, char *name)
|
|||||||
return OptionsNew(SREQ_BUF, self->buf, (checkfun) CheckBuffer,
|
return OptionsNew(SREQ_BUF, self->buf, (checkfun) CheckBuffer,
|
||||||
(PyObject *) self);
|
(PyObject *) self);
|
||||||
else if (strcmp(name,"__members__") == 0)
|
else if (strcmp(name,"__members__") == 0)
|
||||||
return Py_BuildValue("[ssss]", "name", "number", "vars", "options");
|
return Py_BuildValue("[sssss]", "name", "number", "vars", "options",
|
||||||
|
"valid");
|
||||||
else
|
else
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@@ -1125,6 +1125,9 @@ BufferGetattr(PyObject *self, char *name)
|
|||||||
{
|
{
|
||||||
PyObject *r;
|
PyObject *r;
|
||||||
|
|
||||||
|
if ((r = BufferAttrValid((BufferObject *)(self), name)))
|
||||||
|
return r;
|
||||||
|
|
||||||
if (CheckBuffer((BufferObject *)(self)))
|
if (CheckBuffer((BufferObject *)(self)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@@ -1206,6 +1209,9 @@ TabPageGetattr(PyObject *self, char *name)
|
|||||||
{
|
{
|
||||||
PyObject *r;
|
PyObject *r;
|
||||||
|
|
||||||
|
if ((r = TabPageAttrValid((TabPageObject *)(self), name)))
|
||||||
|
return r;
|
||||||
|
|
||||||
if (CheckTabPage((TabPageObject *)(self)))
|
if (CheckTabPage((TabPageObject *)(self)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@@ -1224,6 +1230,9 @@ WindowGetattr(PyObject *self, char *name)
|
|||||||
{
|
{
|
||||||
PyObject *r;
|
PyObject *r;
|
||||||
|
|
||||||
|
if ((r = WindowAttrValid((WindowObject *)(self), name)))
|
||||||
|
return r;
|
||||||
|
|
||||||
if (CheckWindow((WindowObject *)(self)))
|
if (CheckWindow((WindowObject *)(self)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@@ -1067,12 +1067,15 @@ static PyMappingMethods BufferAsMapping = {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
BufferGetattro(PyObject *self, PyObject*nameobj)
|
BufferGetattro(PyObject *self, PyObject *nameobj)
|
||||||
{
|
{
|
||||||
PyObject *r;
|
PyObject *r;
|
||||||
|
|
||||||
GET_ATTR_STRING(name, nameobj);
|
GET_ATTR_STRING(name, nameobj);
|
||||||
|
|
||||||
|
if ((r = BufferAttrValid((BufferObject *)(self), name)))
|
||||||
|
return r;
|
||||||
|
|
||||||
if (CheckBuffer((BufferObject *)(self)))
|
if (CheckBuffer((BufferObject *)(self)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@@ -1094,7 +1097,8 @@ BufferSetattro(PyObject *self, PyObject *nameobj, PyObject *val)
|
|||||||
static PyObject *
|
static PyObject *
|
||||||
BufferDir(PyObject *self UNUSED)
|
BufferDir(PyObject *self UNUSED)
|
||||||
{
|
{
|
||||||
return Py_BuildValue("[sssss]", "name", "number",
|
return Py_BuildValue("[ssssssss]",
|
||||||
|
"name", "number", "vars", "options", "valid",
|
||||||
"append", "mark", "range");
|
"append", "mark", "range");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1283,6 +1287,9 @@ TabPageGetattro(PyObject *self, PyObject *nameobj)
|
|||||||
|
|
||||||
GET_ATTR_STRING(name, nameobj);
|
GET_ATTR_STRING(name, nameobj);
|
||||||
|
|
||||||
|
if ((r = TabPageAttrValid((TabPageObject *)(self), name)))
|
||||||
|
return r;
|
||||||
|
|
||||||
if (CheckTabPage((TabPageObject *)(self)))
|
if (CheckTabPage((TabPageObject *)(self)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@@ -1303,6 +1310,9 @@ WindowGetattro(PyObject *self, PyObject *nameobj)
|
|||||||
|
|
||||||
GET_ATTR_STRING(name, nameobj);
|
GET_ATTR_STRING(name, nameobj);
|
||||||
|
|
||||||
|
if ((r = WindowAttrValid((WindowObject *)(self), name)))
|
||||||
|
return r;
|
||||||
|
|
||||||
if (CheckWindow((WindowObject *)(self)))
|
if (CheckWindow((WindowObject *)(self)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@@ -513,6 +513,7 @@ for _b in vim.buffers:
|
|||||||
if _b is not cb:
|
if _b is not cb:
|
||||||
vim.command('bwipeout! ' + str(_b.number))
|
vim.command('bwipeout! ' + str(_b.number))
|
||||||
del _b
|
del _b
|
||||||
|
cb.append('valid: b:%s, cb:%s' % (repr(b.valid), repr(cb.valid)))
|
||||||
for expr in ('b[1]','b[:] = ["A", "B"]','b[:]','b.append("abc")', 'b.name = "!"'):
|
for expr in ('b[1]','b[:] = ["A", "B"]','b[:]','b.append("abc")', 'b.name = "!"'):
|
||||||
try:
|
try:
|
||||||
exec(expr)
|
exec(expr)
|
||||||
@@ -663,9 +664,13 @@ cb.append('Current tab page: ' + repr(vim.current.tabpage))
|
|||||||
cb.append('Current window: ' + repr(vim.current.window))
|
cb.append('Current window: ' + repr(vim.current.window))
|
||||||
cb.append('Current buffer: ' + repr(vim.current.buffer))
|
cb.append('Current buffer: ' + repr(vim.current.buffer))
|
||||||
cb.append('Current line: ' + repr(vim.current.line))
|
cb.append('Current line: ' + repr(vim.current.line))
|
||||||
|
ws = list(vim.windows)
|
||||||
|
ts = list(vim.tabpages)
|
||||||
for b in vim.buffers:
|
for b in vim.buffers:
|
||||||
if b is not cb:
|
if b is not cb:
|
||||||
vim.command('bwipeout! ' + str(b.number))
|
vim.command('bwipeout! ' + str(b.number))
|
||||||
|
cb.append('w.valid: ' + repr([w.valid for w in ws]))
|
||||||
|
cb.append('t.valid: ' + repr([t.valid for t in ts]))
|
||||||
EOF
|
EOF
|
||||||
:tabonly!
|
:tabonly!
|
||||||
:only!
|
:only!
|
||||||
|
@@ -328,6 +328,7 @@ testdir/bar
|
|||||||
1:BufFilePre:1
|
1:BufFilePre:1
|
||||||
7:BufFilePost:1
|
7:BufFilePost:1
|
||||||
testdir/test86.in
|
testdir/test86.in
|
||||||
|
valid: b:False, cb:True
|
||||||
i:<buffer test86.in>
|
i:<buffer test86.in>
|
||||||
i2:<buffer test86.in>
|
i2:<buffer test86.in>
|
||||||
i:<buffer a>
|
i:<buffer a>
|
||||||
@@ -344,7 +345,7 @@ Number of tabs: 4
|
|||||||
Current tab pages:
|
Current tab pages:
|
||||||
<tabpage 0>(1): 1 windows, current is <window object (unknown)>
|
<tabpage 0>(1): 1 windows, current is <window object (unknown)>
|
||||||
Windows:
|
Windows:
|
||||||
<window object (unknown)>(1): displays buffer <buffer test86.in>; cursor is at (36, 0)
|
<window object (unknown)>(1): displays buffer <buffer test86.in>; cursor is at (37, 0)
|
||||||
<tabpage 1>(2): 1 windows, current is <window object (unknown)>
|
<tabpage 1>(2): 1 windows, current is <window object (unknown)>
|
||||||
Windows:
|
Windows:
|
||||||
<window object (unknown)>(1): displays buffer <buffer 0>; cursor is at (1, 0)
|
<window object (unknown)>(1): displays buffer <buffer 0>; cursor is at (1, 0)
|
||||||
@@ -370,6 +371,8 @@ Current tab page: <tabpage 2>
|
|||||||
Current window: <window 0>
|
Current window: <window 0>
|
||||||
Current buffer: <buffer test86.in>
|
Current buffer: <buffer test86.in>
|
||||||
Current line: 'Type error at assigning None to vim.current.buffer'
|
Current line: 'Type error at assigning None to vim.current.buffer'
|
||||||
|
w.valid: [True, False]
|
||||||
|
t.valid: [True, False, True, False]
|
||||||
vim.vars:Dictionary:True
|
vim.vars:Dictionary:True
|
||||||
vim.options:Options:True
|
vim.options:Options:True
|
||||||
vim.bindeval("{}"):Dictionary:True
|
vim.bindeval("{}"):Dictionary:True
|
||||||
|
@@ -500,6 +500,7 @@ for _b in vim.buffers:
|
|||||||
if _b is not cb:
|
if _b is not cb:
|
||||||
vim.command('bwipeout! ' + str(_b.number))
|
vim.command('bwipeout! ' + str(_b.number))
|
||||||
del _b
|
del _b
|
||||||
|
cb.append('valid: b:%s, cb:%s' % (repr(b.valid), repr(cb.valid)))
|
||||||
for expr in ('b[1]','b[:] = ["A", "B"]','b[:]','b.append("abc")'):
|
for expr in ('b[1]','b[:] = ["A", "B"]','b[:]','b.append("abc")'):
|
||||||
try:
|
try:
|
||||||
exec(expr)
|
exec(expr)
|
||||||
@@ -641,9 +642,13 @@ cb.append('Current tab page: ' + repr(vim.current.tabpage))
|
|||||||
cb.append('Current window: ' + repr(vim.current.window))
|
cb.append('Current window: ' + repr(vim.current.window))
|
||||||
cb.append('Current buffer: ' + repr(vim.current.buffer))
|
cb.append('Current buffer: ' + repr(vim.current.buffer))
|
||||||
cb.append('Current line: ' + repr(vim.current.line))
|
cb.append('Current line: ' + repr(vim.current.line))
|
||||||
|
ws = list(vim.windows)
|
||||||
|
ts = list(vim.tabpages)
|
||||||
for b in vim.buffers:
|
for b in vim.buffers:
|
||||||
if b is not cb:
|
if b is not cb:
|
||||||
vim.command('bwipeout! ' + str(b.number))
|
vim.command('bwipeout! ' + str(b.number))
|
||||||
|
cb.append('w.valid: ' + repr([w.valid for w in ws]))
|
||||||
|
cb.append('t.valid: ' + repr([t.valid for t in ts]))
|
||||||
EOF
|
EOF
|
||||||
:tabonly!
|
:tabonly!
|
||||||
:only!
|
:only!
|
||||||
|
@@ -317,6 +317,7 @@ testdir/bar
|
|||||||
1:BufFilePre:1
|
1:BufFilePre:1
|
||||||
7:BufFilePost:1
|
7:BufFilePost:1
|
||||||
testdir/test87.in
|
testdir/test87.in
|
||||||
|
valid: b:False, cb:True
|
||||||
i:<buffer test87.in>
|
i:<buffer test87.in>
|
||||||
i2:<buffer test87.in>
|
i2:<buffer test87.in>
|
||||||
i:<buffer a>
|
i:<buffer a>
|
||||||
@@ -333,7 +334,7 @@ Number of tabs: 4
|
|||||||
Current tab pages:
|
Current tab pages:
|
||||||
<tabpage 0>(1): 1 windows, current is <window object (unknown)>
|
<tabpage 0>(1): 1 windows, current is <window object (unknown)>
|
||||||
Windows:
|
Windows:
|
||||||
<window object (unknown)>(1): displays buffer <buffer test87.in>; cursor is at (36, 0)
|
<window object (unknown)>(1): displays buffer <buffer test87.in>; cursor is at (37, 0)
|
||||||
<tabpage 1>(2): 1 windows, current is <window object (unknown)>
|
<tabpage 1>(2): 1 windows, current is <window object (unknown)>
|
||||||
Windows:
|
Windows:
|
||||||
<window object (unknown)>(1): displays buffer <buffer 0>; cursor is at (1, 0)
|
<window object (unknown)>(1): displays buffer <buffer 0>; cursor is at (1, 0)
|
||||||
@@ -359,6 +360,8 @@ Current tab page: <tabpage 2>
|
|||||||
Current window: <window 0>
|
Current window: <window 0>
|
||||||
Current buffer: <buffer test87.in>
|
Current buffer: <buffer test87.in>
|
||||||
Current line: 'Type error at assigning None to vim.current.buffer'
|
Current line: 'Type error at assigning None to vim.current.buffer'
|
||||||
|
w.valid: [True, False]
|
||||||
|
t.valid: [True, False, True, False]
|
||||||
vim.vars:Dictionary:True
|
vim.vars:Dictionary:True
|
||||||
vim.options:Options:True
|
vim.options:Options:True
|
||||||
vim.bindeval("{}"):Dictionary:True
|
vim.bindeval("{}"):Dictionary:True
|
||||||
|
@@ -728,6 +728,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1044,
|
||||||
/**/
|
/**/
|
||||||
1043,
|
1043,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user