src/ui-term.c
errr Term_keypress(keycode_t k, byte mods)
{
	/* Hack -- Refuse to enqueue non-keys */
	if (!k) return (-1);

	if(!Term->complex_input) {
		switch (k)
		{
			case '\r':
			case '\n':
			  	k = KC_ENTER;
			  	break;
			case 8:
			  	k = KC_BACKSPACE;
			  	break;
			case 9:
			  	k = KC_TAB;
			  	break;
			case 27:
			  	k = ESCAPE;
			  	break;
		}
	}

	/* Store the char, advance the queue */
	Term->key_queue[Term->key_head].type = EVT_KBRD;
	Term->key_queue[Term->key_head].key.code = k;
	Term->key_queue[Term->key_head].key.mods = mods;
	Term->key_head++;

	/* Circular queue, handle wrap */
	if (Term->key_head == Term->key_size) Term->key_head = 0;

	/* Success (unless overflow) */
	if (Term->key_head != Term->key_tail) return (0);

	/* Problem */
	return (1);
}
/**
 * Add a keypress to the "queue"
 */
Add a keypress to the "queue"
Add a keypress to the " queue "
errr Term_keypress(keycode_t k, byte mods)
{
	if (!k) return (-1);
	if(!Term->complex_input) {
		switch (k)
		{
			case '\r':
			case '\n':
			  	k = KC_ENTER;
			  	break;
			case 8:
			  	k = KC_BACKSPACE;
			  	break;
			case 9:
			  	k = KC_TAB;
			  	break;
			case 27:
			  	k = ESCAPE;
			  	break;
		}
	}
	Term->key_queue[Term->key_head].type = EVT_KBRD;
	Term->key_queue[Term->key_head].key.code = k;
	Term->key_queue[Term->key_head].key.mods = mods;
	Term->key_head++;
	if (Term->key_head == Term->key_size) Term->key_head = 0;
	if (Term->key_head != Term->key_tail) return (0);
	return (1);
}
errr Term_keypress ( keycode_t k , byte mods ) { if ( ! k ) return ( -1 ) ; if ( ! Term -> complex_input ) { switch ( k ) { case ' \r ' : case ' \n ' : k = KC_ENTER ; break ; case 8 : k = KC_BACKSPACE ; break ; case 9 : k = KC_TAB ; break ; case 27 : k = ESCAPE ; break ; } } Term -> key_queue [ Term -> key_head ] . type = EVT_KBRD ; Term -> key_queue [ Term -> key_head ] . key . code = k ; Term -> key_queue [ Term -> key_head ] . key . mods = mods ; Term -> key_head ++ ; if ( Term -> key_head == Term -> key_size ) Term -> key_head = 0 ; if ( Term -> key_head != Term -> key_tail ) return ( 0 ) ; return ( 1 ) ; }
Add a keypress to the "queue"
Add a keypress to the " queue "
/* Hack -- Refuse to enqueue non-keys */ /* Store the char, advance the queue */ /* Circular queue, handle wrap */ /* Success (unless overflow) */ /* Problem */