_
This section describes new options user have when defining comments.
This section describes new options user have when defining comments.
Comments handling in UDL 2.0 changed significantly.
Let's start with the most obvious part, the GUI.
Line comments:
Line comments now support three set of keywords: open, continue and close.
Open:
In most languages this is the only one you'll need. Define your comment line starters here: # // !
Example:
// line comment
Continue:
If this string is at the end of line comment, than line comment extends to following line: e.g. \
Example:
// line comment \
that extends to next line
Close:
This is a very rare feature, but in some languages comments have start and end markers, but if end marker is missing, a comment automatically becomes a line comment and ends at the end of current line. This is where you need to define close string, e.g.: !
Example:
// line comment ! text that doesn't belong to a comment
This is a very "basic" demonstration, but it serves its purpose well.
|
Comments:
Comments are defined in a way that is similar to UDL 1.0.
You just create a list of strings that represent comment start position and comment end position. But there is a hidden feature here.
Notice vertical position of Open and Close edit boxes! Notice how I defined two separate comment pairs and how they align vertically. I wanted to define these two comment sets:
- /* this is a C language comment */
- /+ this is a D language comment +/
Now, lets try to nest these two comment types, to see the difference between UDL 1.0 and UDL 2.0
This is an UDL 1.0 screen capture. Comments are underlined so it would be more obvious where they end. Notice how "*/" string always ends a comment !! This happens because UDL 1.0 simply goes through a list of comment close strings, and as soon as it finds the first one to match, it accepts it as a comment end. UDL 1.0 has no way to connect matching open/close strings. It simply settles with the first one it can find, which works great if you have just one pair. If you have more, nesting will break, as demonstrated in line 4. |
This is an UDL 2.0 screen capture. Notice how in line 4, UDL 2.0 correctly highlights D-style comments, even if there is a "*/" within comment. This is possible because UDL 2.0 uses indexes to match correct close string. When Open string is found, its index is recorded internally (e.g. for "/+", index is 1). That means that a comment can be closed only by a Close string of the same index. So, users can just vertically align open and close strings, and UDL 2.0 will take care of the rest. |
Nesting of comments
Example 1:
Example 2:
Example 3:
Example 4:
If you want Line comments to look like Comments, but to be highlighted when nested (and only when nested), that can be done too. Just define Delimiter 2 (any delimiter will do, I'll use this one for demonstration) like in picture on the right. EOL is a special keyword that is expanded to a vector of three strings: "\r\n" "\n" "r" So, every new line combination is covered. EOL has been introduced just for this reason. It allows users to define Delimiter equivalent of Line comments. Notice how I wrapped EOL with special double brace operator. This operator has a special meaning in UDL 2.0 and it is explained in more detail in Delimiters section. For this example it is enough to remember that it expands EOL into an end of line character. As you can see on the right, nesting of delimiters that imitate line comments works just as good. |
Example 5:
Folding of comments
Example 1:
When option Allow folding of comments is set, UDL 2.0 automatically tracks comment lines and allows folding of two or more consecutive comment lines.
Notice how last example can be folded only in "pure" comment lines. Folding of comments never folds non comment text !! |
Example 2:
UPDATE:
Beta 1 will have an option to force line comments to start at the beginning of line !!
When this option is switched on, line comments will be recognized only if they are located at the beginning of line. Anywhere else, they will be treated as default text.
Conclusion
As you can see, comment handling in UDL 2.0 changed quite a bit from UDL 1.0.
I tried to make it intuitive and easy, and I hope users will like it as much as I do.
I tried to make it intuitive and easy, and I hope users will like it as much as I do.