]> git.ipfire.org Git - thirdparty/newt.git/commitdiff
Add showCursor flag for listboxes.
authorsopwith <sopwith>
Fri, 21 Sep 2001 00:38:36 +0000 (00:38 +0000)
committersopwith <sopwith>
Fri, 21 Sep 2001 00:38:36 +0000 (00:38 +0000)
configure.in
listbox.c
newt.h
snack.py
snackmodule.c
test.c

index 50a484b6551450717b8057bc80643ea874344ab3..993c209b799ffbc11bfb39169a1708ca9368df8e 100644 (file)
@@ -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)
index 734a3cc794373e43926bec46791d502bb56d43a3..e6716f9ea57ec2f51bb6e9917c5a2c367ffe0086 100644 (file)
--- 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 7e958270bd5834f16f1a5251a7247cbd9d999123..3805b4e4f15a8232b0bd01759c9e3c296f9bc949 100644 (file)
--- 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)
index e97c93f5c4c47796f9ca5563b5318baa92b63dd9..82cf6d72b69a4d67ed6721ef0af741edbaaf8671 100644 (file)
--- 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):
index d02f7b83498779f901e92b6cea6fab3d6ae1e463..fda6bad4123e17674cc3728ed4a7d67ec6948fa5 100644 (file)
@@ -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 04ccc039d38300bd5f63cb406a802f69409e4f20..754da624014d072006a2ba23f031fcef3f80bd3c 100644 (file)
--- 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);