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

support all named colors from X11 rgb.txt #138

Open
markus-oberhumer opened this issue May 10, 2021 · 5 comments · May be fixed by #175
Open

support all named colors from X11 rgb.txt #138

markus-oberhumer opened this issue May 10, 2021 · 5 comments · May be fixed by #175
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@markus-oberhumer
Copy link

Just came across this nice program, only to realize that it is missing many named colors:

$ pastel color red3
[pastel error]: Could not parse color 'red3'

Please see https://en.wikipedia.org/wiki/X11_color_names and https://cgit.freedesktop.org/xorg/app/rgb/tree/rgb.txt .

The few clashing color names could be resolved by using a x11- prefix like in x11-gray.

@sharkdp
Copy link
Owner

sharkdp commented May 10, 2021

Thank you for your feedback.

I'm okay with adding these color names. I'm not sure if they should show by default when calling pastel list though.

As for the name clashes: maybe we could prefix all of them with x11? But then there's the issue of discoverability.

See also: #32

@markus-oberhumer
Copy link
Author

I agree that this might be an UI issue.

So prefixing all colors with x11- and (maybe) hiding them from pastel list would be fine.

@sharkdp sharkdp added enhancement New feature or request good first issue Good for newcomers labels May 11, 2021
@sharkdp sharkdp changed the title wishlist: support all named colors from X11 rgb.txt support all named colors from X11 rgb.txt May 11, 2021
@markus-oberhumer
Copy link
Author

The following small Python program

#!/usr/bin/env python3
import re

# NOTE: wget https://cgit.freedesktop.org/xorg/app/rgb/plain/rgb.txt
lines = open("rgb.txt").read().splitlines()

colors = []
for l in lines:
    m = re.match(r"^(\d+)\s+(\d+)\s+(\d+)\s+(.*)", l.strip())
    if m:
        colors.append([m.group(4), m.group(1), m.group(2), m.group(3)])

print(f'// {len(colors)} X11 colors')
for name, r, g, b in sorted(colors):
    print(f'        named_color("x11-{name}", {r}, {g}, {b}),'

creates 782 entries in the form of

        named_color("x11-AliceBlue", 240, 248, 255),
        named_color("x11-AntiqueWhite", 250, 235, 215),
        ...

for inclusion into src/named.rs.

After compiling pastel list seems to work, but pastel color x11-red does not - probably some issue with the parser.

@devhell
Copy link

devhell commented Jun 24, 2021

This would be awesome! I've been trying to create various colorschemes for programs that only have support for xterm-type colors, and would thoroughly enjoy having the ability to match colors to their nearest xterm equivalent. Thank you for such a thoughtful and amazing tool! Prost! 🍻

@Vinegret43
Copy link

Vinegret43 commented Aug 30, 2021

@sharkdp, maybe we could add something like '--all' option for list command that will display all colors, and without this option it will display only base colors, excluding X11, this will solve problem with discoverability. (i'm working on this issue right now and just want to know your opinion about adding this option, i already tested it on my machine)

Also, X11's rgb.txt has some color names which consist of multiple words (They are just synonyms for their single-worded alternatives, like 'royal blue' and 'royalblue'). The question is: should i delete these multi-worded synonyms from the list?

@dyuri dyuri linked a pull request Jan 6, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants