• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ COLOR_PAIR函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: print_content

static void
print_content(void)
{
	int required_lines = 0, disable_detailed = 0, disabled_graphical = 0;

	if (NULL == get_current_node())
		return;

	if (c_list_in_list) {
		NEXT_ROW;
		putl("");

		if (c_use_colors)
			attrset(COLOR_PAIR(LAYOUT_HEADER) | layout[LAYOUT_HEADER].attr);
	
		NEXT_ROW;
		putl("  #   Tarjeta de Red ' Rawil'               RX Tasa         RX #   " \
			"  TX Tasa         TX #");
	
		NEXT_ROW;
		hline(ACS_HLINE, cols);

		if (c_combined_node_list)
			foreach_node(draw_node, NULL);
		else
			draw_node(get_current_node(), NULL);
	} else {
		NEXT_ROW;
		hline(ACS_HLINE, cols);
		move(row, 24);
		addstr(" Press l to enable list view ");
		move(row, 0);
	}

	/*
	 * calculate lines required for graphical and detailed stats unfolded
	 */
	if (c_graphical_in_list)
		required_lines += lines_required_for_graphical();
	else
		required_lines++;

	if (c_detailed_in_list)
		required_lines += lines_required_for_detailed();
	else
		required_lines++;

	if ((rows - row) <= (required_lines + 1)) {
		/*
		 * not enough lines, start over with detailed stats disabled
		 */
		required_lines = 0;
		disable_detailed = 1;

		/*
		 * 1 line for folded detailed stats display
		 */
		required_lines++;

		if (c_graphical_in_list)
			required_lines += lines_required_for_graphical();
		else
			required_lines++;

		if ((rows - row) <= (required_lines + 1)) {
			/*
			 * bad luck, not even enough space for graphical stats
			 * reserve 2 lines for displaying folded detailed and
			 * graphical stats
			 */
			required_lines = 2;
			disabled_graphical = 1;
		}
	}

	/*
	 * Clear out spare space
	 */
	while (row < (rows - (required_lines + 2))) {
		NEXT_ROW; putl("");
	}

	NEXT_ROW;
	hline(ACS_HLINE, cols);

	if (c_graphical_in_list) {
		if (disabled_graphical) {
			move(row, 15);
			addstr(" Increase screen size to see graphical statistics ");
			move(row, 0);
		} else
			draw_graphic();
	} else {
		move(row, 20);
		addstr(" Press g to enable graphical statistics ");
		move(row, 0);
	}

	NEXT_ROW;
	hline(ACS_HLINE, cols);
//.........这里部分代码省略.........
开发者ID:Csrawil,项目名称:canaima,代码行数:101,代码来源:out_curses.c


示例17: engine_draw_next_pieces

void engine_draw_next_pieces(game_s* g)
{
	WINDOW* w = NULL;
	int i, k;
	for (i = 0; i < global.game_next_no; i++)
	{
		piece_s p = g->piece_next[i];
		w = engine.screen.next[i].win;

		werase(w);

		/* This is a little hack to pretty-print pieces
		 * TODO somehow manage to fix this */
		for (k = 0; k < 4; k++)
		{
			/* shifting them to the left */
			p.block[k].x -= p.x + 1;
			p.block[k].y -= p.y;

			p.block[k].y--;

			if (p.type == PIECE_O)
				p.block[k].y -= 1;
		}
		engine_draw_piece(&p, w);
		wnoutrefresh(w);
	}

	w = engine.screen.middle_right.win;

	if (global.screen_fancy_borders)
	{
		mvwaddch(w, 3, 0, ACS_LLCORNER|COLOR_PAIR(WHITE_BLACK));
		mvwhline(w, 3, 1, ACS_HLINE|COLOR_PAIR(BLACK_BLACK)|A_BOLD, 8);
		mvwaddch(w, 3, 9, ACS_LRCORNER|COLOR_PAIR(BLACK_BLACK)|A_BOLD);
	}
	else
	{
		wattrset(w, engine_get_color(COLOR_BLACK, COLOR_BLACK, true));
		mvwhline(w, 3, 1, '-', 8);
	}

	wattrset(w, engine_get_color(COLOR_BLUE, COLOR_BLACK, false));
	mvwaddstr(w, 0, 1, "Next");
	wnoutrefresh(w);

	window_s* win = &(engine.screen.middle_right);

	/* RE-DRAWING BORDERS (damn this sucks) */
	if (global.screen_fancy_borders)
	{
		window_fancy_borders(win->win);
		/* making the top line between 1st next and the rest */
		mvwaddch(win->win, 3, 0, ACS_LLCORNER|COLOR_PAIR(WHITE_BLACK));
		mvwhline(win->win, 3, 1, ACS_HLINE|COLOR_PAIR(BLACK_BLACK)|A_BOLD, win->width - 2);
		mvwaddch(win->win, 3, win->width - 1, ACS_LRCORNER|COLOR_PAIR(BLACK_BLACK)|A_BOLD);

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

	}
	else
	{
		window_normal_borders(win->win);
		wattrset(win->win, engine_get_color(COLOR_BLACK, COLOR_BLACK, true));
		mvwhline(win->win, 3, 1, '-', win->width - 2);
	}

}
开发者ID:liushizhe,项目名称:yetris,代码行数:71,代码来源:engine.c


示例18: curses_draw

static void
curses_draw(void)
{
	if (NULL == get_current_node()) {
		first_node();
		first_intf();
	}

    row = 0;
    move(0,0);
	
	getmaxyx(stdscr, rows, cols);
	
	if (cols < 80) {
		clear();
		putl("Screen must be at least 80 columns wide");
		refresh();
		return;
	}

	if (c_use_colors)
		attrset(COLOR_PAIR(LAYOUT_STATUSBAR) | layout[LAYOUT_STATUSBAR].attr);
	else
		attrset(A_REVERSE);

	if (get_current_node() && get_current_intf()) {
		putl(" interface: %s at %s",
			get_current_intf()->i_name, get_current_node()->n_name);
	}

	move(row, COLS - strlen(PACKAGE_STRING) - 1);
	putl("%s", PACKAGE_STRING);
	move(row, 0);
	
	if (c_use_colors)
		attrset(COLOR_PAIR(LAYOUT_DEFAULT) | layout[LAYOUT_DEFAULT].attr);
	else
		attroff(A_REVERSE);
	
	print_content();

	if (quit_mode)
		print_quit();
	else if (print_help)
		draw_help();

	for (; row < rows-2;) {
		move(++row, 0);
		putl("");
	}
	
	row = rows-1;
	move(row, 0);

	if (c_use_colors)
		attrset(COLOR_PAIR(LAYOUT_STATUSBAR) | layout[LAYOUT_STATUSBAR].attr);
	else
		attrset(A_REVERSE);

	putl(" ^ prev interface, v next interface, <- prev node, -> next node, ? help");
	
	attrset(0);
	refresh();
}
开发者ID:Csrawil,项目名称:canaima,代码行数:64,代码来源:out_curses.c


示例19: draw_item_list

int draw_item_list(select_menu *menu)
{
	select_item *it;
	int i=0,j=0,k=0,d,sc=0;
	int c,curopt=0;
	char buf[40];
	select_item *current=NULL;
	int should_scroll,max_display;
	int len,max_len=0;
	int disp_start=0,actual_pos=0;
again:
	i=0;j=0;k=0;
	max_display=max_y/2-2;
	should_scroll=menu->item_no>max_display?1:0;

	wclear(menu_window);

	/* print title in colour */
	attron(COLOR_PAIR(1));
	mvprintw(HIGH_NOTICE_Y,max_x/2-20,menu->name);
	attroff(COLOR_PAIR(1));

	if (should_scroll) {
		for (it=menu->item_list,sc=0;it;it=it->next,sc++) {
			/* only draw visible part of menu */
			if (sc>=disp_start && i < max_display) {
				wmove(menu_window, max_y/4+j++, max_x / 2 - 20);
				i++;
				snprintf(buf, sizeof(buf), "[%s] %s", it->enabled ? "*" : " ", it->name);
				waddstr(menu_window, buf);
				len=strlen(it->name);
				if (len > max_len)
					max_len=len;
			}
		}
	} else {
		for (it=menu->item_list,sc=0;it;it=it->next,sc++) {
			/* draw everything */
			wmove(menu_window, max_y/4+j++, max_x / 2 - 20);
			i++;
			snprintf(buf, sizeof(buf), "[%s] %s", it->enabled ? "*" : " ", it->name);
			waddstr(menu_window, buf);
			len=strlen(it->name);
			if (len > max_len)
				max_len=len;
		}

		/* marker is always in par with the selected option */
		actual_pos=curopt;
	}

	for(it=menu->item_list;it;it=it->next)
		if (k++ == curopt) {
			current=it;
			break;
		}

	/* print current item description */
	if (current->description) {
		attron(COLOR_PAIR(1));
		print_notice(NOTICE_Y,NOTICE_X,0,current->description);
		attroff(COLOR_PAIR(1));
	}

	move(max_y/4+actual_pos,max_x/2-19);

	/* draw box */
	wattron(menu_window,COLOR_PAIR(2));
	for (d=-1;d<i+1;d++) {
		wmove(menu_window,max_y/4+d,max_x/2-26);
		wprintw(menu_window,"|");
		wmove(menu_window,max_y/4+d,max_x/2-10+max_len);
		wprintw(menu_window,"|");
	}

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

	/* show scrolling notifications if it's the case */
	if (should_scroll && disp_start > 0) {
		wmove(menu_window,max_y/4,max_x/2-5+max_len);
		wprintw(menu_window,"Scroll up for more");
	}

	if (should_scroll && disp_start + max_display < menu->item_no) {
		wmove(menu_window,max_y/4+max_display-1,max_x/2-5+max_len);
		wprintw(menu_window,"Scroll down for more");
	}

	wattroff(menu_window,COLOR_PAIR(2));

	wrefresh(menu_window);
	k=0;

	while ((c = getch())) {
		switch (c) {
//.........这里部分代码省略.........
开发者ID:WuKongQC,项目名称:opensips,代码行数:101,代码来源:curses.c


示例20: main

/* Starts the program and prints the main menu */
int main(int qw) {
    static int mm = -1;
    mm++;
    initscr();
    curs_set(0);
    noecho();
    if(qw == 2)
        banner(4);
    else if(qw == 1)
        banner(3);
    ITEM **my_items;
    int c;
    MENU *my_menu;
    WINDOW *my_menu_win;
    int n_choices, i;
    ITEM *cur;
    /* Initialize curses */
    initscr();
    start_color();
    init_pair(5, COLOR_RED, COLOR_BLACK);
    init_pair(6, COLOR_BLACK, COLOR_RED);
    init_pair(7, COLOR_CYAN, COLOR_BLACK);
    cbreak();
    noecho();
    keypad(stdscr, TRUE);
    init_pair(1, COLOR_RED, COLOR_BLACK);
START:
    attrset(COLOR_PAIR(7));
    n_choices = ARRAY_SIZE(choices_index);
    my_items = (ITEM **)calloc(n_choices, sizeof(ITEM *));
    for(i = 0; i < n_choices; ++i) {
        my_items[i] = new_item(choices_index[i], NULL);
        if(i == 0)
            /* Set the user pointer */
            set_item_userptr(my_items[i], mains);
        else if(i == 1)
            set_item_userptr(my_items[i], race_menu);
        else if(i == 2)
            set_item_userptr(my_items[i], exitit);
    }
    my_items[n_choices] = (ITEM *)NULL;
    /* Crate menu */
    my_menu = new_menu((ITEM **)my_items);

    /* Create the window to be associated with the menu */
    my_menu_win = newwin(8, 25, 15, 70);
    keypad(my_menu_win, TRUE);

    /* Set main window and sub window */
    set_menu_win(my_menu, my_menu_win);
    set_menu_sub(my_menu, derwin(my_menu_win, 5, 19, 3, 1));

    /* Set menu mark to the string " * " */
    set_menu_mark(my_menu, "-->  

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ COMBINE_DATA函数代码示例发布时间:2022-05-30
下一篇:
C++ COLOR函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap