summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2014-07-16 16:11:17 +0200
committerLukas Fleischer <calcurse@cryptocrack.de>2014-07-16 16:13:07 +0200
commitb36d253dce737a188bff85891fc5b4c4341f6564 (patch)
treec89204d08308fad83c9e10d718451c494ef3145c /src
parent6550591b08eed2c06932f194d5f44ee44084b9b3 (diff)
downloadcalcurse-b36d253dce737a188bff85891fc5b4c4341f6564.zip
Automatically select first item in list boxes
If the selection is empty during listbox_load_items() and there is at least one item in the list, automatically select the first item. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
Diffstat (limited to 'src')
-rw-r--r--src/listbox.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/listbox.c b/src/listbox.c
index 5cdc9a1..853dc03 100644
--- a/src/listbox.c
+++ b/src/listbox.c
@@ -88,6 +88,9 @@ void listbox_load_items(struct listbox *lb, int item_count)
lb->item_count = item_count;
+ if (item_count > 0 && lb->item_sel < 0)
+ lb->item_sel = 0;
+
if (lb->item_sel >= item_count)
lb->item_sel = item_count - 1;