Highlight line based on leading character?

Syntax highlighting, code folding, brace matching, code indenting, and function list

Highlight line based on leading character?

Postby mksql » Wed Aug 13, 2008 9:55 pm

I have a custom script that I would like to highlight based on the first character per line. Example:

+Highlight Red
.No Highlight
-Highlight blue

Can glean from the docs how this might be possible in UE 14.10. Suggestions?
User avatar
mksql
Newbie
 
Posts: 5
Joined: Wed Dec 01, 2004 12:00 am

Re: Highlight line based on leading character?

Postby Mofi » Thu Aug 14, 2008 2:40 am

Highlighting an entire line based on a character in a specified column is possible only with line comments:

Line Comment = + Line Comment Valid Columns = [1] Line Comment Alt = - Line Comment Valid Columns Alt = [1]

The problem is that only 2 such line comments can be specified and both line comments are highlighted with the same color. So this solution does not work for the highlighting you want for your script.

You can use following to highlight words starting with + or - :

/C1"Words starting with +"
** +
/C2"Words starting with -"
** -


But that highlights only the words following immediately the + or - and not the entire lines and this highlighting is not bound on the first character of a line.

The highlighting could be easily solved if the lines starting with + or - always end with the same (special) character like ! # § or a non breaking space (decimal code 160) because then marker characters or line comment + alternate block comment (has a separate color) could be used to highlight the entire lines, although they would also not be bound on the first column (except the line comment). Such appending of a special character at end of the lines starting with + or - could be easily done on file open with a regular expression replace, but those characters must be removed on every file save again with a regular expression replace.

Tim, yes if UE would support regular expressions for syntax highlighting, this special need would be no problem.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4042
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: Highlight line based on leading character?

Postby mksql » Mon Aug 18, 2008 11:22 am

Thanks, this gets me close enough!

Mofi wrote:Tim, yes if UE would support regular expressions for syntax highlighting, this special need would be no problem.


I agree. Regex based highlighting would be a very useful addition.
User avatar
mksql
Newbie
 
Posts: 5
Joined: Wed Dec 01, 2004 12:00 am


Return to Syntax Highlighting