Minor fixes in Wrap

Print first character of the new line.
Control maxX and maxY to avoid invalid calls to View.SetRune.
Add error handling when calling View.SetRune.
This commit is contained in:
Roi Martin 2014-11-15 13:13:19 +01:00
parent 382efdcc54
commit f78a0704f1
1 changed files with 6 additions and 4 deletions

10
view.go
View File

@ -189,20 +189,22 @@ func (v *View) draw() error {
if x == maxX && v.Wrap {
x = 0
y++
for _, p := range v.WrapPrefix {
if x == maxX {
for _, p := range v.WrapPrefix + string(ch) {
if x >= maxX || y >= maxY {
break
}
v.setRune(x, y, p)
if err := v.setRune(x, y, p); err != nil {
return err
}
x++
}
} else if x < maxX && y < maxY {
if err := v.setRune(x, y, ch); err != nil {
return err
}
}
x++
}
}
y++
}
return nil