Skip to content

Commit

Permalink
revert attempt at sequence compression + cursorUpBy
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxwell Huang-Hobbs committed Feb 28, 2022
1 parent 94b5738 commit 1efd40f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 20 deletions.
4 changes: 0 additions & 4 deletions screen.go
Expand Up @@ -27,10 +27,6 @@ func cursorDown(w io.Writer) {
fmt.Fprintf(w, te.CSI+te.CursorDownSeq, 1)
}

func cursorUpBy(w io.Writer, count int) {
fmt.Fprintf(w, te.CSI+te.CursorUpSeq, count)
}

func insertLine(w io.Writer, numLines int) {
fmt.Fprintf(w, te.CSI+"%dL", numLines)
}
Expand Down
8 changes: 1 addition & 7 deletions screen_test.go
Expand Up @@ -46,13 +46,7 @@ func TestScreen(t *testing.T) {
exercise(t, cursorUp, []byte("\x1b[1A"))
})

t.Run("upBy", func(t *testing.T) {
exercise(t, func(w io.Writer) {
cursorUpBy(w, 3)
}, []byte("\x1b[3A"))
})

t.Run("downBy", func(t *testing.T) {
t.Run("down", func(t *testing.T) {
exercise(t, cursorDown, []byte("\x1b[1B"))
})

Expand Down
12 changes: 3 additions & 9 deletions standard_renderer.go
Expand Up @@ -138,23 +138,17 @@ func (r *standardRenderer) flush() {

// Clear any lines we painted in the last render.
if r.linesRendered > 0 {
jumpedLines := 0
for i := r.linesRendered - 1; i > 0; i-- {
// If the number of lines we want to render hasn't increased and
// new line is the same as the old line we can skip rendering for
// this line as a performance optimization.
if (len(newLines) <= len(oldLines)) && (len(newLines) > i && len(oldLines) > i) && (newLines[i] == oldLines[i]) {
skipLines[i] = struct{}{}
jumpedLines++
} else {
cursorUpBy(out, jumpedLines)
} else if _, exists := r.ignoreLines[i]; !exists {
clearLine(out)

jumpedLines = 0
}
}
if jumpedLines >= 1 {
cursorUpBy(out, jumpedLines+1)

cursorUp(out)
}

if _, exists := r.ignoreLines[0]; !exists {
Expand Down

0 comments on commit 1efd40f

Please sign in to comment.