Remove unused View.HasLoader functionality

This commit is contained in:
Stefan Haller 2026-04-06 20:07:24 +02:00
parent d06522482f
commit 21e49dc3b7
3 changed files with 1 additions and 47 deletions

View file

@ -1609,13 +1609,6 @@ func (g *Gui) StartTicking(ctx context.Context) {
if g.suspended {
continue outer
}
for _, view := range g.Views() {
if view.HasLoader {
g.UpdateAsync(func(g *Gui) error { return nil })
continue outer
}
}
return
case <-ctx.Done():
return

View file

@ -1,31 +0,0 @@
package gocui
import "time"
func (v *View) loaderLines() [][]cell {
duplicate := make([][]cell, len(v.lines))
for i := range v.lines {
if i < len(v.lines)-1 {
duplicate[i] = make([]cell, len(v.lines[i]))
copy(duplicate[i], v.lines[i])
} else {
duplicate[i] = make([]cell, len(v.lines[i])+2)
copy(duplicate[i], v.lines[i])
duplicate[i][len(duplicate[i])-2] = cell{chr: " "}
duplicate[i][len(duplicate[i])-1] = Loader()
}
}
return duplicate
}
// Loader can show a loading animation
func Loader() cell {
frames := []string{"|", "/", "-", "\\"}
now := time.Now()
nanos := now.UnixNano()
index := nanos / 50000000 % int64(len(frames))
return cell{
chr: frames[index],
}
}

View file

@ -164,9 +164,6 @@ type View struct {
// Overlaps describes which edges are overlapping with another view's edges
Overlaps byte
// If HasLoader is true, the message will be appended with a spinning loader animation
HasLoader bool
// ParentView is the view which catches events bubbled up from the given view if there's no matching handler
ParentView *View
@ -1315,9 +1312,6 @@ func (v *View) refreshViewLinesIfNeeded() {
maxX := v.InnerWidth()
lineIdx := 0
lines := v.lines
if v.HasLoader {
lines = v.loaderLines()
}
for i, line := range lines {
wrap := 0
if v.Wrap {
@ -1336,9 +1330,7 @@ func (v *View) refreshViewLinesIfNeeded() {
lineIdx++
}
}
if !v.HasLoader {
v.tainted = false
}
v.tainted = false
}
}