mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-03 19:16:46 +00:00
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
This commit is contained in:
@@ -67,7 +67,7 @@ const char * const help_info[] = {
|
|||||||
void winch_handler(int sig);
|
void winch_handler(int sig);
|
||||||
void show_help(WINDOW *win);
|
void show_help(WINDOW *win);
|
||||||
void draw_main_menu(WINDOW *menu, int curopt);
|
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);
|
||||||
int run_category_menu(WINDOW *menu, int cat_num);
|
int run_category_menu(WINDOW *menu, int cat_num);
|
||||||
void draw_title_window(WINDOW *title);
|
void draw_title_window(WINDOW *title);
|
||||||
@@ -122,18 +122,72 @@ void draw_main_menu(WINDOW *menu, int curopt)
|
|||||||
wrefresh(menu);
|
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)
|
||||||
|
{
|
||||||
|
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 i = 0;
|
||||||
int j = 0;
|
int j = 0;
|
||||||
struct member *mem, *curmem = NULL;
|
struct member *mem;
|
||||||
struct depend *dep;
|
|
||||||
struct conflict *con;
|
|
||||||
char buf[64];
|
char buf[64];
|
||||||
const char *desc = NULL;
|
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);
|
wclear(menu);
|
||||||
|
|
||||||
|
i = 0;
|
||||||
AST_LIST_TRAVERSE(&cat->members, mem, list) {
|
AST_LIST_TRAVERSE(&cat->members, mem, list) {
|
||||||
if (i < start) {
|
if (i < start) {
|
||||||
i++;
|
i++;
|
||||||
@@ -148,38 +202,13 @@ void draw_category_menu(WINDOW *menu, struct category *cat, int start, int end,
|
|||||||
waddstr(menu, buf);
|
waddstr(menu, buf);
|
||||||
|
|
||||||
if (curopt + 1 == i)
|
if (curopt + 1 == i)
|
||||||
curmem = mem;
|
display_mem_info(menu, mem, start, end);
|
||||||
|
|
||||||
if (i == end)
|
if (i == end)
|
||||||
break;
|
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);
|
wmove(menu, curopt - start, max_x / 2 - 9);
|
||||||
|
|
||||||
wrefresh(menu);
|
wrefresh(menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,6 +221,7 @@ int run_category_menu(WINDOW *menu, int cat_num)
|
|||||||
int c;
|
int c;
|
||||||
int curopt = 0;
|
int curopt = 0;
|
||||||
int maxopt;
|
int maxopt;
|
||||||
|
int changed = 1;
|
||||||
|
|
||||||
AST_LIST_TRAVERSE(&categories, cat, list) {
|
AST_LIST_TRAVERSE(&categories, cat, list) {
|
||||||
if (i++ == cat_num)
|
if (i++ == cat_num)
|
||||||
@@ -202,9 +232,10 @@ int run_category_menu(WINDOW *menu, int cat_num)
|
|||||||
|
|
||||||
maxopt = count_members(cat) - 1;
|
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())) {
|
while ((c = getch())) {
|
||||||
|
changed = 0;
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case KEY_UP:
|
case KEY_UP:
|
||||||
if (curopt > 0) {
|
if (curopt > 0) {
|
||||||
@@ -212,6 +243,7 @@ int run_category_menu(WINDOW *menu, int cat_num)
|
|||||||
if (curopt < start) {
|
if (curopt < start) {
|
||||||
start--;
|
start--;
|
||||||
end--;
|
end--;
|
||||||
|
changed = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -221,6 +253,7 @@ int run_category_menu(WINDOW *menu, int cat_num)
|
|||||||
if (curopt > end - 1) {
|
if (curopt > end - 1) {
|
||||||
start++;
|
start++;
|
||||||
end++;
|
end++;
|
||||||
|
changed = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -238,6 +271,7 @@ int run_category_menu(WINDOW *menu, int cat_num)
|
|||||||
case '\n':
|
case '\n':
|
||||||
case ' ':
|
case ' ':
|
||||||
toggle_enabled(cat, curopt);
|
toggle_enabled(cat, curopt);
|
||||||
|
changed = 1;
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
case 'H':
|
case 'H':
|
||||||
@@ -245,15 +279,17 @@ int run_category_menu(WINDOW *menu, int cat_num)
|
|||||||
break;
|
break;
|
||||||
case KEY_F(7):
|
case KEY_F(7):
|
||||||
set_all(cat, 0);
|
set_all(cat, 0);
|
||||||
|
changed = 1;
|
||||||
break;
|
break;
|
||||||
case KEY_F(8):
|
case KEY_F(8):
|
||||||
set_all(cat, 1);
|
set_all(cat, 1);
|
||||||
|
changed = 1;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (c == 'x' || c == 'X' || c == 'Q' || c == 'q')
|
if (c == 'x' || c == 'X' || c == 'Q' || c == 'q')
|
||||||
break;
|
break;
|
||||||
draw_category_menu(menu, cat, start, end, curopt);
|
draw_category_menu(menu, cat, start, end, curopt, changed);
|
||||||
}
|
}
|
||||||
|
|
||||||
wrefresh(menu);
|
wrefresh(menu);
|
||||||
|
Reference in New Issue
Block a user