From ac40cc874aebf614326d4829223d7d639efd5b84 Mon Sep 17 00:00:00 2001 From: Felix Angell Date: Sat, 19 May 2018 00:03:30 +0100 Subject: [PATCH] cursor renders under text --- gui/buffer.go | 57 ++++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/gui/buffer.go b/gui/buffer.go index a37d418..8b238a3 100644 --- a/gui/buffer.go +++ b/gui/buffer.go @@ -1298,6 +1298,27 @@ func (b *Buffer) renderAt(ctx *strife.Renderer, rx int, ry int) { lastSelection.renderAt(ctx, b.x+b.ex, b.y+b.ey) } + cursorHeight := last_h + pad + + // render the ol' cursor + if b.HasFocus() && (renderFlashingCursor || b.curs.moving) && b.cfg.Cursor.Draw { + cursorWidth := b.cfg.Cursor.GetCaretWidth() + if cursorWidth == -1 { + cursorWidth = last_w + } + + xPos := b.ex + (rx + b.curs.rx*last_w) - (b.cam.x * last_w) + yPos := b.ey + (ry + b.curs.ry*cursorHeight) - (b.cam.y * cursorHeight) + + ctx.SetColor(strife.HexRGB(b.buffOpts.cursor)) + ctx.Rect(xPos, yPos, cursorWidth, cursorHeight, strife.Fill) + + if DEBUG_MODE { + ctx.SetColor(strife.HexRGB(0xff00ff)) + ctx.Rect(xPos, yPos, cursorWidth, cursorHeight, strife.Line) + } + } + numLines := len(b.table.Lines) var y_col int @@ -1336,13 +1357,6 @@ func (b *Buffer) renderAt(ctx *strife.Renderer, rx int, ry int) { ctx.SetColor(strife.HexRGB(b.buffOpts.foreground)) - // if we're currently over a character then set - // the font colour to something else - // ONLY SET THE COLOUR IF WE HAVE FOCUS ALSO! - if b.HasFocus() && b.curs.x+1 == x_col && b.curs.y == y_col && should_draw { - ctx.SetColor(strife.HexRGB(b.buffOpts.cursorInvert)) - } - if info, ok := matches[idx]; ok { for i := 0; i < info.length; i++ { colorStack = append(colorStack, info.background) @@ -1355,6 +1369,14 @@ func (b *Buffer) renderAt(ctx *strife.Renderer, rx int, ry int) { ctx.SetColor(strife.HexRGB(a)) } + // if we're currently over a character then set + // the font colour to something else + // ONLY SET THE COLOUR IF WE HAVE FOCUS ALSO! + if b.HasFocus() && b.curs.x+1 == x_col && b.curs.y == y_col { + // fixme! + ctx.SetColor(strife.HexRGB(b.buffOpts.cursorInvert)) + } + lineHeight := last_h + pad xPos := b.ex + (rx + ((x_col - 1) * last_w)) yPos := b.ey + (ry + (y_col * lineHeight)) + halfPad @@ -1396,27 +1418,6 @@ func (b *Buffer) renderAt(ctx *strife.Renderer, rx int, ry int) { y_col += 1 } - cursorHeight := last_h + pad - - // render the ol' cursor - if b.HasFocus() && (renderFlashingCursor || b.curs.moving) && b.cfg.Cursor.Draw { - cursorWidth := b.cfg.Cursor.GetCaretWidth() - if cursorWidth == -1 { - cursorWidth = last_w - } - - xPos := b.ex + (rx + b.curs.rx*last_w) - (b.cam.x * last_w) - yPos := b.ey + (ry + b.curs.ry*cursorHeight) - (b.cam.y * cursorHeight) - - ctx.SetColor(strife.HexRGB(b.buffOpts.cursor)) - ctx.Rect(xPos, yPos, cursorWidth, cursorHeight, strife.Fill) - - if DEBUG_MODE { - ctx.SetColor(strife.HexRGB(0xff00ff)) - ctx.Rect(xPos, yPos, cursorWidth, cursorHeight, strife.Line) - } - } - if b.autoComplete.hasSuggestions() { xPos := b.ex + (rx + b.curs.rx*last_w) - (b.cam.x * last_w)