Skip to content
Snippets Groups Projects
Commit 1b85726c authored by Russell Bryant's avatar Russell Bryant
Browse files

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: https://origsvn.digium.com/svn/asterisk/trunk@33576 65c4cc65-6c06-0410-ace0-fbb531ad65f3
parent 40b3ce5c
Branches
Tags
No related merge requests found
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment