From c03af2199f7b27214948614a70404ed602ac3688 Mon Sep 17 00:00:00 2001 From: Felix Angell Date: Sun, 6 May 2018 14:53:31 +0100 Subject: [PATCH] attempted to not blink while moving... didnt work! --- gui/buffer.go | 7 +++++-- gui/cursor.go | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/gui/buffer.go b/gui/buffer.go index f11afd7..1facd8f 100644 --- a/gui/buffer.go +++ b/gui/buffer.go @@ -837,6 +837,9 @@ func (b *Buffer) HandleEvent(evt strife.StrifeEvent) { var lastCursorDraw = time.Now() var renderFlashingCursor = true +var lastTimer = time.Now() +var ldx, ldy = 0, 0 + func (b *Buffer) OnUpdate() bool { return false } @@ -885,7 +888,7 @@ func (b *Buffer) processInput(pred func(r int) bool) bool { } // handle cursor flash - if b.cfg.Cursor.Flash && runtime.GOOS == "spookyghost" { + if b.cfg.Cursor.Flash && 15 == 12 { if time.Now().Sub(lastCursorDraw) >= time.Duration(b.cfg.Cursor.Flash_Rate)*time.Millisecond { renderFlashingCursor = !renderFlashingCursor lastCursorDraw = time.Now() @@ -1098,7 +1101,7 @@ func (b *Buffer) renderAt(ctx *strife.Renderer, rx int, ry int) { } // render the ol' cursor - if b.HasFocus() && renderFlashingCursor && b.cfg.Cursor.Draw { + if b.HasFocus() && (renderFlashingCursor || b.curs.moving) && b.cfg.Cursor.Draw { cursorWidth := b.cfg.Cursor.GetCaretWidth() if cursorWidth == -1 { cursorWidth = last_w diff --git a/gui/cursor.go b/gui/cursor.go index 89ff8a4..21a6dee 100644 --- a/gui/cursor.go +++ b/gui/cursor.go @@ -3,6 +3,8 @@ package gui type Cursor struct { x, y int rx, ry int + dx, dy int + moving bool } func (c *Cursor) gotoStart() { @@ -18,6 +20,20 @@ func (c *Cursor) move(x, y int) { // moves the cursors position, and the // rendered coordinates by the given amount func (c *Cursor) moveRender(x, y, rx, ry int) { + if x > 0 { + c.dx = 1 + } else if x < 0 { + c.dx = -1 + } + + if y > 0 { + c.dy = 1 + } else if y < 0 { + c.dy = -1 + } + + c.moving = true + c.x += x c.y += y