void send_line(char dumb, char *dumber) { int server; WaitPrompt *OldPrompt; server = from_server; from_server = get_window_server(0); unhold_a_window(curr_scr_win); if (current_screen->promptlist && current_screen->promptlist->type == WAIT_PROMPT_LINE) { OldPrompt = current_screen->promptlist; (*OldPrompt->func) (OldPrompt->data, get_input()); set_input(empty_str); current_screen->promptlist = OldPrompt->next; new_free(&OldPrompt->data); new_free(&OldPrompt->prompt); new_free(&OldPrompt); change_input_prompt(-1); } else { char *line, *tmp = NULL; line = get_input(); if (line && (*line != get_int_var(CMDCHARS_VAR)) && get_int_var(NICK_COMPLETION_VAR)) { char auto_comp_char = ':'; if (!(auto_comp_char = (char) get_int_var(NICK_COMPLETION_CHAR_VAR))) auto_comp_char = ':'; /* possible nick completion */ if (strchr(line, auto_comp_char)) { char *p; struct channel *chan; struct nick_list *nick; char *channel; malloc_strcpy(&tmp, line); p = strchr(tmp, auto_comp_char); *p++ = 0; if (*tmp && *p && (channel = get_current_channel_by_refnum(0))) { chan = lookup_channel(channel, from_server, 0); for (nick = next_nicklist(chan, NULL); nick; nick = next_nicklist(chan, nick)) if (!my_strnicmp(tmp, nick->nick, strlen(tmp))) break; if (nick) { if (get_fset_var(FORMAT_NICK_COMP_FSET)) malloc_strcpy(&tmp, stripansicodes(convert_output_format (get_fset_var(FORMAT_NICK_COMP_FSET), "%s %s", nick->nick, p))); else malloc_sprintf(&tmp, "%s%c %s", nick->nick, auto_comp_char, p); } else malloc_strcpy(&tmp, line); } else malloc_strcpy(&tmp, line); } else malloc_strcpy(&tmp, line); } else malloc_strcpy(&tmp, line); if (do_hook(INPUT_LIST, "%s", tmp)) { if (get_int_var(INPUT_ALIASES_VAR)) parse_line(NULL, tmp, empty_str, 1, 0); else parse_line(NULL, tmp, NULL, 1, 0); } update_input(UPDATE_ALL); new_free(&tmp); } new_free(&input_lastmsg); *new_nick = 0; in_completion = STATE_NORMAL; from_server = server; }
/* * 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 */ }