PDA

View Full Version : Syntax Highlighting



beefster09
06-21-2007, 04:05 PM
I'm really surprised that no one has suggested this before. It's annoying to not be able to know what you are doing right and wrong while zscripting.

Examples of keywords could be:

Loop and Condition-related keywords (including void run) could be dark blue.
Hardcoded Variables could be dark teal.
Hardcoded Functions could be dark orange.
Comments could be dark red.
Script and pointer types could be dark green.
Pointers and symbols could be dark gray.

These are all system colors. I just checked.

Heck, I'd even be willing to make a comprehensive list of keywords.

DarkDragon
06-21-2007, 11:19 PM
The problem is, all but the most trivial syntax highlighting requires some kind of *context* instead of simple pattern matching. For instance, in the following script,


ffc script foo {
void run()
{
Screen->D[0] = 1;
{
int Screen = 0;
Screen = Screen*2;
}
}
}

the syntax highlighter would need to understand that the first instance of Screen should be highlighted in the "built-in" color, but that the next two lines are just normal variables.

The compiler can figure things out of course, but at compile time, not during real-time editing.

beefster09
06-22-2007, 12:55 AM
I think JCreator has source code. I think it's in Java, but you could probably take a peek at the syntax highlighting code to see a very efficient way to syntax highlight. And maybe you could borrow the code because aren't Java and C++ somewhat similar?

I'm desperate for syntax highlighting, yet I don't know C++. XD I'm taking it this year, though.