Background
Hi I am trying to write a custom display for my tab completion output in readline. Here is my display hook function-
Code
def match_display_hook(self, substitution, matches, longest_match_length):
print ''
for match in matches:
print match
readline.redisplay()
Question
But the problem is that I have to press the return key to get a prompt unlike the default tab completion output where I can get the prompt right away. I see rl module has been suggested by someone in another thread, but is there no way to get it done through readline itself?
Okay i found a way, not sure if this is the right way to fix it. But i printed the prompt and readline buffer at the end of the match_display_hook and all seems well and good. Here is my new match_display_hook:
def match_display_hook(self, substitution, matches, longest_match_length):
print ''
for match in matches:
print match
print self.prompt.rstrip(),
print readline.get_line_buffer(),
readline.redisplay()
This works well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With