From d4d991ee5aff51322086eefd591708d5e9c68338 Mon Sep 17 00:00:00 2001 From: russell Date: Sun, 11 Jun 2006 22:11:38 +0000 Subject: optimize the display of the module selection menus by only clearing the screen and starting over if a selection has changed or the menu needs to be scrolled. For moving the cursor up and down the menu, it works a lot faster now. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@33576 f38db490-d61c-443f-a65b-d21fe96a405b --- build_tools/menuselect_curses.c | 102 +++++++++++++++++++++++++++------------- 1 file changed, 69 insertions(+), 33 deletions(-) (limited to 'build_tools') diff --git a/build_tools/menuselect_curses.c b/build_tools/menuselect_curses.c index 180582a72..6728dd98c 100644 --- a/build_tools/menuselect_curses.c +++ b/build_tools/menuselect_curses.c @@ -67,7 +67,7 @@ const char * const help_info[] = { void winch_handler(int sig); void show_help(WINDOW *win); void draw_main_menu(WINDOW *menu, int curopt); -void draw_category_menu(WINDOW *menu, struct category *cat, int start, int end, int curopt); +void draw_category_menu(WINDOW *menu, struct category *cat, int start, int end, int curopt, int changed); int run_category_menu(WINDOW *menu, int cat_num); int run_category_menu(WINDOW *menu, int cat_num); void draw_title_window(WINDOW *title); @@ -122,18 +122,72 @@ void draw_main_menu(WINDOW *menu, int curopt) wrefresh(menu); } -void draw_category_menu(WINDOW *menu, struct category *cat, int start, int end, int curopt) +void display_mem_info(WINDOW *menu, struct member *mem, int start, int end) { - int i = 0; - int j = 0; - struct member *mem, *curmem = NULL; + char buf[64]; struct depend *dep; struct conflict *con; + + wmove(menu, end - start + 2, max_x / 2 - 16); + wclrtoeol(menu); + wmove(menu, end - start + 3, max_x / 2 - 16); + wclrtoeol(menu); + wmove(menu, end - start + 4, max_x / 2 - 16); + wclrtoeol(menu); + + if (mem->displayname) { + wmove(menu, end - start + 2, max_x / 2 - 16); + waddstr(menu, mem->displayname); + } + if (!AST_LIST_EMPTY(&mem->deps)) { + wmove(menu, end - start + 3, max_x / 2 - 16); + strcpy(buf, "Depends on: "); + AST_LIST_TRAVERSE(&mem->deps, dep, list) { + strncat(buf, dep->name, sizeof(buf) - strlen(buf) - 1); + if (AST_LIST_NEXT(dep, list)) + strncat(buf, ", ", sizeof(buf) - strlen(buf) - 1); + } + waddstr(menu, buf); + } + if (!AST_LIST_EMPTY(&mem->conflicts)) { + wmove(menu, end - start + 4, max_x / 2 - 16); + strcpy(buf, "Conflicts with: "); + AST_LIST_TRAVERSE(&mem->conflicts, con, list) { + strncat(buf, con->name, sizeof(buf) - strlen(buf) - 1); + if (AST_LIST_NEXT(con, list)) + strncat(buf, ", ", sizeof(buf) - strlen(buf) - 1); + } + waddstr(menu, buf); + } + +} + +void draw_category_menu(WINDOW *menu, struct category *cat, int start, int end, int curopt, int changed) +{ + int i = 0; + int j = 0; + struct member *mem; char buf[64]; const char *desc = NULL; + if (!changed) { + /* If all we have to do is move the cursor, + * then don't clear the screen and start over */ + AST_LIST_TRAVERSE(&cat->members, mem, list) { + i++; + if (curopt + 1 == i) { + display_mem_info(menu, mem, start, end); + break; + } + } + wmove(menu, curopt - start, max_x / 2 - 9); + wrefresh(menu); + return; + } + wclear(menu); + i = 0; AST_LIST_TRAVERSE(&cat->members, mem, list) { if (i < start) { i++; @@ -148,38 +202,13 @@ void draw_category_menu(WINDOW *menu, struct category *cat, int start, int end, waddstr(menu, buf); if (curopt + 1 == i) - curmem = mem; + display_mem_info(menu, mem, start, end); if (i == end) break; } - if (curmem->displayname) { - wmove(menu, end - start + 2, max_x / 2 - 16); - waddstr(menu, curmem->displayname); - } - if (!AST_LIST_EMPTY(&curmem->deps)) { - wmove(menu, end - start + 3, max_x / 2 - 16); - strcpy(buf, "Depends on: "); - AST_LIST_TRAVERSE(&curmem->deps, dep, list) { - strncat(buf, dep->name, sizeof(buf) - strlen(buf) - 1); - if (AST_LIST_NEXT(dep, list)) - strncat(buf, ", ", sizeof(buf) - strlen(buf) - 1); - } - waddstr(menu, buf); - } - if (!AST_LIST_EMPTY(&curmem->conflicts)) { - wmove(menu, end - start + 4, max_x / 2 - 16); - strcpy(buf, "Conflicts with: "); - AST_LIST_TRAVERSE(&curmem->conflicts, con, list) { - strncat(buf, con->name, sizeof(buf) - strlen(buf) - 1); - if (AST_LIST_NEXT(con, list)) - strncat(buf, ", ", sizeof(buf) - strlen(buf) - 1); - } - waddstr(menu, buf); - } wmove(menu, curopt - start, max_x / 2 - 9); - wrefresh(menu); } @@ -192,6 +221,7 @@ int run_category_menu(WINDOW *menu, int cat_num) int c; int curopt = 0; int maxopt; + int changed = 1; AST_LIST_TRAVERSE(&categories, cat, list) { if (i++ == cat_num) @@ -202,9 +232,10 @@ int run_category_menu(WINDOW *menu, int cat_num) maxopt = count_members(cat) - 1; - draw_category_menu(menu, cat, start, end, curopt); + draw_category_menu(menu, cat, start, end, curopt, changed); while ((c = getch())) { + changed = 0; switch (c) { case KEY_UP: if (curopt > 0) { @@ -212,6 +243,7 @@ int run_category_menu(WINDOW *menu, int cat_num) if (curopt < start) { start--; end--; + changed = 1; } } break; @@ -221,6 +253,7 @@ int run_category_menu(WINDOW *menu, int cat_num) if (curopt > end - 1) { start++; end++; + changed = 1; } } break; @@ -238,6 +271,7 @@ int run_category_menu(WINDOW *menu, int cat_num) case '\n': case ' ': toggle_enabled(cat, curopt); + changed = 1; break; case 'h': case 'H': @@ -245,15 +279,17 @@ int run_category_menu(WINDOW *menu, int cat_num) break; case KEY_F(7): set_all(cat, 0); + changed = 1; break; case KEY_F(8): set_all(cat, 1); + changed = 1; default: break; } if (c == 'x' || c == 'X' || c == 'Q' || c == 'q') break; - draw_category_menu(menu, cat, start, end, curopt); + draw_category_menu(menu, cat, start, end, curopt, changed); } wrefresh(menu); -- cgit v1.2.3