From: sopwith Date: Fri, 21 Sep 2001 00:38:36 +0000 (+0000) Subject: Add showCursor flag for listboxes. X-Git-Tag: r0-50-35~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b5c4016a09f311f93e9d06b7b3005543137b68a2;p=thirdparty%2Fnewt.git Add showCursor flag for listboxes. --- diff --git a/configure.in b/configure.in index 50a484b..993c209 100644 --- a/configure.in +++ b/configure.in @@ -3,9 +3,9 @@ dnl Process this file with autoconf to produce a configure script. AC_INIT(newt_pr.h) AC_CONFIG_HEADER(config.h) -VERSION=$(awk '/^%define version/ {print $3}' newt.spec) +VERSION=$(awk '/^%define version/ {print $3}' $srcdir/newt.spec) -VERSION=0.50.34 +VERSION=0.50.35 SONAME=0.50 AC_SUBST(VERSION) AC_SUBST(SONAME) diff --git a/listbox.c b/listbox.c index 734a3cc..e6716f9 100644 --- a/listbox.c +++ b/listbox.c @@ -100,7 +100,7 @@ newtComponent newtListbox(int left, int top, int height, int flags) { li->bdxAdjust = 0; li->bdyAdjust = 0; li->flags = flags & (NEWT_FLAG_RETURNEXIT | NEWT_FLAG_BORDER | - NEWT_FLAG_MULTIPLE); + NEWT_FLAG_MULTIPLE | NEWT_FLAG_SHOWCURSOR); if (li->flags & NEWT_FLAG_BORDER) { li->bdxAdjust = 2; @@ -524,7 +524,7 @@ static void listboxDraw(newtComponent co) SLsmg_write_nstring(item->text, li->curWidth); } - newtGotorc(co->top + (li->currItem - li->startShowItem), co->left); + newtGotorc(co->top + (li->currItem - li->startShowItem) + 1, co->left + 1); } static struct eventResult listboxEvent(newtComponent co, struct event ev) { @@ -668,12 +668,16 @@ static struct eventResult listboxEvent(newtComponent co, struct event ev) { case EV_FOCUS: li->isActive = 1; listboxDraw(co); + if(li->flags & NEWT_FLAG_SHOWCURSOR) + newtCursorOn(); er.result = ER_SWALLOWED; break; case EV_UNFOCUS: li->isActive = 0; listboxDraw(co); + if(li->flags & NEWT_FLAG_SHOWCURSOR) + newtCursorOff(); er.result = ER_SWALLOWED; break; diff --git a/newt.h b/newt.h index 7e95827..3805b4e 100644 --- a/newt.h +++ b/newt.h @@ -73,6 +73,7 @@ enum newtFlagsSense { NEWT_FLAGS_SET, NEWT_FLAGS_RESET, NEWT_FLAGS_TOGGLE }; #define NEWT_FLAG_SELECTED (1 << 9) #define NEWT_FLAG_CHECKBOX (1 << 10) #define NEWT_FLAG_PASSWORD (1 << 11) /* draw '*' of chars in entrybox */ +#define NEWT_FLAG_SHOWCURSOR (1 << 12) /* Only applies to listbox for now */ #define NEWT_FD_READ (1 << 0) #define NEWT_FD_WRITE (1 << 1) #define NEWT_FD_EXCEPT (1 << 2) diff --git a/snack.py b/snack.py index e97c93f..82cf6d7 100644 --- a/snack.py +++ b/snack.py @@ -104,8 +104,8 @@ class Listbox(Widget): self.item2key = {} self.w.listboxClear() - def __init__(self, height, scroll = 0, returnExit = 0, width = 0): - self.w = _snack.listbox(height, scroll, returnExit) + def __init__(self, height, scroll = 0, returnExit = 0, width = 0, showCursor = 0): + self.w = _snack.listbox(height, scroll, returnExit, showCursor) self.key2item = {} self.item2key = {} if (width): diff --git a/snackmodule.c b/snackmodule.c index d02f7b8..fda6bad 100644 --- a/snackmodule.c +++ b/snackmodule.c @@ -621,15 +621,17 @@ static PyObject * widgetTextboxText(snackWidget * s, PyObject * args) { static snackWidget * listboxWidget(PyObject * s, PyObject * args) { snackWidget * widget; int height; - int doScroll = 0, returnExit = 0 ; + int doScroll = 0, returnExit = 0, showCursor = 0 ; - if (!PyArg_ParseTuple(args, "i|ii", &height, &doScroll, &returnExit)) + if (!PyArg_ParseTuple(args, "i|iii", &height, &doScroll, &returnExit, &showCursor)) return NULL; widget = snackWidgetNew (); widget->co = newtListbox(-1, -1, height, - (doScroll ? NEWT_FLAG_SCROLL : 0) | - (returnExit ? NEWT_FLAG_RETURNEXIT : 0)); + (doScroll ? NEWT_FLAG_SCROLL : 0) | + (returnExit ? NEWT_FLAG_RETURNEXIT : 0) | + (showCursor ? NEWT_FLAG_SHOWCURSOR : 0) + ); widget->anint = 1; return widget; diff --git a/test.c b/test.c index 04ccc03..754da62 100644 --- a/test.c +++ b/test.c @@ -98,7 +98,7 @@ int main(void) { newtFormAddComponents(f, rsf, scale, NULL); lb = newtListbox(45, 1, 6, NEWT_FLAG_MULTIPLE | NEWT_FLAG_BORDER | - NEWT_FLAG_SCROLL); + NEWT_FLAG_SCROLL | NEWT_FLAG_SHOWCURSOR); newtListboxAppendEntry(lb, "First", (void *) 1); newtListboxAppendEntry(lb, "Second", (void *) 2); newtListboxAppendEntry(lb, "Third", (void *) 3);