From 3442b13a044dbdc9657565606bd09e3a17b873a1 Mon Sep 17 00:00:00 2001 From: Jakob Maier Date: Sun, 14 Jan 2018 11:36:27 +0100 Subject: [PATCH] Added ScrollToBeginning() and ScrollToEnd() to TextView --- textview.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/textview.go b/textview.go index 6f5bd72..124a4e2 100644 --- a/textview.go +++ b/textview.go @@ -249,6 +249,21 @@ func (t *TextView) SetDoneFunc(handler func(key tcell.Key)) *TextView { return t } +// ScrollToBeginning scrolls to the top left corner of the text. +func (t *TextView) ScrollToBeginning() *TextView { + t.trackEnd = false + t.lineOffset = 0 + t.columnOffset = 0 + return t +} + +// ScrollToEnd scrolls to the bottom left corner of the text. +func (t *TextView) ScrollToEnd() *TextView { + t.trackEnd = true + t.columnOffset = 0 + return t +} + // Clear removes all text from the buffer. func (t *TextView) Clear() *TextView { t.buffer = nil