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

C++ endwin函数代码示例

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

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



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

示例1: main


//.........这里部分代码省略.........
  parse_conf_file (&argc, &argv);
  parse_cmd_line (argc, argv);

  /* initialize storage */
  init_storage ();
  /* setup to use the current locale */
  set_locale ();

#ifdef HAVE_LIBGEOIP
  init_geoip ();
#endif

  /* init logger */
  logger = init_log ();
  /* init parsing spinner */
  parsing_spinner = new_gspinner ();
  parsing_spinner->process = &logger->process;

  /* outputting to stdout */
  if (conf.output_html) {
    ui_spinner_create (parsing_spinner);
    goto out;
  }

  /* init curses */
  set_input_opts ();
  if (conf.no_color || has_colors () == FALSE) {
    conf.color_scheme = NO_COLOR;
    conf.no_color = 1;
  } else {
    start_color ();
  }
  init_colors ();
  init_windows (&header_win, &main_win);
  set_curses_spinner (parsing_spinner);

  /* configuration dialog */
  if (isatty (STDIN_FILENO) && (conf.log_format == NULL || conf.load_conf_dlg)) {
    refresh ();
    quit = verify_format (logger, parsing_spinner);
  }
  /* straight parsing */
  else {
    ui_spinner_create (parsing_spinner);
  }

out:

  /* main processing event */
  time (&start_proc);
  if (conf.load_from_disk)
    set_general_stats ();
  else if (!quit && parse_log (&logger, NULL, -1))
    FATAL ("Error while processing file");

  logger->offset = logger->process;

  /* no valid entries to process from the log */
  if ((logger->process == 0) || (logger->process == logger->invalid))
    FATAL ("Nothing valid to process.");

  /* init reverse lookup thread */
  gdns_init ();
  parse_initial_sort ();
  allocate_holder ();

  end_spinner ();
  time (&end_proc);

  /* stdout */
  if (conf.output_html) {
    /* CSV */
    if (conf.output_format && strcmp ("csv", conf.output_format) == 0)
      output_csv (logger, holder);
    /* JSON */
    else if (conf.output_format && strcmp ("json", conf.output_format) == 0)
      output_json (logger, holder);
    /* HTML */
    else
      output_html (logger, holder);
  }
  /* curses */
  else {
    allocate_data ();
    if (!conf.skip_term_resolver)
      gdns_thread_create ();

    render_screens ();
    get_keys ();

    attroff (COLOR_PAIR (COL_WHITE));
    /* restore tty modes and reset
     * terminal into non-visual mode */
    endwin ();
  }
  /* clean */
  house_keeping ();

  return EXIT_SUCCESS;
}
开发者ID:liuzhengyi,项目名称:goaccess,代码行数:101,代码来源:goaccess.c


示例2: CON_Init

/*
==================
CON_Init

Initialize the console in curses mode, fall back to tty mode on failure
==================
*/
void CON_Init(void)
{
    int col;

#ifndef _WIN32
    // If the process is backgrounded (running non interactively)
    // then SIGTTIN or SIGTOU is emitted, if not caught, turns into a SIGSTP
    signal(SIGTTIN, SIG_IGN);
    signal(SIGTTOU, SIG_IGN);
#endif

    // Make sure we're on a tty
    if (!isatty(STDIN_FILENO) || !isatty(STDOUT_FILENO))
    {
        CON_Init_tty();
        return;
    }

    // Initialize curses and set up the root window
    if (!curses_on)
    {
        SCREEN *test = newterm(NULL, stdout, stdin);
        if (!test)
        {
            CON_Init_tty();
            CON_Print_tty("Couldn't initialize curses, falling back to tty\n");
            return;
        }
        endwin();
        delscreen(test);
        initscr();
        cbreak();
        noecho();
        nonl();
        intrflush(stdscr, FALSE);
        nodelay(stdscr, TRUE);
        keypad(stdscr, TRUE);
        wnoutrefresh(stdscr);

        // Set up colors
        if (has_colors())
        {
            use_default_colors();
            start_color();
            init_pair(1, COLOR_BLACK, -1);
            init_pair(2, COLOR_RED, -1);
            init_pair(3, COLOR_GREEN, -1);
            init_pair(4, COLOR_YELLOW, -1);
            init_pair(5, COLOR_BLUE, -1);
            init_pair(6, COLOR_CYAN, -1);
            init_pair(7, COLOR_MAGENTA, -1);
            init_pair(8, -1, -1);
        }

        // Prevent bad libraries from messing up the console
        fclose(stderr);
    }

    // Create the border
    borderwin = newwin(LOG_LINES + 2, LOG_COLS + 2, 1, 0);
    CON_SetColor(borderwin, 2);
    box(borderwin, 0, 0);
    wnoutrefresh(borderwin);

    // Create the log window
    logwin = newpad(MAX_LOG_LINES, LOG_COLS);
    scrollok(logwin, TRUE);
    idlok(logwin, TRUE);
    if (curses_on)
    {
        CON_ColorPrint(logwin, logbuf, qtrue);
    }
    getyx(logwin, lastline, col);
    if (col)
    {
        lastline++;
    }
    scrollline = lastline - LOG_LINES;
    if (scrollline < 0)
    {
        scrollline = 0;
    }
    pnoutrefresh(logwin, scrollline, 0, 2, 1, LOG_LINES + 1, LOG_COLS + 1);

    // Create the scroll bar
    scrollwin = newwin(LOG_LINES, 1, 2, COLS - 1);
    CON_DrawScrollBar();
    CON_SetColor(stdscr, 3);
    mvaddch(1, COLS - 1, SCRLBAR_UP);
    mvaddch(LINES - 2, COLS - 1, SCRLBAR_DOWN);

    // Create the input field
    inputwin                 = newwin(1, COLS - Q_PrintStrlen(PROMPT) - 8, LINES - 1, Q_PrintStrlen(PROMPT) + 8);
//.........这里部分代码省略.........
开发者ID:rafal1137,项目名称:etlegacy,代码行数:101,代码来源:con_curses.c


示例3: mutt_compose_menu


//.........这里部分代码省略.........
              /* avoid freeing other attachments */
              idx[idxlen]->content->next = NULL;
              idx[idxlen]->content->parts = NULL;
              mutt_free_body (&idx[idxlen]->content);
              FREE (&idx[idxlen]->tree);
              FREE (&idx[idxlen]);
            }
            FREE (&idx);
            idxlen = 0;
            idxmax = 0;
          }
	  r = -1;
	  loop = 0;
	  break;
	}
	else if (i == -1)
	  break; /* abort */

	/* fall through to postpone! */

      case OP_COMPOSE_POSTPONE_MESSAGE:

        if(check_attachments(idx, idxlen) != 0)
        {
	  menu->redraw = REDRAW_FULL;
	  break;
	}
      
	loop = 0;
	r = 1;
	break;

      case OP_COMPOSE_ISPELL:
	endwin ();
	snprintf (buf, sizeof (buf), "%s -x %s", NONULL(Ispell), msg->content->filename);
	if (mutt_system (buf) == -1)
	  mutt_error (_("Error running \"%s\"!"), buf);
	else
        {
	  mutt_update_encoding (msg->content);
	  menu->redraw |= REDRAW_STATUS;
	}
	break;

      case OP_COMPOSE_WRITE_MESSAGE:

       fname[0] = '\0';
       if (Context)
       {
	 strfcpy (fname, NONULL (Context->path), sizeof (fname));
	 mutt_pretty_mailbox (fname, sizeof (fname));
       }
       if (idxlen)
         msg->content = idx[0]->content;
       if (mutt_enter_fname (_("Write message to mailbox"), fname, sizeof (fname),
                             &menu->redraw, 1) != -1 && fname[0])
       {
         mutt_message (_("Writing message to %s ..."), fname);
         mutt_expand_path (fname, sizeof (fname));

         if (msg->content->next)
           msg->content = mutt_make_multipart (msg->content);

         if (mutt_write_fcc (fname, msg, NULL, 0, NULL) < 0)
           msg->content = mutt_remove_multipart (msg->content);
         else
开发者ID:twoerner,项目名称:susemutt,代码行数:67,代码来源:compose.c


示例4: main

int main() {
    int ch, x, y;
    char fname[80];
    FILE *fp;
    bool entering_metadata = false;
    char to_delete;
    char existing;

    initscr();
    cbreak();
    noecho();

    nonl();
    intrflush(stdscr, false);
    keypad(stdscr, true);             /* Enable arrow keys.                  */

    getmaxyx(stdscr, ROW, COL);

    move(0,0);
    start_color();                    /* Yay colors!                         */
    init_pair(1, COLOR_RED, COLOR_WHITE);
    // attron(COLOR_PAIR(1));
    // printw("rows: %d, columns: %d\n", ROW, COL);

    char** contents = new_string_table(ROW, COL);

    char* blank_row = (char*)malloc(COL*sizeof(char));
    for (int i=0; i<COL; i++) {
        blank_row[i] = ' ';
    }


    getyx(stdscr, y, x);


    while (true) {
        ch = getch();
        switch (ch) {
            case KEY_LEFT:
                x -= 1;
                break;
            case KEY_RIGHT:
                x += 1;
                break;
            case KEY_UP:
                y -= 1;
                break;
            case KEY_DOWN:
                y += 1;
                break;
            case BACKSPACE:  /* KEY_BACKSPACE wasn't working. */
                --x;
                move(y, x);
                to_delete = inch();
                attron(COLOR_PAIR(1));
                addch(to_delete);
                attroff(COLOR_PAIR(1));
                break;
            case KEY_DC:
                //attron(COLOR_PAIR(1));
                addch('X');
                //attroff(COLOR_PAIR(1));
                break;
            case ESC:
                ch = getch();
                switch (ch) {
                    case ESC:          /* Press ESC twice to exit.           */
                        endwin();
                        free(blank_row);
                        delete_string_table(contents, ROW);
                        return 0;
                        break;
                    case 'w':
                        move(ROW-1, 0);
                        printw("Enter a file name (up to 80 characters): ");
                        echo();
                        if (getnstr(fname, 80) == ERR) {
                            perror("Something went wrong reading the file name you gave.");
                        }
                        noecho();
                        fp = fopen(fname, "w");
                        if (fp == NULL) {
                            perror("Cannot open file");
                        }
                        contents_to_file(contents, fp, ROW, COL);
                        fclose(fp);
                        move(ROW-1, 0);
                        printw(blank_row);
                        break;
                    default:
                        break;
                }
                break;
            default:
                existing = contents[y][x];
                //printw("%d", (int)existing);
                if (existing == '\0') {
                    addch(ch);
                    ensureposition(&y, &x);
                    contents[y][x] = ch;
//.........这里部分代码省略.........
开发者ID:tdb-alcorn,项目名称:ncurses-play,代码行数:101,代码来源:editor.c


示例5: main

int main()
{	ITEM **my_items;
	int c;				
	MENU *my_menu;
        int n_choices, i;
	ITEM *cur_item;
	
	/* Initialize curses */	
	initscr();
	start_color();
        cbreak();
        noecho();
	keypad(stdscr, TRUE);
	init_pair(1, COLOR_RED, COLOR_BLACK);
	init_pair(2, COLOR_GREEN, COLOR_BLACK);
	init_pair(3, COLOR_MAGENTA, COLOR_BLACK);

	/* Initialize items */
        n_choices = ARRAY_SIZE(choices);
        my_items = (ITEM **)calloc(n_choices + 1, sizeof(ITEM *));
        for(i = 0; i < n_choices; ++i)
	{       my_items[i] = new_item(choices[i], choices[i]);
		/* Set the user pointer */
		set_item_userptr(my_items[i], func);
	}
	my_items[n_choices] = (ITEM *)NULL;

	/* Create menu */
	my_menu = new_menu((ITEM **)my_items);

	/* Post the menu */
	mvprintw(LINES - 3, 0, "Press <ENTER> to see the option selected");
	mvprintw(LINES - 2, 0, "Up and Down arrow keys to naviage (F1 to Exit)");
	post_menu(my_menu);
	refresh();

	while((c = getch()) != KEY_F(1))
	{       switch(c)
	        {	case KEY_DOWN:
				menu_driver(my_menu, REQ_DOWN_ITEM);
				break;
			case KEY_UP:
				menu_driver(my_menu, REQ_UP_ITEM);
				break;
			case 10: /* Enter */
			{	ITEM *cur;
				void (*p)(char *);

				cur = current_item(my_menu);
				p = item_userptr(cur);
				p((char *)item_name(cur));
				pos_menu_cursor(my_menu);
				break;
			}
			break;
		}
	}	
	unpost_menu(my_menu);
	for(i = 0; i < n_choices; ++i)
		free_item(my_items[i]);
	free_menu(my_menu);
	endwin();
}
开发者ID:tony,项目名称:NCURSES-Programming-HOWTO-examples,代码行数:63,代码来源:user-pointer.c


示例6: display_end

void
display_end(void)
{
	endwin();
}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:5,代码来源:display.c


示例7: dialog_checklist

/*
 * Display a dialog box with a list of options that can be turned on or off
 * in the style of radiolist (only one option turned on at a time).
 */
int dialog_checklist(const char *title, const char *prompt, int height,
		     int width, int list_height, int item_no,
		     const char *const *items)
{
	int i, x, y, box_x, box_y;
	int key = 0, button = 0, choice = 0, scroll = 0, max_choice, *status;
	WINDOW *dialog, *list;

	/* Allocate space for storing item on/off status */
	if ((status = malloc(sizeof(int) * item_no)) == NULL) {
		endwin();
		fprintf(stderr,
			"\nCan't allocate memory in dialog_checklist().\n");
		exit(-1);
	}

	/* Initializes status */
	for (i = 0; i < item_no; i++) {
		status[i] = !strcasecmp(items[i * 3 + 2], "on");
		if ((!choice && status[i])
		    || !strcasecmp(items[i * 3 + 2], "selected"))
			choice = i + 1;
	}
	if (choice)
		choice--;

	max_choice = MIN(list_height, item_no);

	/* center dialog box on screen */
	x = (COLS - width) / 2;
	y = (LINES - height) / 2;

	draw_shadow(stdscr, y, x, height, width);

	dialog = newwin(height, width, y, x);
	keypad(dialog, TRUE);

	draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr);
	wattrset(dialog, border_attr);
	mvwaddch(dialog, height - 3, 0, ACS_LTEE);
	for (i = 0; i < width - 2; i++)
		waddch(dialog, ACS_HLINE);
	wattrset(dialog, dialog_attr);
	waddch(dialog, ACS_RTEE);

	print_title(dialog, title, width);

	wattrset(dialog, dialog_attr);
	print_autowrap(dialog, prompt, width - 2, 1, 3);

	list_width = width - 6;
	box_y = height - list_height - 5;
	box_x = (width - list_width) / 2 - 1;

	/* create new window for the list */
	list = subwin(dialog, list_height, list_width, y + box_y + 1,
	              x + box_x + 1);

	keypad(list, TRUE);

	/* draw a box around the list items */
	draw_box(dialog, box_y, box_x, list_height + 2, list_width + 2,
	         menubox_border_attr, menubox_attr);

	/* Find length of longest item in order to center checklist */
	check_x = 0;
	for (i = 0; i < item_no; i++)
		check_x = MAX(check_x, +strlen(items[i * 3 + 1]) + 4);

	check_x = (list_width - check_x) / 2;
	item_x = check_x + 4;

	if (choice >= list_height) {
		scroll = choice - list_height + 1;
		choice -= scroll;
	}

	/* Print the list */
	for (i = 0; i < max_choice; i++) {
		print_item(list, items[(scroll + i) * 3 + 1],
			   status[i + scroll], i, i == choice);
	}

	print_arrows(dialog, choice, item_no, scroll,
		     box_y, box_x + check_x + 5, list_height);

	print_buttons(dialog, height, width, 0);

	wnoutrefresh(dialog);
	wnoutrefresh(list);
	doupdate();

	while (key != ESC) {
		key = wgetch(dialog);

		for (i = 0; i < max_choice; i++)
//.........这里部分代码省略.........
开发者ID:0xD34D,项目名称:android_external_busybox,代码行数:101,代码来源:checklist.c


示例8: main


//.........这里部分代码省略.........
					prev = NULL;
					while(temp->next)
					{
						temp->x = temp->next->x;
						temp->y = temp->next->y;

						prev = temp;
						temp = temp->next;
					}

					if ( temp->y > 0 )
					{
//						if (!prev || (prev->y != temp->y+1 && prev->x != temp->x))
//						{
							cury--;
							temp->y = temp->y - 1;
//						}
					}
					else
						GAME = 0;
					break;
			default:	
					break;
		}
		if ( ch == 'Q' || ch == 'q' )
			break;

		temp = snk;
		while(temp->next)
		{
			if ( temp->x == curx && temp->y == cury )
			{
				GAME = 0;
				break;
			}
			temp = temp->next;
		}

		if ( GAME == 0 )
		{
			start_color();
			init_pair(1, COLOR_RED, COLOR_BLACK);
			attron(COLOR_PAIR(1));

			mvprintw(MaxX/2, MaxY/2-6, "GAME OVER");
			while(1)
			{
				ch = wgetch(stdscr);
				if ( ch == 'q' || ch == 'Q' )
					break;
			}
			break;
		}

		mvprintw(oldx, oldy, " ");

		temp = snk;
		while(temp)
		{
			mvprintw(temp->x, temp->y, "=");
			temp = temp->next;
		}

		if ( curx == randX && cury == randY )
		{
			snk_len++;
			temp = (struct snake *)malloc(sizeof(struct snake));
			temp->x = oldx;
			temp->y = oldy;
			temp->next = snk;
			snk = temp;

			FOOD = 0;
		}

		if (!FOOD)
		{
			srand ( time(NULL) );
			randX = rand()%MaxX;
			srand ( time(NULL) );
			randY = rand()%MaxY;
			mvprintw(randX, randY, "$");

			FOOD = 1;
		}
	}

	refresh();			/* Print it on to the real screen */
	endwin();			/* End curses mode		  */

	while(snk)
	{
		temp = snk;
		snk = snk->next;
		temp->next = NULL;
		free(temp);
	}

	return 0;
}
开发者ID:ajaysa,项目名称:SNAKE-GAME,代码行数:101,代码来源:snake.c


示例9: main

int main() {
    //cria um objeto da classe Jogo
    Jogo j;

    j.iniciaJogo(); //inicia o jogo apenas montando o cenario
    int op=0;
    int tecla=0;
    //apresenta o menu
    while(op!=3){
        cout << "--------------------------------" << endl;
        cout << "(1) Jogar ; " << endl;
        cout << "(2) Testar ; " << endl;
        cout << "(3) Sair." << endl;
        cout << "--------------------------------" << endl;
        cout << "Informe uma opcao:" << endl;
        cin >> op;
        switch (op) {
            //operacao JOGAR
            case 1:
                //apresenta os comandos validos do jogo
                cout << "Movimentos validos <cima> <baixo> <esquerda> e <direita>" << endl;
                cout << "Para sair do jogo pressione <ESC>" << endl << endl;
                //apresenta a tela atual
                j.mostrarTelaAtual();
                do {
                	initscr();
                keypad(stdscr, true);
                    tecla= getch();
                    endwin();
                    cout << tecla << endl;


                    //joga de acordo com a tecla apertada
                    switch (tecla) {
                        case 72:
                            //move o bloco para cima
                            j.jogar('C');
                            break;
                        case 80:
                            //move o bloco para baixo
                            j.jogar('B');
                            break;
                        case 77:
                            //move o bloco para a direita
                            j.jogar('D');
                            break;
                        case 75:
                            //move o bloco para a esquerdas
                            j.jogar('E');
                            break;
                    }
                    //passa de fase verificando a vitoria a cada nivel
                    if (j.getFaseAtual()<7){
                        if (j.verificaVitoria()) {
                            j.passarFase();
                        } else if (j.verificaDerrota()){
                            j.reiniciaJogo();
                        }
                    }
                //faz a funcao ate que a tecla <esc> seja pressionada
                } while (tecla != 27);               
                break;
            //operacao TESTAR
            case 2:
                //testa o jogo com os movimentos passados no final do arquivo da fase
                for (int i=0 ; i<7 ; i++){
                    j.testarJogo();
                    cout << "pressione uma tecla para continuar" << endl;
                    tecla=getch();
                    if (j.getFaseAtual()<7)
                        j.passarFase();
                }
                cout << "teste do jogo completo." << endl;
                break;
            //sai do jogo
            case 3: break;//exit(0);
        }
    }
    return 0;
}
开发者ID:brvboas,项目名称:Bloxors,代码行数:80,代码来源:principal.cpp


示例10: tstp

static void
tstp(int dummy GCC_UNUSED)
{
    sigset_t mask, omask;
    sigaction_t act, oact;

#ifdef SIGTTOU
    int sigttou_blocked;
#endif

    T(("tstp() called"));

    /*
     * The user may have changed the prog_mode tty bits, so save them.
     *
     * But first try to detect whether we still are in the foreground
     * process group - if not, an interactive shell may already have
     * taken ownership of the tty and modified the settings when our
     * parent was stopped before us, and we would likely pick up the
     * settings already modified by the shell.
     */
    if (SP != 0 && !SP->_endwin)	/* don't do this if we're not in curses */
#if HAVE_TCGETPGRP
        if (tcgetpgrp(STDIN_FILENO) == getpgrp())
#endif
            def_prog_mode();

    /*
     * Block window change and timer signals.  The latter
     * is because applications use timers to decide when
     * to repaint the screen.
     */
    (void) sigemptyset(&mask);
    (void) sigaddset(&mask, SIGALRM);
#if USE_SIGWINCH
    (void) sigaddset(&mask, SIGWINCH);
#endif
    (void) sigprocmask(SIG_BLOCK, &mask, &omask);

#ifdef SIGTTOU
    sigttou_blocked = sigismember(&omask, SIGTTOU);
    if (!sigttou_blocked) {
        (void) sigemptyset(&mask);
        (void) sigaddset(&mask, SIGTTOU);
        (void) sigprocmask(SIG_BLOCK, &mask, NULL);
    }
#endif

    /*
     * End window mode, which also resets the terminal state to the
     * original (pre-curses) modes.
     */
    endwin();

    /* Unblock SIGTSTP. */
    (void) sigemptyset(&mask);
    (void) sigaddset(&mask, SIGTSTP);
#ifdef SIGTTOU
    if (!sigttou_blocked) {
        /* Unblock this too if it wasn't blocked on entry */
        (void) sigaddset(&mask, SIGTTOU);
    }
#endif
    (void) sigprocmask(SIG_UNBLOCK, &mask, NULL);

    /* Now we want to resend SIGSTP to this process and suspend it */
    act.sa_handler = SIG_DFL;
    sigemptyset(&act.sa_mask);
    act.sa_flags = 0;
#ifdef SA_RESTART
    act.sa_flags |= SA_RESTART;
#endif /* SA_RESTART */
    sigaction(SIGTSTP, &act, &oact);
    kill(getpid(), SIGTSTP);

    /* Process gets suspended...time passes...process resumes */

    T(("SIGCONT received"));
    sigaction(SIGTSTP, &oact, NULL);
    flushinp();

    /*
     * If the user modified the tty state while suspended, he wants
     * those changes to stick.  So save the new "default" terminal state.
     */
    def_shell_mode();

    /*
     * This relies on the fact that doupdate() will restore the
     * program-mode tty state, and issue enter_ca_mode if need be.
     */
    doupdate();

    /* Reset the signals. */
    (void) sigprocmask(SIG_SETMASK, &omask, NULL);
}
开发者ID:StarchLinux,项目名称:ncurses,代码行数:96,代码来源:lib_tstp.c


示例11: main

int main()
{
        initscr();
        struct player {
                char *name;
                unsigned short age;
                unsigned short health;
                unsigned int level;
                unsigned short location;
                unsigned short active;
                unsigned short inventory[50];
        };
        char input[25] = "";
        struct player *main_character = NULL;
        main_character = malloc(sizeof(struct player));
        main_character -> level = 1;
        main_character -> location = 0;
        main_character -> health = 100;
        main_character -> active = 1;
        for (unsigned short i = 0; i < 50; i++) {
                main_character -> inventory[i] = 0;
        }
        main_character -> name = malloc(sizeof(char) * 15);
        printw("What is your name? (Maximum of 15 characters)\n");
        getstr(main_character -> name);
        refresh();
        printw("Welcome, %s\n", main_character -> name);
        refresh();
        while (main_character -> active == 1) {
                if (main_character -> location == 0) {
                        printw("You are in a dark room. There is a door to the north.\n");
                        refresh();
                        scanw("%s", &input);
                        if (strncmp(input, "north", 5) == 0 || strncmp(input, "n", 1) == 0) {
                                printw("You walk through the doorway.\n");
                                refresh();
                                main_character -> location = 1;
                        }
                        if (strncmp(input, "exit", 4) == 0 || strncmp(input, "quit", 4) == 0) {
                                printw("Exiting game...");
                                refresh();
                                main_character -> active = 0;
                        }
                }
                if (main_character -> location == 1) {
                        printw("You are now in a hallway. There is a light to the west.\n");
                        refresh();
                        scanw("%s", &input);
                        if (strncmp(input, "west", 4) == 0 || strncmp(input, "w", 1) == 0) {
                                printw("You are free.\n");
                                refresh();
                                main_character -> active = 0;
                        }
                }
        }
        printw("Game over. Press any key to quit.\n");
        refresh();
        getch();
        endwin();
        return 0;
}
开发者ID:michaelrutherford,项目名称:Freeskate,代码行数:61,代码来源:test_game.c


示例12: exit_graphics

//退出屏幕函数
void exit_graphics(void)
{
	endwin();
}
开发者ID:psc0606,项目名称:embedded,代码行数:5,代码来源:curses.c


示例13: ttclose

/*
 * This function gets called just
 * before we go back home to the shell. Put all of
 * the terminal parameters back.
 */
void
ttclose (void)
{
  endwin ();
  tcsetattr (0, TCSANOW, &oldtty);
}
开发者ID:bloovis,项目名称:micro-emacs,代码行数:11,代码来源:ttyio.c


示例14: die

static void die(int onsig)
{
    signal(onsig, SIG_IGN);
    endwin();
    exit(0);
}
开发者ID:Distrotech,项目名称:slang,代码行数:6,代码来源:blue.c


示例15: teams

void Draft::makeBoard(Team *arr, vector<NodeData*>& a, int teams) {
	int sY = 8, sX = 0, w = 14, h = 4, ch, j = 0, z = 0;
	string tName;			
	WINDOW *board[BOARD_SIZE]; //timer + players + menu  + roster + titles +    title +    teams(2)
					   //ar[34]  arr[33]   ar[32]  ar[31]   arr[20-29]    ar[30]  ar[0-19]

	initscr();											//start curses
	cbreak();											//line buffer off
	keypad(stdscr, TRUE);								//to use f1
	printw("Press cntr+c to exit");						//print 
	refresh();											//output

	board[TITLE] = createWin(4, 100, 1, 0);				//title
	wattron(board[TITLE], A_BOLD);
	mvwprintw(board[TITLE], 1, 10, "John Zoeller Draft");	//print T
	wrefresh(board[TITLE]);								//output

	board[34] = createWin(4, 40, 1, 101);				//timer
	wattron(board[34], A_BOLD);
	mvwprintw(board[34], 1, 1, "ROUND");				//print time
	wrefresh(board[34]);								//output

	for(int k = 0; k < 10; k++){						//team names
		board[k + 20] = createWin(3, 14, 5, (sX + (w * k)));
		wattron(board[k + 20], A_BOLD);	

		if(arr[k].getUser()){
			tName = to_string(arr[k].getPosition()) + " " + arr[k].getName();
			wattron(board[k + 20], A_UNDERLINE);
		} else
			tName = to_string(k + 1) + " Auto";

		mvwprintw(board[k + 20], 1, 1, tName.c_str());
		wrefresh(board[k + 20]);
	} 

	for(int i = 0; i < 10; i++)
		board[i] = createWin(h, w, (sY + (h * j)), (sX + (w * i)));

	j++;

	for(int a = 19; a >= 10; a--){
		board[a] = createWin(h, w, (sY + (h * j)), (sX + (w * z)));
		z++;
	}

	int dims[] = { 22, 45, 16, 0 };
	makeWindow("PLAYERS", dims, PLAYERS_AVAILABLE);


	board[33] = createWin(22, 45, 16, 0);				//players
	wattron(board[33], A_BOLD);
	mvwprintw(board[33], 1, 1, "PLAYERS");				//print title
	wattroff(board[33], A_BOLD);
	wrefresh(board[33]);								//output

	board[32] = createWin(10, 45, 16, 46);				//menu
	wattron(board[32], A_BOLD);
	mvwprintw(board[32], 1, 1, "MENU");					//print title
	wattroff(board[32], A_BOLD);
	wrefresh(board[32]);								//output

	board[31] = createWin(22, 45, 16, 92);				//roster
	wattron(board[31], A_BOLD);
	mvwprintw(board[31], 1, 1, "MY ROSTER");				//print title
	wattroff(board[31], A_BOLD);
	wrefresh(board[31]);								//output

	while((ch = getch()) != KEY_F(1)){					//drafting
		startDraft(arr, a, teams, board);
	}

	for(int i = 0; i < 35; i++){						//delete windows
		if(board[i] != NULL)
			destroy_win(board[i]);
	}

	endwin();
}
开发者ID:JohnFZoeller,项目名称:Personal---FantasyFootballDrafter,代码行数:79,代码来源:draft.cpp


示例16: con_done

 void con_done()
 {
   delwin(conio_scr);
   endwin();
 }
开发者ID:bbonev,项目名称:vslib,代码行数:5,代码来源:unicon.cpp


示例17: newwin

bool game::opening_screen()
{
    std::map<std::string, WORLDPTR> worlds;
    if (world_generator) {
        world_generator->set_active_world(NULL);
        worlds = world_generator->get_all_worlds();
    }
    WINDOW *w_background = newwin(TERMY, TERMX, 0, 0);
    werase(w_background);
    wrefresh(w_background);

    // main window should also expand to use available display space.
    // expanding to evenly use up half of extra space, for now.
    int extra_w = ((TERMX - FULL_SCREEN_WIDTH) / 2) - 1;
    int extra_h = ((TERMY - FULL_SCREEN_HEIGHT) / 2) - 1;
    extra_w = (extra_w > 0 ? extra_w : 0);
    extra_h = (extra_h > 0 ? extra_h : 0);
    const int total_w = FULL_SCREEN_WIDTH + extra_w;
    const int total_h = FULL_SCREEN_HEIGHT + extra_h;

    // position of window within main display
    const int x0 = (TERMX - total_w) / 2;
    const int y0 = (TERMY - total_h) / 2;

    WINDOW *w_open = newwin(total_h, total_w, y0, x0);

    const int iMenuOffsetX = 2;
    int iMenuOffsetY = total_h - 3;

    std::vector<std::string> vSubItems;
    vSubItems.push_back(pgettext("Main Menu|New Game", "<C>ustom Character"));
    vSubItems.push_back(pgettext("Main Menu|New Game", "<P>reset Character"));
    vSubItems.push_back(pgettext("Main Menu|New Game", "<R>andom Character"));
    vSubItems.push_back(pgettext("Main Menu|New Game", "Play <N>ow!"));

    std::vector<std::string> vWorldSubItems;
    vWorldSubItems.push_back(pgettext("Main Menu|World", "<C>reate World"));
    vWorldSubItems.push_back(pgettext("Main Menu|World", "<D>elete World"));
    vWorldSubItems.push_back(pgettext("Main Menu|World", "<R>eset World"));

    print_menu(w_open, 0, iMenuOffsetX, iMenuOffsetY);

    std::vector<std::string> savegames, templates;
    dirent *dp;
    DIR *dir;

    dir = opendir("save");
    if (!dir){
        #if (defined _WIN32 || defined __WIN32__)
            mkdir("save");
        #else
            mkdir("save", 0777);
        #endif
        dir = opendir("save");
    }
    if (!dir) {
        dbg(D_ERROR) << "game:opening_screen: Unable to make save directory.";
        debugmsg("Could not make './save' directory");
        endwin();
        exit(1);
    }
    closedir(dir);

    dir = opendir("data");
    while ((dp = readdir(dir))) {
        std::string tmp = dp->d_name;
        if (tmp.find(".template") != std::string::npos) {
            templates.push_back(tmp.substr(0, tmp.find(".template")));
        }
    }
    closedir(dir);

    int sel1 = 1, sel2 = 1, sel3 = 1, layer = 1;
    InputEvent input;
    int chInput;
    bool start = false;

    // Load MOTD and store it in a string
    // Only load it once, it shouldn't change for the duration of the application being open
    static std::vector<std::string> motd;
    if (motd.empty()) {
        std::ifstream motd_file;
        motd_file.open("data/motd");
        if (!motd_file.is_open()) {
            motd.push_back(_("No message today."));
        } else {
            while (!motd_file.eof()) {
                std::string tmp;
                getline(motd_file, tmp);
                if (!tmp.length() || tmp[0] != '#') {
                    motd.push_back(tmp);
                }
            }
        }
    }

    // Load Credits and store it in a string
    // Only load it once, it shouldn't change for the duration of the application being open
    static std::vector<std::string> credits;
    if (credits.empty()) {
//.........这里部分代码省略.........
开发者ID:DapperDogman,项目名称:Cataclysm-DDA,代码行数:101,代码来源:main_menu.cpp


示例18: tty_restore

/** Curses window finalization. */
static void
tty_restore(void)
{
  if (!b_interactive) return;
  endwin();
}
开发者ID:Distrotech,项目名称:libcdio,代码行数:7,代码来源:cdda-player.c


示例19: endwin

	~DisplayManager() {
		endwin();
	}
开发者ID:tapotigner,项目名称:touche-coule,代码行数:3,代码来源:DisplayManager.hpp


示例20: get_command

void get_command(void)
{
	char com[255];

	int text_width, text_startx;
	allocated_block_t *allocated_block = NULL;
	int i = 0;
	int count = 0;

	WINDOW *command_win = NULL;
        List allocated_blocks = NULL;
	ListIterator results_i;

	if (params.commandline && !params.command) {
		printf("Configure won't work with commandline mode.\n");
		printf("Please remove the -c from the commandline.\n");
		bg_configure_ba_fini();
		exit(0);
	}

	if (working_cluster_rec) {
		char *cluster_name = slurm_get_cluster_name();
		if (strcmp(working_cluster_rec->name, cluster_name)) {
			xfree(cluster_name);
			endwin();
			printf("To use the configure option you must be on the "
			       "cluster the configure is for.\nCross cluster "
			       "support doesn't exist today.\nSorry for the "
			       "inconvenince.\n");
			bg_configure_ba_fini();
			exit(0);
		}
		xfree(cluster_name);
	}

	/* make sure we don't get any noisy debug */
	ba_configure_set_ba_debug_flags(0);

	bg_configure_ba_setup_wires();

	color_count = 0;

	allocated_blocks = list_create(_destroy_allocated_block);

	if (params.commandline) {
		snprintf(com, sizeof(com), "%s", params.command);
		goto run_command;
	} else {
		text_width = text_win->_maxx;
		text_startx = text_win->_begx;
		command_win = newwin(3, text_width - 1, LINES - 4,
				     text_startx + 1);
		curs_set(1);
		echo();
	}

	while (strcmp(com, "quit")) {
		clear_window(grid_win);
		print_grid();
		clear_window(text_win);
		box(text_win, 0, 0);
		box(grid_win, 0, 0);

		if (!params.no_header)
			_print_header_command();

		if (error_string != NULL) {
			i = 0;
			while (error_string[i] != '\0') {
				if (error_string[i] == '\n') {
					main_ycord++;
					main_xcord=1;
					i++;
				}
				mvwprintw(text_win,
					  main_ycord,
					  main_xcord,
					  "%c",
					  error_string[i++]);
				main_xcord++;
			}
			main_ycord++;
			main_xcord = 1;
			memset(error_string, 0, 255);
		}
		results_i = list_iterator_create(allocated_blocks);

		count = list_count(allocated_blocks)
			- (LINES-(main_ycord+5));

		if (count<0)
			count=0;
		i=0;
		while ((allocated_block = list_next(results_i)) != NULL) {
			if (i >= count)
				_print_text_command(allocated_block);
			i++;
		}
		list_iterator_destroy(results_i);

//.........这里部分代码省略.........
开发者ID:IFCA,项目名称:slurm,代码行数:101,代码来源:configure_functions.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ energy函数代码示例发布时间:2022-05-30
下一篇:
C++ endutxent函数代码示例发布时间: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