forked from Mirrors/bubbletea
Fix a bug where left area on the first line was not always cleared
This commit is contained in:
parent
debaf312f7
commit
8539cfcf8c
10
renderer.go
10
renderer.go
|
@ -146,6 +146,7 @@ func (r *renderer) flush() {
|
||||||
defer r.mtx.Unlock()
|
defer r.mtx.Unlock()
|
||||||
|
|
||||||
if r.linesRendered > 0 {
|
if r.linesRendered > 0 {
|
||||||
|
|
||||||
// Clear the lines we painted in the last render.
|
// Clear the lines we painted in the last render.
|
||||||
for i := r.linesRendered; i > 0; i-- {
|
for i := r.linesRendered; i > 0; i-- {
|
||||||
|
|
||||||
|
@ -160,6 +161,15 @@ func (r *renderer) flush() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, exists := r.ignoreLines[0]; !exists {
|
if _, exists := r.ignoreLines[0]; !exists {
|
||||||
|
// We need to return to the start of the line here to properly
|
||||||
|
// erase it. Going back the entire width of the terminal will
|
||||||
|
// usually be farther than we need to go, but terminal emulators
|
||||||
|
// will stop the cursor at the start of the line as a rule.
|
||||||
|
//
|
||||||
|
// We use this sequence in particular because it's part of the ANSI
|
||||||
|
// standard (whereas others are proprietary to, say, VT100/VT52).
|
||||||
|
cursorBack(out, r.width)
|
||||||
|
|
||||||
clearLine(out)
|
clearLine(out)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,3 +38,7 @@ func restoreCursorPosition(w io.Writer) {
|
||||||
func changeScrollingRegion(w io.Writer, top, bottom int) {
|
func changeScrollingRegion(w io.Writer, top, bottom int) {
|
||||||
fmt.Fprintf(w, te.CSI+te.ChangeScrollingRegionSeq, top, bottom)
|
fmt.Fprintf(w, te.CSI+te.ChangeScrollingRegionSeq, top, bottom)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func cursorBack(w io.Writer, n int) {
|
||||||
|
fmt.Fprintf(w, te.CSI+te.CursorBackSeq, n)
|
||||||
|
}
|
||||||
|
|
6
tea.go
6
tea.go
|
@ -197,14 +197,12 @@ func (p *Program) Start() error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// AltScreen exits the altscreen. This is just a wrapper around the termenv
|
// AltScreen enters the alternate screen buffer.
|
||||||
// function.
|
|
||||||
func AltScreen() {
|
func AltScreen() {
|
||||||
termenv.AltScreen()
|
termenv.AltScreen()
|
||||||
}
|
}
|
||||||
|
|
||||||
// ExitAltScreen exits the altscreen. This is just a wrapper around the termenv
|
// ExitAltScreen exits the alternate screen buffer.
|
||||||
// function.
|
|
||||||
func ExitAltScreen() {
|
func ExitAltScreen() {
|
||||||
termenv.ExitAltScreen()
|
termenv.ExitAltScreen()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue