bug-readline
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-readline] Async printing to stdout while preserving prompt


From: Hans Lub
Subject: Re: [Bug-readline] Async printing to stdout while preserving prompt
Date: Sun, 4 Oct 2009 15:22:14 +0200

Hi Julian

(from memory:)

You can use the callback interface (section 2.4.12 of the readline info) within a select() loop that watches both stdin and the source of your asynchronous information.

When select() returns with stdin readable, you just call rl_callback_read_char()
When it returns with your other descriptor readable, you can read, and display the information as you see fit (possibly using rl_message) 

If you moved the cursor you'll have to move it back to its original place, possibly with some "low level terminal interaction"  If you messed up the screen, you may have to call rl_redisplay()

I think this is about all there is to it.

Hans

2009/10/4 Julian Scheid <address@hidden>
I am working on a command line application with an input loop driven
by readline. The application can receive information asynchronously
(not in direct response to commands entered via stdin) and I would
like to display this information instantly while preserving the prompt
and any text entered by the user on the prompt so far - just like
<TAB><TAB> in bash will "push down" the prompt when printing available
completions. Is this possible and if so, how can I achieve this
without resorting to low-level terminal interaction?

I have read about rl_save_prompt() and rl_restore_prompt() as well as
rl_crlf() but it is unclear to me how I can clear the currently
displayed prompt, especially if the prompt spans multiple screen rows.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]