only move cursor up if pos > 0
This commit is contained in:
parent
d6ecaa2cbf
commit
7ea905871a
1 changed files with 5 additions and 2 deletions
|
@ -25,7 +25,7 @@ type Progress struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewProgress(w io.Writer) *Progress {
|
func NewProgress(w io.Writer) *Progress {
|
||||||
p := &Progress{pos: -1, w: w}
|
p := &Progress{w: w}
|
||||||
go p.start()
|
go p.start()
|
||||||
return p
|
return p
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,10 @@ func (p *Progress) render() error {
|
||||||
p.mu.Lock()
|
p.mu.Lock()
|
||||||
defer p.mu.Unlock()
|
defer p.mu.Unlock()
|
||||||
|
|
||||||
fmt.Fprintf(p.w, "\033[%dA", p.pos)
|
if p.pos > 0 {
|
||||||
|
fmt.Fprintf(p.w, "\033[%dA", p.pos)
|
||||||
|
}
|
||||||
|
|
||||||
for _, state := range p.states {
|
for _, state := range p.states {
|
||||||
fmt.Fprintln(p.w, state.String())
|
fmt.Fprintln(p.w, state.String())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue