[GH-ISSUE #341] The behavior of TextView.SetScrollable() is very strange #257

Closed
opened 2026-03-04 01:03:24 +03:00 by kerem · 2 comments
Owner

Originally created by @dzpao on GitHub (Aug 31, 2019).
Original GitHub issue: https://github.com/rivo/tview/issues/341

Talk is cheap, show you the code:

package main

import (
	"fmt"
	"time"

	"github.com/rivo/tview"
)

func main() {
	app := tview.NewApplication()
	textView := tview.NewTextView()
	textView.SetScrollable(false)  // <------ Please note here
	textView.SetBorder(true)
	textView.SetChangedFunc(func() {
		text := textView.GetText(false)
		textView.SetTitle(fmt.Sprintf("%d bytes", len(text)))
		app.Draw()
	})

	go func() {
		n := 1
		for {
			fmt.Fprintf(textView, "line %d\n", n)
			n++
			time.Sleep(200 * time.Millisecond)
		}
	}()

	if err := app.SetRoot(textView, true).Run(); err != nil {
		panic(err)
	}
}

When I ran this code, I observed that the screen would be empty after it was full.
But according to the TextView documentation, it should be that only text that is above the top of the screen will be discarded.

If the text is not scrollable, any text above the top visible line is discarded.

So what am I doing wrong?

Originally created by @dzpao on GitHub (Aug 31, 2019). Original GitHub issue: https://github.com/rivo/tview/issues/341 Talk is cheap, show you the code: ```Golang package main import ( "fmt" "time" "github.com/rivo/tview" ) func main() { app := tview.NewApplication() textView := tview.NewTextView() textView.SetScrollable(false) // <------ Please note here textView.SetBorder(true) textView.SetChangedFunc(func() { text := textView.GetText(false) textView.SetTitle(fmt.Sprintf("%d bytes", len(text))) app.Draw() }) go func() { n := 1 for { fmt.Fprintf(textView, "line %d\n", n) n++ time.Sleep(200 * time.Millisecond) } }() if err := app.SetRoot(textView, true).Run(); err != nil { panic(err) } } ``` When I ran this code, I observed that the screen would be empty after it was full. But according to the TextView documentation, it should be that only text that is above the top of the screen will be discarded. > If the text is not scrollable, any text above the top visible line is discarded. So what am I doing wrong?
kerem closed this issue 2026-03-04 01:03:24 +03:00
Author
Owner

@dzpao commented on GitHub (Aug 31, 2019):

I have retired several versions and located the problem that should be introduced by fc28d64. The behavior of previous versions of this version is as expected.

<!-- gh-comment-id:526846218 --> @dzpao commented on GitHub (Aug 31, 2019): I have retired several versions and located the problem that should be introduced by fc28d64. The behavior of previous versions of this version is as expected.
Author
Owner

@rivo commented on GitHub (Oct 18, 2019):

Thanks. It was really just a typo in the code. Should be fixed now.

<!-- gh-comment-id:543700288 --> @rivo commented on GitHub (Oct 18, 2019): Thanks. It was really just a typo in the code. Should be fixed now.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tview#257
No description provided.