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() {
|
func main() {
|
||||||
l, err := readline.NewEx(&readline.Config{
|
l, err := readline.NewEx(&readline.Config{
|
||||||
Prompt: "\033[31m»\033[0m ",
|
Prompt: "\033[31m»\033[0m ",
|
||||||
HistoryFile: "/tmp/readline.tmp",
|
HistoryFile: "/tmp/readline.tmp",
|
||||||
AutoComplete: completer,
|
AutoComplete: completer,
|
||||||
|
InterruptPrompt: "\nInterrupt",
|
||||||
|
EOFPrompt: "exit",
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
@ -58,7 +60,7 @@ func main() {
|
||||||
log.SetOutput(l.Stderr())
|
log.SetOutput(l.Stderr())
|
||||||
for {
|
for {
|
||||||
line, err := l.Readline()
|
line, err := l.Readline()
|
||||||
if err != nil {
|
if err == io.EOF {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
line = strings.TrimSpace(line)
|
line = strings.TrimSpace(line)
|
||||||
|
|
Loading…
Reference in New Issue