mirror of
https://github.com/rivo/tview.git
synced 2026-04-27 13:55:51 +03:00
[GH-ISSUE #456] utils.go: Can't output normally if "[xxxx]" in string #325
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tview#325
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 @Chen-Haohuang on GitHub (Jun 5, 2020).
Original GitHub issue: https://github.com/rivo/tview/issues/456
when I output a string into textview, I find it can't output normally if if "[xxxx]" in the string.
e.g.
I want to show "before[unknown]after" in output textview, but it only leaves "before".
I know maybe I can use "before[unknown[]after", but I can't know what the string contains before I output.
I have found where the bug is.
In function:utils.go:decomposeString
We also need to filter it out if the tag is not a color tag. So I modified the function.
@abitrolly commented on GitHub (Jun 5, 2020):
Or just use
Escape()function?https://pkg.go.dev/github.com/rivo/tview?tab=doc#hdr-Colors
@rivo commented on GitHub (Jun 10, 2020):
Checking for colour names will only work until somebody wants to output "[red]" without escaping it. It's not a good solution in my opinion.
As @abitrolly mentioned, there is an
Escape()function. Or simply calltextView.SetDynamicColors(false)to ignore any colour tags.@ghostsquad commented on GitHub (Jun 17, 2020):
I'm a bit confused here. If someone wants to output the literal value of
[red], would you useEscape()first? then inject/wrap with color?@ghostsquad commented on GitHub (Jun 17, 2020):
Also, what happens if
[red]shows up in the text along with ANSI Escape Codes? Would you firstEscape(), then useTranslateANSI()?@rivo commented on GitHub (Jun 28, 2020):
I guess that's what I would do.
TranslateANSI()should do the escaping for you. There should be no need to callEscape()first if you're translating ANSI escape sequences. If that doesn't work, it's a bug and I have to fix it. (Please let me know if that's the case.)@rivo commented on GitHub (Jul 12, 2020):
Please let me know if any more help is needed. If not, I'll close the issue soon.