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


C++ printw函数代码示例

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


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

示例1: main

/*
 * The Big Cheese
 */
int
main(int argc, char *argv[])
{
  scrgame *sg;
  int c;
  char *bn = basename(argv[0]);
  if (!bn || errno) {
    /* basename can return a NULL pointer, causing a segfault on
       strncmp below */
    errx(errno, "Something went wrong in determining the %s",
	 "filename by which nmm was called.");
  }
  if (argc != 1) {
    errx(EINVAL, "%s doesn't take any arguments.", bn);
  }
  if ((sg = malloc(sizeof(*sg)))) {
    if ((sg->game = malloc(sizeof(*sg->game)))) {
      point *board;
      if ((board = calloc(ROWS * COLS, sizeof(*board)))) {
	int r;
	for (r = 0; r < ROWS; r++) {
	  for (c = 0; c < COLS; c++) {
	    sg->game->board[r][c] = board++;
	  }
	}
      } else {
	errx(errno, "Unable to allocate memory for the board");
      }
    } else {
      errx(errno, "Unable to allocate memory for the game");
    }
  } else {
    errx(errno, "Unable to allocate memory");
  }
  initscr();
  cbreak();
  keypad(stdscr, TRUE);
  clear();
  printw("Display instructions? (y/n) ");
  refresh();
  c = getch();
  c = tolower(c);
  if (c == 'y') {
    printinstrs(sg);
  }
  clear();
  noecho();
  refresh();
  if (strncmp("tmm", bn, 3) == 0) {
    c = TMM;
  } else if (strncmp("twmm", bn, 4) == 0) {
    c = TWMM;
  } else {
    c = NMM;
  }
  for (;;) {
    initall(sg, c);
    refresh();
    phaseone(sg);
    phasetwothree(sg);
    if (!gameend(sg)) {
      break;
    }
  }
  refresh();
  endwin();
  return 0;
}
开发者ID:ryanakca,项目名称:nmm,代码行数:71,代码来源:nmm.c

示例2: cargaNivel

int cargaNivel(int n_nivel, Nivel *nivel)
{

    int error = 1;

    char ruta_nivel[255];
    FILE *f_niveles;

    sprintf(ruta_nivel, "nivel%d.txt", n_nivel);
    printw("Cargando nivel: %s\n", ruta_nivel);

    f_niveles = fopen(ruta_nivel, "r");

    if(f_niveles != NULL)
    {

        int i = 0;

        void *mas_piedras;

        nivel->numero_nivel = n_nivel;

        nivel->piedras.lista = NULL;
        nivel->piedras.elementos = 0;



        nivel->diamantes.lista = NULL;
        nivel->diamantes.elementos = 0;
        void *mas_diamantes;

        fscanf(f_niveles,"posInicial_x = %4d", &nivel->posicioInicial.fila);
        fgetc(f_niveles); //Obtenemos el final de linea
        fscanf(f_niveles,"posInicial_y = %4d", &nivel->posicioInicial.columna);
        fgetc(f_niveles); //Obtenemos el final de linea
        fscanf(f_niveles,"diamantes_necesarios = %4d", &nivel->diamantes.elementos_necesarios);
        fgetc(f_niveles); //Obtenemos el final de linea
        fscanf(f_niveles,"posSalida_x = %4d", &nivel->posicioSortida.fila);
        fgetc(f_niveles); //Obtenemos el final de linea
        fscanf(f_niveles,"posSalida_y = %4d", &nivel->posicioSortida.columna);
        fgetc(f_niveles); //Obtenemos el final de linea
        fscanf(f_niveles,"puntosPorGanar = %4d", &nivel->puntosPorGanar);
        fgetc(f_niveles); //Obtenemos el final de linea


        printw("Posicion Inicial: X:%d Y:%d\n", nivel->posicioInicial.fila, nivel->posicioInicial.columna);

        while( !feof(f_niveles) )
        {
            fgets(nivel->caracteres[i], NIVEL_COLUMNAS + 1, f_niveles);
            fgetc(f_niveles); //Obtenemos el final de linea

            printw("Leido %d: %s\n", i, nivel->caracteres[i]);

            int j = 0;
            while(j<=NIVEL_COLUMNAS+1)
            {

                if(nivel->caracteres[i][j] == 'O')  //Es una pedra.
                {
                    printw("Piedra leida en la posicion: X:%d, Y:%d\n", i, j);
                    nivel->piedras.elementos++;

                    mas_piedras = realloc(nivel->piedras.lista, sizeof(Lista_Piedras) * (nivel->piedras.elementos) );

                    if(mas_piedras != NULL)
                    {
                        nivel->piedras.lista = mas_piedras;
                        nivel->piedras.lista[nivel->piedras.elementos-1].posicion.fila = i;
                        nivel->piedras.lista[nivel->piedras.elementos-1].posicion.columna = j;
                        nivel->piedras.lista[nivel->piedras.elementos-1].segunda_oportunidad = 1;
                        nivel->piedras.lista[nivel->piedras.elementos-1].direccion = 0;
                    }
                    else
                    {
                        free(nivel->piedras.lista);
                        printw("Error rehahuecando memoria para las piedras.\n");
                        exit(1);
                    }
                }

                if(nivel->caracteres[i][j] == 'V')  //Es un diamant.
                {
                    printw("Diamante leido en la posicion: X:%d, Y:%d\n", i, j);
                    nivel->diamantes.elementos++; // A1 - Al detectar el diamante se incrementa la cantidad ahora para que el realloc funcione correctamente.

                    mas_diamantes = realloc(nivel->diamantes.lista, sizeof(Lista_Diamantes) * nivel->diamantes.elementos);

                    if(mas_diamantes != NULL)
                    {
                        nivel->diamantes.lista = mas_diamantes;
                        nivel->diamantes.lista[nivel->diamantes.elementos-1].posicion.fila = i; //Ver A1 + y aqui le restamos 1 para que empieze en la posicion 0 del array.
                        nivel->diamantes.lista[nivel->diamantes.elementos-1].posicion.columna = j;
                        nivel->diamantes.lista[nivel->diamantes.elementos-1].eliminado = 0;
                    }
                    else
                    {
                        free(nivel->piedras.lista);
                        printw("Error rehahuecando memoria para los diamantes.\n");
                        exit(1);
//.........这里部分代码省略.........
开发者ID:catunlock,项目名称:TerminalStones,代码行数:101,代码来源:nivel.c

示例3: main

int main()
{
	char label_text[LMAX][20] = { "I", "AM", "SAM", "DO",
								 "NOT", "LIKE", "THAT", "SAY",
								 "WOULD", "COULD", "YOU",
								 "GREEN EGGS AND HAM" };
	int label,ch;
	
	slk_init(2);					/* 12 soft labels */
	initscr();
	noecho();						/* disable key echoing */
	keypad(stdscr,TRUE);			/* Turn on Fkey reading */
	
/* display the labels and instructions */
	for(label=0;label<LMAX;label++)
		slk_set(label+1,label_text[label],CENTER);
	slk_refresh();
	addstr("Use the Function Keys to type\n");
	addstr("Press '?' or '!' or '.' to end a line\n");
	addstr("Press Enter to quit\n\n");
	refresh();

/* Process input */
	while( (ch=getch()) != '\n')
	{
		switch(ch)
		{
				case '?':
				case '!':
				case '.':
					addch(ch);
					addch('\n');
					break;
				case KEY_F(1):
					printw("%s ",label_text[0]);
					break;
				case KEY_F(2):
					printw("%s ",label_text[1]);
					break;
				case KEY_F(3):
					printw("%s ",label_text[2]);
					break;
				case KEY_F(4):
					printw("%s ",label_text[3]);
					break;
				case KEY_F(5):
					printw("%s ",label_text[4]);
					break;
				case KEY_F(6):
					printw("%s ",label_text[5]);
					break;
				case KEY_F(7):
					printw("%s ",label_text[6]);
					break;
				case KEY_F(8):
					printw("%s ",label_text[7]);
					break;
				case KEY_F(9):
					printw("%s ",label_text[8]);
					break;
				case KEY_F(10):
					printw("%s ",label_text[9]);
					break;
				case KEY_F(11):
					printw("%s ",label_text[10]);
					break;
				case KEY_F(12):
					printw("%s ",label_text[11]);
					break;
				default:
					break;
		}
		refresh();
	}

	endwin();
	return 0;
}
开发者ID:wkoszek,项目名称:ncurses_guide,代码行数:78,代码来源:ham.c

示例4: main

int
main (int argc, char **argv)
{
	int     i,l;		/* non-descript indices */
	char    c;		/* non-descript character storage */

	if (pledge("stdio rpath wpath cpath tty exec", NULL) == -1)
		err(1, "pledge");

	signal(SIGINT, getout);	/* trap interrupts */

	/* use whole screen for text */
	begscr = 0;

	getarg(argc, argv);

	initcurses();

	/* check if restored game and save flag for later */
	if ((rfl = rflag)) {
		if (pledge("stdio rpath wpath cpath tty", NULL) == -1)
			err(1, "pledge");

		wrboard();	/* print board */
		/* if new game, pretend to be a non-restored game */
		if (cturn == 0)
			rflag = 0;
	} else {
		rscore = wscore = 0;	/* zero score */

		if (aflag) {	/* print rules */
			addstr(rules);
			if (yorn(0)) {
				endwin();
				execl(TEACH, "teachgammon", (char *)NULL);

				err(1, "%s", noteach);
			} else {/* if not rules, then instructions */
				addstr(need);
				if (yorn(0)) {	/* print instructions */
					clear();
					text(instruct);
				}
			}
		}

		if (pledge("stdio rpath wpath cpath tty", NULL) == -1)
			err(1, "pledge");

		init();		/* initialize board */

		if (pnum == 2) {/* ask for color(s) */
			printw("\n%s", askcol);
			while (pnum == 2) {
				c = readc();
				switch (c) {

				case 'R':	/* red */
					pnum = -1;
					break;

				case 'W':	/* white */
					pnum = 1;
					break;

				case 'B':	/* both */
					pnum = 0;
					break;

				case 'P':	/* Control the dice */
					iroll = 1;
					addstr("\nDice controlled!\n");
					addstr(askcol);
					break;

				default:	/* error */
					beep();
				}
			}
		}

		wrboard();		/* print board */

		move(18, 0);
	}
	/* limit text to bottom of screen */
	begscr = 17;

	for (;;)  {			/* begin game! */
		/* initial roll if needed */
		if ((!rflag) || raflag)
			roll();

		/* perform ritual of first roll */
		if (!rflag) {
			move(17, 0);
			while (D0 == D1)	/* no doubles */
				roll();

			/* print rolls */
//.........这里部分代码省略.........
开发者ID:Bluerise,项目名称:openbsd-src,代码行数:101,代码来源:main.c

示例5: main


//.........这里部分代码省略.........
		cleanup(files);
		done = TRUE;
		break;
	    case KEY_BACKSPACE:
	    case '\b':
		if (--which < 0)
		    which = last;
		break;
	    case ' ':
		if (++which > last)
		    which = 0;
		break;
	    default:
		beep();
		continue;
	    }

	    if (ch == 'q') {
		;
	    } else if (scr_restore(files[which]) == ERR) {
		endwin();
		printf("Cannot load screen-dump %s\n", files[which]);
		cleanup(files);
		ExitProgram(EXIT_FAILURE);
	    } else {
		wrefresh(curscr);
	    }
	}
    } else {
	int y;
	int x;

	move(2, 0);
	printw("Use h,j,k,l or arrows to move around the screen\n");
	printw("Press 'q' to quit, ' ' to dump a screen\n");
	printw("When the last screen has been dumped, press 'n' to run the\n");
	printw("screen-loader.  That allows only 'q', backspace and ' ' for\n");
	printw("stepping through the dumped/restored screens.\n");
	getyx(stdscr, y, x);

	while (!done) {
	    switch (ch = get_command(which, last)) {
	    case 'n':
		setup_next();
		done = TRUE;
		break;
	    case 'q':
		endwin();
		cleanup(files);
		done = TRUE;
		break;
	    case ' ':
		if (files[which] != 0) {
		    show_what(which + 1, last);
		    if (scr_dump(files[which]) == ERR) {
			endwin();
			printf("Cannot write screen-dump %s\n", files[which]);
			cleanup(files);
			done = TRUE;
			break;
		    }
		    ++which;
		    if (has_colors()) {
			short pair = which % COLOR_PAIRS;
			bkgd(COLOR_PAIR(pair));
		    }
开发者ID:Brainiarc7,项目名称:ralink_sdk,代码行数:67,代码来源:savescreen.c

示例6: game_loop

void game_loop( RubikCube & cube, std::string & args ) {
	int ch;
	bool doSolve = false;

	// Main loop
	while (42) {
		// Read Input (Also calls refresh)
		// refresh();
		ch = getch();
		// clear();

		// if (ch == KEY_LEFT) {
		if (ch == 'q' || ch == 'Q') {
			break;
		} else if (ch == 'w') { cube[0].rotate_c();  args.append(" U");  // UP C
		} else if (ch == 'e') { cube[0].rotate_cc(); args.append(" U'"); // UP CC
		} else if (ch == 'r') { cube[0].rotate_2();  args.append(" U2"); // UP 180
		} else if (ch == 'a') { cube[4].rotate_c();  args.append(" F");  // FRONT C
		} else if (ch == 's') { cube[4].rotate_cc(); args.append(" F'"); // FRONT CC
		} else if (ch == 'd') { cube[4].rotate_2();  args.append(" F2"); // FRONT 180
		} else if (ch == 'z') { cube[3].rotate_c();  args.append(" R");  // RIGHT C
		} else if (ch == 'x') { cube[3].rotate_cc(); args.append(" R'"); // RIGHT CC
		} else if (ch == 'c') { cube[3].rotate_2();  args.append(" R2"); // RIGHT 180
		} else if (ch == 't') { cube[5].rotate_c();  args.append(" B");  // BACK C
		} else if (ch == 'y') { cube[5].rotate_cc(); args.append(" B'"); // BACK CC
		} else if (ch == 'u') { cube[5].rotate_2();  args.append(" B2"); // BACK 180
		} else if (ch == 'g') { cube[2].rotate_c();  args.append(" L");  // LEFT C
		} else if (ch == 'h') { cube[2].rotate_cc(); args.append(" L'"); // LEFT CC
		} else if (ch == 'j') { cube[2].rotate_2();  args.append(" L2"); // LEFT 180
		} else if (ch == 'v') { cube[1].rotate_c();  args.append(" D");  // DOWN C
		} else if (ch == 'b') { cube[1].rotate_cc(); args.append(" D'"); // DOWN CC
		} else if (ch == 'n') { cube[1].rotate_2();  args.append(" D2"); // DOWN 180
		} else if (ch == ' ') {
			doSolve = true;
			break;
		}
		draw_screen(args, cube, "");
	}
	if (doSolve) {
		clock_t loop_time = 400000;
		clock_t loop_start_time = clockToUseconds(clock());
		std::string solution = solve(cube.getMikeFormat());
		std::string solution_buffer;
		std::string cmd;
		std::size_t pos;
		while (42) {
			ch = getch();
			if (ch == 'q' || ch == 'Q')
				break;
			// Timing
			if (clockToUseconds(clock()) - loop_start_time < loop_time)
				continue;
			loop_start_time = clockToUseconds(clock());
			// Solution
			pos = solution.find_first_of(" \n");
			cmd = solution.substr(0, pos);
			cube.apply(cmd);
			solution_buffer += ' ';
			solution_buffer += cmd;
			if (pos != std::string::npos) ++pos;
			solution.erase(0, pos);
			draw_screen(args, cube, solution_buffer);
			if (solution.size() == 0)
				break;
		}
		attron(COLOR_PAIR(1));
		attron(A_BOLD);
		printw("\nPress Q to Quit");
		attroff(A_BOLD);
		attroff(COLOR_PAIR(1));
		while (42) {
			nodelay(stdscr, FALSE);
			ch = getch();
			if (ch == 'q' || ch == 'Q')
				break;
		}
	}
}
开发者ID:sploadie,项目名称:rubik,代码行数:78,代码来源:main.cpp

示例7: main

int main (int argc, char *argv[])
{
    setup();

    printw("%d row\n%d col\n", row, col);

    char ch = ' ';
    int x = 0, y = 0;
    while(ch != CTRLD)
    {
        move(y, x);
        ch = getch();
        switch(ch){
            case 27:
                ch = getch();
                ch = getch();
                switch(ch){
                    case 68: // Left
                        x -= 1;
                        break;
                    case 65: // Up
                        y -= 1;
                        break;
                    case 67: // Right
                        x += 1;
                        break;
                    case 66: // Down
                        y += 1;
                        break;
                }
                /*printw("TEST", ch);*/
                break;
            case 10: // Newline
                x = 0;
                y += 1;
                break;
            case 127: // Backspace

                if (y == 0 && x == 0)
                {
                    break;
                }

                x -= 1;
                if(x < 0)
                {
                    x = col - 1;
                    y -= 1;
                }
                mvaddch(y, x, ' ');
                break;
            default:
                /*move(0,0);*/
                /*printw("%d", ch);*/
                /*mvaddch(y, x, ch);*/
                mvaddch(y, x, ch);
                refresh();
                x += 1;
                if( x >= col )
                {
                    x = 0;
                    y += 1;
                }
                break;
        }

    }

    teardown();
}
开发者ID:Skuzzzy,项目名称:wan,代码行数:70,代码来源:wan.c

示例8: display_data

static void
display_data(int colors) {
	char cur_time[20];
	struct tm *tm_time;
	time_t epoc_time;
	size_t counter, line;
	long long r,w;
	unsigned long long rt, wt;
	sg_disk_io_stats *disk_io_stat_ptr;
	sg_network_io_stats *network_stat_ptr;
	sg_fs_stats *disk_stat_ptr;
	/* Size before it will start overwriting "uptime" */
	char hostname[15];
	char *ptr;

	if (stats.host_info != NULL) {
		move(0,12);
		strncpy(hostname, stats.host_info->hostname, (sizeof(hostname) - 1));
		/* strncpy does not NULL terminate.. If only strlcpy was on all platforms :) */
		hostname[14] = '\0';
		ptr=strchr(hostname, '.');
		/* Some hosts give back a FQDN for hostname. To avoid this, we'll
		 * just blank out everything after the first "."
		 */
		if (ptr != NULL){
			*ptr = '\0';
		}
		if (colors) {
			attron(COLOR_PAIR(1));
		}
		printw("%s", hostname);
		move(0,36);
		printw("%s", hr_uptime(stats.host_info->uptime));
		epoc_time=time(NULL);
		tm_time = localtime(&epoc_time);
		strftime(cur_time, 20, "%Y-%m-%d %T", tm_time);
		move(0,61);
		printw("%s", cur_time);
		if (colors) {
			attroff(COLOR_PAIR(1));
		}
	}

	if (stats.load_stats != NULL) {
		/* Load */
		if (colors) {
			attron(COLOR_PAIR(6));
		}
		move(2,12);
		if (colors && fabs(stats.load_stats->min1 - stats.load_stats->min5) > THRESHOLD_LOAD) {
			attron(A_BOLD);
		}
		printw("%6.2f", stats.load_stats->min1);
		if (colors) {
			attroff(A_BOLD);
		}
		move(3,12);
		if (colors && fabs(stats.load_stats->min5 - stats.load_stats->min15) > THRESHOLD_LOAD) {
			attron(A_BOLD);
		}
		printw("%6.2f", stats.load_stats->min5);
		if (colors) {
			attroff(A_BOLD);
		}
		move(4,12);
		if (colors && fabs(stats.load_stats->min1 - stats.load_stats->min15) > THRESHOLD_LOAD) {
			attron(A_BOLD);
		}
		printw("%6.2f", stats.load_stats->min15);
		if (colors) {
			attroff(A_BOLD);
		}
	}

	if (stats.cpu_percents != NULL) {
		/* CPU */
		move(2,33);
		printw("%6.2f%%", stats.cpu_percents->idle);
		move(3,33);
		printw("%6.2f%%", (stats.cpu_percents->kernel + stats.cpu_percents->iowait + stats.cpu_percents->swap));
		move(4,33);
		if (colors && stats.cpu_percents->user + stats.cpu_percents->nice > THRESHOLD_ALERT_CPU) {
			attron(A_STANDOUT);
			attron(A_BOLD);
		}
		else if (colors && stats.cpu_percents->user + stats.cpu_percents->nice > THRESHOLD_WARN_CPU) {
			attron(A_BOLD);
		}
		printw("%6.2f%%", (stats.cpu_percents->user + stats.cpu_percents->nice));
		if(colors) {
			attroff(A_BOLD);
			attroff(A_STANDOUT);
			attron(COLOR_PAIR(6));
		}
	}

	if (stats.process_count != NULL) {
		/* Process */
		move(2, 54);
		printw("%5llu", stats.process_count->running);
//.........这里部分代码省略.........
开发者ID:RsrchBoy,项目名称:dpkg-libstatgrab,代码行数:101,代码来源:saidar.c

示例9: m4_draw_cmd

void m4_draw_cmd(int xpos, int ypos) {
  move(ypos,xpos); 
  int x;
  for(x=0;x<16;x++) printw("%X ",(unsigned int)mfb[x]);
}
开发者ID:DaElf,项目名称:aldl,代码行数:5,代码来源:mode4.c

示例10: viewkill


//.........这里部分代码省略.........
    if(i>seeks_len){
      if(seeks_len){
	free(seeks);
	free(stats);
      }
      seeks_len=i-1;
      seeks=malloc((i-1)*sizeof(long));
      tst_err_malloc(seeks,25); /* выполняет exit, если NULL*/
      stats=malloc((i-1)*sizeof(char));
      tst_err_malloc(stats,26); /* выполняет exit, если NULL*/
    }
    rewind(file);
    i=0;
    while(!feof(file)){
      if(getc(file)=='\n'){
	seeks[i]=ftell(file);
	stats[i]='\0';
	i++;
      }
    }
    /* проверить корректность текущей строки и первой строки */
    if(curline>nlines-1){
      curline=nlines-1;
      if(curline<firstline) firstline=curline;
    }

  }

  mywbkgd(stdscr, MAIN_PANEL_ATTR);
  /* Заголовок просмотра */
  attrset(MAIN_PANEL_TOP_ATTR);
  move(0,0);
  if(x_beg){
    printw("  Shift: %d", x_beg);
  }
  if(firstline>=0)
    { /* известен номер первой строки*/
      printw(" Line: %d", curline+1);
    }else{
      printw(" Line: ?");
    }
  if(usr_str[0])
    { /* показываются процессы выбранного пользователя*/
      addstr("  User: ");
      addstr(usr_str);
    }else{
      addstr("  All users");
    }
  getyx(stdscr, y, x);
  while(x++<COLS) addch(' ');

  attrset(MAIN_PANEL_ATTR);


  /* вывод первой строки */
  move(FIRST-1, 0);
  addstr(tmp_first);

  fseek(file, seeks[firstline], 0);

  y=FIRST;

  while(feof(file)==0 && ferror(file)==0 && y<FIRST+lines){
    x=0;
    if(y-FIRST==curline-firstline) attrset(MAIN_PANEL_PTR_ATTR);
    do{
开发者ID:kotohvost,项目名称:conix,代码行数:67,代码来源:viewkill.c

示例11: display_headings

static void
display_headings(void) {
	int line;

	move(0,0);
	printw("Hostname  :");
	move(0,27);
	printw("Uptime : ");
	move(0,54);
	printw("Date : ");

	/* Load */
	move(2,0);
	printw("Load 1    :");
	move(3,0);
	printw("Load 5    :");
	move(4,0);
	printw("Load 15   :");

	/* CPU */
	move(2,21);
	printw("CPU Idle  :");
	move(3,21);
	printw("CPU System:");
	move(4,21);
	printw("CPU User  :");

	/* Process */
	move(2, 42);
	printw("Running   :");
	move(3, 42);
	printw("Sleeping  :");
	move(4, 42);
	printw("Stopped   :");
	move(2, 62);
	printw("Zombie    :");
	move(3, 62);
	printw("Total     :");
	move(4, 62);
	printw("No. Users :");

	/* Mem */
	move(6, 0);
	printw("Mem Total :");
	move(7, 0);
	printw("Mem Used  :");
	move(8, 0);
	printw("Mem Free  :");

	/* Swap */
	move(6, 21);
	printw("Swap Total:");
	move(7, 21);
	printw("Swap Used :");
	move(8, 21);
	printw("Swap Free :");

	/* VM */
	move(6, 42);
	printw("Mem Used  :");
	move(7, 42);
	printw("Swap Used :");
	move(8, 42);
	printw("Total Used:");

	/* Paging */
	move(6, 62);
	printw("Paging in :");
	move(7, 62);
	printw("Paging out:");

	/* Disk IO */
	move(10,0);
	printw("Disk Name");
	move(10,15);
	printw("Read");
	move(10,28);
	printw("Write");

	line = 10;
	if (stats.network_io_stats != NULL) {
		/* Network IO */
		move(line, 42);
		printw("Network Interface");
		move(line, 67);
		printw("rx");
		move(line, 77);
		printw("tx");
		line += 2 + stats.network_io_entries;
	}

	move(line, 42);
	printw("Mount Point");
	move(line, 65);
	printw("Free");
	move(line, 75);
	printw("Used");

	refresh();
}
开发者ID:RsrchBoy,项目名称:dpkg-libstatgrab,代码行数:100,代码来源:saidar.c

示例12: control_orientation_update

int control_orientation_update(desCntrl_T & desCntrl, motInfo & mot, const double & curTime)
{

  
  //static gazebo::math::Quaternion quarDes; 
  //const gazebo::msgs::IMU & IMU_data_ptr
  static pidInfo motRoll; 	// X
  static pidInfo motYaw;	// Z
  static pidInfo motPitch;	// Y
  static double prevTime = 0;
  double dt;
  double tMult;
  double errYawLim = 0.1;
  
  dt = curTime - prevTime;
  //update_orientation();
  
  //quarDes.SetFromEuler(0,0,0);
  
  tMult = std::sqrt( std::pow(desCntrl.thrust,2) + std::pow(body_orientation.x,2) + std::pow(body_orientation.y,2));
  
  desCntrl.errRoll  = desCntrl.roll  - body_orientation.GetRoll();
  desCntrl.errPitch = desCntrl.pitch - body_orientation.GetPitch();
  desCntrl.errYaw   = desCntrl.yaw   - body_orientation.GetYaw();

//#warning "Yaw Hack In Place!"
//  desCntrl.errYaw = 0; // Yaw Hack
  
  if (desCntrl.errYaw > errYawLim)
  {
    desCntrl.errYaw = errYawLim;
  }
  else if (desCntrl.errYaw < -1*errYawLim)
  {
    desCntrl.errYaw = -1*errYawLim;
  }
  
  //clear();
  mvprintw(0,0,"Yaw: %f\n",body_orientation.GetYaw());
  printw("errYaw: %f\n",desCntrl.errYaw);
  refresh();
  //vecDes.
  
//  motRoll.curVal = -1*motRoll.kp*IMU_data_ptr->angular_velocity().x() + 
//		   -1*motRoll.ki*(IMU_data_ptr->angular_velocity().x()*dt + motRoll.preVal) +
//		   -1*motRoll.kd*(IMU_data_ptr->angular_velocity().x() - motRoll.preVal)/dt;
  
//   motRoll.curVal = 100*motRoll.kp*(desCntrl->errRoll);// + 
		   //motRoll.ki*(IMU_data_ptr->angular_velocity().x()*dt + motRoll.preVal) +
		   //motRoll.kd*(IMU_data_ptr->angular_velocity().x() - motRoll.preVal)/dt;
  
//  motPitch.curVal = -1*motPitch.kp*IMU_data_ptr->angular_velocity().y() + 
//		   -1*motPitch.ki*(IMU_data_ptr->angular_velocity().y()*dt + motPitch.preVal) +
//		   -1*motPitch.kd*(IMU_data_ptr->angular_velocity().y() - motPitch.preVal)/dt; 
//		   
//  motYaw.curVal = -1*motYaw.kp*IMU_data_ptr->angular_velocity().z() + 
//		   -1*motYaw.ki*(IMU_data_ptr->angular_velocity().z()*dt + motYaw.preVal) +
//		   -1*motYaw.kd*(IMU_data_ptr->angular_velocity().z() - motYaw.preVal)/dt;
//		   
 
  // Calc integral
  motRoll.intSum  = motRoll.intSum  + desCntrl.errRoll*dt;
  motPitch.intSum = motPitch.intSum + desCntrl.errPitch*dt;
  motYaw.intSum   = motYaw.intSum   + desCntrl.errYaw*dt;

  // Calc Derivative
  motRoll.derDiff  = (desCntrl.errRoll  - motRoll.preVal)/dt;
  motPitch.derDiff = (desCntrl.errPitch - motPitch.preVal)/dt;
  motYaw.derDiff   = (desCntrl.errYaw   - motYaw.preVal)/dt;
  
  motRoll.curVal  = 1*0.1*4*(50*motRoll.kp*(desCntrl.errRoll)   + 0*10*motRoll.ki*motRoll.intSum   + 0*3*10*motRoll.kd*motRoll.derDiff);
  motPitch.curVal = 1*0.1*4*(50*motPitch.kp*(desCntrl.errPitch) + 0*10*motPitch.ki*motPitch.intSum + 0*3*10*motPitch.kd*motPitch.derDiff);
  motYaw.curVal   = 2*0.1*.05*(50*motYaw.kp*(desCntrl.errYaw)   + 0*10*motYaw.ki*motYaw.intSum     + 0*10*motYaw.kd*motYaw.derDiff);
  
  // Save err values
  motRoll.preVal  = desCntrl.errRoll;
  motPitch.preVal = desCntrl.errPitch;
  motYaw.preVal   = desCntrl.errYaw;
  
  
//     ^x
//     |	
// y <-oz
//
//     2
//     |
// 4---+---3
//     |
//     1
//
// + Roll -> -y -> -M3, +M4
// + Pitch -> +x -> -M2, +M1
// + Yaw -> CC
  
  mot.mot1 = 1 * tMult +  0 * motRoll.curVal + 	1 * motYaw.curVal +  1 * motPitch.curVal;
  mot.mot3 = 1 * tMult + -1 * motRoll.curVal + -1 * motYaw.curVal +  0 * motPitch.curVal;
  mot.mot2 = 1 * tMult +  0 * motRoll.curVal +  1 * motYaw.curVal + -1 * motPitch.curVal;
  mot.mot4 = 1 * tMult +  1 * motRoll.curVal + -1 * motYaw.curVal +  0 * motPitch.curVal;
  
  if(mot.mot1 < 0)
//.........这里部分代码省略.........
开发者ID:mattprompt,项目名称:quadcopter_controller,代码行数:101,代码来源:control_orientation.cpp

示例13: start

void start(std::string filename, bool saveprog, bool savestats,bool usetree)
{
	if(!progrunning)
		return;

	clear();

	Textstream ts;
	ts.open_file(filename);
	if(saveprog)
		ts.loadposition();

	Wordtree errortree;
	std::string treefilename="wordstat.stat";
	
	if(usetree)
		errortree.restorefromFile(treefilename);

	//Variables
	bool timerunning = false;

	int keystrokes = 0;
	int wrongstrokes = 0;
	std::chrono::high_resolution_clock::time_point starttime;
	std::chrono::high_resolution_clock::time_point curtime;
	int elapsedseconds = 0;
	float keysperminute = 0.0;
	float errorpercent = 0.0;

	Intstring line;
	int clength = 0;
	int tprog = 0;
	bool * correctness = new bool;
	bool lastwordwrong = false;
	std::string typedword;

	int yval = 0;

	std::mutex printingmutex;

	//Lambdas
	auto add_widech = [&](int c){
		char bytes[5];
		for(unsigned char a = 0; a < 5 ; ++a)
			bytes[a] = 0;

		felocale::to_utf8(c,bytes);
		printw(bytes);
	};

	auto updatestates = [&](){
		if(timerunning)
		{
			curtime = std::chrono::high_resolution_clock::now();
			elapsedseconds = std::chrono::duration_cast <std::chrono::seconds> (curtime - starttime) .count();
		}
		if(elapsedseconds > 0)
			keysperminute = (((double)keystrokes) * 60 / ((double)elapsedseconds));
		errorpercent = (float)(wrongstrokes * 100) / (float)keystrokes;
	};

	auto printstatus = [&](){
		printingmutex.lock();
		if(timerunning)
		{
			updatestates();
			move(0,0);
			clrtoeol();
			std::string s = "Seconds elapsed: "+std::to_string(elapsedseconds)+" Error Ratio:"+std::to_string(errorpercent)+'%'
			+" Keystrokes per Minutes:"+std::to_string(keysperminute);
			mvprintw(0,0,s.c_str());
		}
		else
		{
			mvprintw(0,0,"Begin Typing to start the time measurement....");
		}
		refresh();
		printingmutex.unlock();
	};

	auto nextline = [&](){
		clear();
		std::string tstring = ts.nextline();
		line = tstring;
		if(line.empty()){
			clear();
			mvprintw(1,0,"You reached The End of the line...");
			printstatus();
			timerunning = false;
			progrunning = false;
		}
		else
		{
			if(clength < line.length())
			{
				delete[] correctness;
				correctness = new bool [line.length()];
				clength = line.length();
			}
			tprog = 0;
//.........这里部分代码省略.........
开发者ID:fegies,项目名称:ncurses-typetrainer,代码行数:101,代码来源:typescreen.cpp

示例14: playerDie

void playerDie(player* pl, player* w){
    printw("You are dead\n");
    endGame(pl, w);
}
开发者ID:EricWpG,项目名称:100-Problems,代码行数:4,代码来源:035-matt-wumpus.c

示例15: layout_callback

static cb_ret_t
layout_callback (struct Dlg_head *h, dlg_msg_t msg, int parm)
{
    switch (msg) {
    case DLG_DRAW:
    	/*When repainting the whole dialog (e.g. with C-l) we have to
    	  update everything*/
	common_dialog_repaint (h);

   	old_first_panel_size = -1;
    	old_horizontal_split = -1;
    	old_output_lines     = -1;

	attrset (COLOR_HOT_NORMAL);
	update_split ();
	dlg_move (h, 6, 13);
	addch ('=');
	if (console_flag){
	    if (old_output_lines != _output_lines){
		old_output_lines = _output_lines;
		attrset (COLOR_NORMAL);
		dlg_move (h, 9, 16 + first_width);
		addstr (output_lines_label);
		dlg_move (h, 9, 10 + first_width);
		printw ("%02d", _output_lines);
	    }
	}
	return MSG_HANDLED;

    case DLG_POST_KEY:
	_filetype_mode = check_options [8].widget->state & C_BOOL;
	_permission_mode = check_options [7].widget->state & C_BOOL;
	_equal_split = check_options [6].widget->state & C_BOOL;
/* 	_menubar_visible = check_options [5].widget->state & C_BOOL; */
/* 	_command_prompt = check_options [4].widget->state & C_BOOL; */
/* 	_keybar_visible = check_options [2].widget->state & C_BOOL; */
	_message_visible = check_options [1].widget->state & C_BOOL;
/* 	_xterm_title = check_options [0].widget->state & C_BOOL; */
	if (console_flag){
	    int minimum;
	    if (_output_lines < 0)
		_output_lines = 0;
	    height = LINES - _keybar_visible - _command_prompt -
		     _menubar_visible - _output_lines - _message_visible;
	    minimum = MINHEIGHT * (1 + _horizontal_split);
	    if (height < minimum){
		_output_lines -= minimum - height;
		height = minimum;
	    }
	} else {
	    height = LINES - _keybar_visible - _command_prompt -
		_menubar_visible - _output_lines - _message_visible;
	}
	if (_horizontal_split != radio_widget->sel){
	    _horizontal_split = radio_widget->sel;
	    if (_horizontal_split)
		_first_panel_size = height / 2;
	    else
		_first_panel_size = COLS / 2;
	}
	update_split ();
	if (console_flag){
	    if (old_output_lines != _output_lines){
		old_output_lines = _output_lines;
		attrset (COLOR_NORMAL);
		dlg_move (h, 9, 10 + first_width);
		printw ("%02d", _output_lines);
	    }
	}
	return MSG_HANDLED;

    default:
	return default_dlg_callback (h, msg, parm);
    }
}
开发者ID:BackupTheBerlios,项目名称:mcvox,代码行数:75,代码来源:layout.c


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