From 71ecf1f4299c6d72b16d20da72405b7e85ac8720 Mon Sep 17 00:00:00 2001 From: Oliver <480930+rivo@users.noreply.github.com> Date: Mon, 28 May 2018 21:27:25 +0200 Subject: [PATCH] Added a scroll function to TextView. Resolves #124 --- textview.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/textview.go b/textview.go index 3361914..34197c3 100644 --- a/textview.go +++ b/textview.go @@ -270,6 +270,16 @@ func (t *TextView) SetDoneFunc(handler func(key tcell.Key)) *TextView { return t } +// ScrollTo scrolls to the specified row and column (both starting with 0). +func (t *TextView) ScrollTo(row, column int) *TextView { + if !t.scrollable { + return t + } + t.lineOffset = row + t.columnOffset = column + return t +} + // ScrollToBeginning scrolls to the top left corner of the text if the text view // is scrollable. func (t *TextView) ScrollToBeginning() *TextView {