+0.59 -> 0.50.10
+ - added support for help
+
+0.57 -> 0.59
+ - minor fixes
+
0.55 -> 0.56
- added newtCheckboxTreeSetEntry(), newtCheckboxTreeGetEntryValue()
and newtCheckboxTreeSetEntryValue()
AC_INIT(newt_pr.h)
AC_CONFIG_HEADER(config.h)
-VERSION=0.50.9
+VERSION=0.50.10
SONAME=0.50
AC_SUBST(VERSION)
AC_SUBST(SONAME)
int maxFd;
int timer; /* in milliseconds */
struct timeval lastTimeout;
+ void * helpTag;
+ newtCallback helpCb;
};
static void gotoComponent(struct form * form, int newComp);
static struct eventResult sendEvent(newtComponent comp, struct event ev);
static void formPlace(newtComponent co, int left, int top);
+/* Global, ick */
+static newtCallback helpCallback;
+
/* this isn't static as grid.c tests against it to find forms */
struct componentOps formOps = {
newtDrawForm,
return 1;
}
-newtComponent newtForm(newtComponent vertBar, const char * help, int flags) {
+newtComponent newtForm(newtComponent vertBar, void * help, int flags) {
newtComponent co;
struct form * form;
else
form->vertBar = NULL;
+ form->helpTag = help;
+ form->helpCb = helpCallback;
+
return co;
}
}
}
+ if (key == NEWT_KEY_F1 && form->helpTag && form->helpCb)
+ form->helpCb(co, form->helpTag);
+
if (!done) {
ev.event = EV_KEYPRESS;
ev.u.key = key;
form->fds[form->numFds++].flags = fdFlags;
if (form->maxFd < fd) form->maxFd = fd;
}
+
+void newtSetHelpCallback(newtCallback cb) {
+ helpCallback = cb;
+}
void newtRefresh(void);
void newtSuspend(void);
void newtSetSuspendCallback(newtSuspendCallback cb, void * data);
+void newtSetHelpCallback(newtCallback cb);
void newtResume(void);
void newtPushHelpLine(const char * text);
void newtRedrawHelpLine(void);
} u;
} ;
-newtComponent newtForm(newtComponent vertBar, const char * help, int flags);
+newtComponent newtForm(newtComponent vertBar, void * helpTag, int flags);
void newtFormSetTimer(newtComponent form, int millisecs);
void newtFormWatchFd(newtComponent form, int fd, int fdFlags);
void newtFormSetSize(newtComponent co);
Summary: A development library for text mode user interfaces.
Name: newt
-%define version 0.50.9
+%define version 0.50.10
Version: %{version}
Release: 1
Copyright: LGPL
from snack import *
import sys
+def help(screen, text):
+ ButtonChoiceWindow(screen, "Help", text)
+
t = TextboxReflowed(25, "Some text which needs to be wrapped at a good place.")
li = Listbox(5, width = 20, returnExit = 1)
li.append("First", "f")
screen = SnackScreen()
+screen.helpCallback(help)
+
foo = EntryWindow(screen, 'Title', 'This is some text for the entry window',
['prompt', 'more', 'info'])
screen.gridWrappedWindow(g, "title")
-f = Form()
+f = Form("This is some help")
f.add(li)
f.add(b)
f.add(e)
f.add(r2)
f.add(t)
-f.addHotKey("F1")
-
res = f.run()
screen.popWindow()
self.w.draw()
return None
- def __init__(self):
+ def __init__(self, helpArg = None):
self.trans = {}
- self.w = _snack.form()
+ self.w = _snack.form(helpArg)
+ # we do the reference count for the helpArg in python! gross
+ self.helpArg = helpArg
def setCurrent (self, co):
self.w.setcurrent (co.w)
def suspend(self):
_snack.suspend()
+ def doHelpCallback(self, arg):
+ self.helpCb(self, arg)
+
+ def helpCallback(self, cb):
+ self.helpCb = cb
+ return _snack.helpcallback(self.doHelpCallback)
+
def suspendCallback(self, cb, data = None):
if data:
return _snack.suspendcallback(cb, data)
};
static struct callbackStruct suspend;
+static struct callbackStruct helpCallback;
static void emptyDestructor(PyObject * s);
static PyObject * scaleSet(snackWidget * s, PyObject * args);
static PyObject * screenSize(PyObject * s, PyObject * args);
static PyObject * setSuspendCallback(PyObject * s, PyObject * args);
+static PyObject * setHelpCallback(PyObject * s, PyObject * args);
static PyObject * reflowText(PyObject * s, PyObject * args);
static snackWidget * textWidget(PyObject * s, PyObject * args);
static PyObject * ternaryWindow(PyObject * s, PyObject * args);
{ "form", (PyCFunction) formCreate, METH_VARARGS, NULL },
{ "grid", (PyCFunction) gridCreate, METH_VARARGS, NULL },
{ "gridwrappedwindow", gridWrappedWindow, METH_VARARGS, NULL },
+ { "helpcallback", setHelpCallback, METH_VARARGS, NULL },
{ "init", initScreen, METH_VARARGS, NULL },
{ "label", (PyCFunction) labelWidget, METH_VARARGS, NULL },
{ "listbox", (PyCFunction) listboxWidget, METH_VARARGS, NULL },
return Py_BuildValue("(ii)", width, height);
}
+static void helpCallbackMarshall(newtComponent co, void * data) {
+ PyObject * args, * result;
+
+ args = Py_BuildValue("(O)", data);
+ result = PyEval_CallObject(helpCallback.cb, args);
+ Py_DECREF (args);
+ Py_XDECREF(result);
+
+ return;
+}
+
static void suspendCallbackMarshall(void * data) {
struct callbackStruct * scs = data;
PyObject * args, * result;
return Py_None;
}
+static PyObject * setHelpCallback(PyObject * s, PyObject * args) {
+ if (!PyArg_ParseTuple(args, "O", &helpCallback.cb))
+ return NULL;
+
+ /*if (helpCallback.cb) {
+ Py_DECREF (helpCallback.cb);
+ }*/
+
+ Py_INCREF (helpCallback.cb);
+
+ newtSetHelpCallback(helpCallbackMarshall);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
static PyObject * drawRootText(PyObject * s, PyObject * args) {
int left, top;
char * text;
static snackForm * formCreate(PyObject * s, PyObject * args) {
snackForm * form;
+ PyObject * help = Py_None;
+
+ if (!PyArg_ParseTuple(args, "|O", &help)) return NULL;
+
+ if (help == Py_None)
+ help = NULL;
form = PyObject_NEW(snackForm, &snackFormType);
- form->fo = newtForm(NULL, NULL, 0);
+ form->fo = newtForm(NULL, help, 0);
return form;
}
if (!PyArg_ParseTuple(args, "i", &index))
return NULL;
- newtListboxSetCurrentByKey(s->co, index);
+ newtListboxSetCurrentByKey(s->co, (void *) index);
Py_INCREF(Py_None);
return Py_None;
if (!PyArg_ParseTuple(args, ""))
return NULL;
- selection = newtCheckboxTreeGetSelection(s->co, &numselected);
+ selection = (void **) newtCheckboxTreeGetSelection(s->co, &numselected);
sel = PyList_New(0);
newtResume();
}
+void helpCallback(newtComponent co, void * tag) {
+ newtWinMessage("Help", "Ok", tag);
+}
+
int main(void) {
newtComponent b1, b2, r1, r2, r3, e2, e3, l1, l2, l3, scale;
newtComponent lb, t, rsf, answer, timeLabel;
newtCls();
newtSetSuspendCallback(suspend, NULL);
+ newtSetHelpCallback(helpCallback);
newtDrawRootText(0, 0, "Newt test program");
newtPushHelpLine(NULL);
newtOpenWindow(2, 2, 30, 10, "first window");
newtOpenWindow(10, 5, 65, 16, "window 2");
- f = newtForm(NULL, NULL, 0);
+ f = newtForm(NULL, "This is some help text", 0);
chklist = newtForm(NULL, NULL, 0);
b1 = newtButton(3, 1, "Exit");