static void quit(void) { restore(); restore_input(&org); erase_display(); pthread_mutex_destroy(&mut); pthread_cond_destroy(&cond); printf("\n"); exit(0); }
void TechBot::eventManager(std::string str) { SavePrevevent(); setEvent(str); Saveinput(); SetInput(str); if(!same_event()) { selectMatch(); } restore_input(); }
void CBot::handle_repetition() { if(response_list.size() > 0) { response_list.erase(response_list.begin()); } if(no_response()) { save_input(); set_input(m_sEvent); find_match(); restore_input(); } select_response(); }
void CBot::handle_event(std::string str) { save_prev_event(); set_event(str); save_input(); insert_space(str); set_input(str); if(!same_event()) { find_match(); } restore_input(); }
static void process_input(brl_t *brl) { unsigned char c; int mapped, type, in, n, diff; char out, *line, *hentry; while((n = read(brl->fd, &c, sizeof(c))) > 0) { if (brl->esc) { if (brl->seq_len < (int)sizeof(brl->seq)) brl->seq[brl->seq_len++] = c; if (brl->seq_len == 2) { if (c != '[') { mapped = map_esc_sequence(brl); brl->esc = FALSE; } else continue; } else { if (0x40 <= c && c <= 0x7e) { mapped = map_ctrl_sequence(brl); brl->esc = FALSE; } else { if (brl->seq_len == (int)sizeof(brl->seq)) { mapped = BRL_TYPE_INVALID; brl->esc = FALSE; } else continue; } } } else mapped = map_input(brl, c); type = BRL_INPUT_TYPE(mapped); in = BRL_INPUT_DATA(mapped); switch (type) { case BRL_TYPE_SELF: out = (char)(in & 0xff); insert_input(brl, &out, 1); redraw_prompt(brl); break; case BRL_TYPE_COMMAND: switch (in) { case BRL_CMD_PREV_LINE: if (brl->h.srch == 0) save_input(brl); hentry = ringbuf_search(&brl->h, -1, 0, (char *)brl->saved); debug(brl, "s:%d,'%s'", brl->h.srch, brl->saved ? brl->saved : "-"); if (hentry != NULL) { reset_input(brl); insert_input(brl, hentry, strlen(hentry)); redraw_prompt(brl); } else bell(brl); break; case BRL_CMD_NEXT_LINE: hentry = ringbuf_search(&brl->h, +1, 0, (char *)brl->saved); debug(brl, "s:%d,'%s'", brl->h.srch, brl->saved ? brl->saved : "-"); if (hentry != NULL) { if (hentry == brl->saved) restore_input(brl); else { reset_input(brl); insert_input(brl, hentry, strlen(hentry)); } redraw_prompt(brl); } else bell(brl); break; case BRL_CMD_BACKWARD: move_cursor(brl, -1); redraw_prompt(brl); break; case BRL_CMD_FORWARD: move_cursor(brl, +1); redraw_prompt(brl); break; case BRL_CMD_LINE_START: move_cursor(brl, -brl->offs); redraw_prompt(brl); break; case BRL_CMD_LINE_END: move_cursor(brl, brl->data - brl->offs); redraw_prompt(brl); break; case BRL_CMD_ERASE_BEFORE: erase_input(brl, -1); if (brl->offs < brl->data) move_cursor(brl, -1); redraw_prompt(brl); break; case BRL_CMD_ERASE_AT: erase_input(brl, 1); redraw_prompt(brl); break; case BRL_CMD_ERASE_REST: save_yank(brl, brl->offs, brl->data); erase_input(brl, brl->data - brl->offs); redraw_prompt(brl); break; case BRL_CMD_ERASE_ALL: save_yank(brl, 0, brl->data); reset_input(brl); redraw_prompt(brl); break; case BRL_CMD_YANK: insert_input(brl, (char *)brl->yank, brl->yank_data); redraw_prompt(brl); break; case BRL_CMD_PREV_WORD: diff = input_delimiter(brl, -1); move_cursor(brl, diff); redraw_prompt(brl); break; case BRL_CMD_NEXT_WORD: diff = input_delimiter(brl, +1); move_cursor(brl, diff); redraw_prompt(brl); break; case BRL_CMD_REDRAW: redraw_prompt(brl); break; case BRL_CMD_ENTER: dprintf(brl->fd, "\n\r"); if (brl->line_cb != NULL) { line = alloca(brl->data + 1); strncpy(line, (char *)brl->buf, brl->data); line[brl->data] = '\0'; reset_input(brl); restore_rawmode(brl); brl->line_cb(brl, line, brl->user_data); enable_rawmode(brl); ringbuf_reset_search(&brl->h); debug(brl, ""); redraw_prompt(brl); } else return; break; default: #if 0 printf("editing command 0x%x\n\r", in); #endif bell(brl); } break; case BRL_TYPE_CSEQ: brl->esc = TRUE; brl->seq[0] = c; brl->seq_len = 1; break; case BRL_TYPE_INVALID: default: bell(brl); break; } } }