mirror of
https://github.com/rivo/tview.git
synced 2026-04-27 05:45:49 +03:00
[GH-ISSUE #245] Method to get bottom-most scroll position possible, and getting TrackEnd for TextView #190
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tview#190
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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
TrackEndboolean, 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.
@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.
@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
TrackEndis true, I could addheightandcurrentScrollto 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.
@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?
@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.
@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
to which my last answer would be a solution, I believe. But since you then wrote
I'm not sure if there is a problem anymore.
@diamondburned commented on GitHub (Mar 19, 2019):
How would you implement that? If you would add it, that's fine for me.
@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.