[GH-ISSUE #245] Method to get bottom-most scroll position possible, and getting TrackEnd for TextView #190

Closed
opened 2026-03-04 01:02:49 +03:00 by kerem · 7 comments
Owner

Originally created by @diamondburned on GitHub (Mar 1, 2019).
Original GitHub issue: https://github.com/rivo/tview/issues/245

I was looking to get the bottom-most scroll position and calculate scroll position in percentage, though as of now, there's no way to do this without calling ScrollToEnd(), but this means there will be visual changes.

By exposing the TrackEnd boolean, I could check that if it's false, show a toaster saying there's something updated.

By adding a method to get bottom scroll, I could calculate the scroll position of the buffer as a replacement for a scroll bar.

Originally created by @diamondburned on GitHub (Mar 1, 2019). Original GitHub issue: https://github.com/rivo/tview/issues/245 I was looking to get the bottom-most scroll position and calculate scroll position in percentage, though as of now, there's no way to do this without calling `ScrollToEnd()`, but this means there will be visual changes. By exposing the `TrackEnd` boolean, I could check that if it's false, show a toaster saying there's something updated. By adding a method to get bottom scroll, I could calculate the scroll position of the buffer as a replacement for a scroll bar.
kerem closed this issue 2026-03-04 01:02:49 +03:00
Author
Owner

@rivo commented on GitHub (Mar 9, 2019):

I'm sorry but I'm having trouble understanding what you're trying to achieve. I'm guessing here but do you want to find out if there are more lines beyond what is currently shown in a TextView?

Maybe you could include some kind of example or screenshot that illustrates your requirement.

<!-- gh-comment-id:471172903 --> @rivo commented on GitHub (Mar 9, 2019): I'm sorry but I'm having trouble understanding what you're trying to achieve. I'm guessing here but do you want to find out if there are more lines beyond what is currently shown in a `TextView`? Maybe you could include some kind of example or screenshot that illustrates your requirement.
Author
Owner

@diamondburned commented on GitHub (Mar 11, 2019):

I've actually found a way to get the bottom scroll in one of my forks, which is to check if TrackEnd is true, I could add height and currentScroll to get the bottom-most scroll. Then if the user scrolls up, I could calculate from that the total height of the buffer and give them their location.

As for getting TrackEnd, I would like to see, for example, if the user is looking at the bottom-most line of the buffer, which is where new information is printed. If they're scrolling, TrackEnd would be false, and they would be missing new information, thus I would notify them. This is, of course, a very specific use-case, but that's what is in my mind right now.

<!-- gh-comment-id:471367942 --> @diamondburned commented on GitHub (Mar 11, 2019): I've actually found a way to get the bottom scroll in one of my forks, which is to check if `TrackEnd` is true, I could add `height` and `currentScroll` to get the bottom-most scroll. Then if the user scrolls up, I could calculate from that the total height of the buffer and give them their location. As for getting TrackEnd, I would like to see, for example, if the user is looking at the bottom-most line of the buffer, which is where new information is printed. If they're scrolling, TrackEnd would be false, and they would be missing new information, thus I would notify them. This is, of course, a very specific use-case, but that's what is in my mind right now.
Author
Owner

@rivo commented on GitHub (Mar 16, 2019):

I could add a function that gives you information about what is visible at the moment. Something that tells you "the buffer currently has 42 lines, you are seeing lines 5 to 39 right now". Would that help you?

<!-- gh-comment-id:473524339 --> @rivo commented on GitHub (Mar 16, 2019): I could add a function that gives you information about what is visible at the moment. Something that tells you "the buffer currently has 42 lines, you are seeing lines 5 to 39 right now". Would that help you?
Author
Owner

@diamondburned commented on GitHub (Mar 17, 2019):

Well, I can already do that, but do tell me how the implementations will be, maybe it'll help.

<!-- gh-comment-id:473616478 --> @diamondburned commented on GitHub (Mar 17, 2019): Well, I can already do that, but do tell me how the implementations will be, maybe it'll help.
Author
Owner

@rivo commented on GitHub (Mar 17, 2019):

If you can already do that, then I don't know what you're still missing. You wrote

I would like to see, for example, if the user is looking at the bottom-most line of the buffer, which is where new information is printed.

to which my last answer would be a solution, I believe. But since you then wrote

I can already do that

I'm not sure if there is a problem anymore.

<!-- gh-comment-id:473660684 --> @rivo commented on GitHub (Mar 17, 2019): If you can already do that, then I don't know what you're still missing. You wrote > I would like to see, for example, if the user is looking at the bottom-most line of the buffer, which is where new information is printed. to which my last answer would be a solution, I believe. But since you then wrote > I can already do that I'm not sure if there is a problem anymore.
Author
Owner

@diamondburned commented on GitHub (Mar 19, 2019):

How would you implement that? If you would add it, that's fine for me.

<!-- gh-comment-id:474147667 --> @diamondburned commented on GitHub (Mar 19, 2019): How would you implement that? If you would add it, that's fine for me.
Author
Owner

@rivo commented on GitHub (May 13, 2019):

Apologies for the late reply. I was gone for a while. You'll need to determine it during the last call to Draw() here:

github.com/rivo/tview@7a653a04b3/textview.go (L829-L832)

If line < len(t.index) - 1, then there is still content after the fold.

I would probably save that info in the class and return it when needed.

<!-- gh-comment-id:491819955 --> @rivo commented on GitHub (May 13, 2019): Apologies for the late reply. I was gone for a while. You'll need to determine it during the last call to `Draw()` here: https://github.com/rivo/tview/blob/7a653a04b36c7fbc57aeb65923dc7f2f0d48b963/textview.go#L829-L832 If `line < len(t.index) - 1`, then there is still content after the fold. I would probably save that info in the class and return it when needed.
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#190
No description provided.