diff options
author | Lukas Fleischer <calcurse@cryptocrack.de> | 2014-07-16 16:11:17 +0200 |
---|---|---|
committer | Lukas Fleischer <calcurse@cryptocrack.de> | 2014-07-16 16:13:07 +0200 |
commit | b36d253dce737a188bff85891fc5b4c4341f6564 (patch) | |
tree | c89204d08308fad83c9e10d718451c494ef3145c /src/listbox.c | |
parent | 6550591b08eed2c06932f194d5f44ee44084b9b3 (diff) | |
download | calcurse-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/listbox.c')
-rw-r--r-- | src/listbox.c | 3 |
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; |