Fix drawing fields containing empty lines
This commit is contained in:
parent
024083b2a8
commit
be02667790
|
@ -72,13 +72,13 @@ func NewDemoGame() *game {
|
|||
},
|
||||
}
|
||||
|
||||
g.buffer.SetText(strings.TrimSpace(initialText) + "\n")
|
||||
g.buffer.SetText(strings.TrimSpace(initialText))
|
||||
|
||||
g.input.SetHandleKeyboard(true)
|
||||
g.input.SetSelectedFunc(func() (accept bool) {
|
||||
log.Printf("Input: %s", g.input.Text())
|
||||
|
||||
g.buffer.Write([]byte(fmt.Sprintf("Input: %s\n", g.input.Text())))
|
||||
g.buffer.Write([]byte(fmt.Sprintf("\nInput: %s", g.input.Text())))
|
||||
|
||||
return true
|
||||
})
|
||||
|
|
|
@ -534,6 +534,13 @@ func (f *TextField) wrapContent(withScrollBar bool) {
|
|||
}
|
||||
f.bufferWrapped = f.bufferWrapped[:0]
|
||||
for _, line := range strings.Split(buffer, "\n") {
|
||||
// BoundString returns 0 for strings containing only whitespace.
|
||||
if strings.TrimSpace(line) == "" {
|
||||
f.bufferWrapped = append(f.bufferWrapped, "")
|
||||
f.lineWidths = append(f.lineWidths, 0)
|
||||
continue
|
||||
}
|
||||
|
||||
l := len(line)
|
||||
var start int
|
||||
var end int
|
||||
|
|
Reference in New Issue