Syntax

Colors

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

Objects

SyntaxItem

WordItem

SyntaxRegion

Parser

Sample 1 (create a syntax highlight for C/C++)

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.

3. Create a parser object

4. Highlight single line comment

Single line comment is be a region which starts from // and ends with End of Line(EOL).

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).

5. Highlight multiple line comment

6. Highlight string

The last param of CreateStringRegion means whether the match will be continue to next line!

7. Highlight key words

There are 4 params in CreateWord function. The last one is a string which contains the delimiters that can be treated as word, example:

8. Add matches into Parser

9. Overview

Sample 2 (Enhance C++ syntax highlight)

1. Add todo match in comment region

Create a todo match and add it into single/multiple line comment:

2. Code folding

C++ source files are normally folded begin with { and }

3. Auto Indent

4. Add auto pair complete

5. Add quick line comment

Now you can use Ctrl+/ to comment your selection or active line quickly.

Last updated