From 5660cc8cb6f79191e08f1dff0e451d7a559509dd Mon Sep 17 00:00:00 2001 From: Cheney Date: Fri, 20 Nov 2015 11:26:58 +0800 Subject: [PATCH] example: change (Ctrl+C), (Ctrl+D) to shell-like --- example/main.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/example/main.go b/example/main.go index cc58e57..8a7d9eb 100644 --- a/example/main.go +++ b/example/main.go @@ -46,9 +46,11 @@ var completer = readline.NewPrefixCompleter( func main() { l, err := readline.NewEx(&readline.Config{ - Prompt: "\033[31m»\033[0m ", - HistoryFile: "/tmp/readline.tmp", - AutoComplete: completer, + Prompt: "\033[31m»\033[0m ", + HistoryFile: "/tmp/readline.tmp", + AutoComplete: completer, + InterruptPrompt: "\nInterrupt", + EOFPrompt: "exit", }) if err != nil { panic(err) @@ -58,7 +60,7 @@ func main() { log.SetOutput(l.Stderr()) for { line, err := l.Readline() - if err != nil { + if err == io.EOF { break } line = strings.TrimSpace(line)