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


C++ Term_erase函数代码示例

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


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

示例1: do_cmd_snipe_browse

void do_cmd_snipe_browse(void)
{
    int n = 0;
    int j, line;
    char temp[62 * 4];

    screen_save();

    while(1)
    {
        /* get power */
        if (!get_snipe_power(&n, TRUE))
        {
            screen_load();
            return;
        }

        /* Clear lines, position cursor  (really should use strlen here) */
        Term_erase(12, 22, 255);
        Term_erase(12, 21, 255);
        Term_erase(12, 20, 255);
        Term_erase(12, 19, 255);
        Term_erase(12, 18, 255);

        roff_to_buf(snipe_tips[n], 62, temp, sizeof(temp));
        for(j = 0, line = 19; temp[j]; j += (1 + strlen(&temp[j])))
        {
            prt(&temp[j], line, 15);
            line++;
        }
    }
}
开发者ID:MichaelDiBernardo,项目名称:poschengband,代码行数:32,代码来源:sniper.c

示例2: askfor_aux

/**
 * Get some input at the cursor location.
 *
 * The buffer is assumed to have been initialized to a default string.
 * Note that this string is often "empty" (see below).
 *
 * The default buffer is displayed in yellow until cleared, which happens
 * on the first keypress, unless that keypress is Return.
 *
 * Normal chars clear the default and append the char.
 * Backspace clears the default or deletes the final char.
 * Return accepts the current buffer contents and returns true.
 * Escape clears the buffer and the window and returns false.
 *
 * Note that 'len' refers to the size of the buffer.  The maximum length
 * of the input is 'len-1'.
 *
 * 'keypress_h' is a pointer to a function to handle keypresses, altering
 * the input buffer, cursor position and suchlike as required.  See
 * 'askfor_aux_keypress' (the default handler if you supply NULL for
 * 'keypress_h') for an example.
 */
bool askfor_aux(char *buf, size_t len, bool (*keypress_h)(char *, size_t, size_t *, size_t *, struct keypress, bool))
{
    int y, x;

    size_t k = 0;		/* Cursor position */
    size_t nul = 0;		/* Position of the null byte in the string */

    struct keypress ch = KEYPRESS_NULL;

    bool done = false;
    bool firsttime = true;

    if (keypress_h == NULL)
        keypress_h = askfor_aux_keypress;

    /* Locate the cursor */
    Term_locate(&x, &y);

    /* Paranoia */
    if ((x < 0) || (x >= 80)) x = 0;

    /* Restrict the length */
    if (x + len > 80) len = 80 - x;

    /* Truncate the default entry */
    buf[len-1] = '\0';

    /* Get the position of the null byte */
    nul = strlen(buf);

    /* Display the default answer */
    Term_erase(x, y, (int)len);
    Term_putstr(x, y, -1, COLOUR_YELLOW, buf);

    /* Process input */
    while (!done) {
        /* Place cursor */
        Term_gotoxy(x + k, y);

        /* Get a key */
        ch = inkey();

        /* Let the keypress handler deal with the keypress */
        done = keypress_h(buf, len, &k, &nul, ch, firsttime);

        /* Update the entry */
        Term_erase(x, y, (int)len);
        Term_putstr(x, y, -1, COLOUR_WHITE, buf);

        /* Not the first time round anymore */
        firsttime = false;
    }

    /* Done */
    return (ch.code != ESCAPE);
}
开发者ID:pete-mack,项目名称:angband,代码行数:78,代码来源:ui-input.c

示例3: _list

static void _list(menu_ptr menu, char *keys)
{
    char temp[255];
    int  i;
    int  y = 1;
    int  x = 13;

    Term_erase(x, y, 255);

    if (menu->heading)
        put_str(format("     %s", menu->heading), y++, x);

    for (i = 0; i < menu->count; i++)
    {
        byte attr = TERM_WHITE;
        variant key, text, color;

        var_init(&key);
        var_init(&text);
        var_init(&color);

        menu->fn(MENU_KEY, i, menu->cookie, &key);
        if (var_is_null(&key))
            keys[i] = I2A(i);
        else
            keys[i] = (char)var_get_int(&key);

        if (menu->count <= 26)
            keys[i] = tolower(keys[i]);

        menu->fn(MENU_TEXT, i, menu->cookie, &text);
        if (var_is_null(&text))
            var_set_string(&text, "");

        menu->fn(MENU_COLOR, i, menu->cookie, &color);
        if (!var_is_null(&color))
            attr = var_get_int(&color);

        if (attr == TERM_DARK)
            keys[i] = '\0';

        sprintf(temp, "  %c) %s", keys[i], var_get_string(&text));
        c_prt(attr, temp, y + i, x);

        var_clear(&key);
        var_clear(&text);
        var_clear(&color);
    }
    Term_erase(x, y + menu->count, 255);
}
开发者ID:Alkalinear,项目名称:poschengband,代码行数:50,代码来源:menu.c

示例4: prt_mana

/**
 * Redraw the "monster mana bar"
 *
 * The "monster mana bar" provides visual feedback on the "mana"
 * of the monster currently being "tracked".  It follows the lead of the 
 * monster health bar for who to track.
 */
static void prt_mana(int row, int col)
{
    byte attr = TERM_SLATE;

    /* Not tracking */
    if (!p_ptr->health_who) {
	/* Erase the health bar */
	Term_erase(col, row, 12);
    }

    /* Tracking an unseen, hallucinatory, or dead monster */
    else if ((!m_list[p_ptr->health_who].ml) ||	/* Unseen */
	     (p_ptr->timed[TMD_IMAGE]) ||	/* Hallucination */
	     (m_list[p_ptr->health_who].hp < 0)) {	/* Dead (?) */
	/* The monster mana is "unknown" */
	Term_putstr(col, row, 12, attr, "[----------]");
    }

    /* Tracking a visible monster */
    else {
	int pct, len;

	monster_type *m_ptr = &m_list[p_ptr->health_who];
	monster_race *r_ptr = &r_info[m_ptr->r_idx];

	/* no mana, stop here */
	if (!r_ptr->mana) {
	    /* Erase the mana bar */
	    Term_erase(col, row, 12);

	    return;
	}

	attr = monster_mana_attr();

	/* Extract the "percent" of mana */
	pct = 100L * m_ptr->mana / r_ptr->mana;

	/* Convert percent into "mana" */
	len = (pct < 10) ? 1 : (pct < 90) ? (pct / 10 + 1) : 10;

	/* Default to "unknown" */
	Term_putstr(col, row, 12, TERM_WHITE, "[----------]");

	/* Dump the current "mana" (use '*' symbols) */
	Term_putstr(col + 1, row, len, attr, "**********");
    }
}
开发者ID:artes-liberales,项目名称:FAangband,代码行数:55,代码来源:xtra3.c

示例5: display_tiles

/*
 * Display tiles.
 */
static void display_tiles(int col, int row, int height, int width,
						  byte attr_top, byte char_left)
{
	int i, j;

	/* Clear the display lines */
	for (i = 0; i < height; i++)
		Term_erase(col, row + i, width);

	width = logical_width(width);
	height = logical_height(height);

	/* Display lines until done */
	for (i = 0; i < height; i++) {
		/* Display columns until done */
		for (j = 0; j < width; j++) {
			byte a;
			unsigned char c;
			int x = col + actual_width(j);
			int y = row + actual_height(i);
			int ia, ic;

			ia = attr_top + i;
			ic = char_left + j;

			a = (byte) ia;
			c = (unsigned char) ic;

			/* Display symbol */
			big_pad(x, y, a, c);
		}
	}
}
开发者ID:NickMcConnell,项目名称:FAangband,代码行数:36,代码来源:ui-knowledge.c

示例6: c_prt

/**
 * Display a string on the screen using an attribute, and clear to the
 * end of the line.
 */
void c_prt(byte attr, const char *str, int row, int col) {
	/* Clear line, position cursor */
	Term_erase(col, row, 255);

	/* Dump the attr/text */
	Term_addstr(-1, attr, str);
}
开发者ID:Elfin-Jedi,项目名称:My-Angband-4.0.5,代码行数:11,代码来源:ui-output.c

示例7: roff_top

/*
 * Hack -- Display the "name" and "attr/chars" of a monster race
 */
static void roff_top(const int r_idx, int m_idx)
{
	byte a1, a2;
	char c1, c2;

	char desc[80];
	monster_race *r_ptr = &r_info[r_idx];

	/* Describe the monster */
	if (m_idx)
	{
		/* Describe the monster */
		monster_desc(desc, sizeof(desc), m_idx, 0x80);

		/* Capitalise the first letter */
		if (islower(desc[0])) desc[0] = toupper(desc[0]);
	}
	/* Not describing a specific monster, so hack a description */
	else
	{
		/* Get the name */
		race_desc(desc, sizeof(desc), r_idx, 0x400, 1);
		
		/* Capitalise the first letter */
		if (islower(desc[0])) desc[0] = toupper(desc[0]);
	}

	/* Get the chars */
	c1 = r_ptr->d_char;
	c2 = r_ptr->x_char;

	/* Get the attrs */
	a1 = r_ptr->d_attr;
	a2 = r_ptr->x_attr;


	/* Clear the top line */
	Term_erase(0, 0, 255);

	/* Reset the cursor */
	Term_gotoxy(0, 0);

	/* Dump the name */
	Term_addstr(-1, TERM_WHITE, desc);

	if (!use_dbltile && !use_trptile)
	{
		/* Append the "standard" attr/char info */
		Term_addstr(-1, TERM_WHITE, " ('");
		Term_addch(a1, c1);
		Term_addstr(-1, TERM_WHITE, "')");

		/* Append the "optional" attr/char info */
		Term_addstr(-1, TERM_WHITE, "/('");
		Term_addch(a2, c2);
		if (use_bigtile && (a2 & 0x80)) Term_addch(255, -1);
		Term_addstr(-1, TERM_WHITE, "'):");
	}
}
开发者ID:BackupTheBerlios,项目名称:unangband-svn,代码行数:62,代码来源:monster1.c

示例8: clear_from

/**
 * Clear the bottom part of the screen
 */
void clear_from(int row)
{
    int y;

    /* Erase requested rows */
    for (y = row; y < Term->hgt; y++)
        Term_erase(0, y, 255);
}
开发者ID:pete-mack,项目名称:angband,代码行数:11,代码来源:ui-input.c

示例9: region_erase

void region_erase(const region *loc)
{
	region calc = region_calculate(*loc);
	int i = 0;

	for (i = 0; i < calc.page_rows; i++)
		Term_erase(calc.col, calc.row + i, calc.width);
}
开发者ID:BlackDragonB,项目名称:angband,代码行数:8,代码来源:ui.c

示例10: clear_question

/**
 * Clear the previous question
 */
static void clear_question(void)
{
	int i;

	for (i = QUESTION_ROW; i < TABLE_ROW; i++)
		/* Clear line, position cursor */
		Term_erase(0, i, 255);
}
开发者ID:danaris,项目名称:tgcangband,代码行数:11,代码来源:ui-birth.c

示例11: clear_region

/*
 * Clear a region of the screen, starting from (x,y1)
 * going to (255,y2)
 */
void clear_region(int x, int y1, int y2)
{
	int y;
	for (y = y1; (y < Term->hgt) && (y <= y2); y++)
	{
		/* Erase part of the screen */
		Term_erase(x, y, 255);
	}
}
开发者ID:jcheatham,项目名称:Zangband,代码行数:13,代码来源:ui.c

示例12: roff_top

/*
 * Hack -- Display the "name" and "attr/chars" of a monster race
 */
void roff_top(int r_idx)
{
    monster_race    *r_ptr = &r_info[r_idx];

    byte        a1, a2;
    char        c1, c2;


    /* Access the chars */
    c1 = r_ptr->d_char;
    c2 = r_ptr->x_char;

    /* Access the attrs */
    a1 = r_ptr->d_attr;
    a2 = r_ptr->x_attr;


    /* Clear the top line */
    Term_erase(0, 0, 255);

    /* Reset the cursor */
    Term_gotoxy(0, 0);

    /* A title (use "The" for non-uniques) */
    if (!(r_ptr->flags1 & RF1_UNIQUE))
    {
        Term_addstr(-1, TERM_WHITE, "The ");
    }

    /* Dump the name */
    Term_addstr(-1, TERM_WHITE, (r_name + r_ptr->name));

    /* Append the "standard" attr/char info */
    Term_addstr(-1, TERM_WHITE, " ('");
    Term_add_bigch(a1, c1);
    Term_addstr(-1, TERM_WHITE, "')");

    /* Append the "optional" attr/char info */
    Term_addstr(-1, TERM_WHITE, "/('");
    Term_add_bigch(a2, c2);
    Term_addstr(-1, TERM_WHITE, "'):");

    /* Wizards get extra info */
    if (p_ptr->wizard)
    {
        char buf[6];

        sprintf(buf, "%d", r_idx);

        Term_addstr(-1, TERM_WHITE, " (");
        Term_addstr(-1, TERM_L_BLUE, buf);
        Term_addch(TERM_WHITE, ')');
    }
}
开发者ID:GenericPseudonym,项目名称:pseudoelliposchengband,代码行数:57,代码来源:monster1.c

示例13: clear_from

/*
 * Clear part of the screen
 */
void clear_from(int row)
{
	int y;

	/* Erase requested rows */
	for (y = row; y < Term->hgt; y++)
	{
		/* Erase part of the screen */
		Term_erase(0, y, 255);
	}
}
开发者ID:Kilumanjaro,项目名称:angband,代码行数:14,代码来源:util.c

示例14: doc_sync_term

void doc_sync_term(doc_ptr doc, doc_region_t range, doc_pos_t term_pos)
{
    doc_pos_t pos;
    byte      selection_color = _INVALID_COLOR;

    assert(doc_region_is_valid(&range));

    if (doc_region_is_valid(&doc->selection))
    {
        doc_style_t style = *doc_current_style(doc);
        doc_style_f f = _get_doc_style_f(doc, "selection");
        if (f)
        {
            f(&style);
            selection_color = style.color;
        }
    }

    for (pos.y = range.start.y; pos.y <= range.stop.y; pos.y++)
    {
        int term_y = term_pos.y + (pos.y - range.start.y);
        int max_x = doc->width;

        pos.x = 0;
        if (pos.y == range.start.y)
            pos.x = range.start.x;
        if (pos.y == range.stop.y)
            max_x = range.stop.x;

        if (max_x > 0)
            Term_erase(term_pos.x + pos.x, term_y, doc->width - pos.x);
        if (pos.y <= doc->cursor.y)
        {
            doc_char_ptr cell = doc_char(doc, pos);
            for (; pos.x < max_x; pos.x++, cell++)
            {
                if (cell->c)
                {
                    int term_x = term_pos.x + pos.x;
                    byte         a = cell->a;

                    if ( selection_color != _INVALID_COLOR
                      && doc_region_contains(&doc->selection, pos) )
                    {
                        a = selection_color;
                    }
                    Term_putch(term_x, term_y, a, cell->c);
                }
            }
        }
    }
}
开发者ID:Alkalinear,项目名称:poschengband,代码行数:52,代码来源:z-doc.c

示例15: region_erase_bordered

void region_erase_bordered(const region *loc)
{
	region calc = region_calculate(*loc);
	int i = 0;

	calc.col = MAX(calc.col - 1, 0);
	calc.row = MAX(calc.row - 1, 0);
	calc.width += 2;
	calc.page_rows += 2;

	for (i = 0; i < calc.page_rows; i++)
		Term_erase(calc.col, calc.row + i, calc.width);
}
开发者ID:BlackDragonB,项目名称:angband,代码行数:13,代码来源:ui.c


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