#include #include #include "config.h" #include "misc.h" #include "screen.h" void endgraphics (void) { endwin(); } void startgraphics (WINDOW **w) { // to put the nibbles-window in the center of the screen int offsetx,offsety; int loop,lx,ly; initscr(); if ((COLS < WINDOWX) || (LINES < WINDOWY)) { endwin(); fprintf(stderr,"A terminal with at least %d lines and %d columns is required.\n",WINDOWY,WINDOWX); exit(1); } offsetx = (COLS - WINDOWX) >> 1; offsety = (LINES - WINDOWY) >> 1; w[Main] = newwin(WINDOWY,WINDOWX,offsety,offsetx); w[Grid] = newwin(GRIDY,GRIDX*2,offsety+1,offsetx+1); w[Status] = newwin(1,WINDOWX-2,offsety+WINDOWY-2,offsetx+1); keypad(w[Grid], TRUE); nonl(); cbreak(); noecho(); nodelay(w[Grid], TRUE); curs_set(FALSE); if (!has_colors()) { endwin(); fprintf(stderr,"A terminal with color support is required.\n"); exit(1); } start_color(); // configure colors init_pair(WORMCOLORPAIR,WORMCOLOR,BACKGROUND); init_pair(LINECOLORPAIR,LINECOLOR,BACKGROUND); init_pair(STATUSCOLORPAIR,STATUSCOLOR,BACKGROUND); init_pair(DOTCOLORPAIR,DOTCOLOR,BACKGROUND); // draw pretty lines in w[Main] wattrset(w[Main],COLOR_PAIR(LINECOLORPAIR)|A_BOLD); mvwaddch(w[Main],0,0,ACS_ULCORNER); mvwaddch(w[Main],0,WINDOWX-1,ACS_URCORNER); mvwaddch(w[Main],WINDOWY-1,0,ACS_LLCORNER); mvwaddch(w[Main],WINDOWY-1,WINDOWX-1,ACS_LRCORNER); for (loop=1;loop