当前位置: 首页>>代码示例>>C++>>正文


C++ COLOR_PAIR函数代码示例

本文整理汇总了C++中COLOR_PAIR函数的典型用法代码示例。如果您正苦于以下问题:C++ COLOR_PAIR函数的具体用法?C++ COLOR_PAIR怎么用?C++ COLOR_PAIR使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了COLOR_PAIR函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: slk_attr_set

int slk_attr_set(const attr_t attrs, short color_pair, void *opts)
{
    PDC_LOG(("slk_attr_set() - called\n"));

    return slk_attrset(attrs | COLOR_PAIR(color_pair));
}
开发者ID:Palantir555,项目名称:ecos-mars-zx3,代码行数:6,代码来源:slk.c

示例2: control_task

/**
 * Funzione di rendering e gestione delle iterazioni tra gli oggetti della scena
 */
void control_task()
{
	int i;			
	
	/* System V: inizializzazione */
	// Queue id per i messaggi
	int    qid;			
	
	// Chiave del progetto per individuare la coda dei messaggi
    key_t  msgkey;
    
    // Genero la chiave ipc    
    msgkey = ftok(FTOK_PATH, FTOK_PROJ_ID);    
    
    // Apro (o creo) la coda
    if((qid = msgget(msgkey, 0666 | IPC_CREAT)) == -1)
    {
		perror("Impossibile creare la coda");
		exit(1);
    }
    
    /* Inoltre creo una queue per ogni alieno, per trasmettere le comunicazioni
     * relative alle collisioni */
    int	qid_coll[ALIEN_NUM];
    key_t msgkey_coll[ALIEN_NUM];
    
    // Struttura per memorizzare lo stato delle collisioni ed inviarlo coem messaggio all'alieno
	collision_msg_t coll_m;
	coll_m.mtype = 1;
	
	/* Genero le chiavi e creo le code */
	for(i = 0; i < ALIEN_NUM; i++)
	{
		msgkey_coll[i] = ftok(FTOK_PATH, FTOK_PROJ_ID_COLL_BASE + i);    
		
		// Apro (o creo) la coda
		if((qid_coll[i] = msgget(msgkey_coll[i], 0666 | IPC_CREAT)) == -1)
		{
			perror("Impossibile creare la coda");
			exit(1);
		}		
	}
	
    
    int last_alien_hit = -1;// Id dell'ultimo alieno colpito
	int obj_n = 1;			// Numero di oggetti nella scena
	int scores = 0;			// Punteggio
	char buffer[512];		// Buffer per stampare le stats
	unsigned long iterations = 0;	// Numero di iterazioni		
	int aliens = ALIEN_NUM;	
	
	// Buffer di ricezione
	object_data_t recv_data;
	
	// Informazioni degli oggetti; la navicella e' in posizione 0.
	// L'elemento corrente e' puntato dal puntatore current
	object_data_t objects[OBJECTS_MAX];
	
	// Oggetto corrente e suo id; spaceship = -1;
	object_data_t *current;
	int current_id;
	
	// Variabile che indica se il loop deve essere eseguito
	int playing = 1;
	
	// Variabile temporanea per lo stato delle collisioni dell'oggetto corrente
	int col;
	

	// Inizializzo le ncurses
	initscr();
	
	
	// Inizializzo i colori delle ncurses
	#ifdef COLORS
		start_color();
		init_pair(1, COLOR_WHITE, COLOR_BLACK);
		attron(COLOR_PAIR(1));
	#endif
	
		
	// Non visualizzo i tasti premuti
	noecho();
	
	// Inizializzo il generatore random
	srand((int)time(0));
	
	// Nascondo il cursore
	curs_set(0); 
	
	
	// Inizializzo la navicella
	objects[0].type = OT_SPACESHIP;
	
	// Inizializzo gli oggetti come non utilizzati
	for(i = 0; i < OBJECTS_MAX; i++)
		objects[i].x = -1;
//.........这里部分代码省略.........
开发者ID:dakk,项目名称:spaceinvaders-curses,代码行数:101,代码来源:control.c

示例3: main

int main(){
system("clear");
srand(time(NULL));
int filas=0,columnas=0,opcion=0,a=0;
int **mat;
initscr();
colores();
wbkgd(stdscr,COLOR_PAIR(3));refresh();
do{
	erase();refresh();
	printw("\nMenu\n\t1.-Generar Matriz\n\t2.-Mostrar Soluciones\n\t3.-Cargar Matriz\n\t4.-Guardar Matriz\n\t5.-Ver Matriz\n\t0.-Salir\n");refresh();
	scanw("%i",&opcion);
	switch(opcion){
		case 0:
			printw("\nAdios!\n");refresh();
			printw("\nPresione cualquier tecla.");refresh();
			getch();
			break;
		case 1:
			printw("\nIngrese Filas:");refresh();
			scanw("%i",&filas);
			printw("\nIngrese Columnas:");refresh();
			scanw("%i",&columnas);
			mat=CreaMatriz(filas,columnas);
			Cargar(mat,filas,columnas);
			Mostrar(mat,filas,columnas,0,0);
			printw("\nPresione cualquier tecla.");refresh();
			getch();
			break;
		case 2:
			a=0;
			while(a<columnas){
				if(mat[0][a]!=1){
					attron(COLOR_PAIR(5));
					printw("\n\n\nEntrando por(%i;%i)",0,a);refresh();
					attroff(COLOR_PAIR(5));
					printw("\n(%i;%i)",0,a);refresh();
					mat[0][a]=2;
					Laberinto(mat,filas,columnas,0,a);
					mat[0][a]=0;
				}
				a++;
			}
			printw("\nPresione cualquier tecla.");refresh();
			getch();
			break;
		case 3:
			mat=CargaMat(&filas,&columnas);
			getch();
			break;
		case 4:
			GuardaMat(mat,filas,columnas);
			getch();
			break;
		case 5:
			Mostrar(mat,filas,columnas,0,0);
			printw("\nPresione cualquier tecla.");refresh();
			getch();
			break;
		default:
			printw("\nOpcion Invalida");refresh();
			printw("\nPresione cualquier tecla.");refresh();
			getch();
	}
}while(opcion!=0);
endwin();
return(0);
}
开发者ID:svilerino,项目名称:Desarrollo-Tecnica3,代码行数:68,代码来源:main.c

示例4: get_color

void get_color(void)
{
    chtype bold = (rand() % 2) ? A_BOLD : A_NORMAL;
    attrset(COLOR_PAIR(rand() % 8) | bold);
}
开发者ID:Noiwex,项目名称:luajit-curses,代码行数:5,代码来源:firework.c

示例5: style_to_attr

static inline attr_t style_to_attr(CellStyle *style) {
	return style->attr | COLOR_PAIR(color_pair_get(style->fg, style->bg));
}
开发者ID:erf,项目名称:vis,代码行数:3,代码来源:ui-terminal-curses.c

示例6: _color_pair

int _color_pair (int color)
{
	return COLOR_PAIR(color);
}
开发者ID:AitorATuin,项目名称:lcdk,代码行数:4,代码来源:lcdk.c

示例7: draw_sibling_menu

int draw_sibling_menu(select_menu *menu)
{
	int i,c,maxopt,d;
	char buf[40];
	select_menu *it;
	int cur_index=0;
	int skip=0;
	int max_len=0,len;
again:
	wclear(menu_window);

	/* print title in colour */
	attron(COLOR_PAIR(1));
	mvprintw(HIGH_NOTICE_Y,max_x/2-20,menu->parent?menu->parent->name:"OpenSIPS Main Configuration Menu");
	/* print footer */
	print_notice(NOTICE_Y,NOTICE_X,0,"Press h for navigation help.");
	attroff(COLOR_PAIR(1));

	/* draw actual menu */
	i=0;
	for (it=menu;it;it=it->next_sibling) {
		wmove(menu_window, max_y/4+i++, max_x / 2 - 20);
		snprintf(buf, sizeof(buf), " %s", it->name);
		waddstr(menu_window, buf);
		len = strlen(it->name) +6;
		if (len > max_len)
			max_len = len;
	}

	/* draw selection marker */
	wmove(menu_window, max_y/4+cur_index, (max_x / 2) - 25);
	waddstr(menu_window, "--->");

	/* print box with color */
	wattron(menu_window,COLOR_PAIR(2));
	for (d=-1;d<i+1;d++) {
		wmove(menu_window,max_y/4+d,max_x/2-30);
		wprintw(menu_window,"|");
		wmove(menu_window,max_y/4+d,max_x/2-20+max_len);
		wprintw(menu_window,"|");
	}

	for (d=0;d<max_len+9;d++) {
		wmove(menu_window,max_y/4-2,max_x/2-29+d);
		wprintw(menu_window,"_");
		wmove(menu_window,max_y/4+i,max_x/2-29+d);
		wprintw(menu_window,"_");
	}

	wattroff(menu_window,COLOR_PAIR(2));
	wmove(menu_window, 0, 0);
	wrefresh(menu_window);

	maxopt = i-1;

	c = getch();
	switch (c) {
		case KEY_UP:
			if (cur_index > 0)
				cur_index--;
			break;
		case KEY_DOWN:
			if (cur_index < maxopt)
				cur_index++;
			break;
		case KEY_RIGHT:
		case KEY_ENTER:
		case '\n':
			for (i=0,it=menu;i<cur_index;i++,it=it->next_sibling)
				;
			c = exec_menu_action(it);
			break;
		case 'h':
		case 'H':
			clear();
			print_notice(max_y/2,20,0,"Use UP and DOWN arrow keys to navigate.");
			print_notice(max_y/2+1,20,0,"Use RIGHT arrow or ENTER key to enter a certain menu.");
			print_notice(max_y/2+2,20,0,"Use LEFT arror or Q key to go back.");
			print_notice(max_y/2+3,20,0,"Use SPACE to toggle an entry ON/OFF.\n");
			print_notice(max_y/2+4,20,1,"Press any key to return to menuconfig.");
			refresh();
			break;
		case KEY_LEFT:
		case 'q':
		case 'Q':
			for (it=menu;it;it=it->next_sibling) {
				if (it->child_changed == CHILD_CHANGED) {
					if (skip == 0) {
						/* have we asked before and got negative response ? */
						print_notice(NOTICE_Y,NOTICE_X,0,"You have not saved changes. Go back anyway ? [y/n] ");
						c = getch();
						if (c == 'n' || c == 'N')
							goto again;
						else {
							it->child_changed = CHILD_CHANGE_IGNORED;
							skip=1;
							return 0;
						}
					} else
						it->child_changed = CHILD_CHANGE_IGNORED;
//.........这里部分代码省略.........
开发者ID:WuKongQC,项目名称:opensips,代码行数:101,代码来源:curses.c

示例8: db_login

Status db_login(MYSQL *conn_ptr){

	char	user[50]="",
			password[50]="",
			password_verify[100]="";
	// start_color();
	// init_color(COLOR_BLACK, 0, 0, 0);
	// init_pair(1, COLOR_GREEN, COLOR_BLACK);


	printw("mysql user:\t");
	scanw("%s",user);

	printw("mysql password:\t");
	noecho();  
        scanw("%s",password);   
    echo();
	printw("\n");

	refresh();
        
    conn_ptr=mysql_init(NULL);
    conn_ptr = mysql_real_connect(conn_ptr, "localhost", user, password, NULL, 0, NULL, 0);

    char input_ch;

    if(conn_ptr){
    	attron(A_BOLD);
    	   printw("[ info  @%s]  Connect successfully!\n",user);
    	attroff(A_BOLD);
    	refresh();
    }else{
    	attron(A_BOLD);
    	   printw("[ info  @%s]  Fucked~\n",user);
    	attroff(A_BOLD);
    	refresh();
    	return Status_Forbidden;
    }


	if(mysql_query(conn_ptr, "use HNotes")){
		printw("[ query @%s]  Create database? [Y/n] :  ",user);refresh();
		scanw("%c",&input_ch);
		if(input_ch=='Y' || input_ch=='y' ){
            if(!mysql_query(conn_ptr, "create DATABASE HNotes;")){
            	//mysql_query(conn_ptr, "create table ;")
            	printw("[");    	
            	attron(COLOR_PAIR(1));
                attron(A_BOLD);
            	   printw("  OK");
            	attroff(COLOR_PAIR(1));
                attroff(A_BOLD);
            	printw("   @%s]  Create database already.\n",user);
            	mysql_query(conn_ptr, "use HNotes");
            	printw("[ info  @%s]  Enter database already.\n ",user);

            }

		}
		if(input_ch=='N' || input_ch=='n' ){
			    printw("[");
            	attron(COLOR_PAIR(2));
                attron(A_BOLD);
            	   printw("  NO");
            	attroff(COLOR_PAIR(2));
                attroff(A_BOLD);
            	printw("   @%s]  Refuse to create database.\n",user);
		}
		refresh();
	}else{
		attron(A_BOLD);
		printw("[ info  @%s]  Enter database already.\n ",user);
		attroff(A_BOLD);
	}

	refresh();
	//ShowQueryResult_Select(conn_ptr,"show databases;");
    mysql_query(conn_ptr,"use HNotes;"); 
    ShowQueryResult_Select(stdscr,conn_ptr,"select * from demo1;");



	return Status_OK;
    

}
开发者ID:HotQ,项目名称:HNotes,代码行数:86,代码来源:hn_dbLogin.c

示例9: printgen

void printgen() {				/*Prints genre menu*/
	int y, x;
	clear();
	init_pair(1, COLOR_CYAN, COLOR_BLACK);
	bkgd(COLOR_PAIR(1));
	attron(A_BOLD);
	for(x = 44; x < 100; x++) {
		attron(COLOR_PAIR(1));
		printw("*");
		move(0, x);
		attroff(COLOR_PAIR(1));
	}
	for(y = 0; y < 11; y++) {
		attron(COLOR_PAIR(1));
		printw("*");
		move(y, 44);
		attroff(COLOR_PAIR(1));
	}
	for(x = 44; x < 100; x++) {
		attron(COLOR_PAIR(1));
		printw("*");
		move(11, x);
		attroff(COLOR_PAIR(1));
	}
	for(y = 0; y < 11; y++) {
		attron(COLOR_PAIR(1));
		printw("*");
		move(y, 100);
		attroff(COLOR_PAIR(1));
	}
	init_pair(2,COLOR_YELLOW,COLOR_BLACK);
        attron(COLOR_PAIR(2));
        border(0,0,0,0, 0,0,0,0);
        refresh();
        attroff(COLOR_PAIR(2));
        refresh();	
	mvaddstr(2,60," ----- SELECT GENRES -----");
	mvaddstr(4,48,"1. Fiction");
	mvaddstr(5,48,"2. Non-fiction");
	mvaddstr(6,48,"3. Reference");
	mvaddstr(7,48,"4. Self-help");
	mvaddstr(8,48,"5. Back to main menu");
	mvaddstr(9,48,"Enter your choice:");
   	refresh();
}
开发者ID:djoshi7796,项目名称:Library-Management,代码行数:45,代码来源:printmenus.c

示例10: drawBoard

void drawBoard() {

  int i, h;
  initscr();
  start_color();
  init_pair(1,COLOR_RED,COLOR_GREEN);
  int a = rand()%2;
  if(a == 1){
  init_pair(2,COLOR_YELLOW,COLOR_BLACK);
}
  else if (a == 0){
  init_pair(2,COLOR_GREEN,COLOR_BLACK);
}
  init_pair(3,COLOR_WHITE,COLOR_BLACK);
  for(i=0;i<=17;i++) {
    attrset(COLOR_PAIR(1));
    mvaddch(i, 15, '|');
    mvaddch(i,31,'|');
  }
   attrset(COLOR_PAIR(2));
   mvaddstr(0,0,"    (;;);;)");
   mvaddstr(1,0,"  (;;);;;);;)");
   mvaddstr(2,0,"    (;;(;;;)");
  attrset(COLOR_PAIR(3));
  mvaddstr(3,0,"      |i!|");
  mvaddstr(4,0,"      |ii|");
  attrset(COLOR_PAIR(2));
  mvaddstr(6,0,"    (;;);;)");
  mvaddstr(7,0,"  (;;);;;);;)");
  mvaddstr(8,0,"    (;;(;;;)");
  attrset(COLOR_PAIR(3));
  mvaddstr(9,0,"      |i!|");
  mvaddstr(10,0,"      |ii|");
  attrset(COLOR_PAIR(2));
  mvaddstr(12,0,"    (;;);;)");
  mvaddstr(13,0,"  (;;);;;);;)");
  mvaddstr(14,0,"    (;;(;;;)");
  attrset(COLOR_PAIR(3));
  mvaddstr(15,0,"      |i!|");
  mvaddstr(16,0,"      |ii|");	


  attrset(COLOR_PAIR(2));
  mvaddstr(0,32,"    (;;);;)");
  mvaddstr(1,32,"  (;;);;;);;)");
  mvaddstr(2,32,"    (;;(;;;)");
  attrset(COLOR_PAIR(3));
  mvaddstr(3,32,"      |i!|");
  mvaddstr(4,32,"      |ii|");
  attrset(COLOR_PAIR(2));
  mvaddstr(6,32,"    (;;);;)");
  mvaddstr(7,32,"  (;;);;;);;)");
  mvaddstr(8,32,"    (;;(;;;)");
  attrset(COLOR_PAIR(3));
  mvaddstr(9,32,"      |i!|");
  mvaddstr(10,32,"      |ii|");
  attrset(COLOR_PAIR(2));
  mvaddstr(12,32,"    (;;);;)");
  mvaddstr(13,32,"  (;;);;;);;)");
  mvaddstr(14,32,"    (;;(;;;)");
  attrset(COLOR_PAIR(3));
  mvaddstr(15,32,"      |i!|");
  mvaddstr(16,32,"      |ii|");

  init_pair(40,COLOR_WHITE,COLOR_BLACK);
  init_pair(41,COLOR_YELLOW,COLOR_BLACK);
  init_pair(42,COLOR_RED,COLOR_BLACK);
  init_pair(43,COLOR_GREEN,COLOR_BLACK);
  init_pair(44,COLOR_CYAN,COLOR_BLACK);

  attrset(COLOR_PAIR(44));
  mvprintw(0,55," _ ");
  mvprintw(1,55,"|!|  is treasure (Increase your point).");
  mvprintw(2,55,"|_|");

  attrset(COLOR_PAIR(42)); 
  mvprintw(4,55," O ");
  mvprintw(5,55,"/_\\  is enemy car (If you crash it, game will be over).");
  mvprintw(6,55,"\\O/");

  attrset(COLOR_PAIR(41));
  mvprintw(8,55,"|b|");
  mvprintw(9,55,"|e|  is beer (If you get it, you will be drunken state).");
  mvprintw(10,55,"|r|");

  attrset(COLOR_PAIR(40));
  mvprintw(12,55,"   ");
  mvprintw(13,55,"O~*  is bomb (Decrease your point).");
  mvprintw(14,55,"   ");

  attrset(COLOR_PAIR(43));
  mvprintw(15,55,"/\\ ");
  mvprintw(16,55,"/\\  is Nitrous (Increase jump point).");
  mvprintw(17,55,"/\\ ");

  refresh();
    }
开发者ID:supakan,项目名称:Cargame,代码行数:97,代码来源:tictactoefunctions.c

示例11: i

/*
takes in an int i (current position in list), a list, the count of how many items are in the list(cnt),
an integer to check if the user has won the level (win), and the level counter.
Moves the unit, applies any damage dealt, removes dead units from the list and checks if the
user wins the level.
*/
int MoveUnit(int i, List * L, int * cnt, int * direction, int * win, int levelCount) {
	/*ch holds the farmer avatar value*/
	char ch;
	/*check is set if the unit is travelling vertically
	(code to check for damage is the same travelling up or down, eliminates
	redundant code)*/
	int check = 0;
	mvwprintw(stdscr, 0, 0, "Level %d", levelCount);

	/*Checks which direction to head when travelling vertically, so the unit
	doesn't jump between the path behind it and in front of it. 1 = up,
	0 = down*/
	if(mvinch(L->items[i].y, (L->items[i].x + 1)) != '.' && mvinch(L->items[i].y, (L->items[i].x + 1)) != 'B' && mvinch(L->items[i].y, (L->items[i].x + 1)) != 'Y' && mvinch(L->items[i].y, (L->items[i].x + 1)) != 'S' && mvinch((L->items[i].y - 1), L->items[i].x) == '+')
		L->items[i].direction = 1;
	else if(mvinch(L->items[i].y, (L->items[i].x + 1)) != '.' && mvinch(L->items[i].y, (L->items[i].x + 1)) != 'B' && mvinch(L->items[i].y, (L->items[i].x + 1)) != 'Y' && mvinch(L->items[i].y, (L->items[i].x + 1)) != 'S' && mvinch((L->items[i].y + 1), L->items[i].x) == '+')
		L->items[i].direction = 0;

	/*check if the unit should move to the left*/
	if(mvinch(L->items[i].y, (L->items[i].x - 1)) == '+') {
		/*move avatar to the left, replace its old spot with a '+',
		alter the unit's coordinates.*/
		mvaddch(L->items[i].y, (L->items[i].x - 1), L->items[i].avatar);
		mvaddch(L->items[i].y, L->items[i].x, '+');
		L->items[i].x = L->items[i].x - 1;

		/*damage calculations*/
		ch = (char)mvinch((L->items[i].y - 1), (L->items[i].x - 1));
		if(ch == 'B') {
			L->items[i].hp = L->items[i].hp - BDAM;
			/*if damage is taken, replace the character, but in red*/
			attron(COLOR_PAIR(1));
			mvaddch(L->items[i].y, L->items[i].x, L->items[i].avatar);
			attroff(COLOR_PAIR(1));
		}else if(ch == 'Y') {
			L->items[i].hp = L->items[i].hp - YDAM;
			attron(COLOR_PAIR(1));
			mvaddch(L->items[i].y, L->items[i].x, L->items[i].avatar);
			attroff(COLOR_PAIR(1));
		}else if(ch == 'S') {
			L->items[i].hp = L->items[i].hp - SDAM;
			attron(COLOR_PAIR(1));
			mvaddch(L->items[i].y, L->items[i].x, L->items[i].avatar);
			attroff(COLOR_PAIR(1));
		}

		ch = (char)mvinch((L->items[i].y - 1), (L->items[i].x));
		if(ch == 'B') {
			L->items[i].hp = L->items[i].hp - BDAM;
			attron(COLOR_PAIR(1));
			mvaddch(L->items[i].y, L->items[i].x, L->items[i].avatar);
			attroff(COLOR_PAIR(1));
		}else if(ch == 'Y') {
			L->items[i].hp = L->items[i].hp - YDAM;
			attron(COLOR_PAIR(1));
			mvaddch(L->items[i].y, L->items[i].x, L->items[i].avatar);
			attroff(COLOR_PAIR(1));
		}else if(ch == 'S') {
			L->items[i].hp = L->items[i].hp - SDAM;
			attron(COLOR_PAIR(1));
			mvaddch(L->items[i].y, L->items[i].x, L->items[i].avatar);
			attroff(COLOR_PAIR(1));
		}

		ch = (char)mvinch((L->items[i].y - 1), (L->items[i].x + 1));
		if(ch == 'B') {
			L->items[i].hp = L->items[i].hp - BDAM;
			attron(COLOR_PAIR(1));
			mvaddch(L->items[i].y, L->items[i].x, L->items[i].avatar);
			attroff(COLOR_PAIR(1));
		}else if(ch == 'Y') {
			L->items[i].hp = L->items[i].hp - YDAM;
			attron(COLOR_PAIR(1));
			mvaddch(L->items[i].y, L->items[i].x, L->items[i].avatar);
			attroff(COLOR_PAIR(1));
		}else if(ch == 'S') {
			L->items[i].hp = L->items[i].hp - SDAM;
			attron(COLOR_PAIR(1));
			mvaddch(L->items[i].y, L->items[i].x, L->items[i].avatar);
			attroff(COLOR_PAIR(1));
		}

		ch = (char)mvinch((L->items[i].y + 1), (L->items[i].x - 1));
		if(ch == 'B') {
			L->items[i].hp = L->items[i].hp - BDAM;
			attron(COLOR_PAIR(1));
			mvaddch(L->items[i].y, L->items[i].x, L->items[i].avatar);
			attroff(COLOR_PAIR(1));
		}else if(ch == 'Y') {
			L->items[i].hp = L->items[i].hp - YDAM;
			attron(COLOR_PAIR(1));
			mvaddch(L->items[i].y, L->items[i].x, L->items[i].avatar);
			attroff(COLOR_PAIR(1));
		}else if(ch == 'S') {
			L->items[i].hp = L->items[i].hp - SDAM;
//.........这里部分代码省略.........
开发者ID:backpackless,项目名称:ReverseTowerDefence,代码行数:101,代码来源:Run.c

示例12: color_edit

static void color_edit(void)
/* display the color test pattern, without trying to edit colors */
{
    int	i, c, value = 0, current = 0, field = 0, usebase = 0;

    refresh();

    for (i = 0; i < COLORS; i++)
	init_pair(i, COLOR_WHITE, i);

    do {
	short	red, green, blue;

	attron(A_BOLD);
	mvaddstr(0, 20, "Color RGB Value Editing");
	attroff(A_BOLD);

	for (i = 0; i < COLORS; i++)
        {
	    mvprintw(2 + i, 0, "%c %-8s:",
		     (i == current ? '>' : ' '),
		     (i < sizeof(colors)/sizeof(colors[0]) ? colors[i] : ""));
	    attrset(COLOR_PAIR(i));
	    addstr("        ");
	    attrset(A_NORMAL);

	    /*
	     * Note: this refresh should *not* be necessary!  It works around
	     * a bug in attribute handling that apparently causes the A_NORMAL
	     * attribute sets to interfere with the actual emission of the
	     * color setting somehow.  This needs to be fixed.
	     */
	    refresh();

	    color_content(i, &red, &green, &blue);
	    addstr("   R = ");
	    if (current == i && field == 0) attron(A_STANDOUT);
	    printw("%04d", red);
	    if (current == i && field == 0) attrset(A_NORMAL);
	    addstr(", G = ");
	    if (current == i && field == 1) attron(A_STANDOUT);
	    printw("%04d", green);
	    if (current == i && field == 1) attrset(A_NORMAL);
	    addstr(", B = ");
	    if (current == i && field == 2) attron(A_STANDOUT);
	    printw("%04d", blue);
	    if (current == i && field == 2) attrset(A_NORMAL);
	    attrset(A_NORMAL);
	    addstr(")");
	}

	mvaddstr(COLORS + 3, 0,
	    "Use up/down to select a color, left/right to change fields.");
	mvaddstr(COLORS + 4, 0,
	    "Modify field by typing nnn=, nnn-, or nnn+.  ? for help.");

	move(2 + current, 0);

	switch (c = getch())
	{
	case KEY_UP:
	    current = (current == 0 ? (COLORS - 1) : current - 1);
	    value = 0;
	    break;

	case KEY_DOWN:
	    current = (current == (COLORS - 1) ? 0 : current + 1);
	    value = 0;
	    break;

	case KEY_RIGHT:
	    field = (field == 2 ? 0 : field + 1);
	    value = 0;
	    break;

	case KEY_LEFT:
	    field = (field == 0 ? 2 : field - 1);
	    value = 0;
	    break;

	case '0': case '1': case '2': case '3': case '4':
	case '5': case '6': case '7': case '8': case '9':
	    do {
		value = value * 10 + (c - '0');
		c = getch();
	    } while
		(isdigit(c));
	    if (c != '+' && c != '-' && c != '=')
		beep();
	    else
		ungetch(c);
	    break;

	case '+':
	    usebase = 1;
	    goto changeit;

	case '-':
	    value = -value;
	    usebase = 1;
//.........这里部分代码省略.........
开发者ID:UnitedMarsupials,项目名称:kame,代码行数:101,代码来源:ncurses.c

示例13: xsize

ui::Footer::Footer(int x, int y) : xsize(x), ysize(y),
    _footer(newwin(1, xsize, ysize - 1, 0)),
    time(std::time(nullptr)) {
    init_pair(1, 7, 4);
    wbkgd(_footer, COLOR_PAIR(1));
}
开发者ID:TacoVox,项目名称:AutoTux,代码行数:6,代码来源:Footer.cpp

示例14: cbfs_module_redraw

static int cbfs_module_redraw(WINDOW * win)
{
	struct cbfile *f;
	int i, row = 2;

	print_module_title(win, "CBFS Listing");

	if (!header) {
		mvwprintw(win, 11, 61 / 2, "Bad or missing CBFS header");
		return 0;
	}

	/* Draw a line down the middle. */
	for (i = 2; i < 21; i++)
		mvwaddch(win, i, 30, ACS_VLINE);

	/* Draw the names down the left side. */
	for (i = 0; i < filecount; i++) {
		if (i == selected)
			wattrset(win, COLOR_PAIR(3) | A_BOLD);
		else
			wattrset(win, COLOR_PAIR(2));

		if (strlen(filenames[i]) == 0) {
			if (findfile(filenames[i])->type == COMPONENT_NULL)
				mvwprintw(win, 2 + i, 1, "<free space>");
			else
				mvwprintw(win, 2 + i, 1, "<unnamed>");
		} else {
			mvwprintw(win, 2 + i, 1, "%.25s", filenames[i]);
		}
	}

	f = findfile(filenames[selected]);
	if (!f) {
		mvwprintw(win, 11, 32, "ERROR: CBFS component not found");
		return 0;
	}

	wattrset(win, COLOR_PAIR(2));

	/* mvwprintw(win, row++, 32, "Offset: 0x%x", f->offset); *//* FIXME */
	mvwprintw(win, row, 32, "Type: ");
	switch (ntohl(f->type)) {
	case COMPONENT_BOOTBLOCK:
		mvwprintw(win, row++, 38, "bootblock");
		break;
	case COMPONENT_CBFSHEADER:
		mvwprintw(win, row++, 38, "CBFS header");
		break;
	case COMPONENT_STAGE:
		mvwprintw(win, row++, 38, "stage");
		break;
	case COMPONENT_PAYLOAD:
		mvwprintw(win, row++, 38, "payload");
		break;
	case COMPONENT_OPTIONROM:
		mvwprintw(win, row++, 38, "optionrom");
		break;
	case COMPONENT_RAW:
		mvwprintw(win, row++, 38, "raw");
		break;
	case COMPONENT_MICROCODE:
		mvwprintw(win, row++, 38, "microcode");
		break;
	case COMPONENT_CMOS_LAYOUT:
		mvwprintw(win, row++, 38, "cmos layout");
		break;
	case COMPONENT_NULL:
		mvwprintw(win, row++, 38, "free");
		break;
	case COMPONENT_DELETED:
		mvwprintw(win, row++, 38, "deleted");
		break;
	default:
		mvwprintw(win, row++, 38, "Unknown (0x%x)", ntohl(f->type));
		break;
	}
	mvwprintw(win, row++, 32, "Size: %d", ntohl(f->len));
	mvwprintw(win, row++, 32, "Checksum: 0x%x", ntohl(f->checksum));

	return 0;
}
开发者ID:AdriDlu,项目名称:coreboot,代码行数:83,代码来源:cbfs_module.c

示例15: engine_windows_init

/** Starts all the subscreens of the game */
int engine_windows_init()
{
	window_s  w;
	screen_s* s = &(engine.screen);

	int main_x = 0;
	int main_y = 0;
	if (global.screen_center_horizontally)
		main_x = engine.screen.width/2 - 80/2;

	if (global.screen_center_vertically)
		main_y = engine.screen.height/2 - 24/2;

	/* main window, wrapper of all others */
	w.width  = 80;
	w.height = 24;
	w.x      = main_x;
	w.y      = main_y;
	w.win    = newwin(w.height, w.width, w.y, w.x);
	if (global.screen_show_outer_border)
	{
		if (global.screen_fancy_borders)
			window_fancy_borders(w.win);
		else
			window_normal_borders(w.win);
	}

	wnoutrefresh(w.win);
	s->main = w;

	/* leftmost */
	w.width  = 6 * 2 + 2;
	w.height = s->main.height - 2; /* borders */
	w.x      = 2;
	w.y      = 1;
	w.win    = derwin(s->main.win, w.height, w.width, w.y, w.x);

	if (global.screen_fancy_borders)
	{
		window_fancy_borders(w.win);

		/* If the player has no hold, doesnt make sense printing these parts */
		if (global.game_can_hold)
		{
			/* making the top line between hold and score windows */
			mvwaddch(w.win, 5, 0, ACS_LLCORNER|COLOR_PAIR(WHITE_BLACK));
			my_mvwhline(w.win, 5, 1, ACS_HLINE|COLOR_PAIR(BLACK_BLACK)|A_BOLD, w.width - 2);
			mvwaddch(w.win, 5, w.width - 1, ACS_LRCORNER|COLOR_PAIR(BLACK_BLACK)|A_BOLD);

			/* making the bottom line between hold and score windows */
			mvwaddch(w.win, 6, 0, ACS_ULCORNER|COLOR_PAIR(WHITE_BLACK)|A_BOLD);
			my_mvwhline(w.win, 6, 1, ACS_HLINE|COLOR_PAIR(WHITE_BLACK), w.width - 2);
			mvwaddch(w.win, 6, w.width - 1, ACS_URCORNER|COLOR_PAIR(WHITE_BLACK));
		}

	}
	else
	{
		window_normal_borders(w.win);
		wattrset(w.win, engine_get_color(COLOR_BLACK, COLOR_BLACK, true));
		mvwhline(w.win, 5, 1, '-', w.width - 2);
	}

	wnoutrefresh(w.win);
	s->leftmost = w;

	/* middle-left */
	w.width  = 10 * 2 + 2;
	w.height = s->main.height - 2; /* borders */
	w.x      = s->leftmost.x + s->leftmost.width + 1;
	w.y      = 1;
	w.win    = derwin(s->main.win, w.height, w.width, w.y, w.x);
	if (global.screen_fancy_borders)
		window_fancy_borders(w.win);
	else
		window_normal_borders(w.win);
	wnoutrefresh(w.win);
	s->middle_left = w;

	/* middle-right */
	w.width  = 4 * 2 + 2;
	w.height = s->main.height - 2; /* borders */
	w.x      = s->middle_left.x + s->middle_left.width + 1;
	w.y      = 1;
	w.win    = derwin(s->main.win, w.height, w.width, w.y, w.x);
	if (global.screen_fancy_borders)
	{
		window_fancy_borders(w.win);
		/* making the top line between 1st next and the rest */
		mvwaddch(w.win, 3, 0, ACS_LLCORNER|COLOR_PAIR(WHITE_BLACK));
		mvwhline(w.win, 3, 1, ACS_HLINE|COLOR_PAIR(BLACK_BLACK)|A_BOLD, w.width - 2);
		mvwaddch(w.win, 3, w.width - 1, ACS_LRCORNER|COLOR_PAIR(BLACK_BLACK)|A_BOLD);

		/* making the bottom line between 1st next and the rest */
		mvwaddch(w.win, 4, 0, ACS_ULCORNER|COLOR_PAIR(WHITE_BLACK)|A_BOLD);
		mvwhline(w.win, 4, 1, ACS_HLINE|COLOR_PAIR(WHITE_BLACK), w.width - 2);
		mvwaddch(w.win, 4, w.width - 1, ACS_URCORNER|COLOR_PAIR(WHITE_BLACK));

	}
//.........这里部分代码省略.........
开发者ID:liushizhe,项目名称:yetris,代码行数:101,代码来源:engine.c


注:本文中的COLOR_PAIR函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。