Tutorial: Changing the Script Editor syntax colors

This simple tutorial will show you how to alter the colors of the default text in the script editor in the NWN2 toolset.

The file
The file is SyntaxNWScript.xml - located in the NWN2Toolset folder in the games install folder.

The file is plaintext, and is easy to edit. The main lines to edit are the XXXX lines. Some sample colors are:


 * ControlText - The text color chosen in the NWN2 toolset options. IE: Black.
 * Blue - Bright blue, default for reserved words like "if" and "while"
 * DarkRed - Dark red, default for text strings ("Things in quotes")
 * Green - Green color, default for single and multiline comments
 * Purple - Old NWN1 color for numbers. By default, numbers are black too.
 * DarkBlue - Old NWN1 color for text strings ("Things in quotes")

Other ones may include the W3 Color names list. I am not sure if direct RGB values can be substituted.

Notes: #include and ///

 * 1) include lines do not currently highlight properly, there is no way in the XML file to sort that out, most of the XML file is unused.

/////// also doesn't format correctly, and has black intermingled with green, again it cannot be corrected in the XML file.

Notes: Additional parts of the XML file
The other parts like the definitions of directives, or the way numbers and comments are defined, likely do not do anything. If you find anything that works, update this tutorial or create a new one :)

Original NWN1 colors
This is the changes needed to make the numbers appear purple, the strings appear dark blue again:

   Quantum Whale C language Syntax Scheme for C Language Copyright Quantum Whale, 2003 .c c</FileType> <Version>1.1</Version> <Styles> <Style> idents</Name> ControlText</ForeColor> <Index>0</Index> </Style> <Style> numbers</Name> Purple</ForeColor> <Index>1</Index> </Style> <Style> reswords</Name> Blue</ForeColor> <Index>2</Index> </Style> <Style> comments</Name> Green</ForeColor> <Index>3</Index> <PlainText>true</PlainText> </Style> <Style> whitespace</Name> <Index>4</Index> </Style> <Style> strings</Name> ControlText</ForeColor> <Index>5</Index> </Style> <Style> directives</Name> Blue</ForeColor> <Index>6</Index> </Style> <Style> strings</Name> DarkBlue</ForeColor> <Index>7</Index> </Style> <Style> directives</Name> <ForeColor>Blue</ForeColor> <Index>8</Index> </Style> </Styles> <States> <State> <Name>normal</Name> <CaseSensitive>true</CaseSensitive> <SyntaxBlocks> <SyntaxBlock> <Name>directive</Name> <LexStyle>6</LexStyle> <LeaveState>0</LeaveState> <Expressions> \#.*          </Expressions> <Index>0</Index> </SyntaxBlock> <SyntaxBlock> <Name>idents</Name> <LexStyle>0</LexStyle> <LeaveState>0</LeaveState> <ResWordSets> <ResWordSet> <Name /> <Index>0</Index> <ResWordStyle>2</ResWordStyle> <ResWords> typedef interrupt else near int cdecl volatile long enum void auto char union unsigned while double short register far const float for continue signed goto switch break do                return case default extern if                fortran struct static sizeof huge pascal </ResWords> </ResWordSet> </ResWordSets> <Expressions> [a-zA-Z_][a-zA-Z0-9_]* </Expressions> <Index>1</Index> </SyntaxBlock> <SyntaxBlock> <Name>comment1</Name> <LexStyle>3</LexStyle> <LeaveState>0</LeaveState> <Expressions> //.*          </Expressions> <Index>2</Index> </SyntaxBlock> <SyntaxBlock> <Name>comment2</Name> <LexStyle>3</LexStyle> <LeaveState>1</LeaveState> <Expressions> /\*          </Expressions> <Index>3</Index> </SyntaxBlock> <SyntaxBlock> <Name>numbers</Name> <LexStyle>1</LexStyle> <LeaveState>0</LeaveState> <Expressions> ([0-9]+\.[0-9]*(e|E)(\+|\-)?[0-9]+)|([0-9]+\.[0-9]*)|(0(x|X)[0-9a-fA-F]+)|([0-9]+) </Expressions> <Index>4</Index> </SyntaxBlock> <SyntaxBlock> <Name>string1</Name> <LexStyle>5</LexStyle> <LeaveState>0</LeaveState> <Expressions> ()|'((((\\')|()|[^'])*')|(((\\')|('')|[^'])*))          </Expressions> <Index>5</Index> </SyntaxBlock> <SyntaxBlock> <Name>string2</Name> <LexStyle>5</LexStyle> <LeaveState>0</LeaveState> <Expressions> ("")|"((((\\")|("")|[^"])*")|(((\\")|("")|[^"])*))          </Expressions> <Index>6</Index> </SyntaxBlock> <SyntaxBlock> <Name>whitespace</Name> <LexStyle>4</LexStyle> <LeaveState>0</LeaveState> <Expressions> (\s)* </Expressions> <Index>7</Index> </SyntaxBlock> </SyntaxBlocks> <Index>0</Index> </State> <State> <Name>comment</Name> <CaseSensitive>true</CaseSensitive> <SyntaxBlocks> <SyntaxBlock> <Name>comment21</Name> <LexStyle>3</LexStyle> <LeaveState>0</LeaveState> <Expressions> \*/          </Expressions> <Index>0</Index> </SyntaxBlock> <SyntaxBlock> <Name>comment22</Name> <LexStyle>3</LexStyle> <LeaveState>1</LeaveState> <Expressions> ((?!\*/).)+          </Expressions> <Index>1</Index> </SyntaxBlock> </SyntaxBlocks> <Index>1</Index> </State> </States> </LexScheme> </tt>

Special note: Color
I am ashamed to say it is spelt Colour, since I am British, but its an American game by an American company, so no luck finding that spelling anywhere!