mirror of
https://github.com/rivo/tview.git
synced 2026-04-26 21:35:54 +03:00
[GH-ISSUE #550] Expose utils.printWithStyle function #405
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tview#405
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 @dwillist on GitHub (Jan 14, 2021).
Original GitHub issue: https://github.com/rivo/tview/issues/550
It would be helpful to expose the
printWithStylefunction to let users set the style of a line.Seems like from this issue you've considered this change.
@rivo commented on GitHub (Feb 17, 2021):
Actually, my comment in that issue was meant to advocate for the opposite: Keep these utility functions private. The problems with making them public are still relevant. I still have to modify them from time to time. In fact, the
printWithStyle()function was just modified this week to allow for an improvement to theListprimitive. As I said before, evenPrint()should be private (actually, it shouldn't even exist at all as it is now) but because of the backwards compatibility promise, I'm keeping it public. So it's unlikely that I'll make them public any time soon.You mention changing the style of a line. Which line? How would you use
printWithStyle()for that? It sounds to me likeprintWithStyle()would be a bit overkill to draw lines as its main complexity is in text alignment and handling colour tags etc. Maybe there's a more efficient way to do what you want to do.@rivo commented on GitHub (Apr 27, 2021):
Without any more information, I'll deny this one for now. You can reopen if you feel this needs more discussion.
@tcurdt commented on GitHub (Jan 30, 2023):
Hm. I am conflicted about that argument, @rivo.
While agree it's important to keep the public interface clean...
I was hoping to rip out the
Listinto my own package to turn it into a radio group control.But the private utils make that a lot harder.
It does feel like having a "printing with styles" to be an essential part of allowing custom controls.
Otherwise everyone would have to re-implement that. And I'll be honest:
This function has so much stuff - I wouldn't even know where to start.
Doesn't that suggest it should become part of the public contract?
@rivo commented on GitHub (Apr 15, 2023):
I think this is the critical point: In your application, do you need all the stuff that
printWithStyle()offers, specifically, what it offers over the already publicPrint()function?The original question was about drawing lines which is really simple using
Screen.SetContent()and doesn't require Unicode special character handling, text alignment, character skipping, string index calculation, color tag handling, width calculation, etc. I wonder if all of this is needed in your application.On another note, radio buttons have been requested a few times already (see #839). I guess it's on the roadmap then.
@tcurdt commented on GitHub (Apr 15, 2023):
TBH I wasn't even aware of
Screen.SetContent()when writing that comment.And I agree for (line) drawing that makes total sense to use.
The radio buttons on the other hand (or any custom control really) would probably benefit from using
printWithStyle()over justPrint(), no?@rivo commented on GitHub (Apr 16, 2023):
The difference between
Print()andprintWithStyle()is minimal. Unless you really need this specific extra feature thatprintWithStyle()offers, I'm quite sure you'll be fine withPrint().