[C++] How to "dim" code based on preprocessor directives?


#1

I am new to atom but i must say i love it ! I simply do not want to go back to another IDE now that i have used it for a week.

I am using it for “arduino” programming, however i have 2 issues:

  1. i have not yet found a way to “dim” the code, based on preprocessor directives. Is there any way to do it ?

Image top left is what i want to achieve, and image right is what i get with Atom.

  1. When i define a macro i would like the macro to keep the same “color” through the code but in Atom it stays white. Is there anything i can do to achieve this:

Image bottom left if want i want (with, in that case, VALUE colored even when used/passed through a function) and image bottom right is what i get with Atom.

Sorry for the “4 images in 1”, but as a new user i am only allowed to post one image per post it seems.


#2

Maybe. Highlighting is dictated by the language package and the colors are determined by the syntax theme. It is possible to override some of this behavior, but for complete control you need to modify the packages. If you can give me a precise description of how a computer program would identify which characters should be dimmed, I can tell you what your options are.

When i define a macro i would like the macro to keep the same “color” through the code but in Atom it stays white.

This is impossible to do without interpreting the code, which Atom can’t do. It may be possible in the future since the language server protocol offers easy, cross-platform code interpreters, which would make it viable for editors like Atom to have an awareness of how the language works.


#3

Thanks a lot for your answer DamnedScholar, i don’t think i am qualified enough to be able to “give a precise description of how a computer program would identify which characters should be dimmed” as for me it would be like :

#if True
Serial.print(“this line should NOT be dimmed”);
#else
Serial.print(“this line should be dimmed”);
#endif

Basically what evaluates to true is not dimmed but everything that is false should be dimmed in the preprocessor statements.

But thanks again for taking the time to answer. I will have a look at the syntax theme.


#4

I don’t know anything at all about how the preprocessor works except for the fact that I know how preprocessors work generally. Somewhere along the chain, someone knows what to tell the computer to identify this pattern of data correctly. The question is whether that knowledge, or software in which that knowledge has been encoded, is accessible. Since it’s built on Chrome, Atom has the knowledge of the specific language we call JavaScript built in, but everything else has to be sourced from the outside (either from users or other pieces of software). We’re fortunate to have a very large community of experts who have built a lot of support for different tools into packages that we can use, but not every code concept out there has been (or can be) covered, so there are some gaps. Unless someone pipes up who knows more about C++ than me, this may be one of those.