Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ncurses.h>
- #include <string.h> /* facilitate strlen() */
- #define WHITEONRED 1
- #define WHITEONBLUE 2
- #define WHITEONBLACK 3
- #define BLACKONWHITE 4
- void wCenterTitle(WINDOW *pwin, const char * title)
- {
- int x, maxy, maxx, stringsize;
- getmaxyx(pwin, maxy, maxx);
- stringsize = 4 + strlen(title);
- x = (maxx - stringsize)/2;
- mvwaddch(pwin, 0, x, ACS_RTEE);
- waddch(pwin, ' ');
- waddstr(pwin, title);
- waddch(pwin, ' ');
- waddch(pwin, ACS_LTEE);
- }
- void wclrscr(WINDOW * pwin)
- {
- int y, x, maxy, maxx;
- getmaxyx(pwin, maxy, maxx);
- for(y=0; y < maxy; y++)
- for(x=0; x < maxx; x++)
- mvwaddch(pwin, y, x, ' ');
- }
- int main(int c, char *argv[])
- {
- WINDOW *base_win, *small_win;
- int maxy, maxx;
- /* INITIALIZE CURSES AND COLORS AND REFRESH THE STANDARD SCREEN */
- initscr();
- getmaxyx(stdscr, maxy, maxx);
- start_color();
- init_pair(WHITEONRED, COLOR_WHITE, COLOR_RED);
- init_pair(WHITEONBLUE, COLOR_WHITE, COLOR_BLUE);
- init_pair(WHITEONBLACK, COLOR_WHITE, COLOR_BLACK);
- init_pair(BLACKONWHITE, COLOR_BLACK, COLOR_WHITE);
- wrefresh(stdscr); /* I don't know why this is necessary, but it is! */
- /* CREATE AND DISPLAY THE BASE WINDOW */
- base_win = newwin(maxy, maxx, 0,0);
- wattrset(base_win, COLOR_PAIR(WHITEONBLACK) | WA_BOLD);
- wclrscr(base_win);
- box(base_win, 0, 0);
- wCenterTitle(base_win, "Tux Hat Linux Installer v4.0");
- touchwin(base_win);
- wrefresh(base_win);
- getch();
- /* END CURSES */
- endwin();
- printf("\n\nwin.c\n");
- return(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment