forked from mirror/readline
update readme
This commit is contained in:
parent
6f64c527fe
commit
69871d9ae0
13
README.md
13
README.md
|
@ -15,6 +15,13 @@ Readline will support most of features which GNU Readline is supported, and prov
|
||||||
|
|
||||||
You can read the source code in [example/main.go](https://github.com/chzyer/readline/blob/master/example/main.go).
|
You can read the source code in [example/main.go](https://github.com/chzyer/readline/blob/master/example/main.go).
|
||||||
|
|
||||||
|
# Todo
|
||||||
|
|
||||||
|
* Auto Completeion
|
||||||
|
* Vim mode
|
||||||
|
* Transpose words
|
||||||
|
* More funny examples
|
||||||
|
|
||||||
# Usage
|
# Usage
|
||||||
|
|
||||||
* Simplest example
|
* Simplest example
|
||||||
|
@ -107,7 +114,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 | NoYet |
|
| `Ctrl`+`I` / `Tab` | Command line completion | Not Yet |
|
||||||
| `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 |
|
||||||
|
@ -117,8 +124,8 @@ Users can change that in terminal simulator(i.e. iTerm2) to `Alt`+`B`
|
||||||
| `Ctrl`+`R` | Search backwards in history | Yes |
|
| `Ctrl`+`R` | Search backwards in history | Yes |
|
||||||
| `Ctrl`+`S` | Search forwards in history | Yes |
|
| `Ctrl`+`S` | Search forwards in history | Yes |
|
||||||
| `Ctrl`+`T` | Transpose characters | Yes |
|
| `Ctrl`+`T` | Transpose characters | Yes |
|
||||||
| `Meta`+`T` | Transpose words | NoYet |
|
| `Meta`+`T` | Transpose words | Not Yet |
|
||||||
| `Ctrl`+`U` | Cut text to the beginning of line | NoYet |
|
| `Ctrl`+`U` | Cut text to the beginning of line | Not Yet |
|
||||||
| `Ctrl`+`W` | Cut previous word | Yes |
|
| `Ctrl`+`W` | Cut previous word | Yes |
|
||||||
| `Backspace` | Delete previous character | Yes |
|
| `Backspace` | Delete previous character | Yes |
|
||||||
| `Meta`+`Backspace` | Cut previous word | Yes |
|
| `Meta`+`Backspace` | Cut previous word | Yes |
|
||||||
|
|
1
char.go
1
char.go
|
@ -9,6 +9,7 @@ const (
|
||||||
CharForward = 6
|
CharForward = 6
|
||||||
CharCannel = 7
|
CharCannel = 7
|
||||||
CharCtrlH = 8
|
CharCtrlH = 8
|
||||||
|
CharTab = 9
|
||||||
CharCtrlJ = 10
|
CharCtrlJ = 10
|
||||||
CharKill = 11
|
CharKill = 11
|
||||||
CharEnter = 13
|
CharEnter = 13
|
||||||
|
|
|
@ -18,7 +18,7 @@ bye: quit
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
l, err := readline.NewEx(&readline.Config{
|
l, err := readline.NewEx(&readline.Config{
|
||||||
Prompt: "home \033[31m»\033[0m ",
|
Prompt: "\033[31m»\033[0m ",
|
||||||
HistoryFile: "/tmp/readline.tmp",
|
HistoryFile: "/tmp/readline.tmp",
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -57,6 +57,10 @@ func (o *Operation) ioloop() {
|
||||||
o.ExitSearchMode(true)
|
o.ExitSearchMode(true)
|
||||||
o.buf.Refresh()
|
o.buf.Refresh()
|
||||||
}
|
}
|
||||||
|
case CharTab:
|
||||||
|
if o.cfg.AutoComplete == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
case CharBckSearch:
|
case CharBckSearch:
|
||||||
o.SearchMode(S_DIR_BCK)
|
o.SearchMode(S_DIR_BCK)
|
||||||
keepInSearchMode = true
|
keepInSearchMode = true
|
||||||
|
|
|
@ -7,9 +7,14 @@ type Instance struct {
|
||||||
o *Operation
|
o *Operation
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type AutoCompleter interface {
|
||||||
|
Do(line []rune, pos int) (newLine []rune, newPos int, ok bool)
|
||||||
|
}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Prompt string
|
Prompt string
|
||||||
HistoryFile string
|
HistoryFile string
|
||||||
|
AutoComplete AutoCompleter
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewEx(cfg *Config) (*Instance, error) {
|
func NewEx(cfg *Config) (*Instance, error) {
|
||||||
|
|
Loading…
Reference in New Issue