Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ncurses.h>
- #include <string.h>
- void print_in_middle(WINDOW *win, int starty, int startx, int width, char *string);
- int main(void) {
- int sq = 'o';
- // STARTUP:
- //
- //
- //
- // START NCURSES
- initscr();
- raw();
- keypad(stdscr, TRUE);
- noecho();
- // GET STD TERMINAL SCREEN DIMS
- int w, h;
- getmaxyx(stdscr, h, w);
- // CREATE MENU SCREEN
- WINDOW *menu = newwin(h, w, 0, 0);
- wrefresh(menu);
- // COLORING: // // // // // // //
- //
- //
- // INITIALIZE COLORS
- if(has_colors() == FALSE) {
- printf("Your screen does not support colour\n");
- }
- start_color();
- init_pair(1, COLOR_RED, COLOR_BLACK);
- attron(COLOR_PAIR(1));
- print_in_middle(menu, 0, 0, w, "Hello!\n");
- wrefresh(menu);
- attroff(COLOR_PAIR(1));
- getch();
- // CLEANUP: // // // // // // //
- //
- //
- //
- // PAUSE
- getch();
- delwin(menu);
- // PAUSE
- getch();
- // UPDATE
- refresh();
- // END NCURSES
- endwin();
- return 0;
- }
- void print_in_middle(WINDOW *win, int starty, int startx, int width, char *string) {
- int length, x, y;
- float temp;
- if(win == NULL)
- win = stdscr;
- getyx(win, y, x);
- if(startx != 0)
- x = startx;
- if(starty != 0)
- y = starty;
- if(width == 0)
- width = 80;
- length = strlen(string);
- temp = (width - length)/ 2;
- x = startx + (int)temp;
- mvwprintw(win, y, x, "%s", string);
- refresh();
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement