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

[windows] Fix for background colours besides black #1488

Closed
wants to merge 1 commit into from
Closed

[windows] Fix for background colours besides black #1488

wants to merge 1 commit into from

Conversation

gvanem
Copy link

@gvanem gvanem commented Sep 12, 2022

Fix for issue #1487.

@google-cla
Copy link

google-cla bot commented Sep 12, 2022

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Comment on lines +145 to +146
new_attr = (buffer_info.wAttributes & ~7);
new_attr &= ~8; // Since 'wAttributes' could have been hi-intensity at startup.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are 7 and 8 here? Can we avoid magic numbers?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I simply mask off the foreground bits (~7) and the hi-intensity background colour bit (~8).
Should be clear. And there's no WinCon values for these AFAIK.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I give up.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the comment suggests there's a bug here. BACKGROUND_INTENSITY is 0x0080 i think. FOREGROUND_INTENSITY is 0x0008.

same with the masking of ~7 if you're trying to mask off the backgrounds.. not sure how this works (i am not a windows dev though).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me rephraze: can you not just replace 8 with BACKGROUND_INTENSITY and 7 with FOREGROUND_INTENSITY?

Copy link
Collaborator

@LebedevRI LebedevRI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(as per inline comment)

Comment on lines +145 to +146
new_attr = (buffer_info.wAttributes & ~7);
new_attr &= ~8; // Since 'wAttributes' could have been hi-intensity at startup.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gvanem To clarify/reiterate, what happens if you literally apply the following change:

Suggested change
new_attr = (buffer_info.wAttributes & ~7);
new_attr &= ~8; // Since 'wAttributes' could have been hi-intensity at startup.
new_attr = (buffer_info.wAttributes & ~FOREGROUND_INTENSITY);
new_attr &= ~BACKGROUND_INTENSITY; // Since 'wAttributes' could have been hi-intensity at startup.

Does it not compile?
The problem is that no one will have a clue what those 7 and 8 really meant,
and the docs imply that there are named macros, so we should use them.

@gvanem gvanem closed this Jul 5, 2023
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

Successfully merging this pull request may close these issues.

3 participants