本文整理汇总了C++中rl_callback_read_char函数的典型用法代码示例。如果您正苦于以下问题:C++ rl_callback_read_char函数的具体用法?C++ rl_callback_read_char怎么用?C++ rl_callback_read_char使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rl_callback_read_char函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: postfl
void SC_TerminalClient::onInputRead(const boost::system::error_code &error, std::size_t bytes_transferred)
{
if (error == boost::asio::error::operation_aborted) {
postfl("SCLang Input: Quit requested\n");
return;
}
if (error == boost::asio::error::eof) {
postfl("SCLang Input: EOF. Will quit.\n");
onQuit(0);
return;
}
if (error) {
postfl("SCLang Input: %s.\n", error.message().c_str());
onQuit(1);
return;
}
if (!error) {
#if HAVE_READLINE
if (mUseReadline) {
rl_callback_read_char();
startInputRead();
return;
}
#endif
pushCmdLine( inputBuffer.data(), bytes_transferred );
}
}
示例2: select_loop
static void
select_loop(void)
{
int rv;
while (1)
{
FD_ZERO(&select_fds);
if (cstate != STATE_CMD_USER)
FD_SET(server_fd, &select_fds);
if (cstate != STATE_CMD_SERVER)
FD_SET(0, &select_fds);
rv = select(server_fd+1, &select_fds, NULL, NULL, NULL);
if (rv < 0)
{
if (errno == EINTR)
continue;
else
die("select: %m");
}
if (FD_ISSET(server_fd, &select_fds))
{
server_read();
update_state();
}
if (FD_ISSET(0, &select_fds))
{
rl_callback_read_char();
update_state();
}
}
}
示例3: readlineInit
void *SC_TerminalClient::readlineFunc( void *arg )
{
readlineInit();
SC_TerminalClient *client = static_cast<SC_TerminalClient*>(arg);
HANDLE hStdIn = GetStdHandle(STD_INPUT_HANDLE);
HANDLE hnds[] = { client->mQuitInputEvent, hStdIn };
bool shouldRun = true;
while (shouldRun) {
DWORD result = WaitForMultipleObjects( 2, hnds, false, INFINITE );
if( result == WAIT_FAILED ) {
postfl("readline: wait error.\n");
client->onQuit(1);
break;
}
int hIndex = result - WAIT_OBJECT_0;
if( hIndex == 0 ) {
postfl("readline: quit requested.\n");
break;
}
if( hIndex == 1 ) {
rl_callback_read_char();
}
}
postfl("readline: stopped.\n");
return NULL;
}
示例4: rl_callback_read_char_wrapper
/* Wrapper function for calling into the readline library. The event
loop expects the callback function to have a paramter, while
readline expects none. */
static void
rl_callback_read_char_wrapper (gdb_client_data client_data)
{
rl_callback_read_char ();
if (after_char_processing_hook)
(*after_char_processing_hook) ();
}
示例5: poll
static void poll( void )
{
fd_set rf, ef;
int n;
for(;;) {
FD_ZERO(&rf);
FD_ZERO(&ef);
if( !waiting ){
FD_SET( 0, &rf );
FD_SET( 0, &ef );
}
FD_SET( packet_fd, &rf );
FD_SET( packet_fd, &ef );
n = select( packet_fd + 1, &rf, 0, &ef, 0 );
if( n < 0 ) {
perror( "select" );
exit( EXIT_FAILURE );
}
if( FD_ISSET( 0, &rf ) || FD_ISSET( 0, &ef ))
rl_callback_read_char();
if( FD_ISSET( packet_fd, &rf ) || FD_ISSET( packet_fd, &ef ))
read_packet();
}
}
示例6: console_read_char
void
console_read_char(void)
{
#ifdef USE_READLINE
rl_callback_read_char();
#endif
}
示例7: displayCmdLine
char* displayCmdLine(WINDOW *win){
curs_set(2);
winCommandMode = win;
wmove (win, 1, 1);
//wprintw(winCommandMode, prompt);
wrefresh(win);
//rl_bind_key(RETURN, io_handle_enter);
rl_redisplay_function = (rl_voidfunc_t*)rl_redisplay_mod;
wprintw(winCommandMode, prompt);
char* line = readline(prompt);
add_history(line);
// for testing history
//line = readline(prompt);
wmove (win, 1, 11);
wprintw(winCommandMode, line);
wrefresh(win);
return line;
rl_callback_handler_install(prompt, handle_line);
while (prog_running) {
usleep(10);
rl_callback_read_char();
}
rl_callback_handler_remove();
//handle_command(rl_line_buffer);
return rl_line_buffer;
}
示例8: input_available_cb
gboolean
input_available_cb (GIOChannel *input, GIOCondition condition, gpointer data)
{
g_return_val_if_fail (condition == G_IO_IN, TRUE);
rl_callback_read_char ();
return TRUE;
}
示例9: cli_init
int cli_init(struct parser_state *_state)
{
const char *home;
rl_readline_name = "nft";
rl_instream = stdin;
rl_outstream = stdout;
rl_callback_handler_install("nft> ", cli_complete);
rl_attempted_completion_function = cli_completion;
home = getenv("HOME");
if (home == NULL)
home = "";
snprintf(histfile, sizeof(histfile), "%s/%s", home, CMDLINE_HISTFILE);
read_history(histfile);
history_set_pos(history_length);
state = _state;
scanner = scanner_init(state);
while (!eof)
rl_callback_read_char();
return 0;
}
示例10: rl_callback_handler_install
void *
ConsoleUI::threadMain(void *arg) {
rl_callback_handler_install("", ConsoleUICallbacks::lineRead);
while (!quit) {
while (canRead()) {
lineProcessed = false;
rl_callback_read_char();
if (lineProcessed && rl_prompt != NULL && rl_prompt[0] != '\0') {
// If a line has been processed, reset the prompt
// so we don't see it again after an Enter.
rl_set_prompt("");
rl_display_prompt = NULL;
rl_redisplay();
}
}
pthread_mutex_lock(&outputLock);
if (!output.empty()) {
processOutput();
pthread_cond_broadcast(&outputCond);
}
pthread_mutex_unlock(&outputLock);
usleep(10000);
}
rl_callback_handler_remove();
return NULL;
}
示例11: gdb_rl_callback_read_char_wrapper
static void
gdb_rl_callback_read_char_wrapper (gdb_client_data client_data)
{
struct gdb_exception gdb_expt = exception_none;
/* C++ exceptions can't normally be thrown across readline (unless
it is built with -fexceptions, but it won't by default on many
ABIs). So we instead wrap the readline call with a sjlj-based
TRY/CATCH, and rethrow the GDB exception once back in GDB. */
TRY_SJLJ
{
rl_callback_read_char ();
if (after_char_processing_hook)
(*after_char_processing_hook) ();
}
CATCH_SJLJ (ex, RETURN_MASK_ALL)
{
gdb_expt = ex;
}
END_CATCH_SJLJ
/* Rethrow using the normal EH mechanism. */
if (gdb_expt.reason < 0)
throw_exception (gdb_expt);
}
示例12: main
int
main (int c, char **v)
{
fd_set fds;
int r;
/* Install the line handler. */
rl_callback_handler_install (prompt, cb_linehandler);
/* Enter a simple event loop. This waits until something is available
to read on readline's input stream (defaults to standard input) and
calls the builtin character read callback to read it. It does not
have to modify the user's terminal settings. */
running = 1;
while (running)
{
FD_ZERO (&fds);
FD_SET (fileno (rl_instream), &fds);
r = select (FD_SETSIZE, &fds, NULL, NULL, NULL);
if (r < 0 && errno != EINTR)
{
perror ("rltest: select");
rl_callback_handler_remove ();
break;
}
if (FD_ISSET (fileno (rl_instream), &fds))
rl_callback_read_char ();
}
printf ("rltest: Event loop has exited\n");
return 0;
}
示例13: readline_until_enter_or_signal
static char *
readline_until_enter_or_signal(const char *prompt, int *signal)
{
char * not_done_reading = "";
fd_set selectset;
*signal = 0;
#ifdef HAVE_RL_CATCH_SIGNAL
rl_catch_signals = 0;
#endif
rl_callback_handler_install (prompt, rlhandler);
FD_ZERO(&selectset);
completed_input_string = not_done_reading;
while (completed_input_string == not_done_reading) {
int has_input = 0, err = 0;
while (!has_input)
{ struct timeval timeout = {0, 100000}; /* 0.1 seconds */
/* [Bug #1552726] Only limit the pause if an input hook has been
defined. */
struct timeval *timeoutp = NULL;
if (PyOS_InputHook)
timeoutp = &timeout;
FD_SET(fileno(rl_instream), &selectset);
/* select resets selectset if no input was available */
has_input = select(fileno(rl_instream) + 1, &selectset,
NULL, NULL, timeoutp);
err = errno;
if(PyOS_InputHook) PyOS_InputHook();
}
if (has_input > 0) {
rl_callback_read_char();
}
else if (err == EINTR) {
int s;
#ifdef WITH_THREAD
PyEval_RestoreThread(_PyOS_ReadlineTState);
#endif
s = PyErr_CheckSignals();
#ifdef WITH_THREAD
PyEval_SaveThread();
#endif
if (s < 0) {
rl_free_line_state();
rl_cleanup_after_signal();
rl_callback_handler_remove();
*signal = 1;
completed_input_string = NULL;
}
}
}
return completed_input_string;
}
示例14: cli_rl_stdin
int
cli_rl_stdin (int fd, int idx, void *data,
int poll_out, int poll_in, int poll_err)
{
rl_callback_read_char ();
return 0;
}
示例15: jl_readBuffer
void jl_readBuffer(char *base, ssize_t nread)
{
char *start = base;
while(*start != 0 && nread > 0) {
rl_stuff_char(*start);
start++;
nread--;
}
rl_callback_read_char();
}