aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/config/lxdialog/menubox.c
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2015-01-08 14:33:53 +0000
committerFelix Fietkau <nbd@openwrt.org>2015-01-08 14:33:53 +0000
commit648b9ba08bd610b866b18a39de7a4572c2196cf3 (patch)
treeae40ed05ad376533dd6005724b9d3925e46a77d1 /scripts/config/lxdialog/menubox.c
parent074a033f4e45691e7b220eab76778aba5bc9b9f6 (diff)
downloadupstream-648b9ba08bd610b866b18a39de7a4572c2196cf3.tar.gz
upstream-648b9ba08bd610b866b18a39de7a4572c2196cf3.tar.bz2
upstream-648b9ba08bd610b866b18a39de7a4572c2196cf3.zip
scripts/config: sync with linux upstream
Signed-off-by: Felix Fietkau <nbd@openwrt.org> git-svn-id: svn://svn.openwrt.org/openwrt/trunk@43873 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'scripts/config/lxdialog/menubox.c')
-rw-r--r--scripts/config/lxdialog/menubox.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/scripts/config/lxdialog/menubox.c b/scripts/config/lxdialog/menubox.c
index 48d382e7e3..11ae9ad7ac 100644
--- a/scripts/config/lxdialog/menubox.c
+++ b/scripts/config/lxdialog/menubox.c
@@ -64,7 +64,7 @@ static int menu_width, item_x;
* Print menu item
*/
static void do_print_item(WINDOW * win, const char *item, int line_y,
- int selected, int hotkey)
+ int selected, int hotkey)
{
int j;
char *menu_item = malloc(menu_width + 1);
@@ -182,7 +182,7 @@ static void do_scroll(WINDOW *win, int *scroll, int n)
* Display a menu for choosing among a number of options
*/
int dialog_menu(const char *title, const char *prompt,
- const void *selected, int *s_scroll)
+ const void *selected, int *s_scroll)
{
int i, j, x, y, box_x, box_y;
int height, width, menu_height;
@@ -193,7 +193,7 @@ int dialog_menu(const char *title, const char *prompt,
do_resize:
height = getmaxy(stdscr);
width = getmaxx(stdscr);
- if (height < 15 || width < 65)
+ if (height < MENUBOX_HEIGTH_MIN || width < MENUBOX_WIDTH_MIN)
return -ERRDISPLAYTOOSMALL;
height -= 4;
@@ -203,8 +203,8 @@ do_resize:
max_choice = MIN(menu_height, item_count());
/* center dialog box on screen */
- x = (COLS - width) / 2;
- y = (LINES - height) / 2;
+ x = (getmaxx(stdscr) - width) / 2;
+ y = (getmaxy(stdscr) - height) / 2;
draw_shadow(stdscr, y, x, height, width);
@@ -303,10 +303,11 @@ do_resize:
}
}
- if (i < max_choice ||
- key == KEY_UP || key == KEY_DOWN ||
- key == '-' || key == '+' ||
- key == KEY_PPAGE || key == KEY_NPAGE) {
+ if (item_count() != 0 &&
+ (i < max_choice ||
+ key == KEY_UP || key == KEY_DOWN ||
+ key == '-' || key == '+' ||
+ key == KEY_PPAGE || key == KEY_NPAGE)) {
/* Remove highligt of current item */
print_item(scroll + choice, choice, FALSE);