• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ rl_callback_read_char函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中rl_callback_read_char函数的典型用法代码示例。如果您正苦于以下问题:C++ rl_callback_read_char函数的具体用法?C++ rl_callback_read_char怎么用?C++ rl_callback_read_char使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了rl_callback_read_char函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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 );
	}
}
开发者ID:Angeldude,项目名称:supercollider,代码行数:30,代码来源:SC_TerminalClient.cpp


示例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();
	}
    }
}
开发者ID:jpmuga,项目名称:bird,代码行数:35,代码来源:client.c


示例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;
}
开发者ID:dpalkowski,项目名称:iSuperColliderKit,代码行数:35,代码来源:SC_TerminalClient.cpp


示例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) ();
}
开发者ID:Xilinx,项目名称:gdb,代码行数:10,代码来源:event-top.c


示例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();
	}
}
开发者ID:noqsi,项目名称:NIPP,代码行数:28,代码来源:nipp_terminal.c


示例6: console_read_char

void
console_read_char(void)
{
#ifdef	USE_READLINE
	rl_callback_read_char();
#endif
}
开发者ID:LucasBe,项目名称:sendd,代码行数:7,代码来源:appconsole.c


示例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;
} 
开发者ID:prosbloom225,项目名称:mmpc,代码行数:31,代码来源:io.c


示例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;
}
开发者ID:rib,项目名称:Bosh,代码行数:7,代码来源:bosh-main.c


示例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;
}
开发者ID:FarK,项目名称:nf-nftables,代码行数:26,代码来源:cli.c


示例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;
}
开发者ID:puring0815,项目名称:OpenKore,代码行数:28,代码来源:consoleui.cpp


示例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);
}
开发者ID:Manishearth,项目名称:gdb,代码行数:25,代码来源:event-top.c


示例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;
}
开发者ID:FullStkDev,项目名称:bash,代码行数:34,代码来源:rl-callbacktest.c


示例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;
}
开发者ID:1564143452,项目名称:kbengine,代码行数:59,代码来源:readline.c


示例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;
}
开发者ID:lkundrak,项目名称:glusterfs,代码行数:8,代码来源:cli-rl.c


示例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();
}
开发者ID:HarlanH,项目名称:julia,代码行数:10,代码来源:repl-readline.c


示例16: stdin_read_callback

static void stdin_read_callback (evutil_socket_t fd, short what, void *arg) {
  if (!readline_disabled && !read_one_string) {
    rl_callback_read_char ();
    return;
  }
  if (read_one_string) {
    char c;
    int r = read (0, &c, 1);
    if (r <= 0) {
      perror ("read");
      delete_stdin_event = 1;
      return;
    }
    if (c == '\n' || c == '\r') {
      one_string[one_string_len] = 0;
      one_string_read_end ();
      return;
    }
    if (one_string_len < MAX_ONE_STRING_LEN) {
      one_string[one_string_len ++] = c;
      if (!(one_string_flags & 1)) {
        printf ("%c", c);
        fflush (stdout);
      }
    }
    return;
  }

  if (line_buffer_pos == line_buffer_size) {
    line_buffer = realloc (line_buffer, line_buffer_size * 2 + 100);
    assert (line_buffer);
    line_buffer_size = line_buffer_size * 2 + 100;
    assert (line_buffer);
  }
  int r = read (0, line_buffer + line_buffer_pos, line_buffer_size - line_buffer_pos);
  if (r <= 0) {
    perror ("read");
    delete_stdin_event = 1;
    return;
  }
  line_buffer_pos += r;

  while (1) {
    int p = 0;
    while (p < line_buffer_pos && line_buffer[p] != '\n') { p ++; }
    if (p < line_buffer_pos) {
      line_buffer[p] = 0;
      interpreter (line_buffer);
      memmove (line_buffer, line_buffer + p + 1, line_buffer_pos - p - 1);
      line_buffer_pos -= (p + 1);
    } else {
      break;
    }
  }
}
开发者ID:pwrtelegram,项目名称:tg,代码行数:55,代码来源:loop.c


示例17: stdin_read_callback_all

static void stdin_read_callback_all (int arg, short what, struct event *self) {
  if (!readline_disabled) {
    if (((long)arg) & 1) {
      rl_callback_read_char ();
    } else {
      char *line = 0;        
      size_t len = 0;
      assert (getline (&line, &len, stdin) >= 0);
      got_it (line, strlen (line));
    }
  } else {
    while (1) {
      if (line_buffer_pos == line_buffer_size) {
        line_buffer = realloc (line_buffer, line_buffer_size * 2 + 100);
        assert (line_buffer);
        line_buffer_size = line_buffer_size * 2 + 100;
        assert (line_buffer);
      }
      int r = read (0, line_buffer + line_buffer_pos, line_buffer_size - line_buffer_pos);
      //logprintf ("r = %d, size = %d, pos = %d, what = 0x%x, fd = %d\n", r, line_buffer_size, line_buffer_pos, (int)what, fd);
      if (r < 0) {
        perror ("read");
        delete_stdin_event = 1;
        break;
      }
      if (r == 0) {
        //struct event *ev = event_base_get_running_event (TLS->ev_base);
        //event_del (ev);
        //event_del (self);
        
        delete_stdin_event = 1;
        break;
      }
      line_buffer_pos += r;

      while (1) {
        int p = 0;
        while (p < line_buffer_pos && line_buffer[p] != '\n') { p ++; }
        if (p < line_buffer_pos) {
          if (((long)arg) & 1) {
            line_buffer[p] = 0;
            interpreter (line_buffer);
          } else {
            got_it (line_buffer, p + 1);
          }
          memmove (line_buffer, line_buffer + p + 1, line_buffer_pos - p - 1);
          line_buffer_pos -= (p + 1);
        } else {
          break;
        }
      }
      break;
    }
  }
}
开发者ID:AmesianX,项目名称:tg,代码行数:55,代码来源:loop.c


示例18: ncl_prv_kbinput_cb

static gboolean ncl_prv_kbinput_cb(GIOChannel *source, GIOCondition condition,
				   gpointer data)
{
	rl_callback_read_char();
#ifdef HAVE_LIBEDIT
	/* Editline bug workaround: handler install with the original prompt
	   corrects EL_UNBUFFERED state without side-effects. */
	rl_callback_handler_install(NCL_PROMPT, ncl_parse_line);
#endif
	return TRUE;
}
开发者ID:ABonnemains,项目名称:neardal,代码行数:11,代码来源:ncl.c


示例19: rline_rl_callback_read_char

int rline_rl_callback_read_char(struct rline *rline)
{
    if (!rline)
        return -1;

    /* Capture the last function used here.  */
    rline->rline_rl_last_func = rl_last_func;

    rl_callback_read_char();

    return 0;
}
开发者ID:cgdb,项目名称:cgdb,代码行数:12,代码来源:rline.cpp


示例20: prompt_read

static gboolean prompt_read(GIOChannel *chan, GIOCondition cond,
							gpointer user_data)
{
	if (cond & (G_IO_HUP | G_IO_ERR | G_IO_NVAL)) {
		g_io_channel_unref(chan);
		return FALSE;
	}

	rl_callback_read_char();

	return TRUE;
}
开发者ID:Hibati,项目名称:actuator,代码行数:12,代码来源:interactive.c



注:本文中的rl_callback_read_char函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ rl_dist函数代码示例发布时间:2022-05-30
下一篇:
C++ rl_callback_handler_remove函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap