mirror of
https://github.com/rivo/tview.git
synced 2026-04-26 13:25:51 +03:00
[GH-ISSUE #239] Feature Request: Adding subtext to the TreeView #185
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tview#185
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 @coquizen on GitHub (Feb 21, 2019).
Original GitHub issue: https://github.com/rivo/tview/issues/239
How trivial is it to add subtext to the TreeView? The use case for this would be to display a comment tree from a blog with its respective replies indented to align with its node. I have already started an attempt to add this functionality but struggling to understand how the TreeView is rendered. Can you walk me through the code? (I am a beginner at this and would like to contribute).
The following is an example of what I mean:
| Title of Comment
| Body of Comment
|└──title of reply
| body of reply
| └──title of reply
| Body of reply
Is this a matter of tweaking current code or does it require a rewrite? On my fork of your project I have already written some code to this effect. Great project btw!
[EDITED: for clarification of use case. Ignore the the leading '|' as it was used to maintain alignment.]
[EDITED2: See below for clarification as github automatically removes empty spaces]
@Bios-Marcel commented on GitHub (Feb 23, 2019):
Hey, I'd like to clarify what you mean. Do you mean that you want a tree hierarchy where the nodes support multiline text? Because the example that you have shown us simply looks like a normal treeview.
And why does it need to be a treeview anyway?
@coquizen commented on GitHub (Feb 24, 2019):
My intention with treeview is to adapt it such that the subtext can be multi-lined and properly aligned with the title text. The use case would be for showing comments with its meta data as its title text and the body of the comment as its subtext. Their replies would be subtreenodes of its parent with the functionality of folding each node as before. An added feature would be a setting where the subtext could be folded as well.
--
Ian G Canino
Telegram: telegram.me/iangadev
eMail: ian.canino@gmail.com
On Feb 23, 2019, 5:48 PM -0500, Marcel Schramm notifications@github.com, wrote:
@Bios-Marcel commented on GitHub (Feb 24, 2019):
I dont think you need this. Just use a Textview and regions + highlights if you need a selection. Adding such features to the treeview doesnt seem like the way to go.
@coquizen commented on GitHub (Feb 24, 2019):
Alternatively have tree view support multilie text via respecting '\n' code.
My understanding of regions and highlight in the library is that it affects the styling and ability to tag internally. Not the alignment which is at the core of the feature request.
@Bios-Marcel commented on GitHub (Feb 24, 2019):
Oh right, you want it to break the lines AND have indentation as well. Then I have no better idea :)
@rivo commented on GitHub (Mar 8, 2019):
When you look at the presentation demo, on page 9, the various features of the
TreeVieware shown. Maintaining support for these features while adding variable-height nodes will be a major effort. Even worse will be making line breaks work (automatic as well as forced). I've refactoredTextViewmultiple times to make line breaks work properly with all the edge cases (as well as all the issues that come with unicode characters). I don't see this happening any time soon onTreeView.Two solutions come to mind here: If you insist on the lines that
TreeViewdraws, I would suggest keeping the nodes on one line and showing a preview of your comment texts in them. Maybe like this:When the user navigates to one of the lines, you could show the full text in a second window.
The second idea would be to not use
TreeViewbut instead use aGridlayout. I coded up a small example:Of course, you wouldn't hardcode it like this. And maybe you don't want the borders around the comments. Thirdly, you may need two render passes if you want the height of the comments to adapt to the number of lines in the comments (
tviewdoes not calculate layouts bottom-up but top-down). But like this, it would be possible to show a hierarchy (no lines, though, unless you want to draw them yourself).Let me know if this helps you a bit.