示例#1
0
static bool askfor_aux_numbers(char *buf, size_t buflen, size_t *curs, size_t *len, struct keypress keypress, bool firsttime)
{
	switch (keypress.code)
	{
		case ESCAPE:
		case KC_ENTER:
		case ARROW_LEFT:
		case ARROW_RIGHT:
		case KC_DELETE:
		case KC_BACKSPACE:
		case '0':
		case '1':
		case '2':
		case '3':
		case '4':
		case '5':
		case '6':
		case '7':
		case '8':
		case '9':
			return askfor_aux_keypress(buf, buflen, curs, len, keypress, firsttime);
	}

	return FALSE;
}
示例#2
0
/**
 * A "keypress" handling function for askfor_aux, that handles the special
 * case of '*' for a new random "name" and passes any other "keypress"
 * through to the default "editing" handler.
 */
static bool get_name_keypress(char *buf, size_t buflen, size_t *curs,
                              size_t *len, struct keypress keypress,
                              bool firsttime)
{
    bool result;

    switch (keypress.code)
    {
    case '*':
    {
        *len = randname_make(RANDNAME_TOLKIEN, 4, 8, buf, buflen,
                             name_sections);
        my_strcap(buf);
        *curs = 0;
        result = false;
        break;
    }

    default:
    {
        result = askfor_aux_keypress(buf, buflen, curs, len, keypress,
                                     firsttime);
        break;
    }
    }

    return result;
}