mirror of
https://github.com/mum4k/termdash.git
synced 2026-04-27 03:15:55 +03:00
[GH-ISSUE #190] Text box display colors (custom colors) #111
Labels
No labels
bug
cleanup
enhancement
enhancement
enhancement
good first issue
help wanted
help wanted
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/termdash#111
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 @keithknott26 on GitHub (Apr 27, 2019).
Original GitHub issue: https://github.com/mum4k/termdash/issues/190
Hello,
I noticed something when working with the text box when specifying a custom color... the colors that are displayed are different from what you'd expect, you'll need to add one to the color code in order for it to show the color you were after.
Try this on your side and let me know if you get the same results.
Thanks,
Keith
@keithknott26 commented on GitHub (Apr 27, 2019):
I should point out that I'm using this chart, which may be different from the one you designed with. Maybe that's the issue? (https://jonasjacek.github.io/colors/) I did notice though that when you specify a line in the linechart and then use that same color code in the text box, they don't often match up.
@mum4k commented on GitHub (Apr 27, 2019):
Hey @keithknott26,
thanks for reaching out. This is one of the design decisions that I am not proud of. The color system was implemented very early on and well I didn't know better.
See termbox-go defines value 0 not as the black color but as the default terminal color. It is used when the user didn't provide a color option. This means that black is now color number 1 which makes all the colors off-by-one.
When I implemented our cell API, I have simply copied this without giving it too much thought:
github.com/mum4k/termdash@a9515f2721/cell/color.go (L47-L60)Later when I realized the off-by-one problem I have added this function:
github.com/mum4k/termdash@a9515f2721/cell/color.go (L62-L74)So a quick fix for the code you have included is to use this helper:
Please let me know if this helps as a workaround. Obviously this isn't ideal since it is easy to miss the cell.ColorNumber function. In theory we could still fix this by switching color fields to a pointer and then using nil to represent unset value. Zero could then become black, but at this point this would be a larger change that might break someone. Alternatively we could try to improve the documentation.
Please let me know what you think is best.
@keithknott26 commented on GitHub (Apr 27, 2019):
Great! As always I thank you for your detailed response, your workaround works just fine! Really appreciate the help!