Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #32932 > unrolled thread

Re: how-to use readline.set_completion_display_matches_hook()?

Started byJean-Pierre Miceli <j-p@sunrise.ch>
First post2012-11-08 06:53 +0100
Last post2012-11-08 06:53 +0100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: how-to use readline.set_completion_display_matches_hook()? Jean-Pierre Miceli <j-p@sunrise.ch> - 2012-11-08 06:53 +0100

#32932 — Re: how-to use readline.set_completion_display_matches_hook()?

FromJean-Pierre Miceli <j-p@sunrise.ch>
Date2012-11-08 06:53 +0100
SubjectRe: how-to use readline.set_completion_display_matches_hook()?
Message-ID<mailman.3420.1352353985.27098.python-list@python.org>
Thanks,

I will try rl. 

Have a nice day
J-P

Le 7 nov. 2012 à 14:14, Stefan H. Holek a écrit :

> On 07.11.2012, at 11:36, Jean-Pierre Miceli wrote:
> 
>> Hi all,
>> 
>> I'm working on a tool which enable support of tab completion using the
>> readline modul.
>> And I have a problem with set_completion_display_matches_hook function
>> 
>> I've created a display hook function and registered it. It is called
>> and it prints the desire messages. But once it has completed,
>> readline/python does not display the prompt.
>> I've got to press the 'return' key to see the prompt again.
>> What should the display hook function do to return correctly and let
>> the prompt be displayed?
>> 
>> Example:
>> def completerHook(self, substitution, matches, longest_match_length):
>>   print ""
>>   print "Test of the display hook function"
>>   for i in range(len(matches)):
>>     print matches[i],
>> 
>> I use Python 2.7.3 and done some tests on Mac OS 10.7 (Lion) and
>> Ubuntu. I got the same issue on both system.
> 
> This always happens when you print newlines behind readline's back. To update the prompt area, you'd have to call rl_forced_update_display() which is AFAIK not exposed by the stdlib's readline bindings.
> 
> There is a more complete implementation of the GNU Readline APIs at http://pypi.python.org/pypi/rl. With rl you can fix the prompt by calling rl.readline.redisplay(force=True) after the hook has returned.
> 
> Hope this helps,
> Stefan
> 
> -- 
> Stefan H. Holek
> stefan@epy.co.at
> 

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web