From 5ac13473661cdd2369a95e824119945db8bec209 Mon Sep 17 00:00:00 2001 From: Timon Ringwald Date: Mon, 4 Apr 2022 14:47:38 +0200 Subject: [PATCH] view_scroll refactored --- views/view_scroll.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/views/view_scroll.go b/views/view_scroll.go index 77dd8fe..857f122 100644 --- a/views/view_scroll.go +++ b/views/view_scroll.go @@ -55,6 +55,13 @@ func (v *ScrollView) Draw(buf *tui.ViewBuffer) { copyBufferHeight = v.buf.Height() } + // copy buffer + for x := 0; x < copyBufferWidth; x++ { + for y := 0; y < copyBufferHeight; y++ { + buf.Set(x, y, v.buf.Get(v.horizontalScrollOffset+x, v.verticalScrollOffset+y)) + } + } + scrollVHeight := int(float64(buf.Height()) / float64(v.buf.Height()) * float64(v.height)) scrollVStart := int(math.Ceil(float64(v.verticalScrollOffset) / float64(v.buf.Height()) * float64(v.height))) @@ -75,13 +82,6 @@ func (v *ScrollView) Draw(buf *tui.ViewBuffer) { } } - // copy buffer - for x := 0; x < copyBufferWidth; x++ { - for y := 0; y < copyBufferHeight; y++ { - buf.Set(x, y, v.buf.Get(v.horizontalScrollOffset+x, v.verticalScrollOffset+y)) - } - } - // vertical scrollbar if scrollV { for y := 0; y < v.height; y++ {