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

C++ cbreak函数代码示例

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

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



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

示例1: ncurses_init

int
ncurses_init()
{
    int bg, fg;
    const char *term;
    // Set Locale
    setlocale(LC_CTYPE, "");

    // Initialize curses
    if (!initscr()) {
        fprintf(stderr, "Unable to initialize ncurses mode.\n");
        return -1;
    }

    // Check if user wants a black background
    if (setting_has_value(SETTING_BACKGROUND, "dark")) {
        assume_default_colors(COLOR_WHITE, COLOR_BLACK);
    } else {
        use_default_colors();
    }
    // Enable Colors
    start_color();
    cbreak();

    // Dont write user input on screen
    noecho();
    // Hide the cursor
    curs_set(0);
    // Only delay ESC Sequences 25 ms (we dont want Escape sequences)
    ESCDELAY = 25;

    // Redefine some keys
    term = getenv("TERM");
    if (term
        && (!strcmp(term, "xterm") || !strcmp(term, "xterm-color") || !strcmp(term, "vt220"))) {
        define_key("\033[H", KEY_HOME);
        define_key("\033[F", KEY_END);
        define_key("\033OP", KEY_F(1));
        define_key("\033OQ", KEY_F(2));
        define_key("\033OR", KEY_F(3));
        define_key("\033OS", KEY_F(4));
        define_key("\033[11~", KEY_F(1));
        define_key("\033[12~", KEY_F(2));
        define_key("\033[13~", KEY_F(3));
        define_key("\033[14~", KEY_F(4));
        define_key("\033[17;2~", KEY_F(18));
    }

    if (setting_has_value(SETTING_BACKGROUND, "dark")) {
        fg = COLOR_WHITE;
        bg = COLOR_BLACK;
    } else {
        fg = COLOR_DEFAULT;
        bg = COLOR_DEFAULT;
    }

    // Initialize colorpairs
    init_pair(CP_CYAN_ON_DEF, COLOR_CYAN, bg);
    init_pair(CP_YELLOW_ON_DEF, COLOR_YELLOW, bg);
    init_pair(CP_MAGENTA_ON_DEF, COLOR_MAGENTA, bg);
    init_pair(CP_GREEN_ON_DEF, COLOR_GREEN, bg);
    init_pair(CP_RED_ON_DEF, COLOR_RED, bg);
    init_pair(CP_BLUE_ON_DEF, COLOR_BLUE, bg);
    init_pair(CP_WHITE_ON_DEF, COLOR_WHITE, bg);
    init_pair(CP_DEF_ON_CYAN, fg, COLOR_CYAN);
    init_pair(CP_DEF_ON_BLUE, fg, COLOR_BLUE);
    init_pair(CP_WHITE_ON_BLUE, COLOR_WHITE, COLOR_BLUE);
    init_pair(CP_BLACK_ON_CYAN, COLOR_BLACK, COLOR_CYAN);
    init_pair(CP_WHITE_ON_CYAN, COLOR_WHITE, COLOR_CYAN);
    init_pair(CP_YELLOW_ON_CYAN, COLOR_YELLOW, COLOR_CYAN);
    init_pair(CP_BLUE_ON_CYAN, COLOR_BLUE, COLOR_CYAN);
    init_pair(CP_BLUE_ON_WHITE, COLOR_BLUE, COLOR_WHITE);
    init_pair(CP_CYAN_ON_WHITE, COLOR_CYAN, COLOR_WHITE);
    init_pair(CP_CYAN_ON_BLACK, COLOR_CYAN, COLOR_BLACK);

    return 0;
}
开发者ID:erhuabushuo,项目名称:sngrep,代码行数:77,代码来源:ui_manager.c


示例2: main

int main(int argc, char *argv[]) {
  int i, option, task_list_size;
  int cflag = 0, lflag = 0, dflag = 0, iflag = 0;
  char *cvalue, *dvalue;
  char *tasks[100];
  FILE *task_list;

  while((option = getopt(argc, argv, "ilc:d:")) != -1) {
    switch(option) {
    case 'i':
      iflag = 1;
      break;
    case 'c':
      cflag = 1;
      cvalue = optarg;
      break;
    case 'd':
      dflag = 1;
      dvalue = optarg;
      break;
    case 'l':
      lflag = 1;
      break;
    default:
      fprintf(stderr, "Usage: %s [-c task] [-d task] [-l] [-i]\n", argv[0]);
      exit(EXIT_FAILURE);
    }
  }

  if(iflag) {
    WINDOW *window;
    int startx = 5, starty = 3, c, highlight;
    char buffer[100];

    initscr();
    clear();
    raw();
    noecho();
    cbreak();
    curs_set(0);

    startx = (80 - WIDTH);
    starty = (24 - HEIGHT);
    window = newwin(HEIGHT, WIDTH, starty, startx);
    keypad(window, TRUE);

    while(1) {
      mvwprintw(window, starty, startx, "TODOs ('c' to add, 'd' to remove)");
      wclrtoeol(window);

      if((task_list_size = read_tasks(tasks, task_list))) {
        for(i = 0; i < task_list_size; i++) {
          if(highlight == i) {
            wattron(window, A_REVERSE);
            mvwprintw(window, starty + (i + 2), startx, "%d. %s", i + 1, tasks[i]);
            wattroff(window, A_REVERSE);
          } else {
            mvwprintw(window, starty + (i + 2), startx, "%d. %s", i + 1, tasks[i]);
          }

          wclrtoeol(window);
        }

        wclrtobot(window);
      } else {
        mvwprintw(window, starty + 2, startx, "None!");
        wclrtoeol(window);
        wclrtobot(window);
      }

      wrefresh(window);

      c = wgetch(window);
      switch(c) {
      case KEY_UP:
        if(highlight == 0) {
          highlight = task_list_size - 1;
        } else {
          --highlight;
        }
        break;
      case KEY_DOWN:
        if(highlight == task_list_size - 1) {
          highlight = 0;
        } else {
          ++highlight;
        }
        break;
      case 'd':
        if(delete_task(tasks[highlight], task_list) == 1) {
          --highlight;
        }
        break;
      case 'c':
        mvwprintw(window, starty, startx, "Creating task: ");
        wclrtoeol(window);
        echo();

        if(wgetstr(window, buffer) == OK) {
          if(create_task(buffer, task_list) == 1) {
//.........这里部分代码省略.........
开发者ID:alepharchives,项目名称:dwt,代码行数:101,代码来源:dwt.c


示例3: spitm

/**
 * Main function. Initializes and starts the game
 */
int spitm() {listP mao1,mao2,pl11,pl12,pl13,pl14,pl21,pl22,pl23,pl24;
    int stock1[stk],stock2[stk],baralho[(num*2)-2],pc1[sz],pc2[sz],pc3[sz];
    mao1=mao2=pl11=pl12=pl13=pl14=pl21=pl22=pl23=pl24=NULL;
    int vencedor=0,turno=1,o,d,i=0,n=0,x=(LINES/2),y=(COLS/2);

    initscr();
    cbreak();
    keypad(stdscr,TRUE);
    noecho();
    start_color();
    init_pair(1,COLOR_WHITE,COLOR_GREEN);
    init_pair(2,COLOR_RED,COLOR_GREEN);
    bkgd(COLOR_PAIR(1));
    attron(COLOR_PAIR(2));

    limpa(pc1,13);
    limpa(pc2,13);
    limpa(pc3,13);
    shuff(baralho);
    atoa(baralho,stock1,20);
    atoa(baralho,stock2,20);
    mao1=atod(baralho,mao1,5);
    mao2=atod(baralho,mao2,5);
    while(!i) {
        if(stock1[0] > stock2[0]) {
            turno=1;i++;
        };break;
	    if(stock1[0] < stock2[0]) {
            turno=2;
            i++;
        };break;
	    barStk(stock1,stk);
        barStk(stock2,stk);
	};
    
    while(vencedor==0) {
        while(elemN(mao1)<5)
            mao1=atod(baralho,mao1,1);
        while(turno==1)	{
            clear();
            mostrac(mao1,pl11, pl12,pl13, pl14, mao2, pl21, pl22, pl23,pl24, pc1, pc2, pc3, stock1, stock2,turno);
            echo();
            mvprintw(22,0,"Insira origem(1-10) e destino (1-7):__ __");
            mvscanw(22,36," %d %d",&o,&d);
            if(o>0 && o<6) {
                if(d==1) {
                    if (showi(mao1,elemN(mao1)-o) == topAr(pc1)+1) {
                        dtoa(mao1,elemN(mao1)-o,pc1);
                    };
                };
                if(d==2) {
                    if (showi(mao1,elemN(mao1)-o) == topAr(pc2)+1) {
                        dtoa(mao1,elemN(mao1)-o,pc2);
                    };
                };
			    if(d==3) {
                    if (showi(mao1,elemN(mao1)-o) == topAr(pc3)+1) {
                        dtoa(mao1,elemN(mao1)-o,pc3);
                    };
                };
    			if(d==4) {
                    pl11=poe(pl11,showi(mao1,elemN(mao1)-o));
                    if(elemN(mao1) == o) {
                        mao1=rmUlt(mao1);turno=2;
                    } else {
                        rmI(mao1,elemN(mao1)-(o));
                        turno=2;
                    };
                };
	
			    if(d==5) {
                    pl12=poe(pl12,showi(mao1,elemN(mao1)-o));
                    if(elemN(mao1) == o) {
                        mao1=rmUlt(mao1);
                        turno=2;
                    } else {
                        rmI(mao1,elemN(mao1)-(o));
                        turno=2;
                    };
                };
			    if(d==6) {
                    pl13=poe(pl13,showi(mao1,elemN(mao1)-o));
                    if(elemN(mao1) == o) {
                        mao1=rmUlt(mao1);
                        turno=2;
                    } else {
                        rmI(mao1,elemN(mao1)-(o));
                        turno=2;
                    };
                };
			    if(d==7) {
                    pl14=poe(pl14,showi(mao1,elemN(mao1)-o));
                    if(elemN(mao1) == o) {
                        mao1=rmUlt(mao1);
                        turno=2;
                    } else {
                        rmI(mao1,elemN(mao1)-(o));
//.........这里部分代码省略.........
开发者ID:ruicouto,项目名称:ArkOfGames,代码行数:101,代码来源:spitm.c


示例4: init_display

void
init_display(void)
{
	bool no_display = !!getenv("TIG_NO_DISPLAY");
	const char *term;
	int x, y;

	die_callback = done_display;
	/* XXX: Restore tty modes and let the OS cleanup the rest! */
	if (atexit(done_display))
		die("Failed to register done_display");

	/* Initialize the curses library */
	if (!no_display && isatty(STDIN_FILENO)) {
		cursed = !!initscr();
		opt_tty = stdin;
	} else {
		/* Leave stdin and stdout alone when acting as a pager. */
		FILE *out_tty;

		opt_tty = fopen("/dev/tty", "r+");
		out_tty = no_display ? fopen("/dev/null", "w+") : opt_tty;
		if (!opt_tty || !out_tty)
			die("Failed to open /dev/tty");
		cursed = !!newterm(NULL, out_tty, opt_tty);
	}

	if (!cursed)
		die("Failed to initialize curses");

	nonl();		/* Disable conversion and detect newlines from input. */
	cbreak();       /* Take input chars one at a time, no wait for \n */
	noecho();       /* Don't echo input */
	leaveok(stdscr, false);

	init_colors();

	getmaxyx(stdscr, y, x);
	status_win = newwin(1, x, y - 1, 0);
	if (!status_win)
		die("Failed to create status window");

	/* Enable keyboard mapping */
	keypad(status_win, true);
	wbkgdset(status_win, get_line_attr(NULL, LINE_STATUS));
	enable_mouse(opt_mouse);

#if defined(NCURSES_VERSION_PATCH) && (NCURSES_VERSION_PATCH >= 20080119)
	set_tabsize(opt_tab_size);
#else
	TABSIZE = opt_tab_size;
#endif

	term = getenv("XTERM_VERSION") ? NULL : getenv("COLORTERM");
	if (term && !strcmp(term, "gnome-terminal")) {
		/* In the gnome-terminal-emulator, the warning message
		 * shown when scrolling up one line while the cursor is
		 * on the first line followed by scrolling down one line
		 * corrupts the status line. This is fixed by calling
		 * wclear. */
		use_scroll_status_wclear = true;
		use_scroll_redrawwin = false;

	} else if (term && !strcmp(term, "xrvt-xpm")) {
		/* No problems with full optimizations in xrvt-(unicode)
		 * and aterm. */
		use_scroll_status_wclear = use_scroll_redrawwin = false;

	} else {
		/* When scrolling in (u)xterm the last line in the
		 * scrolling direction will update slowly. */
		use_scroll_redrawwin = true;
		use_scroll_status_wclear = false;
	}
}
开发者ID:butterl,项目名称:tig,代码行数:75,代码来源:display.c


示例5: WinMain


//.........这里部分代码省略.........
            }
            // Ingore unknown options.
            if (!arg_handled) {
                --saved_argc;
                ++saved_argv;
            }
        }
    }

    if (!assure_dir_exist(FILENAMES["user_dir"].c_str())) {
        printf("Can't open or create %s. Check permissions.\n",
               FILENAMES["user_dir"].c_str());
        exit(1);
    }

    setupDebug();

    if (setlocale(LC_ALL, "") == NULL) {
        DebugLog(D_WARNING, D_MAIN) << "Error while setlocale(LC_ALL, '').";
    }

    // Options strings loaded with system locale
    initOptions();
    load_options();

    set_language(true);

    if (initscr() == NULL) { // Initialize ncurses
        DebugLog( D_ERROR, DC_ALL ) << "initscr failed!";
        return 1;
    }
    init_interface();
    noecho();  // Don't echo keypresses
    cbreak();  // C-style breaks (e.g. ^C to SIGINT)
    keypad(stdscr, true); // Numpad is numbers
#if !(defined TILES || defined _WIN32 || defined WINDOWS)
    // For tiles or windows, this is handled already in initscr().
    init_colors();
#endif
    // curs_set(0); // Invisible cursor
    set_escdelay(10); // Make escape actually responsive

    std::srand(seed);

    g = new game;
    // First load and initialize everything that does not
    // depend on the mods.
    try {
        g->load_static_data();
        if (verifyexit) {
            if(g->game_error()) {
                exit_handler(-999);
            }
            exit_handler(0);
        }
        if (check_all_mods) {
            // Here we load all the mods and check their
            // consistency (both is done in check_all_mod_data).
            g->init_ui();
            popup_nowait("checking all mods");
            g->check_all_mod_data();
            if(g->game_error()) {
                exit_handler(-999);
            }
            // At this stage, the mods (and core game data)
            // are find and we could start playing, but this
开发者ID:tetronimo,项目名称:Cataclysm-DDA,代码行数:67,代码来源:main.cpp


示例6: ccbi_cbreak

uint8_t ccbi_cbreak(int on) { return chk(on ? nocbreak() : cbreak()); }
开发者ID:Deewiant,项目名称:CCBI,代码行数:1,代码来源:wrapncrs.c


示例7: main

int
main(int argc, char *argv[])
{
    time_t now;
    struct tm *tm;
    long t, a;
    int i, j, s, k;
    int count = 0;
    FILE *ofp = stdout;
    FILE *ifp = stdin;
    bool scrol = FALSE;

    setlocale(LC_ALL, "");

    CATCHALL(sighndl);

    while ((k = getopt(argc, argv, "sn")) != -1) {
	switch (k) {
	case 's':
	    scrol = TRUE;
	    break;
	case 'n':
	    ifp = fopen("/dev/null", "r");
	    redirected = TRUE;
	    break;
	default:
	    usage();
	}
    }
    if (optind < argc) {
	count = atoi(argv[optind++]);
	assert(count >= 0);
    }
    if (optind < argc)
	usage();

    if (redirected) {
	char *name = getenv("TERM");
	if (name == 0
	    || newterm(name, ofp, ifp) == 0) {
	    fprintf(stderr, "cannot open terminal\n");
	    ExitProgram(EXIT_FAILURE);
	}

    } else {
	initscr();
    }
    cbreak();
    noecho();
    nodelay(stdscr, 1);
    curs_set(0);

    hascolor = has_colors();

    if (hascolor) {
	short bg = COLOR_BLACK;
	start_color();
#if HAVE_USE_DEFAULT_COLORS
	if (use_default_colors() == OK)
	    bg = -1;
#endif
	init_pair(PAIR_DIGITS, COLOR_BLACK, COLOR_RED);
	init_pair(PAIR_OTHERS, COLOR_RED, bg);
	init_pair(PAIR_FRAMES, COLOR_WHITE, bg);
	(void) attrset(COLOR_PAIR(PAIR_OTHERS));
    }

  restart:
    for (j = 0; j < 5; j++)
	older[j] = newer[j] = next[j] = 0;

    clear();
    drawbox(FALSE);

    do {
	char buf[30];

	time(&now);
	tm = localtime(&now);

	mask = 0;
	set(tm->tm_sec % 10, 0);
	set(tm->tm_sec / 10, 4);
	set(tm->tm_min % 10, 10);
	set(tm->tm_min / 10, 14);
	set(tm->tm_hour % 10, 20);
	set(tm->tm_hour / 10, 24);
	set(10, 7);
	set(10, 17);

	for (k = 0; k < 6; k++) {
	    if (scrol) {
		for (i = 0; i < 5; i++)
		    newer[i] = (newer[i] & ~mask) | (newer[i + 1] & mask);
		newer[5] = (newer[5] & ~mask) | (next[k] & mask);
	    } else
		newer[k] = (newer[k] & ~mask) | (next[k] & mask);
	    next[k] = 0;
	    for (s = 1; s >= 0; s--) {
		standt(s);
//.........这里部分代码省略.........
开发者ID:AaronDP,项目名称:ncurses-5.9_adbshell,代码行数:101,代码来源:gdc.c


示例8: main


//.........这里部分代码省略.........
		exit(1);
	}
	wcommand = (wchar_t*)malloc((wcommand_characters+1) * sizeof(wcommand));
	if(wcommand == NULL) {
		fprintf(stderr, "Unicode Handling Error (malloc)\n");
		exit(1);
	}
	mbstowcs(wcommand, command, wcommand_characters+1);
	wcommand_columns = wcswidth(wcommand, -1);



	get_terminal_size();

	/* Catch keyboard interrupts so we can put tty back in a sane state.  */
	signal(SIGINT, die);
	signal(SIGTERM, die);
	signal(SIGHUP, die);
	signal(SIGWINCH, winch_handler);

	/* Set up tty for curses use.  */
	curses_started = 1;
	initscr();
  if (option_color) {
    if (has_colors()) {
      start_color();
      use_default_colors();
      init_ansi_colors();
    } else
      option_color = 0;
  }
	nonl();
	noecho();
	cbreak();

	if (precise_timekeeping)
		next_loop = get_time_usec();

	for (;;) {
		time_t t = time(NULL);
		char *ts = ctime(&t);
		int tsl = strlen(ts);
		char *header;
		FILE *p;
		int x, y;
		int oldeolseen = 1;

		if (screen_size_changed) {
			get_terminal_size();
			resizeterm(height, width);
			clear();
			/* redrawwin(stdscr); */
			screen_size_changed = 0;
			first_screen = 1;
		}

		if (show_title) {
			// left justify interval and command,
			// right justify time, clipping all to fit window width

			int hlen = asprintf(&header, "Every %.1fs: ", interval);

			// the rules:
			//   width < tsl : print nothing
			//   width < tsl + hlen + 1: print ts
			//   width = tsl + hlen + 1: print header, ts
开发者ID:whit537,项目名称:watch,代码行数:67,代码来源:watch.c


示例9: ncurses_setup

static WINDOW *
ncurses_setup(void){
	struct ncurses_input_marshal *nim;
	const char *errstr = NULL;
	WINDOW *w = NULL;

	fprintf(stderr,"Entering ncurses mode...\n");
	if(initscr() == NULL){
		fprintf(stderr,"Couldn't initialize ncurses\n");
		return NULL;
	}
	if(cbreak() != OK){
		errstr = "Couldn't disable input buffering\n";
		goto err;
	}
	if(noecho() != OK){
		errstr = "Couldn't disable input echoing\n";
		goto err;
	}
	if(intrflush(stdscr,TRUE) != OK){
		errstr = "Couldn't set flush-on-interrupt\n";
		goto err;
	}
	if(scrollok(stdscr,FALSE) != OK){
		errstr = "Couldn't disable scrolling\n";
		goto err;
	}
	if(nonl() != OK){
		errstr = "Couldn't disable nl translation\n";
		goto err;
	}
	if(start_color() != OK){
		errstr = "Couldn't initialize ncurses color\n";
		goto err;
	}
	if(use_default_colors()){
		errstr = "Couldn't initialize ncurses colordefs\n";
		goto err;
	}
	w = stdscr;
	keypad(stdscr,TRUE);
	if(nodelay(stdscr,FALSE) != OK){
		errstr = "Couldn't set blocking input\n";
		goto err;
	}
	if(preserve_colors() != OK){
		errstr = "Couldn't preserve initial colors\n";
		goto err;
	}
	if(setup_extended_colors() != OK){
		errstr = "Couldn't initialize extended colors\n";
		assert(init_pair(BORDER_COLOR,COLOR_GREEN,-1) == OK);
		assert(init_pair(HEADER_COLOR,COLOR_BLUE,-1) == OK);
		assert(init_pair(FOOTER_COLOR,COLOR_YELLOW,-1) == OK);
		assert(init_pair(DBORDER_COLOR,COLOR_WHITE,-1) == OK);
		assert(init_pair(DHEADING_COLOR,COLOR_WHITE,-1) == OK);
		assert(init_pair(UBORDER_COLOR,COLOR_CYAN,-1) == OK);
		assert(init_pair(UHEADING_COLOR,COLOR_BLUE,-1) == OK);
		assert(init_pair(PBORDER_COLOR,COLOR_YELLOW,-1) == OK);
		assert(init_pair(PHEADING_COLOR,COLOR_RED,-1) == OK);
		assert(init_pair(BULKTEXT_COLOR,COLOR_WHITE,-1) == OK);
		assert(init_pair(BULKTEXT_ALTROW_COLOR,COLOR_WHITE,-1) == OK);
		assert(init_pair(IFACE_COLOR,COLOR_WHITE,-1) == OK);
		assert(init_pair(LCAST_COLOR,COLOR_CYAN,-1) == OK); // will use A_BOLD via OUR_BOLD
		assert(init_pair(UCAST_COLOR,COLOR_CYAN,-1) == OK);
		assert(init_pair(MCAST_COLOR,COLOR_BLUE,-1) == OK);
		assert(init_pair(BCAST_COLOR,COLOR_MAGENTA,-1) == OK);
		assert(init_pair(LSELECTED_COLOR,-1,COLOR_CYAN) == OK);
		assert(init_pair(USELECTED_COLOR,-1,COLOR_CYAN) == OK);
		assert(init_pair(MSELECTED_COLOR,-1,COLOR_BLUE) == OK);
		assert(init_pair(BSELECTED_COLOR,-1,COLOR_MAGENTA) == OK);
		assert(init_pair(LCAST_L3_COLOR,COLOR_CYAN,-1) == OK);
		assert(init_pair(UCAST_L3_COLOR,COLOR_CYAN,-1) == OK);
		assert(init_pair(MCAST_L3_COLOR,COLOR_BLUE,-1) == OK);
		assert(init_pair(BCAST_L3_COLOR,COLOR_MAGENTA,-1) == OK);
		assert(init_pair(LCAST_RES_COLOR,COLOR_CYAN,-1) == OK);
		assert(init_pair(UCAST_RES_COLOR,COLOR_CYAN,-1) == OK);
		assert(init_pair(MCAST_RES_COLOR,COLOR_BLUE,-1) == OK);
		assert(init_pair(BCAST_RES_COLOR,COLOR_MAGENTA,-1) == OK);
		assert(init_pair(LCAST_ALTROW_COLOR,COLOR_CYAN,-1) == OK);
		assert(init_pair(UCAST_ALTROW_COLOR,COLOR_CYAN,-1) == OK);
		assert(init_pair(MCAST_ALTROW_COLOR,COLOR_BLUE,-1) == OK);
		assert(init_pair(BCAST_ALTROW_COLOR,COLOR_MAGENTA,-1) == OK);
		assert(init_pair(LCAST_ALTROW_L3_COLOR,COLOR_CYAN,-1) == OK);
		assert(init_pair(UCAST_ALTROW_L3_COLOR,COLOR_CYAN,-1) == OK);
		assert(init_pair(MCAST_ALTROW_L3_COLOR,COLOR_BLUE,-1) == OK);
		assert(init_pair(BCAST_ALTROW_L3_COLOR,COLOR_MAGENTA,-1) == OK);
		assert(init_pair(LCAST_ALTROW_RES_COLOR,COLOR_CYAN,-1) == OK);
		assert(init_pair(UCAST_ALTROW_RES_COLOR,COLOR_CYAN,-1) == OK);
		assert(init_pair(MCAST_ALTROW_RES_COLOR,COLOR_BLUE,-1) == OK);
		assert(init_pair(BCAST_ALTROW_RES_COLOR,COLOR_MAGENTA,-1) == OK);
		assert(init_pair(SUBDISPLAY_COLOR,COLOR_WHITE,-1) == OK);
	}else{
		assert(init_pair(BORDER_COLOR,COLOR_ALUMINIUM,-1) == OK);
		assert(init_pair(HEADER_COLOR,COLOR_BLUE,-1) == OK);
		assert(init_pair(FOOTER_COLOR,COLOR_YELLOW,-1) == OK);
		assert(init_pair(DBORDER_COLOR,COLOR_ALUMINIUM,-1) == OK);
		assert(init_pair(DHEADING_COLOR,COLOR_WHITE,-1) == OK);
		assert(init_pair(UBORDER_COLOR,COLOR_CYAN,-1) == OK);
		assert(init_pair(UHEADING_COLOR,COLOR_ORANGE,-1) == OK);
//.........这里部分代码省略.........
开发者ID:ynadji,项目名称:omphalos,代码行数:101,代码来源:ncurses.c


示例10: start_ncurses

int start_ncurses(const char *prog_name, const char *real_prog_name)
{
#if defined(DJGPP) || defined(__MINGW32__)
  if(initscr()==NULL)
  {
    log_critical("initscr() has failed. Exiting\n");
    printf("initscr() has failed. Exiting\n");
    printf("Press Enter key to quit.\n");
    (void)getchar();
    return 1;
  }
#else
  get_newterm(real_prog_name);
  if(screenp==NULL)
  {
    log_critical("Terminfo file is missing.\n");
#if defined(__CYGWIN__)
    printf("The terminfo file '63\\cygwin' is missing.\n");
#else
    printf("Terminfo file is missing.\n");
#endif
    printf("Extract all files and subdirectories before running the program.\n");
    printf("Press Enter key to quit.\n");
    (void)getchar();
    return 1;
  }
#endif
  /* Should solve a problem with users who redefined the colors */
  if(has_colors())
  {
    start_color();
#ifdef HAVE_ASSUME_DEFAULT_COLORS
    assume_default_colors(COLOR_WHITE,COLOR_BLACK);
#endif
    init_pair(1, COLOR_RED, COLOR_BLACK);
    init_pair(2, COLOR_GREEN, COLOR_BLACK);
  }
  noecho();
#ifndef DJGPP
  nonl(); /*don't use for Dos version but enter will work with it... dilema */
#endif
  /*  intrflush(stdscr, FALSE); */
  cbreak();
  curs_set(0);
  {
    int quit=0;
    while(LINES>=8 && LINES<MINIMUM_LINES && quit==0)
    {
      aff_copy(stdscr);
      wmove(stdscr,4,0);
      wprintw(stdscr,"%s need %d lines to work.", prog_name, MINIMUM_LINES);
      wmove(stdscr,5,0);
      wprintw(stdscr,"Please enlarge the terminal.");
      wmove(stdscr,LINES-2,0);
      wattrset(stdscr, A_REVERSE);
      waddstr(stdscr,"[ Quit ]");
      wattroff(stdscr, A_REVERSE);
      wrefresh(stdscr);
      switch(wgetch(stdscr))
      {
	case 'q':
	case 'Q':
	case KEY_ENTER:
#ifdef PADENTER
	case PADENTER:
#endif
	case '\n':
	case '\r':
	  quit=1;
	  break;
      }
    }
  }
  if(LINES < MINIMUM_LINES)
  {
    end_ncurses();
    printf("%s need %d lines to work.\nPlease enlarge the terminal and restart %s.\n", prog_name, MINIMUM_LINES, prog_name);
    log_critical("Terminal has only %d lines\n",LINES);
    return 1;
  }
  return 0;
}
开发者ID:AndrewSmart,项目名称:testdisk,代码行数:82,代码来源:intrfn.c


示例11: main

int main()
{   

    FILE * pwrite = fopen("/dev/rfcomm0", "w");

    if(pwrite == NULL){
        printf("couldn't open rfcomm\n");
        return 0;
    }


    int c;

    initscr();
    clear();
    noecho();
    cbreak();   /* Line buffering disabled. pass on everything */
    
    keypad(stdscr, TRUE);
    mvprintw(0, 0, "Use arrow keys to choose direction of motion");
    mvprintw(1, 0, "Press the same key to undo your selection");
    mvprintw(2, 0, "Spacebar switches between high/low speed");
    refresh();
    while(1)
    {   c = getch();
        // clear();
        switch(c)
        {   
            case ' ':
                fputc(' ', pwrite);
                fflush(pwrite);

                mvprintw(5, 0, "SPEED");
                clrtoeol();
                break;

            case KEY_UP:
                fputc('o', pwrite);
                fflush(pwrite);

                mvprintw(5, 0, "UP");
                clrtoeol();
                break;
            case KEY_DOWN:
                fputc('c', pwrite);
                fflush(pwrite);

                mvprintw(5, 0, "DOWN");
                clrtoeol();
                break;
            case KEY_LEFT:
                fputc('r', pwrite);
                fflush(pwrite);

                mvprintw(5, 0, "LEFT");
                clrtoeol();
                break;
            case KEY_RIGHT:
                fputc('l', pwrite);
                fflush(pwrite);

                mvprintw(5, 0, "RIGHT");
                clrtoeol();
                break;
            default:
                mvprintw(5, 0, "Undefined: %3d '%c'", c, c);
                clrtoeol();
                break;
        }

        refresh();
    }   
    clrtoeol();
    refresh();
    endwin();
    return 0;
}
开发者ID:mattlkf,项目名称:sketchbook,代码行数:77,代码来源:ocs.cpp


示例12: init_gcu


//.........这里部分代码省略.........
	 arg_sound = FALSE;
      }

      /* Change setting */
      use_sound = arg_sound;
   }
#endif

#ifdef USE_GRAPHICS

   /* Try graphics */
   if (arg_graphics)
   {
      /* if USE_NCURSES_ACS is defined, we can do something with graphics in curses! */
#ifdef USE_NCURSES_ACS
      use_graphics = TRUE;
#endif
   }

#endif /* USE_GRAPHICS */



   /*** Low level preparation ***/

#ifdef USE_GETCH

   /* Paranoia -- Assume no waiting */
   nodelay(stdscr, FALSE);

#endif

   /* Prepare */
   cbreak();
   noecho();
   nonl();
   raw();

   /* Extract the game keymap */
   keymap_game_prepare();


   /*** Now prepare the term(s) ***/
   for (i = 0; i < num_term; i++)
   {
      int rows, cols;
      int y, x;

      switch (i)
      {
	 /* Upper left */
	 case 0: rows = 24;
	    cols = 80;
	    y = x = 0;
	    break;
	 /* Lower left */
	 case 1: rows = LINES - 25;
	    cols = 80;
	    y = 24;
	    x = 0;
	    break;
	 /* Upper right */
	 case 2: rows = 24;
	    cols = COLS - 81;
	    y = 0;
	    x = 81;
开发者ID:dplusplus,项目名称:hengband_njslyr,代码行数:67,代码来源:main-gcu.c


示例13: pp_curs_cbreak

cell pp_curs_cbreak(cell x) {
	if (!Running) return UNSPECIFIC;
	cbreak();
	return UNSPECIFIC;
}
开发者ID:fmutant,项目名称:scriptorium,代码行数:5,代码来源:curses.c


示例14: main

int main(void)
{
        WINDOW *win1;
        int x, y, i, j, k;	// j, k not used yet.
	int xidx;
	float xmu[3500] = {}, xvar[3500] = {}, deltamu[3500] = {}, deltavar[3500] = {};
	float ymu[3500] = {}, yvar[3500] = {};
	int xrnd[3500] = {};
	int xused[3500] = {};
	int scnarr[35][100] = {};
	int slowness = 50;

        initscr();
        cbreak();               // Line buffering disabled
        keypad(stdscr, TRUE);   // allow softkeys
        noecho();               // don't display input when (w)getch();
	curs_set(0);		// don't display the cursor.
        getmaxyx(stdscr,y,x);

	srand((unsigned)(int)time(NULL));

        win1 = newwin(y,x,0,0);

	for (i=0; i<3500; i++) {	// i == xrnd[index]
		xrnd[i] = rand()%100;
	}				// end i.
	for (i=0; i<3500; i++) {				// i == xrnd[] index
		if (scnarr[0][xrnd[i]] == 1)
			break;
		for (j=34; j>=0; j--) {				// j == vertical scan index
			if (scnarr[j][xrnd[i]] != 1) {

/** */ 				for (k=0; k<=j; k++) {		// k == white drop space
					if (k>0)
						mvwprintw(win1,k-1,xrnd[i]," ");
					mvwprintw(win1,k,xrnd[i],"O");
					wrefresh(win1);
  // Enable This Line when running from localhost (not over ssh):	
  //					waitmics(slowness);
				}
/*  **/
				scnarr[j][xrnd[i]] = 1;
		break;
			}
		}
		xidx = i;
		ymu[i] = (float)i/100;
	}
	wgetch(win1);
	wclear(win1);
	/*
***********************************************************************************************
	*/
	wrefresh(win1);
	while (1) {
		k = wgetch(win1);
		if (k == 27) {				//clear BS input, keep good stuff
			k = wgetch(win1); //k == 91
			k = wgetch(win1); //k==50s+getch: pgup/pgdn; k==60s up/dn/l/r
			if (k/10 == 5) wgetch(win1); //ignore extra getch sent
		}

		if (k == 68) {				//if KEY_LEFT:
			wclear(win1);			//  print generated ballistic dep.
			for (i=0; i<100; i++) {
				for (j=34; j>=0; j--) {
					if (scnarr[j][i] == 1)	mvwprintw(win1, j, i, "O");
				}
			}
			wrefresh(win1);
 		} else if (k == 67) {			//if KEY_RIGHT
			wclear(win1);			// print statistics and graphs
			mvwprintw(win1, 10, 10," xidx= %d", xidx);
			mvwprintw(win1, 11, 10," ymu = %f", ymu[xidx]);
			mvwprintw(win1, 13, 10," ymu[0:1500](by 100's): ");
			for (i=0; i<15; i++) {
				mvwprintw(win1, 14, i*6, "%.2f", ymu[i*100]);
			}
			wrefresh(win1);

		} else if (k == 10) {			//if ENTER
		        delwin(win1);			//  end
			endwin();
			system("clear");
			break;
		}
	}
	return k;
	/*
***********************************************************************************************
	*/
	delwin(win1);
	endwin();
	system("clear");
        return 0;
}
开发者ID:rcollins0618,项目名称:BDmodel-2014,代码行数:96,代码来源:project05.c


示例15: Sv_InitConsole

/**
 * @brief
 */
void Sv_InitConsole(void) {

	if (!dedicated->value) {
		return;
	}

#if defined(_WIN32)
	if (AllocConsole()) {
		freopen("CONIN$", "r", stdin);
		freopen("CONOUT$", "w", stdout);
		freopen("CONERR$", "w", stderr);
	} else {
		Com_Warn("Failed to allocate console: %u\n", (uint32_t) GetLastError());
	}
#endif

	memset(&sv_console_state, 0, sizeof(sv_console_state));

	sv_console_state.window = initscr();
	sv_console_state.dirty = true;

	cbreak();
	noecho();
	keypad(sv_console_state.window, TRUE);
	nodelay(sv_console_state.window, TRUE);
	curs_set(1);

	if (has_colors() == TRUE) {
		start_color();
		use_default_colors();
		init_pair(CON_COLOR_RED, COLOR_RED, -1);
		init_pair(CON_COLOR_GREEN, COLOR_GREEN, -1);
		init_pair(CON_COLOR_YELLOW, COLOR_YELLOW, -1);
		init_pair(CON_COLOR_BLUE, COLOR_BLUE, -1);
		init_pair(CON_COLOR_CYAN, COLOR_CYAN, -1);
		init_pair(CON_COLOR_MAGENTA, COLOR_MAGENTA, -1);
		init_pair(CON_COLOR_WHITE, COLOR_WHITE, -1);
	}

#ifdef SIGWINCH
	signal(SIGWINCH, Sv_ResizeConsole);
#endif

	memset(&sv_console, 0, sizeof(sv_console));

	sv_console.Append = Sv_Print;

	Con_AddConsole(&sv_console);

	if (dedicated->value) {
		file_t *file = Fs_OpenRead("history");
		if (file) {
			Con_ReadHistory(&sv_console, file);
			Fs_Close(file);
		} else {
			Com_Debug(DEBUG_SERVER, "Couldn't read history");
		}
	}

	Com_Print("Server console initialized\n");
}
开发者ID:jdolan,项目名称:quetoo,代码行数:64,代码来源:sv_console.c


示例16: teacher_menu

int teacher_menu(char *database){
	int i, c, n, choice = 0;
	teacher *xteacher;
	WINDOW *win;
	ITEM **items;
	MENU *menu;
	n = teacher_number(database);
	start_color();
	cbreak();
	noecho();
	keypad(stdscr, TRUE);
	xteacher = (teacher *)malloc(sizeof(teacher) * (n + 1));
	items = (ITEM **)calloc(n + 3, sizeof(ITEM *));
	for(i = 0; i < n; ++i) {
		xteacher[i] = get_teacher(database,i);
		items[i] = new_item(xteacher[i].name, NULL);
	}
	menu = new_menu((ITEM **)items);
	win = newwin(0, 0, 0, 0);
	int y,x;
	getmaxyx(win,y,x);
	keypad(win, TRUE);
	set_menu_win(menu, win);
	set_menu_sub(menu, derwin(win, y - 5, 38, 5, 0.4*x));
	set_menu_format(menu,x - 4, 1);
	set_menu_mark(menu, " * ");
	set_menu_spacing(menu, 0, 2, 0);
	box(win, 0, 0);
	print_in_middle(win, 1, 0, x, "Teachers" , COLOR_PAIR(1));
	mvwaddch(win, 2, 0, ACS_LTEE);
	mvwhline(win, 2, 1, ACS_HLINE, x - 2);
	mvwaddch(win, 2, x - 1, ACS_RTEE);
	mvwaddch(win, y - 3, 0, ACS_LTEE);
	mvwhline(win, y - 3, 1, ACS_HLINE, x - 2);
	mvwaddch(win, y - 3, x - 1, ACS_RTEE);
	refresh();
	if(n) {
		if(n > 1)
			mvwprintw(win,y - 2, 2,"N:New Teacher\t\tR:Remove Teacher\tS:Sort\t\tB:Back\tQ:Quit");
		else
			mvwprintw(win,y - 2, 2,"N:New Teacher\t\tR:Remove Teacher\tB:Back\tQ:Quit");
		for(i = 0; i < choice; i++)
			menu_driver(menu, REQ_DOWN_ITEM);
		post_menu(menu);
		wrefresh(win);
		while((c = wgetch(win))){
			switch(c) {
				case KEY_DOWN:
					menu_driver(menu, REQ_DOWN_ITEM);
					if(choice != n -1)
						choice++;
					break;
				case KEY_UP:
					menu_driver(menu, REQ_UP_ITEM);
					if(choice != 0)
						choice--;
					break;
				case 10: /* Enter */
					remove_menu(menu,items,n);
					return choice;
				case 'R':
				case 'r':
					remove_teacher(database, choice);
					remove_menu(menu,items,n);
					return -1;
				case 'B':
				case 'b':
					remove_menu(menu,items,n);
					return n + 1;
				case 'N':
				case 'n':
					remove_menu(menu,items,n);
					return n + 2;
				case 'Q':
				case 'q':
					remove_menu(menu,items,n);
					return INT_MIN;
				default:
					break;
			}
			wrefresh(win);
		}
	}
	else {
		mvwprintw(win,y - 2, 2,"N:New Teacher\t\tB:Back\t\tQ:Quit");
		mvwprintw(win,5,3*x/7,"No Teachers found :(\n");
		wrefresh(win);
		curs_set(0);
		while((c = wgetch(win)))
		{
			switch(c) {
				case 'n':
				case 'N':
					remove_menu(menu,items,n);
					curs_set(1);
					return n+2;
				case 'b':
				case 'B':
					remove_menu(menu,items,n);
					curs_set(1);
//.........这里部分代码省略.........
开发者ID:shashankgandham,项目名称:xTimetable,代码行数:101,代码来源:teacher.c


示例17: main

int main(int argc, char **argv)
{
	int opt, optind = 0;
	int ch = ERR;

	struct option lopts[] = {
		{ "help",          no_argument,       NULL, 'h' },
		{ "version",       no_argument,       NULL, 'V' },
		{ "networks",      no_argument,       NULL, 'n' },
		{ "vbds",          no_argument,       NULL, 'x' },
		{ "repeat-header", no_argument,       NULL, 'r' },
		{ "vcpus",         no_argument,       NULL, 'v' },
		{ "delay",         required_argument, NULL, 'd' },
		{ "batch",	   no_argument,	      NULL, 'b' },
		{ "iterations",	   required_argument, NULL, 'i' },
		{ "full-name",     no_argument,       NULL, 'f' },
		{ 0, 0, 0, 0 },
	};
	const char *sopts = "hVnxrvd:bi:f";

	if (atexit(cleanup) != 0)
		fail("Failed to install cleanup handler.\n");

	while ((opt = getopt_long(argc, argv, sopts, lopts, &optind)) != -1) {
		switch (opt) {
		default:
			usage(argv[0]);
			exit(1);
		case '?':
		case 'h':
			usage(argv[0]);
			exit(0);
		case 'V':
			version();
			exit(0);
		case 'n':
			show_networks = 1;
			break;
		case 'x':
			show_vbds = 1;
			break;
		case 'r':
			repeat_header = 1;
			break;
		case 'v':
			show_vcpus = 1;
			break;
		case 'd':
			delay = atoi(optarg);
			break;
		case 'b':
			batch = 1;
			break;
		case 'i':
			iterations = atoi(optarg);
			loop = 0;
			break;
		case 'f':
			show_full_name = 1;
			break;
		case 't':
			show_tmem = 1;
			break;
		}
	}

	/* Get xenstat handle */
	xhandle = xenstat_init();
	if (xhandle == NULL)
		fail("Failed to initialize xenstat library\n");

	if (!batch) {
		/* Begin curses stuff */
		cwin = initscr();
		start_color();
		cbreak();
		noecho();
		nonl();
		keypad(stdscr, TRUE);
		halfdelay(5);
#ifndef __sun__
		use_default_colors();
#endif
		init_pair(1, -1, COLOR_YELLOW);

		do {
			gettimeofday(&curtime, NULL);
			if(ch != ERR || (curtime.tv_sec - oldtime.tv_sec) >= delay) {
				erase();
				top();
				oldtime = curtime;
				refresh();
				if ((!loop) && !(--iterations))
					break;
			}
			ch = getch();
		} while (handle_key(ch));
	} else {
		struct sigaction sa = {
			.sa_handler = signal_exit_handler,
//.........这里部分代码省略.........
开发者ID:HackLinux,项目名称:xen-4.5,代码行数:101,代码来源:xentop.c


示例18: main

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

    initscr();
    start_color();
    cbreak();
    keypad(stdscr, TRUE);
    noecho();
    curs_set(0);
    init_pair(1, COLOR_CYAN, COLOR_BLACK);

    attron(COLOR_PAIR(1));
    //画边
    mvaddch(1, 0, '+');
    mvaddch(1, COLS-1, '+');
    mvaddch(LINES-1, COLS-1, '+');
    mvaddch(LINES-1, 0, '+');
    mvhline(1, 1, '-', COLS-1-1);
    mvhline(LINES-1, 1, '-', COLS-1-1);
    mvvline(2, 0, '|', LINES-2-1);
    mvvline(2, COLS-1, '|', LINES-2-1);

    refresh();
    attroff(COLOR_PAIR(1));

    // 来条蛇
    SNAKE snake;
    init_snake(&snake);
    draw_whole_snake(&snake);
    
    // 初始豆儿
    int *food;
    food = random_food(&snake);
    //mvaddch(food[1], food[0], '*');
    draw_food(food);

    int d;
    int i;
    now_time=0;
    while (1)
    {
        if(ioctl(0,FIONREAD,&i)<0)
        {
            printf("ioctl failed, error=%d\n ",errno);
            break;
        }
        if(!i)  // 小蛇自动跑部分
        {
            usleep(time_rate);
            now_time = now_time + time_rate;
            if (!(now_time < speed))
            {
                now_time = 0;
                if (snake_move(&snake, food))
                    break;
            }
            continue;
        }
        now_time = 0;
        ch = getch();
        if (ch < 258 || ch > 261)
            continue;
        if ( ch+snake.d != KEY_LEFT+KEY_UP )
        {
            d = ch - snake.d;
            if ( d == 1 || d == -1)
                continue;
        }
        snake.d = ch;

        if (snake_move(&snake, food))
            break;

    }
    getch();
    endwin();
    return 0;
}
开发者ID:kahn04,项目名称:snake,代码行数:79,代码来源:snake.c


示例19: main

int main(int argc, char **argv) {
    init_buf();
    if (argc > 1)
        strncpy(file_name, argv[1], BUFSIZ);
    else
        strcpy(file_name, "untitled.txt");
    read_file(file_name);
    initscr();
    cbreak();
    noecho();
    if (has_colors()) {
        int white;
        start_color();
        if (COLORS > 255)
            white = 231;
        else if (COLORS > 87)
            white = 79;
        else
            white = 15;
        init_pair(1, white, 0);
        minibuf_attrs = COLOR_PAIR(1);
    } else {
        minibuf_attrs = A_BOLD;
    }

    while (TRUE) {
        int ch;
        // Redisplay
        drop_until(getmaxy(stdscr) / 2);
        print_queue();
        mbuf_display();
        refresh();

        // Wait for input
        switch ((ch = getch())) {
        case EOF:
        case '\x04': // ^D
            quit();
        case '\x08': // ^H
        case '\x7f': // DEL
            del_buf(buf.i - 1); break;
        case '\x17': // ^W
            del_buf(buf.wbeg); break;
        case '\x15': // ^U
            reset_buf("");
            break;
        case '\x1b': // ESC
            mbuf_msg("Press CTRL+D to quit");
            break;
        case '\r':
        case '\n':
            append_buf('\n');
            break;
        default:
            mbuf_msg(file_name);
            if (ch > '\x1f')
                append_buf(ch);
       

鲜花

握手

雷人

路过

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

请发表评论

全部评论

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