mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-10 01:29:05 -04:00
python: Added ncstrwidth function
This commit is contained in:
parent
18df2c8ee3
commit
d070abd96b
@ -14,8 +14,8 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from .misc import notcurses_version, notcurses_version_components
|
from .misc import ncstrwidth, notcurses_version, notcurses_version_components
|
||||||
|
|
||||||
__all__ = (
|
__all__ = (
|
||||||
'notcurses_version', 'notcurses_version_components'
|
'ncstrwidth', 'notcurses_version', 'notcurses_version_components'
|
||||||
)
|
)
|
||||||
|
@ -34,9 +34,20 @@ python_notcurses_version_components(PyObject *Py_UNUSED(self), PyObject *Py_UNUS
|
|||||||
return Py_BuildValue("iiii", major, minor, patch, tweak);
|
return Py_BuildValue("iiii", major, minor, patch, tweak);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static PyObject*
|
||||||
|
python_ncstrwidth(PyObject *Py_UNUSED(self), PyObject *args)
|
||||||
|
{
|
||||||
|
const char* s = NULL;
|
||||||
|
|
||||||
|
PY_CHECK_INT(PyArg_Parse(args, "s", &s));
|
||||||
|
|
||||||
|
return Py_BuildValue("i", ncstrwidth(s));
|
||||||
|
}
|
||||||
|
|
||||||
static PyMethodDef NotcursesMiscMethods[] = {
|
static PyMethodDef NotcursesMiscMethods[] = {
|
||||||
{"notcurses_version", (PyCFunction)python_notcurses_version, METH_NOARGS, "Get a human-readable string describing the running Notcurses version."},
|
{"notcurses_version", (PyCFunction)python_notcurses_version, METH_NOARGS, "Get a human-readable string describing the running Notcurses version."},
|
||||||
{"notcurses_version_components", (PyCFunction)python_notcurses_version_components, METH_NOARGS, "Get a tuple of major, minor, patch, tweak integer of the running Notcurses version."},
|
{"notcurses_version_components", (PyCFunction)python_notcurses_version_components, METH_NOARGS, "Get a tuple of major, minor, patch, tweak integer of the running Notcurses version."},
|
||||||
|
{"ncstrwidth", (PyCFunction)python_ncstrwidth, METH_VARARGS, "Returns the number of columns occupied by a string, or -1 if a non-printable/illegal character is encountered."},
|
||||||
{NULL, NULL, 0, NULL},
|
{NULL, NULL, 0, NULL},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user