]> git.ipfire.org Git - thirdparty/newt.git/commitdiff
fixed:
authorewt <ewt>
Wed, 12 Jan 2000 14:57:28 +0000 (14:57 +0000)
committerewt <ewt>
Wed, 12 Jan 2000 14:57:28 +0000 (14:57 +0000)
1. if an empty listbox has the focus and the user presses a key which isn't
   defined as a hotkey by its form, the program crashes.

2. if the program uses newtListboxSetCurrent() to select an item which is
   not displayed because it is beyond the bottom of the widget, the refresh
   code doesn't make it visible.

listbox.c

index dc966659b0396ecf5b1a83ec35e9a62a599b1c9f..ef276aeb4c43767d3d50feb10ca28089bedfa94a 100644 (file)
--- a/listbox.c
+++ b/listbox.c
@@ -174,10 +174,10 @@ void newtListboxSetCurrent(newtComponent co, int num)
 
     if (li->currItem < li->startShowItem)
        li->startShowItem = li->currItem;
-    else if (li->currItem - li->startShowItem > co->height - 1)
-       li->startShowItem = li->currItem - co->height + 1;
-    if (li->startShowItem + co->height > li->numItems)
-       li->startShowItem = li->numItems - co->height;
+    else if (li->currItem - li->startShowItem > li->curHeight - 1)
+       li->startShowItem = li->currItem - li->curHeight + 1;
+    if (li->startShowItem + li->curHeight > li->numItems)
+       li->startShowItem = li->numItems - li->curHeight;
     if(li->startShowItem < 0)
        li->startShowItem = 0;
 
@@ -629,6 +629,7 @@ static struct eventResult listboxEvent(newtComponent co, struct event ev) {
            er.result = ER_SWALLOWED;
            break;
          default:
+             if (li->numItems <= 0) break;
               if (ev.u.key < NEWT_KEY_EXTRA_BASE && isalpha(ev.u.key)) {
                  for(i = 0, item = li->boxItems; item != NULL &&
                          i < li->currItem; i++, item = item->next);