/* type_text: the BIND function TYPE_TEXT */ void type_text(char c, char *str) { if (!str) return; for (; *str; str++) input_add_character(*str, empty_str); }
/* * edit_char: handles each character for an input stream. Not too difficult * to work out. */ void edit_char (u_char key) { u_char extended_key; WaitPrompt * oldprompt; u_char dummy[2]; int xxx_return = 0; /* XXXX Need i say more? */ if (dumb_mode) { #ifdef TIOCSTI ioctl(0, TIOCSTI, &key); #else say("Sorry, your system doesnt support 'faking' user input..."); #endif return; } /* were we waiting for a keypress? */ if (last_input_screen->promptlist && last_input_screen->promptlist->type == WAIT_PROMPT_KEY) { dummy[0] = key, dummy[1] = 0; oldprompt = last_input_screen->promptlist; last_input_screen->promptlist = oldprompt->next; (*oldprompt->func)(oldprompt->data, dummy); new_free(&oldprompt->data); new_free(&oldprompt->prompt); new_free((char **)&oldprompt); set_input(empty_string); change_input_prompt(-1); xxx_return = 1; } /* * This is only used by /pause to see when a keypress event occurs, * but not to impact how that keypress is handled at all. */ if (last_input_screen->promptlist && last_input_screen->promptlist->type == WAIT_PROMPT_DUMMY) { oldprompt = last_input_screen->promptlist; last_input_screen->promptlist = oldprompt->next; (*oldprompt->func)(oldprompt->data, NULL); new_free(&oldprompt->data); new_free(&oldprompt->prompt); new_free((char **)&oldprompt); } if (xxx_return) return; /* If the high bit is set, mangle it as neccesary. */ if (key & 0x80) { if (current_term->TI_meta_mode) { edit_char('\033'); key &= ~0x80; } else if (!term_eight_bit()) key &= ~0x80; } extended_key = key; /* If we just hit the quote character, add this character literally */ if (last_input_screen->quote_hit) { last_input_screen->quote_hit = 0; input_add_character(extended_key, empty_string); } /* Otherwise, let the keybinding system take care of the work. */ else { last_input_screen->last_key = handle_keypress( last_input_screen->last_key, last_input_screen->last_press, key); get_time(&last_input_screen->last_press); } }
/* * edit_char: handles each character for an input stream. Not too difficult * to work out. */ void edit_char(u_char key) { void (*func) (char, char *) = NULL; char *ptr = NULL; u_char extended_key; WaitPrompt *oldprompt; int meta_hit = 0, meta_not_hit; int i; /* were we waiting for a keypress? */ if (current_screen->promptlist && current_screen->promptlist->type == WAIT_PROMPT_KEY) { char key_[2] = "\0"; key_[0] = key; oldprompt = current_screen->promptlist; (*oldprompt->func) (oldprompt->data, key_); set_input(empty_str); current_screen->promptlist = oldprompt->next; new_free(&oldprompt->data); new_free(&oldprompt->prompt); new_free(&oldprompt); change_input_prompt(-1); return; } extended_key = key; /* Check to see if its an eight bit char and if we allow it */ if (!get_int_var(EIGHT_BIT_CHARACTERS_VAR)) key &= 0x7f; /* mask out non-ascii crap */ /* Check to see if this is a meta-key */ for (i = 1; i <= 9; i++) { if (current_screen->meta_hit[i]) { if (keys[i][key]) { func = key_names[keys[i][key]->key_index].func; ptr = keys[i][key]->stuff; } current_screen->meta_hit[i] = 0; meta_hit = 1; break; } } if (!meta_hit) { if (keys[0][key]) { func = key_names[keys[0][key]->key_index].func; ptr = keys[0][key]->stuff; } } /* is there a meta key that isnt still outstanding? */ meta_not_hit = 1; for (i = 1; i <= 3; i++) meta_not_hit = meta_not_hit && !current_screen->meta_hit[i]; for (i = 5; i <= 9; i++) meta_not_hit = meta_not_hit && !current_screen->meta_hit[i]; if (meta_not_hit) { /* did we just hit the quote character? */ if (current_screen->quote_hit) { current_screen->quote_hit = 0; input_add_character(extended_key, empty_str); } /* nope. none of these. just a regular character */ else if (func) func(extended_key, ptr ? ptr : empty_str); } else term_beep(); /* two metas in a row gets a beep */ }
void highlight_off(char c, char *dumber) { input_add_character(ALL_OFF, dumber); }
void insert_underline(char c, char *dumber) { input_add_character(UND_TOG, dumber); }
void insert_reverse(char c, char *dumber) { input_add_character(REV_TOG, dumber); }
/* These four functions are boomerang functions, which allow the highlight * characters to be bound by simply having these functions put in the * appropriate characters when you press any key to which you have bound * that highlight character. >;-) */ void insert_bold(char c, char *dumber) { input_add_character(BOLD_TOG, dumber); }