本文整理汇总了C++中rl_redisplay函数的典型用法代码示例。如果您正苦于以下问题:C++ rl_redisplay函数的具体用法?C++ rl_redisplay怎么用?C++ rl_redisplay使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rl_redisplay函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: print_line
static void print_line(char *line)
{
char *saved_line = NULL;
int saved_point = 0;
/* This is readline stuff.
- save the cursor position
- save the current line contents
- set the line to blank
- tell readline we're done mucking
- print the message
- restore the standard prompt
- restore the line contents
- restore the cursor position
- tell readline we're done mucking (again)
*/
saved_point = rl_point;
saved_line = rl_copy_text(0, rl_end);
rl_set_prompt("");
rl_replace_line("",0);
rl_redisplay();
fprintf(stdout, "%s", line);
rl_set_prompt(PROMPT);
rl_replace_line(saved_line, 0);
rl_point = saved_point;
rl_redisplay();
free(saved_line);
}
开发者ID:abenson,项目名称:minitalk,代码行数:29,代码来源:minitalk.c
示例2: handle_enter
static int handle_enter(int x, int y)
{
char *line = NULL;
/* Handle when a user presses enter.
- Save the contents of the line.
- Set the prompt to nothing.
- Blank the line.
- pass the message to the message handler
- rl_copy_text returns malloc'd mem, so free it
- restore the prompt
- tell readline we're done mucking
*/
line = rl_copy_text(0, rl_end);
rl_set_prompt("");
rl_replace_line("", 1);
rl_redisplay();
handle_msg(line);
free(line);
rl_set_prompt(PROMPT);
rl_redisplay();
rl_done = 1;
return 0;
}
开发者ID:abenson,项目名称:minitalk,代码行数:28,代码来源:minitalk.c
示例3: cli_printv
void cli_printv(const char *fmt, va_list args)
{
SHL_PROTECT_ERRNO;
_shl_free_ char *line = NULL;
int point;
bool async;
/* In case we print messages during readline() activity, we need to
* correctly save and restore RL-internal state. */
async = is_cli() && !RL_ISSTATE(RL_STATE_DONE);
if (async) {
point = rl_point;
line = rl_copy_text(0, rl_end);
rl_save_prompt();
rl_replace_line("", 0);
rl_redisplay();
}
vprintf(fmt, args);
if (async) {
rl_restore_prompt();
rl_replace_line(line, 0);
rl_point = point;
rl_redisplay();
}
}
开发者ID:ValentinCupif,项目名称:MiraCle,代码行数:28,代码来源:ctl-cli.c
示例4: rl_copy_text
void Console::writeAsync(QString string)
{
int need_hack = (rl_readline_state & RL_STATE_READCMD) > 0;
char *saved_line = NULL;
int saved_point = 0;
if (need_hack)
{
saved_point = rl_point;
saved_line = rl_copy_text(0, rl_end);
rl_save_prompt();
rl_replace_line("", 0);
rl_redisplay();
}
std::cout << "\r" << string.toStdString();
if (need_hack)
{
rl_restore_prompt();
rl_replace_line(saved_line, 0);
rl_point = saved_point;
rl_redisplay();
free(saved_line);
}
}
开发者ID:wesen,项目名称:fatfs,代码行数:26,代码来源:console.cpp
示例5: PrintAndLog
void PrintAndLog(char *fmt, ...)
{
char *saved_line;
int saved_point;
va_list argptr, argptr2;
static FILE *logfile = NULL;
static int logging=1;
// lock this section to avoid interlacing prints from different threats
pthread_mutex_lock(&print_lock);
if (logging && !logfile) {
logfile=fopen(logfilename, "a");
if (!logfile) {
fprintf(stderr, "Can't open logfile, logging disabled!\n");
logging=0;
}
}
int need_hack = (rl_readline_state & RL_STATE_READCMD) > 0;
if (need_hack) {
saved_point = rl_point;
saved_line = rl_copy_text(0, rl_end);
rl_save_prompt();
rl_replace_line("", 0);
rl_redisplay();
}
va_start(argptr, fmt);
va_copy(argptr2, argptr);
vprintf(fmt, argptr);
printf(" "); // cleaning prompt
va_end(argptr);
printf("\n");
if (need_hack) {
rl_restore_prompt();
rl_replace_line(saved_line, 0);
rl_point = saved_point;
rl_redisplay();
free(saved_line);
}
if (logging && logfile) {
vfprintf(logfile, fmt, argptr2);
fprintf(logfile,"\n");
fflush(logfile);
}
va_end(argptr2);
if (flushAfterWrite == 1) //buzzy
{
fflush(NULL);
}
//release lock
pthread_mutex_unlock(&print_lock);
}
开发者ID:AlienDennis,项目名称:proxmark3-1,代码行数:58,代码来源:ui.c
示例6: printlog
void printlog(int c) {
char* saved_line;
int saved_point;
saved_point = rl_point;
saved_line = rl_copy_text(0, rl_end);
rl_set_prompt("");
rl_replace_line("", 0);
rl_redisplay();
//printf("Message: %d\n", c);
rl_set_prompt(prompt);
rl_replace_line(saved_line, 0);
rl_point = saved_point;
rl_redisplay();
free(saved_line);
}
开发者ID:prosbloom225,项目名称:mmpc,代码行数:15,代码来源:test.c
示例7: PrintAndLog
void PrintAndLog(char *fmt, ...)
{
char *saved_line;
int saved_point;
va_list argptr, argptr2;
static FILE *logfile = NULL;
static int logging=1;
if (logging && !logfile) {
logfile=fopen(logfilename, "a");
if (!logfile) {
fprintf(stderr, "Can't open logfile, logging disabled!\n");
logging=0;
}
}
int need_hack = (rl_readline_state & RL_STATE_READCMD) > 0;
if (need_hack) {
saved_point = rl_point;
saved_line = rl_copy_text(0, rl_end);
rl_save_prompt();
rl_replace_line("", 0);
rl_redisplay();
}
va_start(argptr, fmt);
va_copy(argptr2, argptr);
vprintf(fmt, argptr);
printf(" "); // cleaning prompt
va_end(argptr);
printf("\n");
if (need_hack) {
rl_restore_prompt();
rl_replace_line(saved_line, 0);
rl_point = saved_point;
rl_redisplay();
free(saved_line);
}
if (logging && logfile) {
vfprintf(logfile, fmt, argptr2);
fprintf(logfile,"\n");
fflush(logfile);
}
va_end(argptr2);
}
开发者ID:glocklueng,项目名称:proxmark3-lcd,代码行数:48,代码来源:ui.c
示例8: window_write
/*
* window_write()
*
* dopisuje liniê do bufora danego okna.
*/
int window_write(int id, const /*locale*/ char *line)
{
window_t *w = window_exist(id);
readline_window_t *r = readline_window(w);
int i = 1;
if (!line || !w)
return -1;
/* je¶li ca³y bufor zajêty, zwolnij pierwsz± liniê i przesuñ do góry */
if (r->line[MAX_LINES_PER_SCREEN - 1]) {
xfree(r->line[0]);
memmove(&(r->line[0]), &(r->line[1]), sizeof(char *) * (MAX_LINES_PER_SCREEN - 1));
r->line[MAX_LINES_PER_SCREEN - 1] = xstrdup(line);
} else {
/* znajd¼ pierwsz± woln± liniê i siê wpisz. */
for (i = 0; i < MAX_LINES_PER_SCREEN; i++)
if (!r->line[i]) {
r->line[i] = xstrdup(line);
break;
}
}
if (w != window_current) {
set_prompt(current_prompt());
rl_redisplay();
}
return 0;
}
开发者ID:AdKwiatkos,项目名称:ekg2,代码行数:35,代码来源:ui-readline.c
示例9: cli_rl_out
int
cli_rl_out (struct cli_state *state, const char *fmt, va_list ap)
{
int tmp_rl_point = rl_point;
int n = rl_end;
int i = 0;
int ret = 0;
if (rl_end >= 0 ) {
rl_kill_text (0, rl_end);
rl_redisplay ();
}
printf ("\r");
for (i = 0; i <= strlen (state->prompt); i++)
printf (" ");
printf ("\r");
ret = vprintf (fmt, ap);
printf ("\n");
fflush(stdout);
if (n) {
rl_do_undo ();
rl_point = tmp_rl_point;
rl_reset_line_state ();
}
return ret;
}
开发者ID:lkundrak,项目名称:glusterfs,代码行数:33,代码来源:cli-rl.c
示例10: async_printf
void
async_printf (const char *fmt, va_list ap)
{
int tmp_rl_point = rl_point;
int n = rl_end;
unsigned int i;
if (rl_end >= 0 ) {
rl_kill_text (0, rl_end);
rl_redisplay ();
}
printf ("\r");
for (i=0 ; i<=strlen (state.prompt) ; i++)
printf (" ");
printf ("\r");
vprintf (fmt, ap);
printf ("\n");
fflush(stdout);
if (n) {
rl_do_undo ();
rl_point = tmp_rl_point;
rl_reset_line_state ();
}
rl_forced_update_display ();
}
开发者ID:avati,项目名称:freetalk,代码行数:25,代码来源:util.c
示例11: match_paren
static int
match_paren(int x, int k)
{
int tmp;
fd_set readset;
struct timeval timeout;
rl_insert(x, k);
/* Did we just insert a quoted paren? If so, then don't bounce. */
if (rl_point - 1 >= 1
&& rl_line_buffer[rl_point - 2] == '\\')
return 0;
/* tmp = 200000 */
timeout.tv_sec = 0 /* tmp / 1000000 */ ;
timeout.tv_usec = 200000 /* tmp % 1000000 */ ;
FD_ZERO(&readset);
FD_SET(fileno(rl_instream), &readset);
if(rl_point > 1) {
tmp = rl_point;
rl_point = find_matching_paren(k);
if(rl_point > -1) {
rl_redisplay();
select(1, &readset, NULL, NULL, &timeout);
}
rl_point = tmp;
}
return 0;
}
开发者ID:bsmr-linux-window-manager,项目名称:librep,代码行数:32,代码来源:readline.c
示例12: edit_deinit
void edit_deinit(const char *history_file,
int (*filter_cb)(void *ctx, const char *cmd))
{
rl_set_prompt("");
rl_replace_line("", 0);
rl_redisplay();
rl_callback_handler_remove();
readline_free_completions();
eloop_unregister_read_sock(STDIN_FILENO);
if (history_file) {
/* Save command history, excluding lines that may contain
* passwords. */
HIST_ENTRY *h;
history_set_pos(0);
while ((h = current_history())) {
char *p = h->line;
while (*p == ' ' || *p == '\t')
p++;
if (filter_cb && filter_cb(edit_cb_ctx, p)) {
h = remove_history(where_history());
if (h) {
free(h->line);
free(h->data);
free(h);
} else
next_history();
} else
next_history();
}
write_history(history_file);
}
}
开发者ID:0x000000FF,项目名称:wpa_supplicant_for_edison,代码行数:34,代码来源:edit_readline.c
示例13: io_handle_enter
int io_handle_enter(int x, int y) {
char* line = NULL;
line = rl_copy_text(0, rl_end);
rl_set_prompt("");
rl_replace_line("", 1);
rl_redisplay();
//cmd_execute(line);
if (strcmp(line, "") != 0) {
add_history(line);
}
free(line);
/* rl_set_prompt(prompt); */
/* rl_redisplay(); */
// wip - clear line on enter
wmove(winCommandMode, 1, 1);
//wprintw(winCommandMode, " ");
wclrtoeol(winCommandMode);
wmove(winCommandMode, 1, 1);
wprintw(winCommandMode, ">");
wrefresh(winCommandMode);
/* force readline to think that the current line was "eaten" and executed */
rl_done = 1;
return 0;
}
开发者ID:prosbloom225,项目名称:mmpc,代码行数:31,代码来源:io.c
示例14: 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
示例15: redisplay
static PyObject *
redisplay(PyObject *self, PyObject *noarg)
{
rl_redisplay();
Py_INCREF(Py_None);
return Py_None;
}
开发者ID:pruan,项目名称:TestDepot,代码行数:7,代码来源:readline.c
示例16: cli_destroy
void cli_destroy(void)
{
unsigned int i;
if (!cli_event)
return;
if (cli_rl) {
cli_rl = false;
rl_replace_line("", 0);
rl_crlf();
rl_on_new_line();
rl_redisplay();
rl_message("");
rl_callback_handler_remove();
}
sd_event_source_unref(cli_stdin);
cli_stdin = NULL;
for (i = 0; cli_sigs[i]; ++i) {
sd_event_source_unref(cli_sigs[i]);
cli_sigs[i] = NULL;
}
cli_cmds = NULL;
sd_bus_detach_event(cli_bus);
cli_bus = NULL;
sd_event_unref(cli_event);
cli_event = NULL;
}
开发者ID:ValentinCupif,项目名称:MiraCle,代码行数:33,代码来源:ctl-cli.c
示例17: cli_rl_err
int
cli_rl_err (struct cli_state *state, const char *fmt, va_list ap)
{
int tmp_rl_point = rl_point;
int n = rl_end;
int ret = 0;
if (rl_end >= 0 ) {
rl_kill_text (0, rl_end);
rl_redisplay ();
}
fprintf (stderr, "\r%*s\r", (int)strlen (state->prompt), "");
ret = vfprintf (stderr, fmt, ap);
fprintf (stderr, "\n");
fflush(stderr);
if (n) {
rl_do_undo ();
rl_point = tmp_rl_point;
rl_reset_line_state ();
}
return ret;
}
开发者ID:YanyunGao,项目名称:glusterfs,代码行数:27,代码来源:cli-rl.c
示例18: input_stop_list
void
input_stop_list(void)
{
/* Reprint the currently edited line after listing */
rl_on_new_line();
rl_redisplay();
}
开发者ID:Oryon,项目名称:bird-ext-lsa,代码行数:7,代码来源:birdc.c
示例19: rl_callback_handler_remove
char *ssc_input_read_string(char *str, int size)
{
#if USE_READLINE
char *input;
/* disable readline callbacks */
if (ssc_input_handler_f)
rl_callback_handler_remove();
rl_reset_line_state();
/* read a string a feed to 'str' */
input = readline(ssc_input_prompt);
strncpy(str, input, size - 1);
str[size - 1] = 0;
/* free the copy malloc()'ed by readline */
free(input);
/* reinstall the func */
if (ssc_input_handler_f)
rl_callback_handler_install(ssc_input_prompt, ssc_input_handler_f);
rl_redisplay();
return str;
#else
return fgets(str, size, stdin);
#endif
}
开发者ID:KerwinMa,项目名称:restcomm-ios-sdk,代码行数:30,代码来源:ssc_input.c
示例20: rl_printf
void rl_printf(const char *fmt, ...)
{
va_list args;
bool save_input;
char *saved_line;
int saved_point;
save_input = !RL_ISSTATE(RL_STATE_DONE);
if (save_input) {
saved_point = rl_point;
saved_line = rl_copy_text(0, rl_end);
rl_save_prompt();
rl_replace_line("", 0);
rl_redisplay();
}
va_start(args, fmt);
vprintf(fmt, args);
va_end(args);
if (save_input) {
rl_restore_prompt();
rl_replace_line(saved_line, 0);
rl_point = saved_point;
rl_forced_update_display();
free(saved_line);
}
}
开发者ID:AlanApter,项目名称:steamlink-sdk,代码行数:29,代码来源:display.c
注:本文中的rl_redisplay函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论