From 8bc6a3f68406413f399873701baee89cebe1cac1 Mon Sep 17 00:00:00 2001 From: Oliver <480930+rivo@users.noreply.github.com> Date: Sun, 14 Jan 2018 13:35:57 +0100 Subject: [PATCH] Minor additions to pull request #30. Resolves #28. --- textview.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/textview.go b/textview.go index 28c3aea..4ed7cf7 100644 --- a/textview.go +++ b/textview.go @@ -286,16 +286,25 @@ func (t *TextView) SetDoneFunc(handler func(key tcell.Key)) *TextView { return t } -// ScrollToBeginning scrolls to the top left corner of the text. +// ScrollToBeginning scrolls to the top left corner of the text if the text view +// is scrollable. func (t *TextView) ScrollToBeginning() *TextView { + if !t.scrollable { + return t + } t.trackEnd = false t.lineOffset = 0 t.columnOffset = 0 return t } -// ScrollToEnd scrolls to the bottom left corner of the text. +// ScrollToEnd scrolls to the bottom left corner of the text if the text view +// is scrollable. Adding new rows to the end of the text view will cause it to +// scroll with the new data. func (t *TextView) ScrollToEnd() *TextView { + if !t.scrollable { + return t + } t.trackEnd = true t.columnOffset = 0 return t