Custom Language numbers only working in some places
-
I have an issue getting numbers to style how I want them too.
I want it to change any number that is by itself anywhere in the code such as inside of () or [] etc although it’s working inside of [] but not inside of the ()
although it did work in this instance
what I don’t want it to do is change a number that is next to any word such as the circle with the red x I want those to stay the same. I don’t want the numbers that are attached to variable names, etc to change if that makes sense.
Here is all my settings so far building this style
-
Use the comma as an additional operator or define it inside suffix1 or 2 in the number style.
-
@Ekopalypse The delimiter for the comma worked great thanks!
What about for stuff I’m using in the keywords? The comma after each one is being set to the same color as the keyword.
How do I make sure all commas are the same color and not included in the syntax highlighting?
Also na is be used as an argument such a true or false but it also can be a function like in this example. How do I set different color for each. I need the na functions to be blue like the others?
Also the na’s inside of a function are not being colored as well. They should be pinkish color as well. Like this.
which is the editor in tradingview which I am trying to imitate for a styling in notepad++
-
I am assuming () are set as a set of delimiters… If so, then in the delimiters styler, you need to make sure you allow nesting for operators and the appropriate keywords.
I didn’t fully replicate your results, but something like this:
Without nesting, it looks like:
With nesting added, it looks like:
-
@PeterJones I put the delimiter in it’s own style like under the Delimiter 1 style I put the commas as the end instead of adding the commas on the main delimiter at the top. That caused the issues it was my own mistake that made it not work properly.
Thanks again for all your help
I just need to figure out how to get the last na the correct color. Which is these.
I need the na after the = to also be the pinkish/brown color.
Also if I add numbers in the () delimiter to allow numbers to change orange like the rest of the code it also changes numbers that are not supposed to change like this.
-
@Victor-Nonya said in Custom Language numbers only working in some places:
I need the na after the = to also be the pinkish/brown color.
I showed you the example where the
na
in both locations was the same color. I don’t know what you currently have, so there’s no way for me to know why it’s different for you. My guess is you havena
defined in two conflicting locations, but it’s impossible for me to know for sure.As far as the numbers go, you may have hit upon one of the limitations of UDL. You can do a lot in UDL – as you have already seen – but there are limits to the rules that can be implemented. If you can get close to what you want, you can sometimes use @Ekopalypse’s EnhanceAnyLexer to add a regex that can change the foreground color based on a regular expression – so you could either turn off nesting of numbers inside of DELIMITER
(...)
, and then use EnhanceAnyLexer to only match digits that aren’t part of an alphanumeric “word” and colors them the same as a normal word, or you could turn on nesting of numbers inside DELIMITER(...)
and then use EnhanceAnyLexer to match “words” that contain numbers at the end and colors them to match non-highlighted text: either should work -
@PeterJones Yes but the example you showed all the na’s were the same color. In your example all three of the na’s in different locations were all orange.
I’m trying to set the na function to another color and all the other na’s be orange.
in your example you have the function as orange. I need it to be blue but I still need the na, na, na, and the = na to be orange.
the result I’m looking for would look like this.
It may also be a limitation like with the numbers that I’ll just have to live with it being the same color which is fine if that’s the case it doesn’t have to be identical to the tradingview editor.
I’ve added na in two locations in the keywords section. One in the main keywords that stores all the functions which are blue. Then I’ve added it again in another keyword section that is pinkish color and using the () delimiter it works great as long as the na’s are inside the () but the ones outside are blue so it’s probably just a limitation that I’ll have to live with since the na’s that are functions are also outside of the ().
as far as the numbers issue I can always change the way I am coding and stop using numbers in the variables and type them out like one, two, three if that truly bothers me. it’s not really a big issue. It is super cool the stuff you can do with notepad++ I do enjoy learning this stuff.
EDIT: after removing the () delimiter that I was only using for the na that fixed the issue with the numbers not working. All the numbers show up as they should now. I’ll just live with all the na’s being one color it’s not too big of an issue for me.