]> git.ipfire.org Git - thirdparty/newt.git/commitdiff
- updated descriptions
authormsw <msw>
Thu, 25 Feb 1999 17:35:14 +0000 (17:35 +0000)
committermsw <msw>
Thu, 25 Feb 1999 17:35:14 +0000 (17:35 +0000)
- added support for navigating listboxes with alphabetical keypresses

listbox.c
newt.spec

index 4363cfbfde1470ce3333b3cad00dc947ad4ef201..b043a10a2ac2ad84b2b4f628838e3f9fdf7b6533 100644 (file)
--- a/listbox.c
+++ b/listbox.c
@@ -7,6 +7,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <ctype.h>
 
 #include "newt.h"
 #include "newt_pr.h"
@@ -527,7 +528,9 @@ static void listboxDraw(newtComponent co)
 static struct eventResult listboxEvent(newtComponent co, struct event ev) {
     struct eventResult er;
     struct listbox * li = co->data;
-
+    struct items *item;
+    int i;
+    
     er.result = ER_IGNORED;
 
     if(ev.when == EV_EARLY || ev.when == EV_LATE) {
@@ -603,7 +606,7 @@ static struct eventResult listboxEvent(newtComponent co, struct event ev) {
                li->startShowItem = li->numItems - li->curHeight;
            }
            li->currItem += li->curHeight;
-           if(li->currItem > li->numItems) {
+           if(li->currItem >= li->numItems) {
                li->currItem = li->numItems - 1;
            }
            newtListboxRealSetCurrent(co);
@@ -626,7 +629,34 @@ static struct eventResult listboxEvent(newtComponent co, struct event ev) {
            er.result = ER_SWALLOWED;
            break;
          default:
-           /* keeps gcc quiet */
+             if (isalpha(ev.u.key)) {
+
+                 for(i = 0, item = li->boxItems; item != NULL &&
+                         i < li->currItem; i++, item = item->next);
+
+                 if (item->text && (toupper(*item->text) == toupper(ev.u.key))) {
+                     item = item->next;
+                     i++;
+                 } else { 
+                     item = li->boxItems;
+                     i = 0;
+                 }
+                 while (item && item->text &&
+                        toupper(*item->text) != toupper(ev.u.key)) {
+                     item = item->next;
+                     i++;
+                 }
+                 if (item) {
+                     li->currItem = i;
+                     if(li->currItem < li->startShowItem ||
+                        li->currItem > li->startShowItem)
+                         li->startShowItem = li->currItem;
+                     if(li->sb)
+                         newtScrollbarSet(li->sb, li->currItem + 1, li->numItems);
+                     newtListboxRealSetCurrent(co);
+                     er.result = ER_SWALLOWED;
+                 }
+             }
        }
        break;
 
index 1359223a208ea852d7ccba3391c7b17188904bc4..fb4977925a1df2a301cd7fe4dbb80ce229981c1f 100644 (file)
--- a/newt.spec
+++ b/newt.spec
@@ -2,7 +2,7 @@ Summary: A development library for text mode user interfaces.
 Name: newt
 %define version 0.40
 Version: %{version}
-Release: 4
+Release: 5
 Copyright: LGPL
 Group: System Environment/Libraries
 Source: ftp://ftp.redhat.com/pub/redhat/code/newt/newt-%{version}.tar.gz
@@ -55,6 +55,10 @@ rm -rf $RPM_BUILD_ROOT
 %postun -p /sbin/ldconfig
 
 %changelog
+* Thu Feb 25 1999 Matt Wilson <msw@redhat.com>
+- updated descriptions
+- added support for navigating listboxes with alphabetical keypresses
+
 * Mon Feb  8 1999 Matt Wilson <msw@redhat.com>
 - made grid wrapped windows at least the size of their title bars