When you are writing a syntax highlight, you are supposed to distinguish colors of data types. EverEdit provides a couple of built-in colors.
COLOR_DEFAULT: Normal text without any syntax state
COLOR_COMMENT1: Single line comment, example:// in C/C++
COLOR_COMMENT2: Block line comment, example:/your comment/ in C/C++
COLOR_STRING1: Single quoted string, example:'your single quoted string' in PHP
COLOR_STRING2: Double quoted string, example:"your double quoted string" in PHP
COLOR_TAG: Use for HTML/XML tag match, EverEdit could find the matched tag automatically
COLOR_MACRO: Macro define, example:#define/Import/Range VALUE 100 in C/C++/C#/Java
COLOR_URL: URL, example:http://www.everedit.net
COLOR_EMAIL: Email address, example:support@everedit.net
COLOR_NUMBER: Numbers, example:10,0x20,1.35
COLOR_FOUND: When you search something, EverEdit will use this state to draw the found text
COLOR_PAIR: Paired strings, example:()[]{}<>""''
COLOR_FUNCTION: Function name
COLOR_VAR: Variables
COLOR_SUBLAN: Sub-language, example: in HTML
COLOR_OPERATOR: Operators, example:+-*/ ++ --
COLOR_WORD1: Key word 1, built-in keywords. example:int bool double do while in C/C++/Java
COLOR_WORD2: Key word 2, framework keywords. example:CString CMap CArray in MFC
COLOR_WORD3: Key word 3
COLOR_WORD4: Key word 4
COLOR_HIGHLIGHT1~COLOR_HIGHLIGHT8: User defined highlight, used for custom marker
COLOR_IGNORE: The foreground color of text will be same as the background. It will show on selecting
COLOR_CONCEAL: The text will not be displayed expect selecting
This sample will guide you to define a new syntax highlight for EverEdit! let's have a look at some key syntax elements of C/C++:
Single line comment
Multiple line comment
String
Key word
The above elements are key parts for most of syntax highlights.
1. Create a file
Create a mycpp.mac and put it into (syntax) folder;
Include color define file
EverEdit provides predefined colors, so let's include it first.
Include( ".\const.mac" )
3. Create a parser object
Set cpp=Parser.CreateParser()
4. Highlight single line comment
Single line comment is be a region which starts from // and ends with End of Line(EOL).
Set regionLine=cpp.CreateRegion( COLOR_COMMENT1,"+//+","$", True )
Note: The text surrounded by plus(+) means this is a normal string match (simple&fast), not regular expression.(This kind of usage is available in CreateRegion function only).