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 forceColor command which allows forcing color on non-tty devices #21

Merged
merged 4 commits into from
Oct 1, 2016

Conversation

benni012
Copy link
Contributor

Hey agauniyal,
I tried my best at implementing the forceColor ostream modifier. I'm a first timer in PR's and would really appreciate if you could take a look and give me some criticism 😄. I hope I didn't mess up too bad 😅.

Regarding the code, I don't really like to expose the getIword method, but I cannot think of any other way to give access to it.

Hope this kind of helps and thanks in advance,
benni012

@agauniyal
Copy link
Owner

If user enters neither of rang::control::autoColor or rang::control::forceColor then what happens? should be autoColor by default, right?

@benni012
Copy link
Contributor Author

benni012 commented Oct 1, 2016

Yes, it's rang::autoColor by default because the iword memory is initialized as 0 when xalloc'ed.
Edit: Oopsie 😅

@benni012 benni012 closed this Oct 1, 2016
@benni012 benni012 reopened this Oct 1, 2016
@agauniyal
Copy link
Owner

The code looks good, I do have a few questions though -

  • are you writing these values(108/109) to the stream somewhere? If not, had they been 0 or 1, would it matter?
enum class control {
    autoColor = 108,
    forceColor = 109
};
  • Is this sticky implementation, sticky as in if we declare std::cout << rang::control::forceColor, it stays on forceColor mode till we don't change it.

@benni012
Copy link
Contributor Author

benni012 commented Oct 1, 2016

  1. They are not written to the stream, they are just constants I used to handle the control commands. They could be any value. Makes way more sense to make them 0 and 1 now that I think about it. 😄
  2. The forceColor flag is stream-wide. After being activated, it will stay active in the stream until a autoColor flag is sent.

@agauniyal
Copy link
Owner

agauniyal commented Oct 1, 2016

Okay let's change them to 0/1 instead and I'll merge it 😄 , though you can skip assigning them numbers all together.

@agauniyal agauniyal changed the base branch from master to develop October 1, 2016 08:04
@@ -146,15 +159,33 @@ using enable = typename std::enable_if
std::is_same<T, rang::bgB>::value,
std::ostream&
>::type;
template <typename T>
Copy link
Owner

Choose a reason for hiding this comment

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

an empty line before this to help readablity ;)

@agauniyal
Copy link
Owner

There's a subtle warning by clang builds too - https://travis-ci.org/agauniyal/rang/jobs/164220342#L346

@agauniyal agauniyal changed the base branch from develop to master October 1, 2016 08:54
@agauniyal agauniyal changed the base branch from master to develop October 1, 2016 08:56
@agauniyal agauniyal merged commit 57a64c9 into agauniyal:develop Oct 1, 2016
@agauniyal
Copy link
Owner

I would like to thank you for taking out time to add this feature into rang library 😸

@benni012
Copy link
Contributor Author

benni012 commented Oct 1, 2016

You're very welcome 😄. Thank you for the warm welcome to the open source community.

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.

2 participants