Пример #1
0
/**
 * Keyhandler callback for processing player keystrokes while collecting the
 * query string. This stores typed characters into the conv_query buffer.
 *
 * @param kh is the keyhandler pushed for input handling.
 * @param key is the key the player just typed.
 * @returns 1 if the player is done entering the query, else 0.
 */
static int conv_get_player_query(struct KeyHandler *kh, int key, int keymod)
{
        int done = 0;

        if (console_handle_key(key, keymod)) {
                return 0;
        }

        switch (key) {
	case CANCEL:
                console_end();
		while (conv_ptr > conv_query) {
			conv_ptr--;
			*conv_ptr = 0;
			cmdwin_pop();
			conv_room++;
		}
                done = 1;
                break;
        case '\n':
                console_end();
                done = 1;
                break;
        case '\b':
                console_end();
		if (conv_ptr != conv_query) {
			conv_ptr--;
			*conv_ptr = 0;
			conv_room++;
			cmdwin_pop();
		}
                break;
        default:
                if (isprintable(key) 
                    && conv_room) {
                        console_end();
                        /* Print user input in console rather than cmdwin */
                        cmdwin_toggle_showcmd();
                        cmdwin_push("%c", key);
                        cmdwin_toggle_showcmd();
                        console_print("%c", key);
                        *conv_ptr++ = key;
                        conv_room--;
                }
                break;
        }

        return done;
}
Пример #2
0
static void recall()
{
        if( remempos == rememend ) // current position
        {
                buf[0][0] = '\0';
        }
        else
        {
                free(buf[0]);
                size[0] = strlen(rememory[remempos])+1;
                buf[0] = malloc(size[0]);
                strcpy(buf[0], rememory[remempos]);
        }

        console_end();
}