mirror of https://github.com/chzyer/readline.git
example: change (Ctrl+C), (Ctrl+D) to shell-like
This commit is contained in:
parent
db2e5eae91
commit
5660cc8cb6
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue