aboutsummaryrefslogtreecommitdiffstats
path: root/Godeps/_workspace/src/github.com/peterh/liner/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'Godeps/_workspace/src/github.com/peterh/liner/README.md')
-rw-r--r--Godeps/_workspace/src/github.com/peterh/liner/README.md17
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 {