int dcli_get_input_string( dcli_sChannel *chn, char *out_string, unsigned long *out_terminator, int out_maxlen, dcli_sRecall *recall, unsigned long option, int timeout, int (* timeout_func) (), void *timeout_arg, const char *prompt) { char input_str[200]; char out_str[200]; char dum_str[200]; int maxlen = 199; unsigned long terminator; int index; int recall_index = 0; if ( prompt != NULL) #if defined OS_VMS r_print( chn, "\n%s", prompt); #else r_print( chn, "%s", prompt); #endif terminator = 0; index = 0; out_str[0] = 0; while ( 1) { dcli_get_input( chn, input_str, &terminator, maxlen, option, timeout); if (terminator == DCLI_K_RETURN) break; if ((terminator == DCLI_K_ARROW_LEFT) && ((option & DCLI_OPT_NOEDIT) != 0)) break; if ((terminator == DCLI_K_ARROW_RIGHT) && ((option & DCLI_OPT_NOEDIT) != 0)) break; if ((terminator == DCLI_K_DELETE) && ((option & DCLI_OPT_NOEDIT) != 0)) break; if ((terminator == DCLI_K_BACKSPACE) && ((option & DCLI_OPT_NOEDIT) != 0)) break; if ((terminator == DCLI_K_ARROW_UP) && ((option & DCLI_OPT_NORECALL) != 0)) break; if ((terminator == DCLI_K_ARROW_DOWN) && ((option & DCLI_OPT_NORECALL) != 0)) break; if ((terminator == DCLI_K_TIMEOUT) && ((option & DCLI_OPT_NOEDIT) != 0)) { if ( timeout_func != NULL) (timeout_func) ( timeout_arg); else break; } if ( (option & DCLI_OPT_NOEDIT) == 0) { switch ( terminator) { case DCLI_K_TIMEOUT: strcpy( dum_str, (char *) &out_str[index]); strcpy( (char *) &out_str[index], input_str); index += strlen(input_str); strcpy( (char *) &out_str[index], dum_str); if ( timeout_func != NULL) { store_cursorpos( chn); (timeout_func) ( timeout_arg); restore_cursorpos( chn); } break; case DCLI_K_ARROW_LEFT: strcpy( dum_str, (char *) &out_str[index]); strcpy( &out_str[index], input_str); index += strlen(input_str); strcpy( &out_str[index], dum_str); if ( index > 0) { index--; cursor_rel( chn, 0, -1); } break; case DCLI_K_ARROW_RIGHT: strcpy( dum_str, (char *) &out_str[index]); strncpy( (char *) &out_str[index], input_str, strlen(input_str)); index += strlen(input_str); strcpy( (char *) &out_str[index], dum_str); if ( index < (int)strlen( out_str)) { index++; cursor_rel( chn, 0, 1); } break; case DCLI_K_BACKSPACE: strcpy( dum_str, (char *) &out_str[index]); strncpy( &out_str[index], input_str, strlen(input_str)); index += strlen(input_str); strcpy( &out_str[index], dum_str); if ( index > 0) { cursor_rel( chn, 0, - index); index = 0; } break; case DCLI_K_DELETE: strcpy( dum_str, (char *) &out_str[index]); strncpy( &out_str[index], input_str, strlen(input_str)); index += strlen(input_str); strcpy( &out_str[index], dum_str); if ( index > 0) { strcpy( dum_str, &out_str[index]); index--; cursor_rel( chn, 0, -1); strcpy( &out_str[index], dum_str); char_delete( chn, 1); } break; } } if ( (option & DCLI_OPT_NORECALL) == 0) { switch ( terminator) { case DCLI_K_ARROW_UP: if ( !recall) break; index += strlen(input_str); recall_index++; if ( recall_index > DCLI_RECALL_MAX) recall_index = DCLI_RECALL_MAX + 1; dcli_recall_getcommand( recall, recall_index - 1, out_str); cursor_rel( chn, 0, -index); eofline_erase( chn); index = strlen(out_str); r_print( chn,"%s", out_str); break; case DCLI_K_ARROW_DOWN: if ( !recall) break; index += strlen(input_str); recall_index--; if ( recall_index < 0) recall_index = 0; dcli_recall_getcommand( recall, recall_index - 1, out_str); cursor_rel( chn, 0, -index); eofline_erase( chn); index = strlen( out_str); r_print( chn,"%s", out_str); break; } } } strcpy( dum_str, (char *) &out_str[index]); strncpy( &out_str[index], input_str, strlen(input_str)); index += strlen(input_str); strcpy( &out_str[index], dum_str); strcpy( out_string, out_str); if ( (option & DCLI_OPT_NORECALL) == 0) { /* Save in recall buffer */ recall_index = 0; dcli_recall_insert( recall, out_string); } *out_terminator = terminator; return DCLI__SUCCESS; }
void game_delete() { map_delete(); char_delete(); }