本文整理汇总了C++中rl_insert_text函数的典型用法代码示例。如果您正苦于以下问题:C++ rl_insert_text函数的具体用法?C++ rl_insert_text怎么用?C++ rl_insert_text使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rl_insert_text函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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);
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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");
}
示例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();
}
示例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;
}
示例11: set_deftext
static int
set_deftext ()
{
if (deftext)
{
rl_insert_text (deftext);
deftext = (char *)NULL;
rl_startup_hook = (Function *)NULL;
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}