Styling Variables

How can I make a local variable displayed in italic style?
It is necessary that a beginner can recognize global and local variables by the font style

Welcome!
I don't think this is possible, though others can say for sure(and it might be possible in IDE 2.x, but not 1.x).
But why do something differently than the rest of the world? Establish a naming convention, and stick with it, and all will be well. Many such exist; for your purposes, maybe:

int gloA, gloB;
would signify global scope, while

int lclC, lclD;
could signify local scope.
Up to you.

1 Like

Is it IDE 1.x or IDE 2.x or a totally different development environment?

2 Likes

IDE 1.x & IDE 2.x

Solve using memory resources?
Arduino doesn't have a lot of memory space anyway.

What does a naming convention have to do with memory resources?

3 Likes

Is it?

I'm not aware of any IDEs which do that.

As @camsysca said, the usual way is to adopt a naming convention. Common practice is to minimise globals, so just the globals get identified.

Solve what? Using what "memory resources"? :man_shrugging:

True - but that has nothing to do with highlighting in the editor?

Given the lack of comprehensible reply, pure speculation follows.
You think you can help some beginners by making it obvious which variables are global vs local, thus helping them manage memory resources for Arduinos which have limited memory resources.

Far better to teach them the differences, and variable scoping, right from the beginning, so they can do it right from the start. Fancy display techniques won't help much, using their minds will. Just a free opinion, for what it's worth!

4 Likes

Hi @tur55. As others have already indicated, it is not possible to do this in Arduino IDE 1.x.

Arduino IDE 1.x does have a theming system, which allows you to configure the colors and fonts. However, the IDE doesn't have any knowledge of which variables are local vs. global, so there aren't separate theme settings for each variable type. In addition, the font is only configurable for each panel of the IDE window. At the sub-panel granularity, only the color is configurable.

Documentation of the Arduino IDE 1.x theme system is available here:

https://github.com/per1234/themetest#theme-documentation

This screenshot demonstrates the available settings:

Even though the capability you hoped for isn't available, maybe you will find it useful to clearly differentiate some of the other elements that are configurable via a custom theme.


Arduino IDE 2.x has a completely different theme system. Although its theming system is generally more capable and intelligent than the Arduino IDE 1.x theme system, I still don't think it provides the capability to style local vs. global variables differently.

You can learn about the Arduino IDE 2.x theme system here:

Uploading: Безzxvczй.jpg…

You are not true Thonny IDE can do this

This a phyton IDE with integrated phyton interpreter. That is something completely different from the IDE we are talking about here.

If you can apply a different style to a variable, function, class. Why can't you apply a different style to a local variable? IDE doesn't see the difference between a local and a global variable?

As mentioned above, there is no such option in the IDE.

What do you expect from the forum?
Do you think someone will add this to the IDE especially for you?

If you are familiar with the IDE source code, you can add this feature yourself and offer a pull request on Github - I think that the authors of the code will gratefully accept your additions.

2 Likes

This!

That is correct. It simply doesn't have an awareness of the code to that level.

You might be misled by what appears to be "code aware" Arduino IDE 1.x theme settings:

  • editor.data_type.style
  • editor.function.style
  • editor.reserved_word.style
  • editor.variable.style
  • editor.reserved_word_2.style

However, instead of using an awareness of the program, Arduino IDE actually identifies which code elements to color according to these settings by doing a string comparison against lists of keywords in keywords.txt configuration files that were manually created by the core and library authors:

https://arduino.github.io/arduino-cli/latest/library-specification/#keywords

Although very crude, that system works to some extent when it comes to API components. But it can't be used to color arbitrary variables created by the user with any imaginable name.

5 Likes

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.