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