fix apt scrollbars

This commit is contained in:
Liam Galvin 2018-11-04 18:58:12 +00:00
parent 6a643a763e
commit de3f07897f
3 changed files with 43 additions and 5 deletions

View File

@ -638,6 +638,17 @@ func (buffer *Buffer) Backspace() {
func (buffer *Buffer) CarriageReturn() { func (buffer *Buffer) CarriageReturn() {
defer buffer.emitDisplayChange() defer buffer.emitDisplayChange()
for {
line := buffer.getCurrentLine()
if line == nil {
break
}
if line.wrapped && buffer.cursorY > 0 {
buffer.cursorY--
} else {
break
}
}
buffer.cursorX = 0 buffer.cursorX = 0
} }

View File

@ -223,11 +223,39 @@ func TestClearWithFullView(t *testing.T) {
func TestCarriageReturn(t *testing.T) { func TestCarriageReturn(t *testing.T) {
b := NewBuffer(80, 20, CellAttributes{}) b := NewBuffer(80, 20, CellAttributes{})
b.Write([]rune("hello!\rsecret")...) b.Write([]rune("hello!")...)
b.CarriageReturn()
b.Write([]rune("secret")...)
lines := b.GetVisibleLines() lines := b.GetVisibleLines()
assert.Equal(t, "secret", lines[0].String()) assert.Equal(t, "secret", lines[0].String())
} }
func TestCarriageReturnOnFullLine(t *testing.T) {
b := NewBuffer(20, 20, CellAttributes{})
b.Write([]rune("abcdeabcdeabcdeabcde")...)
b.CarriageReturn()
b.Write([]rune("xxxxxxxxxxxxxxxxxxxx")...)
lines := b.GetVisibleLines()
assert.Equal(t, "xxxxxxxxxxxxxxxxxxxx", lines[0].String())
}
func TestCarriageReturnOnOverflowedLine(t *testing.T) {
b := NewBuffer(20, 20, CellAttributes{})
b.Write([]rune("abcdeabcdeabcdeabcdezzzzz")...)
b.CarriageReturn()
b.Write([]rune("xxxxxxxxxxxxxxxxxxxx")...)
lines := b.GetVisibleLines()
assert.Equal(t, "xxxxxxxxxxxxxxxxxxxx", lines[0].String())
}
func TestCarriageReturnOnFullLastLine(t *testing.T) {
b := NewBuffer(20, 2, CellAttributes{})
b.Write([]rune("\nabcdeabcdeabcdeabcde\rxxxxxxxxxxxxxxxxxxxx")...)
lines := b.GetVisibleLines()
assert.Equal(t, "", lines[0].String())
assert.Equal(t, "xxxxxxxxxxxxxxxxxxxx", lines[1].String())
}
func TestCarriageReturnOnWrappedLine(t *testing.T) { func TestCarriageReturnOnWrappedLine(t *testing.T) {
b := NewBuffer(80, 6, CellAttributes{}) b := NewBuffer(80, 6, CellAttributes{})
b.Write([]rune("hello!\rsecret")...) b.Write([]rune("hello!\rsecret")...)
@ -253,11 +281,10 @@ func TestCarriageReturnOnOverWrappedLine(t *testing.T) {
b := NewBuffer(6, 10, CellAttributes{}) b := NewBuffer(6, 10, CellAttributes{})
b.Write([]rune("hello there!\rsecret sauce")...) b.Write([]rune("hello there!\rsecret sauce")...)
lines := b.GetVisibleLines() lines := b.GetVisibleLines()
require.Equal(t, 3, len(lines)) require.Equal(t, 2, len(lines))
assert.Equal(t, "hello", lines[0].String()) assert.Equal(t, "secret", lines[0].String())
assert.Equal(t, "secret", lines[1].String())
assert.True(t, b.lines[1].wrapped) assert.True(t, b.lines[1].wrapped)
assert.Equal(t, " sauce", lines[2].String()) assert.Equal(t, " sauce", lines[1].String())
} }
func TestCarriageReturnOnLineThatDoesntExist(t *testing.T) { func TestCarriageReturnOnLineThatDoesntExist(t *testing.T) {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 614 B

After

Width:  |  Height:  |  Size: 418 B