bobappleyard/readline — pull request #10 by knuesel (2012-10-26 13:39:45+00:00)
Title: Completion

Added a FilenameCompleter() function wrapping the corresponding functionality from readline. For example I have a completer function that uses it to get a list of files, and filter the list to keep only files with the desired extension. FilenameCompleter() could be implemented in Go, but wrapping the readline version ensures it behaves consistently with the library, e.g. can be configured through readline configuration.

I also removed the use of rl_completion_suppress_append, instead setting rl_completion_append_char to 0 (by default) or the value supplied by the user, for more flexibility.

Finally, simplified the code a bit, caling escapePrompt() systematically instead of exposing it to the user. I think the performance hit is insignificant and the API nicer this way. Also a 'reset' ANSI sequence is now always prefixed. This is a simple way to ensure the prompt is never corrupted by its own escape sequences after a resize or a completion display.