Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New feature : List - color per line #4

Closed
yesnault opened this issue Mar 14, 2015 · 16 comments
Closed

New feature : List - color per line #4

yesnault opened this issue Mar 14, 2015 · 16 comments

Comments

@yesnault
Copy link
Contributor

Hi,

It would be nice to be able to define a line (per line) color in the widget list.

Thks !

@gizak
Copy link
Owner

gizak commented Mar 14, 2015

Hi @yesnault , this will be a useful feature! I think we can put it this way:

data = []string{
  "1. pass: foobar0",
  "[[color=red]]2. warning: foobar1",
  "3. pass: foobar2"}

If one wants to specify a particular color, insert a piece like [[color=xxx]] in the front into the data passing to List, then List can detect it and render it differently. This will avoid adding in dramatic changes in current codes.

@yesnault
Copy link
Contributor Author

LGTM !
Le sam. 14 mars 2015 à 20:24, Zack Guo notifications@github.com a écrit :

Hi @yesnault https://github.com/yesnault , this will be a useful
feature! I think we can put it this way:

data = []string{
"1. pass: foobar0",
"[[color=red]]2. warning: foobar1",
"3. pass: foobar2"}

If one wants to specify a particular color, insert a piece like
[[color=xxx]] in the front into the data passing to List, then List can
detect it and render it differently. This will avoid adding in dramatic
changes in current codes.


Reply to this email directly or view it on GitHub
#4 (comment).

@yesnault
Copy link
Contributor Author

I don't know if it's possible or better, but another solution is to use same syntax than term color, like that for yellow color

\e[33;My Text here

@gizak
Copy link
Owner

gizak commented Mar 16, 2015

@yesnault I like your solution, since it looks more "natural" in the sense of terminal printing:)

@warmans
Copy link

warmans commented Mar 28, 2015

Another option I've seen is to use HTML style syntax e.g.

item := "<style color="red">ERROR</style> Something went wrong" 

This is nice as it lets you color individual parts of a line.

@gizak
Copy link
Owner

gizak commented Mar 28, 2015

That seems pretty good, but have to type up many chars. How about this:

item := "[ERROR](red,bold) Something went wrong"

Does the same thing but uses markdown-like syntax.

@yesnault
Copy link
Contributor Author

+1

@Matt3o12
Copy link
Contributor

Has anyone already started working on it? If not, I could start in a few days.

@gizak
Copy link
Owner

gizak commented Mar 31, 2015

👍 That would be great! I was also thinking maybe we can apply this for any text rendering not just List. Introduced a new struct text that:

text.Len() int // return string real length
text.Buffer() []Point// return Points
text.SetBg(Attribute)
text.SetFg(Attribute)

Then all text procedures can use this structure to render, which gives the ability of using specific color.

@fgrehm
Copy link

fgrehm commented Apr 1, 2015

👍

@Matt3o12
Copy link
Contributor

Matt3o12 commented Apr 1, 2015

While something like that was my initial idea, it is not going to work because of text overflows.
I will implement an Api that is easy to implement and customizable. I was thinking of an interface that implements a method for the normalized text (I.e. All formating elements are stripped out) so the list class can work with that text. But instead of creating the buffer itself, there will be a method that will return a buffer for the given text sequence.

This should not break backwards compatibility and it will be customizable so that @warmans can implement his html formating if he wants to.
I will implement markdown and ASCII escape codes.

Sent from my iPhone

On Apr 1, 2015, at 1:25 AM, Zack Guo notifications@github.com wrote:

That would be great! I was also thinking maybe we can apply this for any text rendering not just List. Introduced a new struct text that:

text.Len() int // return string real length
text.Buffer() []Point// return Points
text.SetBg(Attribute)
text.SetFg(Attribute)
Then all text procedures can use this structure to render, which gives the ability of using specific color.


Reply to this email directly or view it on GitHub.

@Matt3o12 Matt3o12 mentioned this issue Apr 5, 2015
@divan
Copy link
Contributor

divan commented Apr 21, 2015

+1 for markdown syntax: it's easy to pick up even if you're terminal codes guy.

@Matt3o12
Copy link
Contributor

@divan:
Both are already implemented and the pull request #22 is pending

@gizak gizak added bug pending and removed bug labels Apr 22, 2015
@omeid
Copy link

omeid commented Jun 4, 2015

👍

@gizak
Copy link
Owner

gizak commented Oct 29, 2015

Done!

@gizak gizak closed this as completed Oct 29, 2015
@yesnault
Copy link
Contributor Author

yesnault commented Nov 1, 2015

Thanks to everyone !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants