From 3fd8d1f3c78fcfa52a68b49cbe09d50f4df249f6 Mon Sep 17 00:00:00 2001 From: William McBrine Date: Tue, 6 Dec 2005 10:29:38 +0000 Subject: [PATCH] Fixed the menu-drawing optimization so it actually works. Also took out A_PROTECT, because I think it's hideous. --- demos/testcurs.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/demos/testcurs.c b/demos/testcurs.c index 2e6120fe..612722ec 100644 --- a/demos/testcurs.c +++ b/demos/testcurs.c @@ -34,7 +34,7 @@ #ifdef PDCDEBUG # define CURSES_LIBRARY /* needed for the prototype of PDC_debug */ -char *rcsid_testcurs = "$Id: testcurs.c,v 1.16 2005/12/06 00:20:31 wmcbrine Exp $"; +char *rcsid_testcurs = "$Id: testcurs.c,v 1.17 2005/12/06 10:29:38 wmcbrine Exp $"; #endif #include @@ -150,6 +150,7 @@ bool quit=FALSE; case 10: case 13: case KEY_ENTER: + old_option = -1; erase(); refresh(); (*command[new_option].function)(win); @@ -157,10 +158,12 @@ bool quit=FALSE; display_menu(old_option,new_option); break; case KEY_UP: + old_option = new_option; new_option = (new_option == 0) ? new_option : new_option-1; display_menu(old_option,new_option); break; case KEY_DOWN: + old_option = new_option; new_option = (new_option == MAX_OPTIONS-1) ? new_option : new_option+1; display_menu(old_option,new_option); break; @@ -875,23 +878,22 @@ void display_menu(old_option,new_option) int old_option,new_option; #endif { - register int i; + if (old_option == -1) { + int i; -#ifdef XCURSES - attrset(A_PROTECT); -#else - attrset(A_BOLD); -#endif - mvaddstr(3,20,"PDCurses Test Program"); - attrset(A_NORMAL); + attrset(A_BOLD); + mvaddstr(3,20,"PDCurses Test Program"); + attrset(A_NORMAL); - for (i=0;i