Skip to content

Fix: non-scrollable textview has strange behavior#342

Closed
dzpao wants to merge 1 commit intorivo:masterfrom
dzpao:fix/issue-341
Closed

Fix: non-scrollable textview has strange behavior#342
dzpao wants to merge 1 commit intorivo:masterfrom
dzpao:fix/issue-341

Conversation

@dzpao
Copy link
Copy Markdown

@dzpao dzpao commented Aug 31, 2019

It seems that there are two lines of code that are upside down.

This should fix #341

@dzpao
Copy link
Copy Markdown
Author

dzpao commented Sep 21, 2019

In order to explain the problem more clearly, I wrote a short example.

If you run the example with the master version, you can see that every time the screen is full, it will be emptied.

With patch applied, the screen will continue to scroll up without being emptied. I think this is more in line with people's expectations.

package main

import (
	"fmt"
	"time"

	"github.com/rivo/tview"
)

func main() {
	app := tview.NewApplication()
	textView := tview.NewTextView().
		SetScrollable(false).
		SetChangedFunc(func() {
			app.Draw()
		})

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

	textView.SetBorder(true)
	mainView := tview.NewFlex().
		SetDirection(tview.FlexRow).
		AddItem(textView, 10, 1, true)
	if err := app.SetRoot(mainView, true).Run(); err != nil {
		panic(err)
	}
}

tslocum added a commit to tslocum/tview that referenced this pull request Oct 18, 2019
@rivo rivo closed this in bacbf51 Oct 18, 2019
@dzpao dzpao deleted the fix/issue-341 branch January 22, 2020 06:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The behavior of TextView.SetScrollable() is very strange

1 participant