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

Add support for short hex color codes (like #CCC) #2639

Closed
mikemaccana opened this issue Sep 2, 2019 · 4 comments · Fixed by #2658
Closed

Add support for short hex color codes (like #CCC) #2639

mikemaccana opened this issue Sep 2, 2019 · 4 comments · Fixed by #2658
Assignees
Labels
Area-Settings Issues related to settings and customizability, for console or terminal Issue-Task It's a feature request, but it doesn't really need a major design. Needs-Tag-Fix Doesn't match tag requirements Product-Terminal The new Windows Terminal. Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release.
Milestone

Comments

@mikemaccana
Copy link
Contributor

mikemaccana commented Sep 2, 2019

Windows 10.0.18908.0. Terminal Preview 0.4.2382.0

Using #CCC instead of #CCCCCC results in an unparsable settings file. Not a big deal but since most other places (eg browser devtools)) that take hex also take short codes, worth fixing.

Not sure re: HSLA etc but that's a separate issue.

@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Sep 2, 2019
@DHowett-MSFT
Copy link
Contributor

Yeah, we should probably support this. The first thing, not the HSLA thing.

@DHowett-MSFT DHowett-MSFT added Area-Settings Issues related to settings and customizability, for console or terminal Issue-Task It's a feature request, but it doesn't really need a major design. Product-Terminal The new Windows Terminal. and removed Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Sep 3, 2019
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label Sep 3, 2019
@DHowett-MSFT DHowett-MSFT added this to the Terminal v1.0 milestone Sep 3, 2019
@DHowett-MSFT DHowett-MSFT changed the title Using short hex colors breaks settings parser. Add support for short hex color codes (like #CCC) Sep 3, 2019
@kojoru
Copy link
Contributor

kojoru commented Sep 3, 2019

Should be a few lines' worth of change around here, right?

COLORREF Utils::ColorFromHexString(const std::string str)
{
THROW_HR_IF(E_INVALIDARG, str.size() < 7 || str.size() >= 8);
THROW_HR_IF(E_INVALIDARG, str[0] != '#');
std::string rStr{ &str[1], 2 };
std::string gStr{ &str[3], 2 };
std::string bStr{ &str[5], 2 };
BYTE r = static_cast<BYTE>(std::stoul(rStr, nullptr, 16));
BYTE g = static_cast<BYTE>(std::stoul(gStr, nullptr, 16));
BYTE b = static_cast<BYTE>(std::stoul(bStr, nullptr, 16));
return RGB(r, g, b);

Can I try and take a stab at it?

@zadjii-msft
Copy link
Member

@kojoru go right ahead!

Bonus points if you add a test in here :)

kojoru added a commit to kojoru/terminal that referenced this issue Sep 4, 2019
kojoru added a commit to kojoru/terminal that referenced this issue Sep 4, 2019
@ghost ghost added the In-PR This issue has a related PR label Sep 4, 2019
kojoru added a commit to kojoru/terminal that referenced this issue Sep 4, 2019
DHowett-MSFT pushed a commit that referenced this issue Sep 4, 2019
This adds a few lines to support shorthand color hex codes like #ABC. They are treated as equivalent of #AABBCC.

Fixes #2639.
@ghost ghost added Needs-Tag-Fix Doesn't match tag requirements Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release. and removed In-PR This issue has a related PR labels Sep 4, 2019
@ghost
Copy link

ghost commented Sep 24, 2019

🎉This issue was addressed in #2658, which has now been successfully released as Windows Terminal Preview v0.5.2661.0.:tada:

Handy links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Settings Issues related to settings and customizability, for console or terminal Issue-Task It's a feature request, but it doesn't really need a major design. Needs-Tag-Fix Doesn't match tag requirements Product-Terminal The new Windows Terminal. Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants