static void DaoSignalHandler( int sig ) { #ifdef DAO_WITH_THREAD if( ! DThread_IsMain() ) return; #endif DaoVmSpace_Stop( vmSpace, 1); if( count ++ ) exit(1); count += 1; if( readingline ){ printf( "\n" ); #ifdef DAO_USE_READLINE if( rl_end ==0 ) printf( "type \"q\" to quit.\n" ); #ifndef MACOSX rl_replace_line( "", 0 ); rl_forced_update_display(); #else rl_reset_terminal( "" ); #endif #endif }else{ printf( "keyboard interrupt...\n" ); } }
static int handle_reset_cmd(CONN_TYPE * conn, const char *arg, cmd_params_st *params) { rl_reset_terminal(NULL); #ifdef HAVE_ORIG_READLINE rl_reset_screen_size(); #endif return 0; }
void ssc_input_reset(void) { #if USE_READLINE rl_reset_terminal(NULL); #else /* nop */ #endif }
void console_exit(void) { #ifdef USE_READLINE rl_callback_handler_remove(); #if RL_VERSION_MAJOR >= 4 rl_cleanup_after_signal(); #endif rl_reset_terminal(NULL); #endif }
static void handle_rlinput(char *rd) { if (rd == NULL) { exit_handler(); #if RL_VERSION_MAJOR >= 4 rl_cleanup_after_signal(); #endif rl_reset_terminal(NULL); #ifdef THREADS pthread_exit(NULL); #else exit(0); #endif } if (*rd != 0) { add_history(rd); } docmd(rd); free(rd); }
// // Function: cmdInputCleanup // // Cleanup the input stream by free-ing the last malloc-ed data // and cleaning up the readline library interface // void cmdInputCleanup(cmdInput_t *cmdInput) { // Add previous read to history when applicable if (cmdInput->readMethod == CMD_INPUT_READLINELIB) { if (cmdInput->input != NULL && (cmdInput->input)[0] != '\0' && (cmdInput->input)[0] != '\n') add_history(cmdInput->input); } // Cleanup previous read if (cmdInput->input != NULL) { free(cmdInput->input); cmdInput->input = NULL; } // Cleanup the readline interface if (cmdInput->readMethod == CMD_INPUT_READLINELIB) { rl_deprep_terminal(); rl_reset_terminal(NULL); } }
/* Createing and Destroying a librline context. {{{*/ struct rline* rline_initialize (int slavefd, command_cb *command, completion_cb *completion, char *TERM) { struct rline *rline = (struct rline*)malloc (sizeof(struct rline)); if (!rline) return NULL; /* Initialize each member variable */ rline->input = NULL; rline->output = NULL; rline->input = fdopen (slavefd, "r"); if (!rline->input) { rline_shutdown (rline); return NULL; } rline->output = fdopen (slavefd, "w"); if (!rline->output) { rline_shutdown (rline); return NULL; } rline->tab_completion = completion; rline->rline_rl_last_func = NULL; rline->rline_rl_completion_query_items = rl_completion_query_items; rl_readline_name = "cgdb"; rl_instream = rline->input; rl_outstream = rline->output; /* Tell readline not to put the initial prompt */ rl_already_prompted = 1; /* Tell readline not to catch signals */ rl_catch_signals = 0; rl_catch_sigwinch = 0; /* Tell readline what the prompt is if it needs to put it back */ rl_callback_handler_install("(gdb) ", command); rl_bind_key ('\t', completion); /* Set the terminal type to dumb so the output of readline can be * understood by tgdb */ if (rl_reset_terminal (TERM) == -1) { rline_shutdown (rline); return NULL; } /* For some reason, readline can not deprep the terminal. * However, it doesn't matter because no other application is working on * the terminal besides readline */ rl_deprep_term_function = custom_deprep_term_function; /* These variables are here to make sure readline doesn't * attempt to query the user to determine if it wants more input. */ rl_completion_query_items = -1; rl_variable_bind ("page-completions", "0"); rl_completer_word_break_characters = " \t\n!@#$%^&*()+=|~`}{[]\"';:?/>.<,-"; rl_completer_quote_characters = "'"; return rline; }
static void tty_info(void) { rl_reset_terminal(NULL); }