2013-03-01 1 views
2

배경을의 readline set_completion_display_matches_hook 내가 작성한 Readline 내 탭 완료 출력에 대한 사용자 지정 표시를 작성하는 것을 시도하고 프롬프트

안녕을 표시하기 전에 리턴 키가 필요합니다. 여기 내 display hook 기능 -

코드입니다

def match_display_hook(self, substitution, matches, longest_match_length): 
    print '' 
    for match in matches: 
     print match 
    readline.redisplay() 

질문

그러나 문제는 내가 기본 탭 완료 출력 위치를 달리 프롬프트를 얻기 위해 리턴 키를 눌러해야한다는 것입니다 나는 당장 프롬프트를 얻을 수있다. 나는 다른 스레드에서 누군가가 제안한 rl 모듈을 보았습니다 만, readline 자체를 통해 처리 할 수있는 방법이 없습니까?

답변

1

그래,이 방법을 고칠 수있는 방법인지는 모르겠다. 하지만 난 match_display_hook의 끝에 프롬프트 및 readline 버퍼를 인쇄하고 모두 잘하고 잘 보인다. 여기 내 새로운 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() 

이것은 잘 작동합니다.

+0

나를 위해 작동하지 않습니다 :/ –

+0

OSX 10.9.5에서 작동합니다 –