Added document as an argument to the LineBreakCallback

This commit is contained in:
odino 2019-08-16 14:37:33 +04:00
parent ea717205ca
commit dbd5467376
4 changed files with 5 additions and 5 deletions

2
go.mod
View File

@ -6,5 +6,5 @@ require (
github.com/mattn/go-runewidth v0.0.3
github.com/mattn/go-tty v0.0.0-20180219170247-931426f7535a
github.com/pkg/term v0.0.0-20180423043932-cda20d4ac917
golang.org/x/sys v0.0.0-20180620133508-ad87a3a340fa // indirect
golang.org/x/sys v0.0.0-20180620133508-ad87a3a340fa
)

View File

@ -235,7 +235,7 @@ func OptionShowCompletionAtStart() Option {
}
// OptionBreakLineCallback to run a callback at every break line
func OptionBreakLineCallback(fn func()) Option {
func OptionBreakLineCallback(fn func(*Document)) Option {
return func(p *Prompt) error {
p.renderer.BreakLineCallback = fn
return nil

View File

@ -12,7 +12,7 @@ type Render struct {
out ConsoleWriter
prefix string
livePrefixCallback func() (prefix string, useLivePrefix bool)
BreakLineCallback func()
BreakLineCallback func(*Document)
title string
row uint16
col uint16
@ -237,7 +237,7 @@ func (r *Render) BreakLine(buffer *Buffer) {
r.out.SetColor(DefaultColor, DefaultColor, false)
debug.AssertNoError(r.out.Flush())
if r.BreakLineCallback != nil {
r.BreakLineCallback()
r.BreakLineCallback(buffer.Document())
}
r.previousCursor = 0

View File

@ -100,7 +100,7 @@ func TestBreakLineCallback(t *testing.T) {
t.Errorf("i should initially be 0, before applying a break line callback")
}
r.BreakLineCallback = func() {
r.BreakLineCallback = func(doc *Document) {
i++
}
r.BreakLine(b)