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

C++ rl_insert_text函数代码示例

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

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



在下文中一共展示了rl_insert_text函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: newline_callback

static int newline_callback(int count, int key) {
    if (!rl_point) return 0;
    spaces_suppressed = 0;
    rl_insert_text("\n");
    int i;
    for (i = 0; i < prompt_length; i++)
        rl_insert_text(" ");
    return 0;
}
开发者ID:BenoitKnecht,项目名称:julia,代码行数:9,代码来源:repl-readline.c


示例2: rl_vi_comment

/* Turn the current line into a comment in shell history.
   A K*rn shell style function. */
int
rl_vi_comment (int count, int key)
{
  rl_beg_of_line (0, 0);

  if (rl_vi_comment_begin != (char *)NULL)
    rl_insert_text (rl_vi_comment_begin);
  else
    rl_insert_text (VI_COMMENT_BEGIN_DEFAULT);	/* Default. */

  rl_redisplay ();
  rl_newline (1, '\n');
  return (0);
}
开发者ID:AOSC-Dev,项目名称:metahtml,代码行数:16,代码来源:vi_mode.c


示例3: suffix_translation

//------------------------------------------------------------------------------
static void suffix_translation()
{
    // readline's path completion may have appended a '/'. If so; flip it.

    char from;
    char* to;

    if (!rl_filename_completion_desired)
    {
        return;
    }

    if (g_slash_translation < 0)
    {
        return;
    }

    // Decide what direction we're going in.
    switch (g_slash_translation)
    {
    case 1:     from = '\\'; to = "/";  break;
    default:    from = '/';  to = "\\"; break;
    }

    // Swap the trailing slash, using Readline's API to maintain undo state.
    if ((rl_point > 0) && (rl_line_buffer[rl_point - 1] == from))
    {
        rl_delete_text(rl_point - 1, rl_point);
        --rl_point;
        rl_insert_text(to);
    }
}
开发者ID:HTshandou,项目名称:clink,代码行数:33,代码来源:rl.c


示例4: space_callback

static int space_callback(int count, int key)
{
    if (!rl_point) strip_initial_spaces++;
    else if (suppress_space()) spaces_suppressed++;
    else rl_insert_text(" ");
    return 0;
}
开发者ID:HarlanH,项目名称:julia,代码行数:7,代码来源:repl-readline.c


示例5: tab_callback

static int tab_callback(int count, int key) {
    if (!rl_point) {
        strip_initial_spaces += tab_width;
        return 0;
    }
    int i;
    for (i = line_start(rl_point); i < rl_point; i++) {
        if (rl_line_buffer[i] != ' ') {
            // do tab completion
            i = rl_point;
            rl_complete_internal('!');
            if (i < rl_point && rl_line_buffer[rl_point-1] == ' ') {
                rl_delete_text(rl_point-1, rl_point);
                rl_point = rl_point-1;
            }
            return 0;
        }
    }
    // indent to next tab stop
    if (suppress_space()) {
        spaces_suppressed += tab_width;
    } else {
        i = line_start(rl_point) + prompt_length;
        do { rl_insert_text(" "); } while ((rl_point - i) % tab_width);
    }
    return 0;
}
开发者ID:BenoitKnecht,项目名称:julia,代码行数:27,代码来源:repl-readline.c


示例6: paste_from_clipboard

//------------------------------------------------------------------------------
static int paste_from_clipboard(int count, int invoking_key)
{
    if (OpenClipboard(NULL) != FALSE)
    {
        HANDLE clip_data = GetClipboardData(CF_UNICODETEXT);
        if (clip_data != NULL)
        {
            wchar_t* from_clipboard = (wchar_t*)clip_data;
            char utf8[1024];

            WideCharToMultiByte(
                CP_UTF8, 0,
                from_clipboard, -1,
                utf8, sizeof(utf8),
                NULL, NULL
            );
            utf8[sizeof(utf8) - 1] = '\0';

            rl_insert_text(utf8);
        }

        CloseClipboard();
    }
    
    return 0;
}
开发者ID:hello-xk,项目名称:kiwi,代码行数:27,代码来源:clink_rl.c


示例7: _cmd_complete

static int
_cmd_complete(int all)
{
	char **argv = NULL;
	int argc = 0;
	int rc = 1;
	char *line = malloc(strlen(rl_line_buffer) + 2);
	if (!line) return -1;
	strcpy(line, rl_line_buffer);
	line[rl_point]   = 2;	/* empty character, will force a word */
	line[rl_point+1] = 0;

	if (tokenize_line(line, &argc, &argv) != 0)
		goto end;

	char *compl = commands_complete(root, argc, (const char **)argv, all);
	if (compl && strlen(argv[argc-1]) < strlen(compl)) {
		if (rl_insert_text(compl + strlen(argv[argc-1])) < 0) {
			free(compl);
			goto end;
		}
		free(compl);
		rc = 0;
		goto end;
	}
	/* No completion or several completion available. */
	fprintf(stderr, "\n");
	rl_forced_update_display();
	rc = 0;
end:
	free(line);
	tokenize_free(argc, argv);
	return rc;
}
开发者ID:ajufrancis,项目名称:lldpd,代码行数:34,代码来源:lldpcli.c


示例8: cli_handler_fn

static void cli_handler_fn(char *input)
{
	_shl_free_ char *original = input;
	_shl_strv_free_ char **args = NULL;
	int r;

	if (!input) {
		rl_insert_text("quit");
		rl_redisplay();
		rl_crlf();
		sd_event_exit(cli_event, 0);
		return;
	}

	r = shl_qstr_tokenize(input, &args);
	if (r < 0)
		return cli_vENOMEM();
	else if (!r)
		return;

	add_history(original);
	r = cli_do(cli_cmds, args, r);
	if (r != -EAGAIN)
		return;

	cli_printf("Command not found\n");
}
开发者ID:ValentinCupif,项目名称:MiraCle,代码行数:27,代码来源:ctl-cli.c


示例9: _rl_vi_stuff_insert

static void
_rl_vi_stuff_insert(int count)
{
  rl_begin_undo_group();
  while (count--)
    rl_insert_text(vi_insert_buffer);
  rl_end_undo_group();
}
开发者ID:cooljeanius,项目名称:apple-gdb-1824,代码行数:8,代码来源:vi_mode.c


示例10: insert_text

static PyObject *
insert_text(PyObject *self, PyObject *args)
{
	char *s;
	if (!PyArg_ParseTuple(args, "s:insert_text", &s))
		return NULL;
	rl_insert_text(s);
	Py_RETURN_NONE;
}
开发者ID:1310701102,项目名称:sl4a,代码行数:9,代码来源:readline.c


示例11: set_deftext

static int
set_deftext ()
{
  if (deftext)
    {
      rl_insert_text (deftext);
      deftext = (char *)NULL;
      rl_startup_hook = (Function *)NULL;
    }
}
开发者ID:OS2World,项目名称:LIB-GNU_Readline_library,代码行数:10,代码来源:rl.c


示例12: insert_text

static PyObject *
insert_text(PyObject *self, PyObject *args)
{
	char *s;
	if (!PyArg_ParseTuple(args, "s:insert_text", &s))
		return NULL;
	rl_insert_text(s);
	Py_INCREF(Py_None);
	return Py_None;
}
开发者ID:svinota,项目名称:cx,代码行数:10,代码来源:readline.c


示例13: set_deftext

static int
set_deftext (void)
{
	if (pre_input_deftext && rl_startup_hook) {
		rl_insert_text (pre_input_deftext);
		g_free (pre_input_deftext);
		pre_input_deftext = NULL;
		rl_startup_hook = NULL;
	}
	return 0;
}
开发者ID:GalliumOS,项目名称:network-manager,代码行数:11,代码来源:agent.c


示例14: nmc_rl_set_deftext

int
nmc_rl_set_deftext (void)
{
	if (nmc_rl_pre_input_deftext && rl_startup_hook) {
		rl_insert_text (nmc_rl_pre_input_deftext);
		g_free (nmc_rl_pre_input_deftext);
		nmc_rl_pre_input_deftext = NULL;
		rl_startup_hook = NULL;
	}
	return 0;
}
开发者ID:GalliumOS,项目名称:network-manager,代码行数:11,代码来源:common.c


示例15: set_deftext

static int
set_deftext ()
{
  if (deftext)
    {
      rl_insert_text (deftext);
      deftext = (char *)NULL;
      rl_startup_hook = (rl_hook_func_t *)NULL;
    }
  return 0;
}
开发者ID:FullStkDev,项目名称:bash,代码行数:11,代码来源:rl.c


示例16: insert_text

static PyObject *
insert_text(PyObject *self, PyObject *string)
{
    PyObject *encoded = encode(string);
    if (encoded == NULL) {
        return NULL;
    }
    rl_insert_text(PyBytes_AS_STRING(encoded));
    Py_DECREF(encoded);
    Py_RETURN_NONE;
}
开发者ID:3lnc,项目名称:cpython,代码行数:11,代码来源:readline.c


示例17: rl_vi_change_to

int
rl_vi_change_to(int count, int key)
{
  int c, start_pos;

  if (_rl_uppercase_p (key))
    rl_stuff_char ('$');
  else if (vi_redoing)
    rl_stuff_char (_rl_vi_last_motion);

  start_pos = rl_point;

  if (rl_vi_domove (key, &c))
    {
      rl_ding ();
      return -1;
    }

  /* These are the motion commands that do not require adjusting the
     mark.  c[wW] are handled by special-case code in rl_vi_domove(),
     and already leave the mark at the correct location. */
  if ((strchr (" l|hwW^0bB", c) == 0) && (rl_mark < rl_end))
    rl_mark++;

  /* The cursor never moves with c[wW]. */
  if ((_rl_to_upper (c) == 'W') && rl_point < start_pos)
    rl_point = start_pos;

  if (vi_redoing)
    {
      if (vi_insert_buffer && *vi_insert_buffer)
	rl_begin_undo_group ();
      rl_delete_text (rl_point, rl_mark);
      if (vi_insert_buffer && *vi_insert_buffer)
	{
	  rl_insert_text (vi_insert_buffer);
	  rl_end_undo_group ();
	}
    }
  else
    {
      rl_begin_undo_group ();		/* to make the `u' command work */
      rl_kill_text (rl_point, rl_mark);
      /* `C' does not save the text inserted for undoing or redoing. */
      if (_rl_uppercase_p (key) == 0)
        _rl_vi_doing_insert = 1;
      _rl_vi_set_last (key, count, rl_arg_sign);
      rl_vi_insertion_mode (1, key);
    }

  return (0);
}
开发者ID:cooljeanius,项目名称:apple-gdb-1824,代码行数:52,代码来源:vi_mode.c


示例18: getc_impl

//------------------------------------------------------------------------------
static int getc_impl(FILE* stream)
{
    int i;
    while (1)
    {
        wchar_t wc[2];
        char utf8[4];

        i = _getwch();
        if (i == 0)
        {
            i = 0xe0;
        }

        // treat esc like cmd.exe does - clear the line.
        if (i == 0x1b)
        {
            rl_delete_text(0, rl_end);
            rl_point = 0;
            display();
            continue;
        }

        if (i < 0x7f || i == 0xe0)
        {
            break;
        }

        // Convert to utf-8 and insert directly into rl's line buffer.
        wc[0] = (wchar_t)i;
        wc[1] = L'\0';

        WideCharToMultiByte(
            CP_UTF8, 0,
            wc, -1,
            utf8, sizeof(utf8),
            NULL,
            NULL
        );

        rl_insert_text(utf8);
        display();
    }

    // Set the "meta" key bit if the ALT key is pressed.
    if (GetAsyncKeyState(VK_MENU) & 0x8000)
    {
        i |= 0x80;
    }

    return i;
}
开发者ID:hello-xk,项目名称:kiwi,代码行数:53,代码来源:clink_rl.c


示例19: my_bind_cr

int my_bind_cr(int count, int key) {
    struct slre_cap caps[4];
    if (my_eoq == 1 || slre_match("(\\\\G|;)\\s*$", rl_line_buffer, strlen(rl_line_buffer), caps, 4, SLRE_IGNORE_CASE) > 0){
        rl_done = 1;
        return 1;
    } else if( slre_match("^(\\\\q|exit)$", rl_line_buffer, strlen(rl_line_buffer), caps, 4, 0) > 0) {
        rl_done = 1;exit_flag=1;
        return 1;
    }
    if (strcmp( rl_line_buffer , "") == 0 || slre_match("^\\s+$", rl_line_buffer, strlen(rl_line_buffer), caps, 4, 0) > 0) {
        printf("\n");
        rl_on_new_line();
    }else{
        rl_insert_text(" \n");
    }
    return 1;
}
开发者ID:hanhan1978,项目名称:mssql,代码行数:17,代码来源:mssql.c


示例20: readline_buffer_ext

static VALUE readline_buffer_ext(VALUE self, VALUE str){
  rb_secure(4);
  StringValue(str);

  if(rl_line_buffer == NULL)
    return Qnil;

#ifdef HAVE_RL_DELETE_TEXT
  rl_delete_text(0, rl_end);
#else
  rl_line_buffer[rl_end = 0] = '\0';
#endif
  rl_insert_text(RSTRING_PTR(str));
  rl_redisplay();

  return rb_str_new(rl_line_buffer, strlen(rl_line_buffer));
}
开发者ID:godfat,项目名称:readline_buffer,代码行数:17,代码来源:readline_buffer_ext.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ rl_printf函数代码示例发布时间:2022-05-30
下一篇:
C++ rl_free函数代码示例发布时间: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