mirror of https://github.com/liamg/aminal.git
fix background renderinf
This commit is contained in:
parent
f0a1742c0a
commit
be60c1d053
|
@ -227,7 +227,7 @@ func (buffer *Buffer) Write(runes ...rune) {
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
for int(buffer.CursorColumn()) >= len(line.cells) {
|
for int(buffer.CursorColumn()) >= len(line.cells) {
|
||||||
line.cells = append(line.cells, newCell())
|
line.cells = append(line.cells, NewBackgroundCell(buffer.cursorAttr.BgColour))
|
||||||
}
|
}
|
||||||
|
|
||||||
cell := &line.cells[buffer.CursorColumn()]
|
cell := &line.cells[buffer.CursorColumn()]
|
||||||
|
@ -383,14 +383,15 @@ func (buffer *Buffer) EraseLineFromCursor() {
|
||||||
defer buffer.emitDisplayChange()
|
defer buffer.emitDisplayChange()
|
||||||
line := buffer.getCurrentLine()
|
line := buffer.getCurrentLine()
|
||||||
|
|
||||||
max := int(buffer.cursorX)
|
line.cells = line.cells[:buffer.cursorX]
|
||||||
if max > len(line.cells) {
|
|
||||||
max = len(line.cells)
|
|
||||||
}
|
|
||||||
|
|
||||||
for c := int(buffer.cursorX); c < len(line.cells); c++ {
|
max := int(buffer.ViewWidth()) - len(line.cells)
|
||||||
line.cells[c].erase()
|
|
||||||
|
buffer.SaveCursor()
|
||||||
|
for i := 0; i < max; i++ {
|
||||||
|
buffer.Write(0)
|
||||||
}
|
}
|
||||||
|
buffer.RestoreCursor()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (buffer *Buffer) EraseDisplay() {
|
func (buffer *Buffer) EraseDisplay() {
|
||||||
|
|
|
@ -289,8 +289,6 @@ func TestGetCellWithBadCursor(t *testing.T) {
|
||||||
b := NewBuffer(80, 2, CellAttributes{})
|
b := NewBuffer(80, 2, CellAttributes{})
|
||||||
b.Write([]rune("Hello\r\nthere\r\nsomething...")...)
|
b.Write([]rune("Hello\r\nthere\r\nsomething...")...)
|
||||||
require.Nil(t, b.GetCell(8, 3))
|
require.Nil(t, b.GetCell(8, 3))
|
||||||
require.Nil(t, b.GetCell(8, -1))
|
|
||||||
require.Nil(t, b.GetCell(-8, 1))
|
|
||||||
require.Nil(t, b.GetCell(90, 0))
|
require.Nil(t, b.GetCell(90, 0))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -365,7 +363,7 @@ func TestEraseLineAfterCursor(t *testing.T) {
|
||||||
b.MovePosition(-3, 0)
|
b.MovePosition(-3, 0)
|
||||||
b.EraseLineFromCursor()
|
b.EraseLineFromCursor()
|
||||||
assert.Equal(t, "hello, this is a test", b.lines[0].String())
|
assert.Equal(t, "hello, this is a test", b.lines[0].String())
|
||||||
assert.Equal(t, "dele\x00\x00\x00", b.lines[1].String())
|
assert.Equal(t, "dele", b.lines[1].String())
|
||||||
}
|
}
|
||||||
func TestEraseDisplay(t *testing.T) {
|
func TestEraseDisplay(t *testing.T) {
|
||||||
b := NewBuffer(80, 5, CellAttributes{})
|
b := NewBuffer(80, 5, CellAttributes{})
|
||||||
|
@ -404,9 +402,9 @@ func TestBackspace(t *testing.T) {
|
||||||
b.Write([]rune("hello")...)
|
b.Write([]rune("hello")...)
|
||||||
b.Backspace()
|
b.Backspace()
|
||||||
b.Backspace()
|
b.Backspace()
|
||||||
b.Write([]rune("l")...)
|
b.Write([]rune("p")...)
|
||||||
lines := b.GetVisibleLines()
|
lines := b.GetVisibleLines()
|
||||||
assert.Equal(t, "hell\x00", lines[0].String())
|
assert.Equal(t, "helpo", lines[0].String())
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBackspaceWithWrap(t *testing.T) {
|
func TestBackspaceWithWrap(t *testing.T) {
|
||||||
|
@ -424,7 +422,7 @@ func TestBackspaceWithWrap(t *testing.T) {
|
||||||
b.Backspace()
|
b.Backspace()
|
||||||
b.EraseLineFromCursor()
|
b.EraseLineFromCursor()
|
||||||
lines := b.GetVisibleLines()
|
lines := b.GetVisibleLines()
|
||||||
assert.Equal(t, "hello\x00\x00\x00\x00\x00", lines[0].String())
|
assert.Equal(t, "hello", lines[0].String())
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestHorizontalResizeView(t *testing.T) {
|
func TestHorizontalResizeView(t *testing.T) {
|
||||||
|
|
|
@ -16,10 +16,6 @@ type CellAttributes struct {
|
||||||
Hidden bool
|
Hidden bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func newCell() Cell {
|
|
||||||
return Cell{}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (cell *Cell) Attr() CellAttributes {
|
func (cell *Cell) Attr() CellAttributes {
|
||||||
return cell.attr
|
return cell.attr
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
package buffer
|
package buffer
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
type Line struct {
|
type Line struct {
|
||||||
wrapped bool // whether line was wrapped onto from the previous one
|
wrapped bool // whether line was wrapped onto from the previous one
|
||||||
cells []Cell
|
cells []Cell
|
||||||
|
@ -40,7 +44,7 @@ func (line *Line) String() string {
|
||||||
for _, cell := range line.cells {
|
for _, cell := range line.cells {
|
||||||
runes = append(runes, cell.r)
|
runes = append(runes, cell.r)
|
||||||
}
|
}
|
||||||
return string(runes)
|
return strings.TrimRight(string(runes), "\x00 ")
|
||||||
}
|
}
|
||||||
|
|
||||||
// @todo test these (ported from legacy) ------------------
|
// @todo test these (ported from legacy) ------------------
|
||||||
|
|
|
@ -219,9 +219,9 @@ func (gui *GUI) Render() error {
|
||||||
cells := lines[y].Cells()
|
cells := lines[y].Cells()
|
||||||
if x < len(cells) {
|
if x < len(cells) {
|
||||||
cell = cells[x]
|
cell = cells[x]
|
||||||
if cell.Rune() == 0 {
|
//if cell.Rune() == 0 {
|
||||||
cell = defaultCell
|
// cell = defaultCell
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,7 +240,7 @@ func (gui *GUI) Render() error {
|
||||||
if x < len(cells) {
|
if x < len(cells) {
|
||||||
cell = cells[x]
|
cell = cells[x]
|
||||||
if cell.Rune() == 0 {
|
if cell.Rune() == 0 {
|
||||||
cell = defaultCell
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -215,7 +215,6 @@ func (r *OpenGLRenderer) DrawCellBg(cell buffer.Cell, col uint, row uint) {
|
||||||
rect.setColour(bg)
|
rect.setColour(bg)
|
||||||
rect.Draw()
|
rect.Draw()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *OpenGLRenderer) DrawCellText(cell buffer.Cell, col uint, row uint) {
|
func (r *OpenGLRenderer) DrawCellText(cell buffer.Cell, col uint, row uint) {
|
||||||
|
|
Loading…
Reference in New Issue