UDL token cannot be both folding indicator and operator/delimiter.
-
If I add “open” to operators, I can no longer fold open-close pairs. :( -
@HalfOffHell said in UDL token cannot be both folding indicator and operator/delimiter.:
I also want them to be colored based on how deep they are and colored if they arent matched
Tracking nested brackets requires a stack-like data structure, so some kind of plugin would be needed. Maybe try the Python script that was suggested here: https://community.notepad-plus-plus.org/post/26901
-
@rdipardo By having an operator and multiple delimiters of the same token with different nesting options already solved this problem. My point is that if I do that, folding is disabled.
The issue is, if I add “open” to operators, I can no longer fold open and close.
-
@HalfOffHell ,
I see by your pic, that you put theopen
operator in theOperator1
box, and these can be glued to other keywords and should only be comprised of non-alphanumeric characters; whereasOperators2
can not be glued to other keywords and must be separated from other keywords, operators, etc, by at least one space and is designed for operators that look like keywords.You should probably check and read closely Ivan Radic 's UDL Documentation, specifically the Operators section.
Let me know if this takes care of your problem. If this doesn’t work, you might consider putting that
open
andclose
in the folding2 style, which also requires whitespace on both sides of the words, as they aren’t allowed to be glued to anything else, like Operators1 are…same with Folding1. You have to be careful when reading the documentation to understand the limits and forward and backward searching of the UDL parser. -
@Lycan-Thrope
putting open in operators 2 makes folding possible, but open loses color.
Delimiters dont work with either folding 1 or 2, sadly. -
@HalfOffHell said in UDL token cannot be both folding indicator and operator/delimiter.:
Delimiters dont work with either folding 1 or 2, sadly.
And they’re not supposed to. Again, really read the Ivan Radic documentation carefully. No where in
Delimiters
example, does he show you an example of using a keyword pair as delimiters. That’s asking far too much of this simple UDL parser. Commonly, delimiters are single characters, other than theEOL
text in parenthesis that represent the End of Line condition.I think you don’t really have a grasp of what the UDL is able to do, versus what you want it to do. You have to learn it’s nuances, not make more.
As for losing
coloring
each of those keywords, delimiters and operators (which controls operators 1 & 2) have stylers to change the coloring. You need to figure out which one controls what, in that labyrinth you’re attempting to construct with making the words keywords, operators and delimiters.In addition, you could use
EnhanceAnyLexer
plugin to custom color things you can’t get done via the UDL.I’m getting to the point of curiousity and asking why you would want to make a multiple functioning word pair? The Keyword, and Folding work, without too much consternation. When you start putting the same things in Operators and Delimiters, it starts to confuse the UDL as to your purpose, I guess, because of the search forward and backward incompatibility with using a word in more than one area.
The Online User Manual has the warning about using a keyword in more than one section here:
This is under the UDL Configuration Tabs section, second paragraph. This is essentially what you’re running into.
Additionally, heeding the explanation of Ivan Radic in the Inroduction part in the ending paragraphs he says:
To sum up: both forward and backward search logic must be implemented in UDL 2.1 and it is the user’s job to decide which one should be applied on a given set of keywords. -
@Lycan-Thrope I do most coloring with enchanceAnyLexer, because it can change foreground color without changing background color, but also because it can’t change background color (and cant lookbehind .* and can’t tell if a delimiter is nested in another.), I have to use built in delimiters for nesting (as u can see in picture they are colored based on how deep they are) and operators to let me know if they are not matched.
I don’t see why or how operators and delimiters would interfere with folding, they are just for color I think? If there is a version of notepads UDL that allows me to ignore everything they do but coloring, then id really like to use it.
If you don’t know any workarounds, can you point me to where in the source code the coloring/folding/UDL happens? You seem like a well-informed person.
-
@HalfOffHell said in UDL token cannot be both folding indicator and operator/delimiter.:
If you don’t know any workarounds, can you point me to where in the source code the coloring/folding/UDL happens? You seem like a well-informed person.
Thanks, but I’m not that guy…I just spent a year and half wrestling with the different parts to come up with my own UDL package leaning heavily on the more expert users here.
I’m not sure if you’re working backwards from the normal process, as most people create the color highlighting UDL, first, using the rules of the UDL 2.1 language to implement their chosen language, and then enhance color processing with the EnhanceAnyLexer plugin that the UDL didn’t. Then they implement the FunctionList functionality or the Autocomplete functionality to get a somewhat more complete IDE type environment.
You sound like you started with EnhanceAnyLexer and are now trying to force the UDL to work with those things. Like I always say, more complexity leads to more problems. I still don’t understand why you need that multi-faceted use out of a single keyword or keyword/pair. Are you actually doing a language or just experimenting with the capabilities of doing something short of writing a plugin or submitting changes to the Notepad++ base code?
The UDL is a part of the source code of Notepad++, and is located on NPP’s GitHub Repository. Any changes except for your own use, would have to be submitted to the developer for approval of inclusion to the base code.
In addition, Notepad++ uses the Scintilla/Lexilla libraries for the editor’s capabilities.
@HalfOffHell said in UDL token cannot be both folding indicator and operator/delimiter.:
I don’t see why or how operators and delimiters would interfere with folding, they are just for color I think?
They do because they are being searched differently. To use the
open
keyword as an Operator, it has to go into Operator 2, which uses a backward searching capability, and the Delimiters and Code Folding uses the Forward search.You should read more of the manual, and the UDL 2.1 spec layed out in both the Online User Manual and the Ivan Radic documentation, and try to see how everything works together as is.
I don’t think the system as is, is going to work the way you want. You might need to employ using the PythonScript capabilty, or writing your own parser as a plugin. All of these are going to involve becoming familiar with the capabilities and functions of the Scintilla libraries and there are much more knowledgeable individuals here that can help you further, if you start posting actual information rather than just screenshots and vague statements about what you’re doing.
Edit: I just noted that your screenshot states it’s a C++ UDL, so my guess is, that you’re trying to further expand C++, which is beyond my ability to help, as originally I tried using the C++ FunctionList as an example for mine and went quickly down a rabbit hole, just barely able to get out before I lost my mind. :-)