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; }
/* * gets_interactive() * * Gets a line of interactive input, using readline if desired. * * prompt: the prompt string to be used * query_buf: buffer containing lines already read in the current command * (query_buf is not modified here, but may be consulted for tab completion) * * The result is a malloc'd string. * * Caller *must* have set up sigint_interrupt_jmp before calling. */ char * gets_interactive(const char *prompt, PQExpBuffer query_buf) { #ifdef USE_READLINE if (useReadline) { char *result; /* * Some versions of readline don't notice SIGWINCH signals that arrive * when not actively reading input. The simplest fix is to always * re-read the terminal size. This leaves a window for SIGWINCH to be * missed between here and where readline() enables libreadline's * signal handler, but that's probably short enough to be ignored. */ #ifdef HAVE_RL_RESET_SCREEN_SIZE rl_reset_screen_size(); #endif /* Make current query_buf available to tab completion callback */ tab_completion_query_buf = query_buf; /* Enable SIGINT to longjmp to sigint_interrupt_jmp */ sigint_interrupt_enabled = true; /* On some platforms, readline is declared as readline(char *) */ result = readline((char *) prompt); /* Disable SIGINT again */ sigint_interrupt_enabled = false; /* Pure neatnik-ism */ tab_completion_query_buf = NULL; return result; } #endif fputs(prompt, stdout); fflush(stdout); return gets_fromFile(stdin); }