Bump gocui

This commit is contained in:
Stefan Haller 2024-08-24 10:47:25 +02:00
parent c28ecabfd8
commit 0aa351443f
4 changed files with 38 additions and 31 deletions

View file

@ -1095,34 +1095,8 @@ func (v *View) draw() error {
}
v.ox = 0
}
if v.tainted {
lineIdx := 0
lines := v.lines
if v.HasLoader {
lines = v.loaderLines()
}
for i, line := range lines {
wrap := 0
if v.Wrap {
wrap = maxX
}
ls := lineWrap(line, wrap)
for j := range ls {
vline := viewLine{linesX: j, linesY: i, line: ls[j]}
if lineIdx > len(v.viewLines)-1 {
v.viewLines = append(v.viewLines, vline)
} else {
v.viewLines[lineIdx] = vline
}
lineIdx++
}
}
if !v.HasLoader {
v.tainted = false
}
}
v.refreshViewLinesIfNeeded()
visibleViewLinesHeight := v.viewLineLengthIgnoringTrailingBlankLines()
if v.Autoscroll && visibleViewLinesHeight > maxY {
@ -1207,6 +1181,38 @@ func (v *View) draw() error {
return nil
}
func (v *View) refreshViewLinesIfNeeded() {
if v.tainted {
maxX := v.Width()
lineIdx := 0
lines := v.lines
if v.HasLoader {
lines = v.loaderLines()
}
for i, line := range lines {
wrap := 0
if v.Wrap {
wrap = maxX
}
ls := lineWrap(line, wrap)
for j := range ls {
vline := viewLine{linesX: j, linesY: i, line: ls[j]}
if lineIdx > len(v.viewLines)-1 {
v.viewLines = append(v.viewLines, vline)
} else {
v.viewLines[lineIdx] = vline
}
lineIdx++
}
}
if !v.HasLoader {
v.tainted = false
}
}
}
// if autoscroll is enabled but we only have a single row of cells shown to the
// user, we don't want to scroll to the final line if it contains no text. So
// this tells us the view lines height when we ignore any trailing blank lines
@ -1310,6 +1316,7 @@ func (v *View) LinesHeight() int {
// ViewLinesHeight is the count of view lines (i.e. lines including wrapping)
func (v *View) ViewLinesHeight() int {
v.refreshViewLinesIfNeeded()
return len(v.viewLines)
}