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

ANSI 256 as #3-tuples #26

Closed
nojhan opened this issue Nov 12, 2022 · 10 comments
Closed

ANSI 256 as #3-tuples #26

nojhan opened this issue Nov 12, 2022 · 10 comments

Comments

@nojhan
Copy link

nojhan commented Nov 12, 2022

Docs says "there is currently no syntax for Color::Ansi256 because I couldn’t come up with a nice syntax and I never used these ansi colors…)". I do need those ones.

What about just using a #123 syntax? If RGB should always be 6-tuple strings, then there is no ambiguity with ANSI's 256 3-tuple.

The meaning should be straigthforward, but may collides in users mind with CSS' short 3-tuple RGB (for which #fff is a valid shortcut for #ffffff).

Alternatively, any other prefix may be used, like @, which reminds the A of ANSI.

@LukasKalbertodt
Copy link
Owner

Just so I don't misunderstand: the 123 in your example would be a decimal number between #0 and #255? Or is it three separate components as you said "3-tuple"? That wouldn't make a lot of sense according to Wikipedia, right? Because (a) how to split 8 bit into 3 components, and (b) the individual components wouldn't really have a meaning on their own like in RGB hex codes, right?

I also immediately thought it would cause confusion with people used to short hex codes in CSS. Thus I would prefer another prefix. Apart from @, $, %, ~ would also be fine I guess. But yeah, why not @ 🤷

@nojhan

This comment was marked as outdated.

@LukasKalbertodt
Copy link
Owner

Woopsie! Because you replied via mail, GitHub detected those the things around @ as email addresses and censored them. Could you write that again via GitHub UI? ^_^

@nojhan
Copy link
Author

nojhan commented Nov 14, 2022

Now that's a fun behavior.

I was thinking of "three digits", between 001 and 255. That would be "@001", "@012", "@123", "@255", etc.

@LukasKalbertodt
Copy link
Owner

Any specific reason you would force users to add leading 0s? The syntax would be unambiguous even for @12, right?

@nojhan
Copy link
Author

nojhan commented Nov 16, 2022

Looked more consistent to me, comparing with RGB hex. But it's probably better to just use short numbers, given that all docs on ANSI present them without leading zeros.

@LukasKalbertodt
Copy link
Owner

Okay yeah, I would also not force leading zeros I think.

I guess then we have a plan. Do you wanna give it a try and prepare a PR? Otherwise I might do it in the near future -- no promises tho!

@nojhan
Copy link
Author

nojhan commented Nov 16, 2022

I still have to learn Rust and use it to port a project (using bunt ;), so it's going to take some time for me as well.

@LukasKalbertodt
Copy link
Owner

Then I will have a stab at it I guess! I hope you're enjoying Rust so far ;-)

@LukasKalbertodt
Copy link
Owner

Fixed in fc63556 and released as v0.2.8

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

No branches or pull requests

2 participants