Skip to content

Commit

Permalink
Merge pull request #71 from codelaboratoryltd/fix-buffer-cutoff
Browse files Browse the repository at this point in the history
fix buffer cutoff mid escape
  • Loading branch information
andydotxyz committed Mar 22, 2024
2 parents 74b5a9f + 3c09859 commit 94240be
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
27 changes: 27 additions & 0 deletions color_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import (
"image/color"
"reflect"
"testing"

"fyne.io/fyne/v2"
"fyne.io/fyne/v2/widget"
"github.com/stretchr/testify/assert"
)

func esc(s string) string {
Expand Down Expand Up @@ -902,3 +906,26 @@ func TestHandleOutput_24_bit_colour(t *testing.T) {

testColor(t, tests)
}

func TestHandleOutput_BufferCutoff(t *testing.T) {
term := New()
termsize := fyne.NewSize(80, 50)
term.Resize(termsize)
term.handleOutput([]byte("\x1b[38;5;64"))
term.handleOutput([]byte("m40\x1b[38;5;65m41"))
tg := widget.NewTextGrid()
tg.Resize(termsize)
c1 := &color.RGBA{R: 95, G: 135, A: 255}
c2 := &color.RGBA{R: 95, G: 135, B: 95, A: 255}
tg.Rows = []widget.TextGridRow{
{
Cells: []widget.TextGridCell{
{Rune: '4', Style: &widget.CustomTextGridStyle{FGColor: c1, BGColor: nil}},
{Rune: '0', Style: &widget.CustomTextGridStyle{FGColor: c1, BGColor: nil}},
{Rune: '4', Style: &widget.CustomTextGridStyle{FGColor: c2, BGColor: nil}},
{Rune: '1', Style: &widget.CustomTextGridStyle{FGColor: c2, BGColor: nil}},
},
},
}
assert.Equal(t, tg.Rows, term.content.Rows)
}
2 changes: 1 addition & 1 deletion output.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func (t *Terminal) handleOutput(buf []byte) []byte {

// record progress for next chunk of buffer
if t.state.esc != noEscape {
t.state.esc = -1
t.state.esc = t.state.esc - i
}
return buf
}
Expand Down

0 comments on commit 94240be

Please sign in to comment.