update README

This commit is contained in:
Cheney 2015-09-26 01:06:47 +08:00
parent 75bbfa6d42
commit 1ff4e718ab
1 changed files with 35 additions and 2 deletions

View File

@ -19,7 +19,6 @@ You can read the source code in [example/main.go](https://github.com/chzyer/read
# Todo # Todo
* Auto Completion
* Vim mode * Vim mode
* Transpose words * Transpose words
* More funny examples * More funny examples
@ -97,6 +96,40 @@ for {
} }
``` ```
* Example with auto completion
```go
import (
"log"
"github.com/chzyer/readline"
)
var completer = readline.NewPrefixCompleter(
readline.PcItem("say",
readline.PcItem("hello"),
readline.PcItem("bye"),
),
readline.PcItem("help"),
)
rl, err := readline.New(&readline.Config{
Prompt: "> ",
AutoComplete: completer,
})
if err != nil {
panic(err)
}
defer rl.Close()
for {
line, err := rl.Readline()
if err != nil { // io.EOF
break
}
println(line)
}
```
# Shortcut # Shortcut
@ -116,7 +149,7 @@ Users can change that in terminal simulator(i.e. iTerm2) to `Alt`+`B`
| `Meta`+`F` | Forward one word | Yes | | `Meta`+`F` | Forward one word | Yes |
| `Ctrl`+`G` | Cancel | Yes | | `Ctrl`+`G` | Cancel | Yes |
| `Ctrl`+`H` | Delete previous character | Yes | | `Ctrl`+`H` | Delete previous character | Yes |
| `Ctrl`+`I` / `Tab` | Command line completion | Not Yet | | `Ctrl`+`I` / `Tab` | Command line completion | Yes |
| `Ctrl`+`J` | Line feed | Yes | | `Ctrl`+`J` | Line feed | Yes |
| `Ctrl`+`K` | Cut text to the end of line | Yes | | `Ctrl`+`K` | Cut text to the end of line | Yes |
| `Ctrl`+`L` | Clean screen | NoYet | | `Ctrl`+`L` | Clean screen | NoYet |