diff options
-rwxr-xr-x | inc/utils.h | 1 | ||||
-rw-r--r--[-rwxr-xr-x] | src/utils.c | 30 |
2 files changed, 20 insertions, 11 deletions
diff --git a/inc/utils.h b/inc/utils.h index 0149aaf..8492179 100755 --- a/inc/utils.h +++ b/inc/utils.h @@ -12,5 +12,6 @@ struct progArgs { int parseArgs(int argc, char **argv, struct progArgs *args); void usage(char *progname); int cursesInit(WINDOW *wins[], PANEL *panels[], int count); +void cursesUnInit(WINDOW *wins[], PANEL *panels[], int count); #endif /*UTILS_H*/ diff --git a/src/utils.c b/src/utils.c index e4fdbc0..86917ae 100755..100644 --- a/src/utils.c +++ b/src/utils.c @@ -48,14 +48,13 @@ void print_in_middle(WINDOW *win, int starty, int startx, int width, char *strin refresh(); } - -void makeWin(WINDOW *win, PANEL *panel, int h, int w, int y, int x, char title[]) { +void makeWin(WINDOW **win, PANEL **panel, int h, int w, int y, int x, char title[]) { int i; - win = newwin(h, w, y, x); - mvwprintw(win, 0, 0, "%s", title); - mvwchgat(win, 0, 0, -1, A_BOLD, 2, NULL); - for(i=1;i<h;i++) mvwchgat(win, i, 0, -1, A_STANDOUT, 1, NULL); - panel = new_panel(win); + *win = newwin(h, w, y, x); + mvwprintw(*win, 0, 0, "%s", title); + mvwchgat(*win, 0, 0, -1, A_BOLD, 2, NULL); + for(i=1;i<h;i++) mvwchgat(*win, i, 0, -1, A_STANDOUT, 1, NULL); + *panel = new_panel(*win); } @@ -66,8 +65,8 @@ int cursesInit(WINDOW *wins[], PANEL *panels[], int count) { initscr(); start_color(); raw(); - noecho(); keypad(stdscr, TRUE); + noecho(); /* Initialize all the colors */ init_pair(1, COLOR_WHITE, COLOR_BLACK); @@ -79,9 +78,9 @@ int cursesInit(WINDOW *wins[], PANEL *panels[], int count) { getmaxyx(stdscr, screenH, screenW); if ( screenH < 8 || screenW < 40 ) return 1; - makeWin(wins[0], panels[0], 3 , screenW, 0 , 0, "Menu"); - makeWin(wins[1], panels[1], screenH-6 , screenW, 3 , 0, "Main Win"); - makeWin(wins[2], panels[2], 2 , screenW, screenH-3 , 0, "Commands"); + makeWin(wins+0, panels+0, 3 , screenW, 0 , 0, "Menu"); + makeWin(wins+1, panels+1, screenH-6 , screenW, 3 , 0, "Main Win"); + makeWin(wins+2, panels+2, 2 , screenW, screenH-3 , 0, "Commands"); /* Set up the user pointers to the next panel set_panel_userptr(panels[0], panels[1]); @@ -95,3 +94,12 @@ int cursesInit(WINDOW *wins[], PANEL *panels[], int count) { return 0; } +void cursesUnInit(WINDOW *wins[], PANEL *panels[], int count) { + int i; + + for (i=0;i<count;i++) { + del_panel(panels[i]); + delwin(wins[i]); + } + endwin(); +} |