li->startShowItem = li->currItem - co->height + 1;
if (li->startShowItem + co->height > li->numItems)
li->startShowItem = li->numItems - co->height;
+ if(li->startShowItem < 0)
+ li->startShowItem = 0;
newtScrollbarSet(li->sb, li->currItem + 1, li->numItems);
listboxDraw(co);
if(!item)
return;
- else
- item->key = text;
-
+ else {
+ free(item->key);
+ item->key = strdup(text);
+ }
if (strlen(text) > li->curWidth) {
co->width = li->curWidth = strlen(text);
if (li->sb)
- li->sb->left = co->left + co->width + 1;
+ li->sb->left = co->left + co->width + 2;
}
if (num >= li->startShowItem && num <= li->startShowItem + co->height)
}
if (text && (strlen(text) > li->curWidth))
- li->curWidth = strlen(text);
+ li->curWidth = strlen(text) ;
- item->key = text; item->data = data; item->next = NULL;
+ item->key = strdup(text); item->data = data; item->next = NULL;
if (li->sb)
- li->sb->left = co->left + li->curWidth + 1;
+ li->sb->left = co->left + li->curWidth + 2;
co->width = li->curWidth;
li->numItems++;
if (text && (strlen(text) > li->curWidth))
li->curWidth = strlen(text);
- item->key = text; item->data = data;
+ item->key = strdup(text); item->data = data;
if (li->sb)
- li->sb->left = co->left + li->curWidth + 1;
+ li->sb->left = co->left + li->curWidth + 2;
co->width = li->curWidth;
li->numItems++;
item2->next = item->next;
}
-
+ free(item->key);
free(item);
li->numItems--;
/* Adjust the listbox width */
co->width = li->curWidth = widest;
if (li->sb)
- li->sb->left = co->left + widest + 1;
+ li->sb->left = co->left + widest + 2;
listboxDraw(co);
newtListboxSetCurrent(co, li->currItem + co->height - 1);
er.result = ER_SWALLOWED;
break;
-
+ case NEWT_KEY_HOME:
+ newtListboxSetCurrent(co, 0);
+ er.result = ER_SWALLOWED;
+ break;
+ case NEWT_KEY_END:
+ newtListboxSetCurrent(co, li->numItems - 1);
+ er.result = ER_SWALLOWED;
+ break;
default:
/* keeps gcc quiet */
}
case EV_UNFOCUS:
li->isActive = 0;
+ listboxDraw(co);
er.result = ER_SWALLOWED;
break;
}
while (item != NULL) {
nextitem = item->next;
+ free(item->key);
free(item);
item = nextitem;
}