Skip to content

Commit

Permalink
(failed) multiline test
Browse files Browse the repository at this point in the history
  • Loading branch information
ldemailly committed Aug 8, 2024
1 parent ae3b45c commit c1304b2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@

Wrapper around [x/term](https://github.com/golang/term) for a "readline" like library for
the [grol](https://github.com/grol-io/grol#grol) command line repl and others.

See [example/main.go](example/main.go) for a rather complete example/demo.
7 changes: 6 additions & 1 deletion example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ const (
afterCmd = "after "
exitCmd = "exit"
helpCmd = "help"
testMLCmd = "multiline"
)

var commands = []string{promptCmd, afterCmd, exitCmd, helpCmd}
var commands = []string{promptCmd, afterCmd, exitCmd, helpCmd, testMLCmd}

// func(line string, pos int, key rune) (newLine string, newPos int, ok bool)

Expand All @@ -43,6 +44,10 @@ func autoCompleteCallback(line string, pos int, key rune) (newLine string, newPo
}
for _, c := range commands { // for now all have unique prefixes
if strings.HasPrefix(c, line) {
if c == testMLCmd {
ret := "multiline {\r\n\tline1\r\n\tline2"
return ret, len(ret), true
}
return c, len(c), true
}
}
Expand Down

0 comments on commit c1304b2

Please sign in to comment.