python: Added ncstrwidth function

pull/1662/head
igo95862 3 years ago committed by Nick Black
parent 18df2c8ee3
commit d070abd96b

@ -14,8 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from .misc import notcurses_version, notcurses_version_components
from .misc import ncstrwidth, notcurses_version, notcurses_version_components
__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);
}
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[] = {
{"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."},
{"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},
};

Loading…
Cancel
Save