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


C++ wprintw函数代码示例

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


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

示例1: help_draw_menu

static void help_draw_menu(ToxWindow *self)
{
    WINDOW *win = self->help->win;

    wmove(win, 1, 1);

    wattron(win, A_BOLD | COLOR_PAIR(RED));
    wprintw(win, "       Help Menu\n");
    wattroff(win, A_BOLD | COLOR_PAIR(RED));

    wattron(win, A_BOLD | COLOR_PAIR(BLUE));
    wprintw(win, " g");
    wattroff(win, A_BOLD | COLOR_PAIR(BLUE));
    wprintw(win, "lobal commands\n");

    wattron(win, A_BOLD | COLOR_PAIR(BLUE));
    wprintw(win, " c");
    wattroff(win, A_BOLD | COLOR_PAIR(BLUE));
    wprintw(win, "hat commands\n");

    wprintw(win, " g");
    wattron(win, A_BOLD | COLOR_PAIR(BLUE));
    wprintw(win, "r");
    wattroff(win, A_BOLD | COLOR_PAIR(BLUE));
    wprintw(win, "oup commands\n");

#ifdef PYTHON
    wattron(win, A_BOLD | COLOR_PAIR(BLUE));
    wprintw(win, " p");
    wattroff(win, A_BOLD | COLOR_PAIR(BLUE));
    wprintw(win, "lugin commands\n");
#endif /* PYTHON */

    wattron(win, A_BOLD | COLOR_PAIR(BLUE));
    wprintw(win, " f");
    wattroff(win, A_BOLD | COLOR_PAIR(BLUE));
    wprintw(win, "riendlist controls\n");

    wattron(win, A_BOLD | COLOR_PAIR(BLUE));
    wprintw(win, " k");
    wattroff(win, A_BOLD | COLOR_PAIR(BLUE));
    wprintw(win, "ey bindings\n");

    wprintw(win, " e");
    wattron(win, A_BOLD | COLOR_PAIR(BLUE));
    wprintw(win, "x");
    wattroff(win, A_BOLD | COLOR_PAIR(BLUE));
    wprintw(win, "it menu\n");

    box(win, ACS_VLINE, ACS_HLINE);
    wnoutrefresh(win);
}
开发者ID:JFreegman,项目名称:toxic,代码行数:52,代码来源:help.c

示例2: outputTest


//.........这里部分代码省略.........
    wclear(win);
    wrefresh(win);
    MvWAddStr(win, 6, 2, "This line shouldn't appear");
    MvWAddStr(win, 4, 2, "Only half of the next line is visible");
    MvWAddStr(win, 5, 2, "Only half of the next line is visible");
    wmove(win, 6, 1);
    wclrtobot(win);
    wmove(win, 5, 20);
    wclrtoeol(win);
    MvWAddStr(win, 8, 2, "This line also shouldn't appear");
    wmove(win, 8, 1);
    wdeleteln(win);
    Continue(win);

    wmove(win, 5, 9);
    ch = winch(win);

    wclear(win);
    wmove(win, 6, 2);
    waddstr(win, "The next char should be l:  ");
    winsch(win, ch);
    Continue(win);

#if HAVE_WINSSTR
    (void) mvwinsstr(win, 6, 2, "A1B2C3D4E5");
    Continue(win);
#endif

    wmove(win, 5, 1);
    winsertln(win);
    MvWAddStr(win, 5, 2, "The lines below should have moved down");
    Continue(win);

    wclear(win);
    wmove(win, 2, 2);
    wprintw(win, "This is a formatted string in a window: %d %s\n", 42,
	    "is it");
    MvWAddStr(win, 10, 1, "Enter a string: ");
    wrefresh(win);
    noraw();
    echo();
    *Buffer = 0;
    wscanw(win, "%s", Buffer);

    printw("This is a formatted string in stdscr: %d %s\n", 42, "is it");
    MvAddStr(10, 1, "Enter a string: ");
    *Buffer = 0;
    scanw("%s", Buffer);

    if (TIGETSTR("cvvis", "vs") != 0) {
	wclear(win);
	curs_set(2);
	MvWAddStr(win, 1, 1, "The cursor should appear as a block (visible)");
	Continue(win);
    }

    if (TIGETSTR("civis", "vi") != 0) {
	wclear(win);
	curs_set(0);
	MvWAddStr(win, 1, 1,
		  "The cursor should have disappeared (invisible)");
	Continue(win);
    }

    if (TIGETSTR("cnorm", "ve") != 0) {
	wclear(win);
	curs_set(1);
	MvWAddStr(win, 1, 1, "The cursor should be an underline (normal)");
	Continue(win);
    }
#ifdef A_COLOR
    if (has_colors()) {
	wclear(win);
	MvWAddStr(win, 1, 1, "Colors should change after you press a key");
	Continue(win);
	init_pair(1, COLOR_RED, COLOR_WHITE);
	wrefresh(win);
    }
#endif

    werase(win);

#if HAVE_TERMNAME
    MvWAddStr(win, 1, 1, "Information About Your Terminal");
    MvWAddStr(win, 3, 1, termname());
    MvWAddStr(win, 4, 1, longname());
    if (termattrs() & A_BLINK)
	MvWAddStr(win, 5, 1, "This terminal supports blinking.");
    else
	MvWAddStr(win, 5, 1, "This terminal does NOT support blinking.");
#endif

    (void) mvwaddnstr(win, 7, 5, "Have a nice day!ok", 16);
    wrefresh(win);

    (void) mvwinnstr(win, 7, 5, Buffer, 18);
    MvAddStr(LINES - 2, 10, Buffer);
    refresh();
    Continue(win);
}
开发者ID:ThomasDickey,项目名称:ncurses-snapshots,代码行数:101,代码来源:testcurs.c

示例3: _show_roster_contacts

void
_show_roster_contacts(GSList *list, gboolean show_groups)
{
    GSList *curr = list;
    while(curr) {

        PContact contact = curr->data;
        GString *title = g_string_new("  ");
        title = g_string_append(title, p_contact_barejid(contact));
        if (p_contact_name(contact) != NULL) {
            title = g_string_append(title, " (");
            title = g_string_append(title, p_contact_name(contact));
            title = g_string_append(title, ")");
        }

        const char *presence = p_contact_presence(contact);
        win_print_time(console, '-');
        if (p_contact_subscribed(contact)) {
            win_presence_colour_on(console, presence);
            wprintw(console->win, "%s\n", title->str);
            win_presence_colour_off(console, presence);
        } else {
            win_presence_colour_on(console, "offline");
            wprintw(console->win, "%s\n", title->str);
            win_presence_colour_off(console, "offline");
        }

        g_string_free(title, TRUE);

        win_print_time(console, '-');
        wprintw(console->win, "    Subscription : ");
        GString *sub = g_string_new("");
        sub = g_string_append(sub, p_contact_subscription(contact));
        if (p_contact_pending_out(contact)) {
            sub = g_string_append(sub, ", request sent");
        }
        if (presence_sub_request_exists(p_contact_barejid(contact))) {
            sub = g_string_append(sub, ", request received");
        }
        if (p_contact_subscribed(contact)) {
            wattron(console->win, COLOUR_SUBSCRIBED);
        } else {
            wattron(console->win, COLOUR_UNSUBSCRIBED);
        }
        wprintw(console->win, "%s\n", sub->str);
        if (p_contact_subscribed(contact)) {
            wattroff(console->win, COLOUR_SUBSCRIBED);
        } else {
            wattroff(console->win, COLOUR_UNSUBSCRIBED);
        }

        g_string_free(sub, TRUE);

        if (show_groups) {
            GSList *groups = p_contact_groups(contact);
            if (groups != NULL) {
                GString *groups_str = g_string_new("    Groups : ");
                while (groups != NULL) {
                    g_string_append(groups_str, groups->data);
                    if (g_slist_next(groups) != NULL) {
                        g_string_append(groups_str, ", ");
                    }
                    groups = g_slist_next(groups);
                }

                cons_show(groups_str->str);
                g_string_free(groups_str, TRUE);
            }
        }

        curr = g_slist_next(curr);
    }

}
开发者ID:cjopcjop,项目名称:profanity,代码行数:74,代码来源:console.c

示例4: RenderTreeIntoWindow

void RenderTreeIntoWindow(comment_item_tree* tree)
{
	zlog_info(c, "Rendering window %dX%d", win->_maxy, win->_maxx);
	wbkgd(win, COLOR_PAIR(1));
	refresh();
	wmove(win, 2, 1);
	//wattron(win, A_BOLD | A_BLINK);
	wattron(win,  A_BOLD);
	wattron(win, COLOR_PAIR(2));
	zlog_info(c, "Starting to parse the tree");
	if(mode == MODE_LOADING){
		wprintw(win, "Loading in articles...one moment please  ");
	}else{
		wprintw(win, "News Comments for article ( %d in total) ", TotalSize(tree) );
	}
	wattroff(win, COLOR_PAIR(2));

	wattroff(win, A_BOLD);



	int row = 4;
	while (row < 30) {
		wmove(win, row, 1);  wprintw(win, "%*s", 120, "");
		row++;
	}
	if(msg1 != NULL && mode == MODE_LOADING){
		wmove(win, LINES - 4, 1);
		wprintw(win, "%s", msg1);
	}

	row = 4;
	int txcol = 7;
	if(_flat != NULL){
		free(_flat);
	}
	ResetFlatTree(tree);
	_flat = ToFlatTree(tree, &_total_tree_size);

	zlog_info(c, "Rendering total of  %d rows", _total_tree_size);

	while (true) {
		if ( (row - 4) == _total_tree_size || (row - 4) >= WINDOW_SIZE) {
			break;
		}
		int chosen_element = MAX(row + start_row - 4, 0);
		if(chosen_element >= _total_tree_size){
			zlog_info(c, "Hit Max, stopping iteration..");
			break;
		}
		zlog_info(c, ">>Rendering  row  %d, ray elem %d - real elem/index %d ", row, row + start_row - 4, chosen_element);
		RenderRow(win, _flat[chosen_element], &row, txcol, row - 4, 0, -1);
	}


	mvwhline(win, 4 + WINDOW_SIZE + 1,  1, ACS_HLINE, COLS  );

	int _text_start = (int)(LINES/2);
	if(_selected > -1){
		row = _text_start;
		while (row < LINES - 2) {
			wmove(win, row, 2);  wprintw(win, "%*s", 120, "");
			row++;
		}

		wmove(win, _text_start, 1);
		s_segments* segs = splitIntoSegments(_flat[_selected]->text, 90);
		int _p = 0;
		for (_p = 0; _p < segs->count; _p++) {
			wmove(win, _text_start + _p, 4);
			wprintw(win, "%s", segs->segments[_p]->string);
		}
		freeSegs(segs);
		if(msg1 != NULL){
			free(msg1);
		}
		msg1 = malloc(50);
		memset(msg1, 0, 50);
		sprintf(msg1, "ID: %d", _flat[_selected]->id);
		wmove(win, LINES - 4, 1);
		wprintw(win, "%120s", "");
		wmove(win, LINES - 4, 1);
		wprintw(win, "%s", msg1);
	}

	/*

	int BOX_W = 11;
	int BOX_H = 3;
	int _stx = 1;
	int _sty = 21;


	while (_sty < 35) {
		while (_stx < 120) {
			//wattron(win, A_BOLD | A_BLINK);
			DrawBox(win, BOX_H, BOX_W,  _sty, _stx, _stx == 1, _stx > 68);
			//wattroff(win, A_BOLD | A_BLINK);
			_stx += BOX_W;
		}
//.........这里部分代码省略.........
开发者ID:phatmanace,项目名称:kingsbridge,代码行数:101,代码来源:crs_tree_test.c

示例5: sepbar_redraw

static void sepbar_redraw(owl_window *w, WINDOW *sepwin, void *user_data)
{
  const owl_messagelist *ml;
  const owl_view *v;
  int x, y, i;
  const char *foo, *appendtosepbar;

  ml=owl_global_get_msglist(&g);
  v=owl_global_get_current_view(&g);

  werase(sepwin);
  wattron(sepwin, A_REVERSE);
  if (owl_global_is_fancylines(&g)) {
    whline(sepwin, ACS_HLINE, owl_global_get_cols(&g));
  } else {
    whline(sepwin, '-', owl_global_get_cols(&g));
  }

  if (owl_global_is_sepbar_disable(&g)) {
    getyx(sepwin, y, x);
    wmove(sepwin, y, owl_global_get_cols(&g)-1);
    return;
  }

  wmove(sepwin, 0, 2);

  if (owl_messagelist_get_size(ml) == 0)
    waddstr(sepwin, " (-/-) ");
  else
    wprintw(sepwin, " (%i/%i/%i) ", owl_global_get_curmsg(&g) + 1,
            owl_view_get_size(v),
            owl_messagelist_get_size(ml));

  foo=owl_view_get_filtname(v);
  if (strcmp(foo, owl_global_get_view_home(&g)))
      wattroff(sepwin, A_REVERSE);
  wprintw(sepwin, " %s ", owl_view_get_filtname(v));
  if (strcmp(foo, owl_global_get_view_home(&g)))
      wattron(sepwin, A_REVERSE);

  if (owl_mainwin_is_curmsg_truncated(owl_global_get_mainwin(&g))) {
    getyx(sepwin, y, x);
    wmove(sepwin, y, x+2);
    wattron(sepwin, A_BOLD);
    waddstr(sepwin, " <truncated> ");
    wattroff(sepwin, A_BOLD);
  }

  i=owl_mainwin_get_last_msg(owl_global_get_mainwin(&g));
  if ((i != -1) &&
      (i < owl_view_get_size(v)-1)) {
    getyx(sepwin, y, x);
    wmove(sepwin, y, x+2);
    wattron(sepwin, A_BOLD);
    waddstr(sepwin, " <more> ");
    wattroff(sepwin, A_BOLD);
  }

  if (owl_global_get_rightshift(&g)>0) {
    getyx(sepwin, y, x);
    wmove(sepwin, y, x+2);
    wprintw(sepwin, " right: %i ", owl_global_get_rightshift(&g));
  }

  if (owl_global_is_zaway(&g) || owl_global_is_aaway(&g)) {
    getyx(sepwin, y, x);
    wmove(sepwin, y, x+2);
    wattron(sepwin, A_BOLD);
    wattroff(sepwin, A_REVERSE);
    if (owl_global_is_zaway(&g) && owl_global_is_aaway(&g)) {
      waddstr(sepwin, " AWAY ");
    } else if (owl_global_is_zaway(&g)) {
      waddstr(sepwin, " Z-AWAY ");
    } else if (owl_global_is_aaway(&g)) {
      waddstr(sepwin, " A-AWAY ");
    }
    wattron(sepwin, A_REVERSE);
    wattroff(sepwin, A_BOLD);
  }

  if (owl_global_get_curmsg_vert_offset(&g)) {
    getyx(sepwin, y, x);
    wmove(sepwin, y, x+2);
    wattron(sepwin, A_BOLD);
    wattroff(sepwin, A_REVERSE);
    waddstr(sepwin, " SCROLL ");
    wattron(sepwin, A_REVERSE);
    wattroff(sepwin, A_BOLD);
  }

  appendtosepbar = owl_global_get_appendtosepbar(&g);
  if (appendtosepbar && *appendtosepbar) {
    getyx(sepwin, y, x);
    wmove(sepwin, y, x+2);
    waddstr(sepwin, " ");
    waddstr(sepwin, owl_global_get_appendtosepbar(&g));
    waddstr(sepwin, " ");
  }

  getyx(sepwin, y, x);
//.........这里部分代码省略.........
开发者ID:andersk,项目名称:barnowl,代码行数:101,代码来源:sepbar.c

示例6: test_opaque

static int
test_opaque(int level, char **argv, WINDOW *stswin)
{
    WINDOW *txtbox = 0;
    WINDOW *txtwin = 0;
    FILE *fp;
    int ch;
    int txt_x = 0, txt_y = 0;
    int base_y;
    bool in_status = FALSE;
    int active = 0;

    if (argv[level] == 0) {
	beep();
	return FALSE;
    }

    if (level > 1) {
	txtbox = newwin(LINES - BASE_Y, COLS - level, BASE_Y, level);
	box(txtbox, 0, 0);
	wnoutrefresh(txtbox);

	txtwin = derwin(txtbox,
			getmaxy(txtbox) - 2,
			getmaxx(txtbox) - 2,
			1, 1);
	base_y = 0;
    } else {
	txtwin = stdscr;
	base_y = BASE_Y;
    }

    keypad(txtwin, TRUE);	/* enable keyboard mapping */
    (void) cbreak();		/* take input chars one at a time, no wait for \n */
    (void) noecho();		/* don't echo input */

    txt_y = base_y;
    txt_x = 0;
    wmove(txtwin, txt_y, txt_x);

    if ((fp = fopen(argv[level], "r")) != 0) {
	while ((ch = fgetc(fp)) != EOF) {
	    if (waddch(txtwin, UChar(ch)) != OK) {
		break;
	    }
	}
	fclose(fp);
    } else {
	wprintw(txtwin, "Cannot open:\n%s", argv[1]);
    }

    for (;;) {
	if (in_status) {
	    to_keyword(stswin, active);

	    ch = wgetch(stswin);
	    show_opaque(stswin, txtwin, TRUE, active);
	    if (Quit(ch))
		break;

	    switch (ch) {
	    case '\t':
		in_status = FALSE;
		break;
	    case KEY_DOWN:
	    case 'j':
		if (active < (int) SIZEOF(bool_funcs) - 1)
		    active++;
		else
		    beep();
		break;
	    case KEY_UP:
	    case 'k':
		if (active > 0)
		    active--;
		else
		    beep();
		break;
	    case ' ':
		bool_funcs[active].func(txtwin,
					!bool_funcs[active].func(txtwin, -1));
		break;
	    default:
		beep();
		break;
	    }
	    show_opaque(stswin, txtwin, FALSE, in_status ? active : -1);
	} else {
	    ch = mvwgetch(txtwin, txt_y, txt_x);
	    show_opaque(stswin, txtwin, TRUE, -1);
	    if (Quit(ch))
		break;

	    switch (ch) {
	    case '\t':
		in_status = TRUE;
		break;
	    case KEY_DOWN:
	    case 'j':
		if (txt_y < getmaxy(txtwin) - 1)
//.........这里部分代码省略.........
开发者ID:SayCV,项目名称:rtems-addon-packages,代码行数:101,代码来源:test_opaque.c

示例7: colprint

/*
 * Prints formatted output onto a window. Borders are handled correctly.
 *
 * %s		= char *
 * %d		= int
 * %f		= double
 * %B %/B	= bold on/off
 * %R %/R	= reverse on/off
 * %0-n% %/0-n%	= color on/off
 *
 */
void colprint(BBox * bbox, int y, int x, color * c, const char *fmt, ...)
{
	va_list			ap;
	unsigned int		i = 0;
	double			f = 0;
	string			output = "";
	bool			parse = false;
	bool			attr = false;
	attr_t			attrval = 0;
	char			buf[1024];
	string			colorstr;
	int			colorint;
	int			pair = 0;
	unsigned int		maxlen;		// max allowed characters printed on screen
	unsigned int		printlen = 0;	// num characters printed on screen

	assert(bbox);

	va_start(ap, fmt);

	/* Check if string is out of range, and cuts if necessary */
	if (x < 0)
	{
		if (strlen(fmt) < abs(x))
			return;

		fmt += abs(x);
		x = 0;
	}

	if (c != NULL)
		pair = c->pair();

	wmove(bbox->window, y, x);
	wattron(bbox->window, pair);

	maxlen = bbox->width() - x + 1;

	while(*fmt && printlen < maxlen)
	{
		if (*fmt == '%' && !parse)
		{
			if (*(fmt + 1) == '%')
			{
				fmt += 2;
				output = "%%";
				wprintw(bbox->window, _(output.c_str()));
				continue;
			}
			parse = true;
			attr = true;
			++fmt;
		}

		if (parse)
		{
			switch(*fmt)
			{
				case '/':
				/* Turn off attribute, SGML style */
					attr = false;
					break;
				case 'B':
					if (attr)
						wattron(bbox->window, A_BOLD);
					else
						wattroff(bbox->window, A_BOLD);
					parse = false;
					break;
				case 'R':
					if (attr)
						wattron(bbox->window, A_REVERSE);
					else
						wattroff(bbox->window, A_REVERSE);
					parse = false;
					break;
				case 'd':
					parse = false;
					i = va_arg(ap, int);
					sprintf(buf, "%d", i);
					wprintw(bbox->window, _(buf));
					printlen += strlen(buf);
					i = 0;
					break;
				case 'f':
					parse = false;
					f = va_arg(ap, double);
					sprintf(buf, "%f", f);
					wprintw(bbox->window, _(buf));
//.........这里部分代码省略.........
开发者ID:PhilT001,项目名称:pms,代码行数:101,代码来源:display.cpp

示例8: cmd_statusmsg

void cmd_statusmsg(ToxWindow *self, Messenger *m, char **args)
{
    char *msg = args[1];
    m_set_statusmessage(m, (uint8_t *) msg, strlen(msg) + 1);
    wprintw(self->window, "Status set to: %s\n", msg);
}
开发者ID:notadecent,项目名称:toxic,代码行数:6,代码来源:prompt.c

示例9: execute

static void execute(ToxWindow *self, Messenger *m, char *u_cmd)
{
    int newlines = 0;
    char cmd[MAX_STR_SIZE] = {0};
    int i;

    for (i = 0; i < strlen(prompt_buf); ++i) {
        if (u_cmd[i] == '\n')
            ++newlines;
        else
            cmd[i - newlines] = u_cmd[i];
    }

    int leading_spc = 0;

    for (i = 0; i < MAX_STR_SIZE && isspace(cmd[i]); ++i)
        leading_spc++;

    memmove(cmd, cmd + leading_spc, MAX_STR_SIZE - leading_spc);

    int cmd_end = strlen(cmd);

    while (cmd_end > 0 && cmd_end--)
        if (!isspace(cmd[cmd_end]))
            break;

    cmd[cmd_end + 1] = '\0';

    /* insert \0 at argument boundaries */
    int numargs = 0;

    for (i = 0; i < MAX_STR_SIZE; i++) {
        char quote_chr;
        if (cmd[i] == '\"' || cmd[i] == '\'') {
            quote_chr = cmd[i];
            while (cmd[++i] != quote_chr && i < MAX_STR_SIZE); /* skip over strings */
            /* Check if got qoute character */
            if (cmd[i] != quote_chr) {
                wprintw(self->window, "Missing terminating %c character\n", quote_chr);
                return;
            }
	}

        if (cmd[i] == ' ') {
            cmd[i] = '\0';

            int j = i;

            while (++j < MAX_STR_SIZE && isspace(cmd[j]));

            i = j - 1;

            numargs++;
        }
    }

    /* excessive arguments */
    if (numargs > 3) {
        wprintw(self->window, "Invalid command: too many arguments.\n");
        return;
    }

    /* read arguments into array */
    char *cmdargs[5];
    int pos = 0;

    for (i = 0; i < 5; i++) {
        cmdargs[i] = cmd + pos;
        pos += strlen(cmdargs[i]) + 1;

        while (isspace(cmd[pos]) && pos < MAX_STR_SIZE)
            ++pos;
    }

    /* no input */
    if (strlen(cmdargs[0]) == 0)
        return;

    /* match input to command list */
    for (i = 0; i < NUM_COMMANDS; i++) {
        if (!strcmp(cmdargs[0], commands[i].name)) {
            /* check for missing arguments */
            int j;

            for (j = 0; j <= commands[i].numargs; j++) {
                if (strlen(cmdargs[j]) == 0) {
                    wprintw(self->window, "Invalid command: %s expected %d arguments, got %d.\n",
                            commands[i].name, commands[i].numargs, j - 1);
                    return;
                }
            }

            /* check for excess arguments */
            if (strcmp(cmdargs[0], "add") && strlen(cmdargs[j]) != 0) {
                wprintw(self->window, "Invalid command: too many arguments to %s.\n", commands[i].name);
                return;
            }

            /* pass arguments to command function */
            (commands[i].func)(self, m, cmdargs);
//.........这里部分代码省略.........
开发者ID:notadecent,项目名称:toxic,代码行数:101,代码来源:prompt.c

示例10: cmd_add

void cmd_add(ToxWindow *self, Messenger *m, char **args)
{
    uint8_t id_bin[FRIEND_ADDRESS_SIZE];
    char xx[3];
    uint32_t x;
    char *id = args[1];
    char *msg = args[2];

    if (!id) {
        wprintw(self->window, "Invalid command: add expected at least one argument.\n");
        return;
    }

    if (!msg)
        msg = "";

    if (strlen(id) != 2 * FRIEND_ADDRESS_SIZE) {
        wprintw(self->window, "Invalid ID length.\n");
        return;
    }

    int i;

    for (i = 0; i < FRIEND_ADDRESS_SIZE; ++i) {
        xx[0] = id[2 * i];
        xx[1] = id[2 * i + 1];
        xx[2] = '\0';

        if (sscanf(xx, "%02x", &x) != 1) {
            wprintw(self->window, "Invalid ID.\n");
            return;
        }

        id_bin[i] = x;
    }

    for (i = 0; i < FRIEND_ADDRESS_SIZE; i++) {
        id[i] = toupper(id[i]);
    }

    int num = m_addfriend(m, id_bin, (uint8_t *) msg, strlen(msg) + 1);

    switch (num) {
        case FAERR_TOOLONG:
            wprintw(self->window, "Message is too long.\n");
            break;

        case FAERR_NOMESSAGE:
            wprintw(self->window, "Please add a message to your request.\n");
            break;

        case FAERR_OWNKEY:
            wprintw(self->window, "That appears to be your own ID.\n");
            break;

        case FAERR_ALREADYSENT:
            wprintw(self->window, "Friend request already sent.\n");
            break;

        case FAERR_UNKNOWN:
            wprintw(self->window, "Undefined error when adding friend.\n");
            break;

        case FAERR_BADCHECKSUM:
            wprintw(self->window, "Bad checksum in address.\n");
            break;

        case FAERR_SETNEWNOSPAM:
            wprintw(self->window, "Nospam was different.\n");
            break;

        default:
            wprintw(self->window, "Friend added as %d.\n", num);
            on_friendadded(m, num);
            break;
    }
}
开发者ID:notadecent,项目名称:toxic,代码行数:77,代码来源:prompt.c

示例11: cmd_help

void cmd_help(ToxWindow *self, Messenger *m, char **args)
{
    wclear(self->window);
    wattron(self->window, COLOR_PAIR(2) | A_BOLD);
    wprintw(self->window, "Commands:\n");
    wattroff(self->window, A_BOLD);

    wprintw(self->window, "      connect <ip> <port> <key> : Connect to DHT server\n");
    wprintw(self->window, "      add <id> <message>        : Add friend\n");
    wprintw(self->window, "      status <type> <message>   : Set your status\n");
    wprintw(self->window, "      statusmsg  <message>      : Set your status\n");
    wprintw(self->window, "      nick <nickname>           : Set your nickname\n");
    wprintw(self->window, "      mynick                    : Print your current nickname\n");
    wprintw(self->window, "      accept <number>           : Accept friend request\n");
    wprintw(self->window, "      myid                      : Print your ID\n");
    wprintw(self->window, "      quit/exit                 : Exit program\n");
    wprintw(self->window, "      help                      : Print this message again\n");
    wprintw(self->window, "      clear                     : Clear this window\n");

    wattron(self->window, A_BOLD);
    wprintw(self->window, "TIP: Use the TAB key to navigate through the tabs.\n\n");
    wattroff(self->window, A_BOLD);

    wattroff(self->window, COLOR_PAIR(2));
}
开发者ID:notadecent,项目名称:toxic,代码行数:25,代码来源:prompt.c

示例12: checkmate

/*check where the king can move
if the king can move to a place will he be in check?
if yes continue to check other conditions 
else no checkmate*/
int checkmate(int row,int col,checkm arr[],int q)
{
	int ccount,valid,i,j,x,y,z,t=0,possible=0,n=0;
	y=row-1;
	x=col-1;
	while(x<0){
		x++;
	}	
	while(y<0)
		y++;
	if(turn!=0){
		while((y<=row+1)&&(x<=col+1)){
			valid=king(row,col,y,x);
			if((turn!=0)&&board[y][x]<0 || (x==8 || y==8)){
				valid=0;
				wprintw(menuwin,"   invalid turn 1");wrefresh(menuwin);
			}
			if(valid){	
				t=0;
				for(j=0;j<=7;j++){
					for(i=0;i<=7;i++){
							if(t==1){
								break;
							}
							if(board[j][i]>=9 && board[j][i]<=16)
								t = pawn(j,i,y,x);
							else if(board[j][i]==2 || board[j][i]==7)
								t = horse(j,i,y,x);
							else if(board[j][i]==4)
								t = queen(j,i,y,x);
							else if(board[j][i]==1 || board[j][i]==8)
								t = rook(j,i,y,x);
							else if(board[j][i]==3 || board[j][i]==6)
								t = bishop(j,i,y,x);
					}
				}
				if(t==1){
					ccount++;
				}
				else if(t==0){ 
					possible++;
				}
			}		
			else{
				ccount++;
			}
			if(y==row+1){
				x++;
			}
			if(y<row+1){
				y++;
			}
		}
		if(possible!=0){
			return;
		}
		for(z=0;z<q;z++)
		{	x=arr[z].x;y=arr[z].y;
			switch(abs(arr[z].piece))
			{	
				case 9:case 10:case 11:case 12:case 13:case 14:case 15:case 16:break;
				case 4:if(arr[z].y-row==arr[z].x-col)
						goto c3;
						//go to bishop case 
						if(arr[z].y==row||arr[z].x==col)
						//go to rook case
				case 1:case 8://rook
						if(row==arr[z].y) {
							for(i=arr[z].x+1;i<col;i++) { 
								if(board[row][i]==0) { 
									if(friendlymove(row,i)){
										possible++;goto end;}
								}
							}
							for(i=arr[z].x-1;i>col;i--) { 
								if(board[row][i]==0) {
									if(friendlymove(row,i)){
										possible++;goto end;}
								}
							}
						}
						else if(col==arr[x].x) { 
							for(i=arr[z].y+1;i<row;i++) {
								if(board[i][col]==0) {
									if(friendlymove(i,col)){
										possible++;goto end;}
								}
							}
							for(i=arr[z].y-1;i>col;i--) {
								if(board[i][col]==0) {
									if(friendlymove(i,col)){
										possible++;goto end;}
								}
							}
						}
						break;
//.........这里部分代码省略.........
开发者ID:rasikabhave,项目名称:myminiproject,代码行数:101,代码来源:projecttrial.c

示例13: main


//.........这里部分代码省略.........
		WINDOW  *win = newwin(wid, len, 5, 1);

		box(win, 0, 0);

		wbkgd(win, COLOR_PAIR(1));

		wrefresh(win);

		wmove(win, y_curr, x_curr);

		refresh();


		cpid = fork();

		if(cpid == 0){
		// IF CHILD1, handle the OUTPUT WINDOW...

			char *msg;

		  output_start:
	
			msg = readNamedPipe();


			getyx(win, y_curr, x_curr);

			if(y_curr > y_max)
				y_curr = y_min;


			wmove(win, y_curr, x_curr);

			wprintw(win, msg);

			wrefresh(win);

			wmove(win, (y_curr+1), x_min);

			refresh();

	
			goto output_start;


		} else{
		// IF CHILD0, handle the INPUT WINDOW...

			/* NOTE: Remember how I created the OUTPUT WINDOW before the
			 *	  FORK?  Because that WINDOW now exists in both the
			 *	  context of CHILD0 and CHILD1, I'm going to delete
			 *	  it in CHILD0 before proceeding to the creation of
			 *	  the INPUT WINDOW.
			 *	 The reason I created the OUTPUT WINDOW first was
			 *	  because if it was initialized inside of CHILD1, it
			 *	  caused a protential issue where if CHILD0 finished
			 *	  creating the INPUT WINDOW before CHILD1 finished
			 *	  its WINDOW, it would affect the way the latter was
			 *	  being drawn. */

			delwin(win);


			// Create INPUT WINDOW:

			wid = 3;
开发者ID:kaethis,项目名称:CS3790_Assign02,代码行数:67,代码来源:scheduler.cpp

示例14: main

int main(int argc, char **argv){
	int i, sock;
//	struct timeval tv;
//	tv.tv_sec = 2;
//	tv.tv_usec = 500000;	
	
	initscr(); // Start curses mode.
	getmaxyx(stdscr, y, x); // Get max screen size.
	refresh(); // The refresh is just needed?
	win[0] = newwin(1, x, 0, (int)(x/2)); // Title window.
	win[1] = newwin(y-2, x, 1, 0); // Main window.
	win[2] = newwin(1, x, y-1, 0); // Input window.
	pan[0] = new_panel(win[0]);
	pan[1] = new_panel(win[1]);
	pan[2] = new_panel(win[2]);
	wprintw(win[0], "Title...");
	wprintw(win[1], "Server bullshit...\n");
	wprintw(win[2], "Input: ");
	update_panels(); // Put our panels in the right order.
	doupdate(); // Refresh them on the screen.
	
	struct sockaddr_in Sock_in;
	unsigned short port = 6969;
	char *servIP, send_buff[BUF], read_buff[BUF];
	servIP = "210.155.158.200";

	if((sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0)
		DieWithError("socket() failed.\n");
	print_win(win[1], "socket() successful\n");
	
	memset(&Sock_in, 0, sizeof(Sock_in));
	Sock_in.sin_family = AF_INET;
	Sock_in.sin_addr.s_addr = inet_addr(servIP);
	Sock_in.sin_port = htons(port);
	
	if(connect(sock, (struct sockaddr *) &Sock_in, sizeof(Sock_in)) < 0)
		DieWithError("connect() failed.\n");

	while(1){
		FD_ZERO(&Go_fd);
		FD_SET(0, &Go_fd);
		FD_SET(sock, &Go_fd);
		
		if(select(sock+1, &Go_fd, NULL, NULL, NULL) < 0)
			DieWithError("select() failed.\n");		

		if(FD_ISSET(sock, &Go_fd)){
			memset(&buf, 0, sizeof(buf));
			if(recv(sock, &buf, sizeof(buf)-1, 0) > 0) print_win(win[1], buf);
		}
		if(FD_ISSET(0, &Go_fd)){ // Check the socket.
			get_string(win[2]);
			sprintf(input, "%s\r", input);
			if(send(sock, &input, sizeof(input), 0) < sizeof(input))
					DieWithError("send() failed");
			print_win(win[1], input);
		}		
	}
	close(sock);
	endwin(); // Stop curses.
	return 0;
}
开发者ID:nuestand,项目名称:GoBan,代码行数:62,代码来源:n_sock.c

示例15: wprintw

void NWindowEditDigits::setValueDouble (double _val)
{
	wprintw (getWriteWindow (), "%f", _val);
}
开发者ID:jerryjiahaha,项目名称:rts2,代码行数:4,代码来源:nwindowedit.cpp


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