您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ start_color函数代码示例

51自学网 2021-06-03 08:21:52
  C++
这篇教程C++ start_color函数代码示例写得很实用,希望能帮到您。

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

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

示例1: main

int main() {  // Initial blocks  uint8_t blocks[5][2] = { {2,1}, {3,5}, {4,5}, {4,6}, {9,8}};  // Initial start position  uint8_t startx = WIDTH / 2;  uint8_t starty = HEIGHT / 2;	  int readc = 0, quit = 0, playerid = PLAYER1;  int textpos = 0;	  // Game area  gamearea* game = new_gamearea(WIDTH,HEIGHT,5,blocks);	  // Player  player* pl1 = new_player(playerid,startx,starty,HEALTH);  initscr(); // Start ncurses  noecho(); // Disable echoing of terminal input  cbreak(); // Individual keystrokes  intrflush(stdscr, FALSE); // Prevent interrupt flush  keypad(stdscr,TRUE); // Allow keypad usage   start_color(); // Initialize colors  // Color pairs init_pair(colorpair id,foreground color, background color)  init_pair(PLAYER1,PLAYER1,COLOR_BLACK); // Player1 = COLOR_RED (1)  init_pair(PLAYER2,PLAYER2,COLOR_BLACK); // Player2 = COLOR_GREEN (2)  init_pair(PLAYER3,PLAYER3,COLOR_BLACK); // Player3 = COLOR_YELLOW (3)  init_pair(PLAYER4,PLAYER4,COLOR_BLACK); // Player4 = COLOR_BLUE (4)  init_pair(PLAYER_HIT_COLOR,COLOR_RED,COLOR_YELLOW);  init_pair(WALL_COLOR,COLOR_WHITE,COLOR_WHITE);  // Prepare everything  clear_log();  prepare_horizontal_line(WIDTH);  ui_draw_grid(game, pl1);  fd_set readfs;  int rval = 0;  while(1) {    FD_ZERO(&readfs);    FD_SET(fileno(stdin),&readfs);     // Block until we have something    if((rval = select(fileno(stdin)+1,&readfs,NULL,NULL,NULL)) > 0) {      // From user      if(FD_ISSET(fileno(stdin),&readfs)) {        readc = getch(); // Get each keypress        pl1->hitwall = 0;        switch(readc) {          case KEY_LEFT:            if(is_position_a_wall(game,pl1->posx-1,pl1->posy)) pl1->hitwall = 1;            else pl1->posx--;            break;          case KEY_RIGHT:            if(is_position_a_wall(game,pl1->posx+1,pl1->posy)) pl1->hitwall = 1;            else pl1->posx++;            break;          case KEY_UP:            if(is_position_a_wall(game,pl1->posx,pl1->posy-1)) pl1->hitwall = 1;            else pl1->posy--;            break;          case KEY_DOWN:            if(is_position_a_wall(game,pl1->posx,pl1->posy+1)) pl1->hitwall = 1;            else pl1->posy++;            break;          // Function keys, here F1 is reacted to          case KEY_F(1):            status = status ^ 1;            break;          case 27: // Escape key            quit = 1;            break;          case '/':            // User wants to write something            memset(&textbuffer,0,BUFFER);            textinput = 1;            textpos = 0;            break;          // Erase text          case KEY_BACKSPACE:          case KEY_DC:            textpos--;            textbuffer[textpos] = '/0';            break;          // Push the line to log with enter          case KEY_ENTER:          case '/n':            textinput = 0;            if(strlen(textbuffer) > 0) add_log(textbuffer,textpos);            textpos = 0;            memset(&textbuffer,0,BUFFER);            break;          // Add the character to textbuffer if we were inputting text          default://.........这里部分代码省略.........
开发者ID:HateBreed,项目名称:Course-example-codes,代码行数:101,


示例2: mousemask

      bool Display::Open()      {        // Open curses        screen=initscr();        if (screen==NULL) {          std::cerr << "Cannot initialize curses" << std::endl;          return false;        }#ifdef NCURSES_MOUSE_VERSION        mousemask(BUTTON1_PRESSED|                  BUTTON1_RELEASED/*|                  BUTTON1_CLICKED|                  BUTTON1_DOUBLE_CLICKED|                  BUTTON1_TRIPLE_CLICKED*/,NULL);#endif        // Check availibility of colors        colorDepth=1;        colorMode=colorModeMonochrome;        if (has_colors() && start_color()!=ERR && COLORS>=8) {          colorMode=colorModeColor;          colorDepth=4;        }        // Basic curses initialisation        curs_set(0);        noecho();        cbreak();        nonl();        raw();        //Images::Factory::Set(OS::Factory::factory->CreateImageFactory(this));        screenWidth=COLS;        screenHeight=LINES;        workAreaWidth=screenWidth;        workAreaHeight=screenHeight;        type=typeTextual;        EvaluateDisplaySize();        for (int c=1; c<COLOR_PAIRS; c++) {          if (init_pair(c,c%COLORS,c/COLORS)==ERR) {            std::cerr << c << " " << c%COLORS << " " << c/COLORS << std::endl;            std::cerr << "Cannot initialize terminal color pairs" << std::endl;            colorDepth=1;            colorMode=colorModeMonochrome;            break;          }        }        propFont=driver->CreateFont();        propFont=propFont->Load();        propFontSize=1;        fixedFont=driver->CreateFont();        fixedFont=fixedFont->Load();        fixedFontSize=1;        theme=new Theme(this);        for (size_t i=0; i<colorCount; i++) {          color[i]=theme->GetColor((ColorIndex)i);        }        multiClickTime=200;        eventLoop=new UnixEventLoop();        eventLoop->AddSource(new CursesEventSource(this));        return true;      }
开发者ID:kolosov,项目名称:libosmscout,代码行数:77,


示例3: do_start_color

void do_start_color(state *st) {  encode_ok_reply(st, start_color());}
开发者ID:sofuture,项目名称:cecho,代码行数:3,


示例4: dialog_run

static intdialog_run (pinentry_t pinentry, const char *tty_name, const char *tty_type){  struct dialog diag;  FILE *ttyfi = NULL;  FILE *ttyfo = NULL;  SCREEN *screen = 0;  int done = 0;  char *pin_utf8;  int alt = 0;#ifndef HAVE_DOSISH_SYSTEM  int no_input = 1;#endif#ifdef HAVE_NCURSESW  char *old_ctype = NULL;  if (pinentry->lc_ctype)    {      old_ctype = strdup (setlocale (LC_CTYPE, NULL));      setlocale (LC_CTYPE, pinentry->lc_ctype);    }  else    setlocale (LC_CTYPE, "");#endif  /* Open the desired terminal if necessary.  */  if (tty_name)    {      ttyfi = fopen (tty_name, "r");      if (!ttyfi)        {          pinentry->specific_err = ASSUAN_ENOENT;          return -1;        }      ttyfo = fopen (tty_name, "w");      if (!ttyfo)	{	  int err = errno;	  fclose (ttyfi);	  errno = err;          pinentry->specific_err = ASSUAN_ENOENT;	  return -1;	}      screen = newterm (tty_type, ttyfo, ttyfi);      set_term (screen);    }  else    {      if (!init_screen)	{          if (!(isatty(fileno(stdin)) && isatty(fileno(stdout))))            {              errno = ENOTTY;              pinentry->specific_err = ASSUAN_ENOTTY;              return -1;            }	  init_screen = 1;	  initscr ();	}      else	clear ();    }  keypad (stdscr, TRUE); /* Enable keyboard mapping.  */  nonl ();		/* Tell curses not to do NL->CR/NL on output.  */  cbreak ();		/* Take input chars one at a time, no wait for /n.  */  noecho ();		/* Don't echo input - in color.  */  if (has_colors ())    {      start_color ();#ifdef NCURSES_VERSION      use_default_colors ();#endif      if (pinentry->color_so == PINENTRY_COLOR_DEFAULT)	{	  pinentry->color_so = PINENTRY_COLOR_RED;	  pinentry->color_so_bright = 1;	}      if (COLOR_PAIRS >= 2)	{	  init_pair (1, pinentry_color[pinentry->color_fg],		     pinentry_color[pinentry->color_bg]);	  init_pair (2, pinentry_color[pinentry->color_so],		     pinentry_color[pinentry->color_bg]);	  bkgd (COLOR_PAIR (1));	  attron (COLOR_PAIR (1) | (pinentry->color_fg_bright ? A_BOLD : 0));	}    }  refresh ();  /* Create the dialog.  */  if (dialog_create (pinentry, &diag))    {      /* Note: pinentry->specific_err has already been set.  */      endwin ();      if (screen)        delscreen (screen);//.........这里部分代码省略.........
开发者ID:GPGTools,项目名称:pinentry-mac,代码行数:101,


示例5: error

void *mode4_init(void *aldl_in) {  aldl = (aldl_conf_t *)aldl_in;  /* sanity check pcm address to avoid using this with wrong ecm */  if(aldl->comm->pcm_address != 0xF4) {    error(EFATAL, ERROR_PLUGIN, "MODE4 Special plugin is for EE only.");  };  /* allocate main message buffer for log entries */  msgbuf = malloc(sizeof(char) * MSGBUFSIZE);  /* initialize root window */  WINDOW *root;  if((root = initscr()) == NULL) {    error(1,ERROR_NULL,"could not init ncurses");  }  curs_set(0); /* remove cursor */  cbreak(); /* dont req. line break for input */  nodelay(root,true); /* non-blocking input */  noecho();  /* configure colors (even though this doesn't use much color) */  start_color();  init_pair(RED_ON_BLACK,COLOR_RED,COLOR_BLACK);  init_pair(BLACK_ON_RED,COLOR_BLACK,COLOR_RED);  init_pair(GREEN_ON_BLACK,COLOR_GREEN,COLOR_BLACK);  init_pair(CYAN_ON_BLACK,COLOR_CYAN,COLOR_BLACK);  init_pair(WHITE_ON_BLACK,COLOR_WHITE,COLOR_BLACK);  init_pair(WHITE_ON_RED,COLOR_WHITE,COLOR_RED);  /* fetch indexes (saves repeated lookups) */  p_idx.rpm = get_index_by_name(aldl,"RPM");  p_idx.idletarget = get_index_by_name(aldl,"IDLESPD");  p_idx.iacsteps = get_index_by_name(aldl,"IAC");  p_idx.cooltemp = get_index_by_name(aldl,"COOLTMP");  p_idx.map = get_index_by_name(aldl,"MAP");  p_idx.adv = get_index_by_name(aldl,"ADV");  p_idx.kr = get_index_by_name(aldl,"KR");  /* get initial screen size */  getmaxyx(stdscr,w_height,w_width);  /* wait for connection */  m4_cons_wait_for_connection();  /* prepare 'empty' mode4 command */  m4_comm_init();  while(1) {    /* get newest record */    rec = newest_record_wait(aldl,rec);    if(rec == NULL) { /* disconnected */      m4_cons_wait_for_connection();      continue;    }    /* process engine status */    get_engine_status();    erase(); /* clear screen --------- */    mvprintw(0,1,M4_USE_STRING); /* print usage */    /* print eng status */    mvprintw(2,1,"%s",print_engine_status());    m4_commrev = 0; /* reset revision bit.  input handler may set it */    m4_consoleif_handle_input(); /* get keyboard input and branch */     #ifdef M4_PRINT_HEX    /* print the m4 string in hex for debug */    m4_draw_cmd(1,1);    #endif    if(m4_commrev == 1) { /* send command if revised */      m4_comm_submit();    }    refresh();    usleep(500);  }  sleep(4);  delwin(root);  endwin();  refresh();  pthread_exit(NULL);  return NULL;}
开发者ID:DaElf,项目名称:aldl,代码行数:92,


示例6: main

int main() {	    gw.begin();    //uint8_t nodeID = 22;  //gw.begin(nodeID,3,RF24_2MBPS);    //uint16_t address = 0;  //gw.begin(address,3,RF24_2MBPS);    /** Setup NCurses**/  /*******************************/   win = initscr();  cbreak();   noecho();  getmaxyx(win,maxX,maxY);    start_color();  curs_set(0);     init_pair(1, COLOR_GREEN, COLOR_BLACK);  init_pair(2, COLOR_RED, COLOR_BLACK);    /** Setup Pads**/  /*******************************/  devPad = newpad(11,40);    meshPad = newpad(11,50);    rf24Pad = newpad(11,40);    connPad = newpad(21,150);  cfgPad = newpad(10,40);    scrollok(meshPad,true);  scrollok(connPad,true);  scrollok(rf24Pad,true);  timeout(0);    drawMain();  /******************************************************************/ /***********************LOOP***************************************/   while(1){		//delayMicroseconds(5000);	//delay(1);	/**	* The gateway handles all IP traffic (marked as EXTERNAL_DATA_TYPE) and passes it to the associated network interface	* RF24Network user payloads are loaded into the user cache			*/    gw.update();    /** Read RF24Network Payloads (Do nothing with them currently) **/  /*******************************/	if( network.available() ){	  RF24NetworkHeader header;	  size_t size = network.peek(header);	  uint8_t buf[size];         if(header.type == 1){	  struct timeStruct{	   uint8_t hr;	   uint8_t min;	  }myTime;	  time_t mTime;	  time(&mTime);	  struct tm* tm = localtime(&mTime);          myTime.hr = tm->tm_hour;          myTime.min = tm->tm_min;         RF24NetworkHeader hdr(header.from_node,1);          network.write(hdr,&myTime,sizeof(myTime));   	}          network.read(header,&buf,size);	}    /** Mesh address/id printout **/  /*******************************/    if(millis() - meshInfoTimer > updateRate){	  getmaxyx(win,maxX,maxY);	  // Draw the pads on screen      drawDevPad();	  prefresh(devPad,0,0, 4,1, 15,25);	        drawMeshPad(); 	  wscrl(meshPad,meshScroll);	  prefresh(meshPad,0,0, 4,26, 15,47);	  	  drawRF24Pad();	  prefresh(rf24Pad,0,0, 4,51, 15, 73);	  	  if(showConnPad){	    drawConnPad();	    wscrl(connPad,connScroll);	    prefresh(connPad,0,0, 15,1, maxX-1,maxY-2);//.........这里部分代码省略.........
开发者ID:eigokor,项目名称:RF24Gateway,代码行数:101,


示例7: main

int main(int argc, char **argv){	int c;	int colouron = 0;	char *fslist = NULL;	time_t last_update = 0;	extern int errno;	int delay=2;	sg_log_init("saidar", "SAIDAR_LOG_PROPERTIES", argc ? argv[0] : NULL);	sg_init(1);	if(sg_drop_privileges() != 0){		fprintf(stderr, "Failed to drop setuid/setgid privileges/n");		return 1;	}#ifdef COLOR_SUPPORT	while ((c = getopt(argc, argv, "d:F:cvh")) != -1){#else	while ((c = getopt(argc, argv, "d:F:vh")) != -1){#endif		switch (c){			case 'd':				delay = atoi(optarg);				if (delay < 1){					fprintf(stderr, "Time must be 1 second or greater/n");					exit(1);				}				break;#ifdef COLOR_SUPPORT			case 'c':				colouron = 1;				break;#endif			case 'v':				version_num(argv[0]);				break;			case 'h':			default:				usage(argv[0]);				return 1;		}	}	if (fslist) {		sg_error rc = set_valid_filesystems(fslist);		if(rc != SG_ERROR_NONE)			die(sg_str_error(rc));		free(fslist);	}	else {		sg_error rc = set_valid_filesystems("!nfs, nfs3, nfs4, cifs, smbfs, samba, autofs");		if(rc != SG_ERROR_NONE)			die(sg_str_error(rc));	}	signal(SIGWINCH, sig_winch_handler);	initscr();#ifdef COLOR_SUPPORT	/* turn on colour */	if (colouron) {		if (has_colors()) {			start_color();			use_default_colors();			init_pair(1,COLOR_RED,-1);			init_pair(2,COLOR_GREEN,-1);			init_pair(3,COLOR_YELLOW,-1);			init_pair(4,COLOR_BLUE,-1);			init_pair(5,COLOR_MAGENTA,-1);			init_pair(6,COLOR_CYAN,-1);		} else {			fprintf(stderr, "Colour support disabled: your terminal does not support colour.");			colouron = 0;		}	}#endif	nonl();	curs_set(0);	cbreak();	noecho();	timeout(delay * 1000);	newwin(0, 0, 0, 0);	clear();	if(!get_stats()){		fprintf(stderr, "Failed to get all the stats. Please check correct permissions/n");		endwin();		return 1;	}	display_headings();	for(;;){		time_t now;		int ch = getch();		if (ch == 'q'){//.........这里部分代码省略.........
开发者ID:RsrchBoy,项目名称:dpkg-libstatgrab,代码行数:101,


示例8: Number

void Number (int argc, char **argv){    initscr ();    noecho ();    start_color ();    clear ();    refresh ();    init_pair (1, COLOR_RED, COLOR_BLACK);    init_pair (2, COLOR_GREEN, COLOR_BLACK);    init_pair (3, COLOR_YELLOW, COLOR_BLACK);    init_pair (4, COLOR_BLUE, COLOR_BLACK);    init_pair (5, COLOR_MAGENTA, COLOR_BLACK);    init_pair (6, COLOR_CYAN, COLOR_BLACK);    init_pair (7, COLOR_WHITE, COLOR_BLACK);    srand (time (NULL));    for (int count = 0; count < atoi ((argc == 2) ? argv [1] : "5"); count++)    {        for (int r = 0, l = LINES - 1; r < LINES && l >= 0; r++, l--)        {            for (int c = 0; c < COLS; c += 2)            {                attrset (A_BOLD | COLOR_PAIR (1 + rand () % 8));                mvprintw (l, c + 1, "%i", rand () % 10);                attrset (A_NORMAL);                attrset (A_BOLD | COLOR_PAIR (1 + rand () % 8));                mvprintw (r, c, "%i", rand () % 10);                attrset (A_NORMAL);            }            move (LINES / 2, COLS / 2);            refresh ();        }        for (int c = 0, v = COLS - 1; c < COLS && v >= 0; c++, v--)        {            for (int r = 0; r < LINES; r += 2)            {                mvaddch (r, c, ' ');                mvaddch (r + 1, v, ' ');            }            move (LINES / 2, COLS / 2);            refresh ();        }        for (int c = 0, v = COLS - 1; c < COLS && v >= 0; c++, v--)        {            for (int r = 0; r < LINES; r += 2)            {                attrset (A_BOLD | COLOR_PAIR (1 + rand () % 8));                mvprintw (r, c, "%i", rand () % 2);                attrset (A_NORMAL);                attrset (A_BOLD | COLOR_PAIR (1 + rand () % 8));                mvprintw (r + 1, v, "%i", rand () % 2);                attrset (A_NORMAL);            }            move (LINES / 2, COLS / 2);            refresh ();        }        for (int r = 0, l = LINES - 1; r < LINES && l >= 0; r++, l--)        {            for (int c = 0; c < COLS; c += 2)            {                mvaddch (l, c + 1, ' ');                mvaddch (r, c, ' ');            }            move (LINES / 2, COLS / 2);            refresh ();        }    }    move (LINES - 1, COLS - 1);    clear ();    refresh ();    endwin ();}
开发者ID:NiNjA-CodE,项目名称:csc-313,代码行数:78,


示例9: main

int main(int argc, char* argv[]){   init_console(); // do this FIRST   //start curses   initscr();   gamelog.initialize(GAMELOG_FILEPATH, OVERWRITE_GAMELOG, NEWLINEMODE_GAMELOG); //Initialize the gamelog (and also initialize artdir and homedir)   time_t t = time(0);   struct tm *now = localtime(&t); //Do not need to deallocate this. Statically allocated by system   char datetime[41];   sprintf(datetime, "---------%i-%02i-%02i %02i:%02i:%02i---------/n/n/n",       now->tm_year+1900, now->tm_mon+1, now->tm_mday, now->tm_hour, now->tm_min, now->tm_sec); //YYYY-MM-DD HH:MM:SS format   gamelog.log(string("/n/n/n---------- PROGRAM STARTED ----------/n") + datetime);   char file_name[13];   FILE *file;   music.play(MUSIC_TITLEMODE); // initialize music and play title mode song (do this BEFORE displaying anything on the screen, but AFTER initializing artdir and homedir)   // set window title   char wtitle[50];   strcpy(wtitle,"Liberal Crime Squad ");   strcat(wtitle,PACKAGE_VERSION);   set_title(wtitle);   noecho();   //initialize curses color   start_color();   initMainRNG();   //initialize the array of color pairs   for(int i=0;i<8;i++)      for(int j=0;j<8;j++)      {         if(i==0&&j==0)         {            init_pair(7*8,0,0);            continue;         }         if(i==7&&j==0) continue;         init_pair(i*8+j,i,j);      }   //turns off cursor   curs_set(0);   //begin the game loop   keypad(stdscr,TRUE);   raw_output(TRUE);   //addstr("Loading Graphics... ");   //getkey();   loadgraphics();   //addstr("Loading Init File Options... ");   //getkey();   loadinitfile();   //addstr("Loading sitemaps.txt... ");   //getkey();   oldMapMode=!readConfigFile("sitemaps.txt"); // load site map data   if(oldMapMode)   {      addstr("Failed to load sitemaps.txt! Reverting to old map mode.",gamelog);      gamelog.nextMessage();      getkey();   }   //move(1,0);   //addstr("Setting initial game data... ");   //getkey();   strcpy(slogan,"We need a slogan!");   if(!LCSrandom(20))   {      switch(LCSrandom(7))      {      case 0: strcpy(slogan,"To Rogues and Revolution!"); break;      case 1: strcpy(slogan,"Hell yes, LCS!"); break;      case 2: strcpy(slogan,"Striking high, standing tall!"); break;      case 3: strcpy(slogan,"Revolution never comes with a warning!"); break;      case 4: strcpy(slogan,"True Liberal Justice!"); break;      case 5: strcpy(slogan,"Laissez ain't fair!"); break;      case 6: strcpy(slogan,"This is a slogan!"); break;      }   }   //Initialize sorting choices.   for(int s=0;s<SORTINGCHOICENUM;s++)//.........这里部分代码省略.........
开发者ID:DanielOaks,项目名称:Liberal-Crime-Squad,代码行数:101,


示例10: main

int main (int argc, char** argv) {	const char* default_port = "23";	struct sigaction sa;	int i;	/* process command line args */	for (i = 1; i < argc; ++i) {		/* help */		if (strcmp(argv[i], "-h") == 0) {			printf(				"CLC %s by Sean Middleditch <[email
C++ start_command函数代码示例
C++ start_capture函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。