mirror of
https://github.com/rivo/tview.git
synced 2026-04-26 21:35:54 +03:00
[GH-ISSUE #648] feature request: expose number of lines in text on TextView #474
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tview#474
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 @rgrannell1 on GitHub (Sep 14, 2021).
Original GitHub issue: https://github.com/rivo/tview/issues/648
Use-case:
I'm dynamically updating a
TextViewwith content from stdout (so is #645), and I'd like to efficiently check the total number of lines ("\n" delimited) in the view. I'm using the view's line-count to:At the moment, I use a multiwriter to copy stdout to a buffer, and count lines from there. This is untidy.
Ideally I could call
that would wrap this functionality.
Implementation:
tview.GetLineCount()is based of a private value
lineCountin theTextViewstruct. This value would be updated in.Writeand.SetTextand wherever else it's needed (reindexBuffer?), and would be capped by the struct valuemaxLinesif present.Related Issues:
@rivo commented on GitHub (Sep 27, 2021):
There are multiple "lines" in
TextViewthis could refer to. Which one is the line count that you mean?TextViewdisplays text, the number of lines in the original text buffer, i.e. the number of\ncharacters (plus one)TextViewis not as wide as the longest line in the original text buffer (and if word wrapping is enabled), this number will be greater than the number of\ncharacters in the buffer.TextView.@rgrannell1 commented on GitHub (Sep 27, 2021):
Sorry, I didn't mean to be ambiguous. Option 3 is well covered by the API already, so I'm referring to options one. I personally won't need option two, but one idea would be to add a
wrapped: boolparameter to allow people to select this@rivo commented on GitHub (Feb 15, 2022):
I added
TextView.GetOriginalLineCount()in the latest commit.