diff options
author | Péter Szilágyi <peterke@gmail.com> | 2016-02-11 22:16:52 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2016-02-11 22:16:52 +0800 |
commit | b019f3ee29ce55c3d515ee8bafe0f4bb14221c0a (patch) | |
tree | 26e023be6c99a10e82a5a0ebadd1e42cefe9bd3c /Godeps/_workspace/src/github.com/peterh/liner/README.md | |
parent | b05e472c076d30035233d6a8b5fb3360b236e3ff (diff) | |
download | go-tangerine-b019f3ee29ce55c3d515ee8bafe0f4bb14221c0a.tar go-tangerine-b019f3ee29ce55c3d515ee8bafe0f4bb14221c0a.tar.gz go-tangerine-b019f3ee29ce55c3d515ee8bafe0f4bb14221c0a.tar.bz2 go-tangerine-b019f3ee29ce55c3d515ee8bafe0f4bb14221c0a.tar.lz go-tangerine-b019f3ee29ce55c3d515ee8bafe0f4bb14221c0a.tar.xz go-tangerine-b019f3ee29ce55c3d515ee8bafe0f4bb14221c0a.tar.zst go-tangerine-b019f3ee29ce55c3d515ee8bafe0f4bb14221c0a.zip |
Godeps: update all dependencies to latest code
Diffstat (limited to 'Godeps/_workspace/src/github.com/peterh/liner/README.md')
-rw-r--r-- | Godeps/_workspace/src/github.com/peterh/liner/README.md | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/Godeps/_workspace/src/github.com/peterh/liner/README.md b/Godeps/_workspace/src/github.com/peterh/liner/README.md index 99027c6e2..9148b2492 100644 --- a/Godeps/_workspace/src/github.com/peterh/liner/README.md +++ b/Godeps/_workspace/src/github.com/peterh/liner/README.md @@ -21,8 +21,8 @@ Ctrl-A, Home | Move cursor to beginning of line Ctrl-E, End | Move cursor to end of line Ctrl-B, Left | Move cursor one character left Ctrl-F, Right| Move cursor one character right -Ctrl-Left | Move cursor to previous word -Ctrl-Right | Move cursor to next word +Ctrl-Left, Alt-B | Move cursor to previous word +Ctrl-Right, Alt-F | Move cursor to next word Ctrl-D, Del | (if line is *not* empty) Delete character under cursor Ctrl-D | (if line *is* empty) End of File - usually quits application Ctrl-C | Reset input (create new empty prompt) @@ -48,13 +48,14 @@ package main import ( "log" "os" + "path/filepath" "strings" "github.com/peterh/liner" ) var ( - history_fn = "/tmp/.liner_history" + history_fn = filepath.Join(os.TempDir(), ".liner_example_history") names = []string{"john", "james", "mary", "nancy"} ) @@ -62,6 +63,8 @@ func main() { line := liner.NewLiner() defer line.Close() + line.SetCtrlCAborts(true) + line.SetCompleter(func(line string) (c []string) { for _, n := range names { if strings.HasPrefix(n, strings.ToLower(line)) { @@ -76,11 +79,13 @@ func main() { f.Close() } - if name, err := line.Prompt("What is your name? "); err != nil { - log.Print("Error reading line: ", err) - } else { + if name, err := line.Prompt("What is your name? "); err == nil { log.Print("Got: ", name) line.AppendHistory(name) + } else if err == liner.ErrPromptAborted { + log.Print("Aborted") + } else { + log.Print("Error reading line: ", err) } if f, err := os.Create(history_fn); err != nil { |