force a render to get font metrics; fixes #43

This commit is contained in:
Felix Angell 2018-04-21 19:22:55 +01:00
parent 112eb553b8
commit 73bbc2a150
2 changed files with 12 additions and 2 deletions

View File

@ -849,6 +849,14 @@ func (b *Buffer) renderAt(ctx *strife.Renderer, rx int, ry int) {
var visibleLines int = 50
// HACK
// force a render off screen
// so we can calculate the size of characters
if int(last_h) == 0 || int(last_w) == 0 {
last_w, last_h = ctx.String("_", -50, -50)
}
// last_h > 0 means we have done
// a render.
if int(last_h) > 0 && int(b.h) != 0 {
@ -875,7 +883,7 @@ func (b *Buffer) renderAt(ctx *strife.Renderer, rx int, ry int) {
// char index => colour
var matches map[int]syntaxRuneInfo
if b.languageInfo != nil {
if b.languageInfo != nil && len(currLine) > 0 {
matches = b.syntaxHighlightLine(string(currLine))
}

View File

@ -145,7 +145,9 @@ func main() {
break
}
if editor.update() || config.Render.Always_Render {
shouldRender := editor.update()
if shouldRender || config.Render.Always_Render {
ctx.Clear()
editor.render(ctx)