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

Discussion in 'Python' started by Jean-Pierre Miceli, Nov 8, 2012.

  1. 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 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
    >
    >
    Jean-Pierre Miceli, Nov 8, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. gavino
    Replies:
    4
    Views:
    525
    gavino
    Sep 20, 2010
  2. Jean-Michel
    Replies:
    0
    Views:
    344
    Jean-Michel
    Dec 22, 2007
  3. Andrew DeFaria
    Replies:
    1
    Views:
    190
    Ben Morrow
    Jan 30, 2008
  4. Jean-Pierre Miceli
    Replies:
    0
    Views:
    157
    Jean-Pierre Miceli
    Nov 7, 2012
  5. Stefan H. Holek
    Replies:
    0
    Views:
    138
    Stefan H. Holek
    Nov 7, 2012
Loading...

Share This Page