void con_ta( int attr ) { __ta = attr; __fg = COLORFG(attr); __bg = COLORBG(attr); __attr = YAS_FGCOLOR(colortab(__fg%8))|YAS_BGCOLOR(colortab(__bg%8))|((__bg>7)*YAS_ITALIC)|((__fg>7)*YAS_BOLD); }
int con_init() { initscr(); start_color(); qiflush(); cbreak(); if ( !getenv("UNICON_NO_RAW") ) { /* To allow curses app to handle properly ctrl+z, ctrl+c, etc. I should not call raw() here, anyway it is known that this will cause misinterpretation of some keys (arrows) after resuming (SUSP -- ctrl+z)... So, unless UNICON_NO_RAW exported and set to any value raw() is called as usual. */ raw(); } noecho(); nonl(); // `return' translation off if (!has_colors()) fprintf(stderr,"Attention: A color terminal may be required to run this application !\n"); conio_scr=newwin(0,0,0,0); keypad(conio_scr,TRUE); // allow function keys (keypad) meta(conio_scr,TRUE); // switch to 8 bit terminal return values // intrflush(conio_scr,FALSE); // idlok(conio_scr,TRUE); // hardware line ins/del (required?) idcok(conio_scr,TRUE); // hardware char ins/del (required?) scrollok(conio_scr,TRUE); // scroll screen if required (cursor at bottom) /* Color initialization */ for ( __bg=0; __bg<8; __bg++ ) for ( __fg=0; __fg<8; __fg++ ) init_pair( CON_PAIR(__fg,__bg), colortab(__fg), colortab(__bg)); con_ta(7); return 0; }
/* Call this before any call to linux conio - except the port functions ! */ void init_lconio (void) /* This is needed, because ncurses needs to be initialized */ { int x,y; initialized=1; initscr(); /* initialize curses screen -- modified by GLF to detect X Windows */ #ifdef XCURSES Xinitscr(1, fakelist); /* fake out argument list */ #else initscr(); #endif start_color(); oldattr=wattr_get(stdscr,&store_oldattr.attrs,&store_oldattr.color_pair,&store_oldattr.opts); nonl(); /* disable translation of CR to newline on input */ raw(); /* characters immediately available -- break not processed; like cbreak() but also passes INTR, QUIT, SUSP, and STOP chars */ noecho(); /* no echo of key input */ /* Removed from original linux-conio: if (!has_colors() & (color_warning>-1)) fprintf(stderr,"Attention: A color terminal may be required to run this application !\n"); */ /* GLF settings added to the original linux-conio initializations */ curs_set(0); /* turn off cursor */ /* cbreak(); */ /* characters immediately available -- break not processed */ clear(); /* clear screen */ timeout(0); /* non-blocking read -- if no input, return ERR */ conio_scr=newwin(0,0,0,0); keypad(conio_scr,TRUE); meta(conio_scr,TRUE); idlok(conio_scr,TRUE); scrollok(conio_scr,TRUE); /* Color initialization */ for (y=0;y<=7;y++) for (x=0;x<=7;x++) init_pair((8*y)+x+1, colortab(x), colortab(y)); txtattr=wattr_get(conio_scr,&store_txtattr.attrs,&store_txtattr.color_pair,&store_txtattr.opts); bgc=0; textcolor(7); textbackground(0); }
void settextcolor(char color, char bgcolor) { if (!initialized) initconio(); wattrset(win, 0); wattron(win, COLOR_PAIR((colortab(bgcolor) << 3) + colortab(color))); }