Added wrappers for tiget{flag,num,str}, for querying terminfo capabilities

This commit is contained in:
Andrew M. Kuchling 2000-07-26 02:57:20 +00:00
parent fdee0f0aa7
commit 70e89c11fe
1 changed files with 47 additions and 0 deletions

View File

@ -2003,6 +2003,50 @@ PyCurses_Start_Color(PyObject *self, PyObject *args)
}
}
static PyObject *
PyCurses_tigetflag(PyObject *self, PyObject *args)
{
char *capname;
PyCursesInitialised;
if (!PyArg_ParseTuple(args, "z", &capname))
return NULL;
return PyInt_FromLong( (long) tigetflag( capname ) );
}
static PyObject *
PyCurses_tigetnum(PyObject *self, PyObject *args)
{
char *capname;
PyCursesInitialised;
if (!PyArg_ParseTuple(args, "z", &capname))
return NULL;
return PyInt_FromLong( (long) tigetnum( capname ) );
}
static PyObject *
PyCurses_tigetstr(PyObject *self, PyObject *args)
{
char *capname;
PyCursesInitialised;
if (!PyArg_ParseTuple(args, "z", &capname))
return NULL;
capname = tigetstr( capname );
if (capname == 0 || capname == (char*) -1) {
Py_INCREF(Py_None);
return Py_None;
}
return PyString_FromString( capname );
}
static PyObject *
PyCurses_TypeAhead(PyObject *self, PyObject *args)
{
@ -2149,6 +2193,9 @@ static PyMethodDef PyCurses_methods[] = {
{"start_color", (PyCFunction)PyCurses_Start_Color},
{"termattrs", (PyCFunction)PyCurses_termattrs},
{"termname", (PyCFunction)PyCurses_termname},
{"tigetflag", (PyCFunction)PyCurses_tigetflag, METH_VARARGS},
{"tigetnum", (PyCFunction)PyCurses_tigetnum, METH_VARARGS},
{"tigetstr", (PyCFunction)PyCurses_tigetstr, METH_VARARGS},
{"typeahead", (PyCFunction)PyCurses_TypeAhead},
{"unctrl", (PyCFunction)PyCurses_UnCtrl},
{"ungetch", (PyCFunction)PyCurses_UngetCh},