]> git.ipfire.org Git - thirdparty/newt.git/commitdiff
added method to change textbox text, added wrap flag
authormsw <msw>
Mon, 28 Jun 1999 03:40:46 +0000 (03:40 +0000)
committermsw <msw>
Mon, 28 Jun 1999 03:40:46 +0000 (03:40 +0000)
snack.py
snackmodule.c

index 09fbc3d20d257cbd1268c5e1cffdbbc165847b73..2b1ca86d9135cc6223954fa7c09de9c263f3f2dd 100644 (file)
--- a/snack.py
+++ b/snack.py
@@ -83,8 +83,11 @@ class Listbox(Widget):
 
 class Textbox(Widget):
 
-    def __init__(self, width, height, text, scroll = 0):
-       self.w = _snack.textbox(width, height, text, scroll)
+    def setText(self, text):
+       self.w.textboxText(text)
+
+    def __init__(self, width, height, text, scroll = 0, wrap = 0):
+       self.w = _snack.textbox(width, height, text, scroll, wrap)
 
 class TextboxReflowed(Textbox):
 
index b6b5d2ed6088e04c44eabed434b1f9937e443d35..34f3d6c704efbfc714f6e060e273679e56b3a37a 100644 (file)
@@ -160,10 +160,12 @@ static PyObject * widgetListboxAdd(snackWidget * s, PyObject * args);
 static PyObject * widgetListboxIns(snackWidget * s, PyObject * args);
 static PyObject * widgetListboxDel(snackWidget * s, PyObject * args);
 static PyObject * widgetListboxGet(snackWidget * s, PyObject * args);
+static PyObject * widgetTextboxText(snackWidget * s, PyObject * args);
 
 static PyMethodDef widgetMethods[] = {
     { "setCallback", (PyCFunction) widgetAddCallback, METH_VARARGS, NULL },
     { "labelText", (PyCFunction) widgetLabelText, METH_VARARGS, NULL },
+    { "textboxText", (PyCFunction) widgetTextboxText, METH_VARARGS, NULL },
     { "entrySetValue", (PyCFunction) widgetEntrySetValue, METH_VARARGS, NULL },
     { "listboxAddItem", (PyCFunction) widgetListboxAdd, METH_VARARGS, NULL },
     { "listboxInsertItem", (PyCFunction) widgetListboxIns, METH_VARARGS, NULL },
@@ -445,6 +447,17 @@ static PyObject * widgetLabelText(snackWidget * s, PyObject * args) {
     return Py_None;
 }
 
+static PyObject * widgetTextboxText(snackWidget * s, PyObject * args) {
+    char * text;
+
+    if (!PyArg_ParseTuple(args, "s", &text)) return NULL;
+
+    newtTextboxSetText(s->co, text);
+
+    Py_INCREF(Py_None);
+    return Py_None;
+}
+
 static snackWidget * listboxWidget(PyObject * s, PyObject * args) {
     snackWidget * widget;
     int height;
@@ -466,14 +479,16 @@ static snackWidget * textWidget(PyObject * s, PyObject * args) {
     char * text;
     int width, height;
     int scrollBar = 0;
+    int wrap = 0;
     snackWidget * widget;
     
-    if (!PyArg_ParseTuple(args, "iis|i", &width, &height, &text, &scrollBar))
+    if (!PyArg_ParseTuple(args, "iis|ii", &width, &height, &text, &scrollBar, &wrap))
        return NULL;
 
     widget = PyObject_NEW(snackWidget, &snackWidgetType);
     widget->co = newtTextbox(-1, -1, width, height,
-                               scrollBar ? NEWT_FLAG_SCROLL : 0);
+                               (scrollBar ? NEWT_FLAG_SCROLL : 0) |
+                               (wrap ? NEWT_FLAG_WRAP : 0));
     newtTextboxSetText(widget->co, text);
     
     return widget;