bug fix: character under cursor rendering (#194)

This commit is contained in:
rrrooommmaaa 2019-02-05 16:16:38 +03:00 committed by Liam Galvin
parent 07952f7505
commit 1f05951012
3 changed files with 38 additions and 15 deletions

View File

@ -207,6 +207,20 @@ func (gui *GUI) generateDefaultCell(reverse bool) {
)
}
func (gui *GUI) getCursorBg(cell *buffer.Cell) (bg [3]float32) {
if gui.config.ColourScheme.Cursor != cell.Bg() {
bg = gui.config.ColourScheme.Cursor
} else {
bg = cell.Fg()
}
return bg
}
func (gui *GUI) getCursorFg(cell *buffer.Cell) (fg [3]float32) {
fg = cell.Bg()
return fg
}
// can only be called on OS thread
func (gui *GUI) resize(w *glfw.Window, width int, height int) {
@ -481,7 +495,12 @@ func (gui *GUI) redraw() {
}
}
gui.renderer.DrawCellBg(*cell, uint(x), uint(y), cursor, colour, false)
if cursor {
var bgColour config.Colour = gui.getCursorBg(cell)
colour = &bgColour
}
gui.renderer.DrawCellBg(*cell, uint(x), uint(y), colour, false)
}
}
@ -501,7 +520,20 @@ func (gui *GUI) redraw() {
for x := 0; x < colCount; x++ {
if x < len(cells) {
cell := cells[x]
if builder.Len() > 0 && (cell.Attr().Dim != dim || cell.Attr().Bold != bold || colour != cell.Fg()) {
cursor := false
if gui.terminal.Modes().ShowCursor {
cursor = cx == uint(x) && cy == uint(y)
}
var newFg [3]float32
if cursor {
newFg = gui.getCursorFg(&cell)
} else {
newFg = cell.Fg()
}
if builder.Len() > 0 && (cell.Attr().Dim != dim || cell.Attr().Bold != bold || colour != newFg) {
var alpha float32 = 1.0
if dim {
alpha = 0.5
@ -511,7 +543,7 @@ func (gui *GUI) redraw() {
builder.Reset()
}
dim = cell.Attr().Dim
colour = cell.Fg()
colour = newFg
bold = cell.Attr().Bold
r := cell.Rune()
if r == 0 {

View File

@ -203,23 +203,14 @@ func (r *OpenGLRenderer) DrawCursor(col uint, row uint, colour config.Colour) {
rect.Free()
}
func (r *OpenGLRenderer) DrawCellBg(cell buffer.Cell, col uint, row uint, cursor bool, colour *config.Colour, force bool) {
func (r *OpenGLRenderer) DrawCellBg(cell buffer.Cell, col uint, row uint, colour *config.Colour, force bool) {
var bg [3]float32
if colour != nil {
bg = *colour
} else {
if cursor {
if r.config.ColourScheme.Cursor != r.backgroundColour {
bg = r.config.ColourScheme.Cursor
} else {
bg = cell.Fg()
}
} else {
bg = cell.Bg()
}
bg = cell.Bg()
}
if bg != r.backgroundColour || force {

View File

@ -81,7 +81,7 @@ DONE:
for hx := col; hx < col+uint16(longestLine)+1; hx++ {
for hy := row - 1; hy < row+uint16(len(lines))+1; hy++ {
gui.renderer.DrawCellBg(buffer.NewBackgroundCell(bg), uint(hx), uint(hy), false, nil, true)
gui.renderer.DrawCellBg(buffer.NewBackgroundCell(bg), uint(hx), uint(hy), nil, true)
}
}