#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <ctype.h>
#include "newt.h"
#include "newt_pr.h"
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) {
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);
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;
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
%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