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: Chet Ramey
Subject: Re: [Bug-readline] Async printing to stdout while preserving prompt
Date: Sun, 04 Oct 2009 13:05:47 -0400
User-agent: Thunderbird 2.0.0.23 (Macintosh/20090812)

Julian Scheid wrote:
> 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.

In general, you don't want to if the prompt contains newlines -- you just
want to clear the portion after the final newline, since that's all
readline is going to consider and use.  If it doesn't and the prompt is
just too long for the current screen width, you can use something like
rl_forced_update_display or rl_refresh_line after saving and restoring
the prompt.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/




reply via email to

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