Tutorial: Changing the Script Editor syntax colors
From NWN2Wiki
This simple tutorial will show you how to alter the colors of the default text in the script editor in the NWN2 toolset.
Contents |
[edit] 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 <ForeColor>XXXX</ForeColor> 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.
[edit] Notes: #include and ///
#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.
[edit] 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 :)
[edit] Original NWN1 colors
This is the changes needed to make the numbers appear purple, the strings appear dark blue again:
<?xml version="1.0" encoding="utf-8"?>
<LexScheme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="scheme.xsd">
<Author>Quantum Whale</Author>
<Name>C language</Name>
<Desc>Syntax Scheme for C Language</Desc>
<Copyright>Copyright Quantum Whale, 2003</Copyright>
<FileExtension>.c</FileExtension>
<FileType>c</FileType>
<Version>1.1</Version>
<Styles>
<Style>
<Name>idents</Name>
<ForeColor>ControlText</ForeColor>
<Index>0</Index>
</Style>
<Style>
<Name>numbers</Name>
<ForeColor>Purple</ForeColor>
<Index>1</Index>
</Style>
<Style>
<Name>reswords</Name>
<ForeColor>Blue</ForeColor>
<Index>2</Index>
</Style>
<Style>
<Name>comments</Name>
<ForeColor>Green</ForeColor>
<Index>3</Index>
<PlainText>true</PlainText>
</Style>
<Style>
<Name>whitespace</Name>
<Index>4</Index>
</Style>
<Style>
<Name>strings</Name>
<ForeColor>ControlText</ForeColor>
<Index>5</Index>
</Style>
<Style>
<Name>directives</Name>
<ForeColor>Blue</ForeColor>
<Index>6</Index>
</Style>
<Style>
<Name>strings</Name>
<ForeColor>DarkBlue</ForeColor>
<Index>7</Index>
</Style>
<Style>
<Name>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>
<string>\#.*</string>
</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>
<word>typedef</word>
<word>interrupt</word>
<word>else</word>
<word>near</word>
<word>int</word>
<word>cdecl</word>
<word>volatile</word>
<word>long</word>
<word>enum</word>
<word>void</word>
<word>auto</word>
<word>char</word>
<word>union</word>
<word>unsigned</word>
<word>while</word>
<word>double</word>
<word>short</word>
<word>register</word>
<word>far</word>
<word>const</word>
<word>float</word>
<word>for</word>
<word>continue</word>
<word>signed</word>
<word>goto</word>
<word>switch</word>
<word>break</word>
<word>do</word>
<word>return</word>
<word>case</word>
<word>default</word>
<word>extern</word>
<word>if</word>
<word>fortran</word>
<word>struct</word>
<word>static</word>
<word>sizeof</word>
<word>huge</word>
<word>pascal</word>
</ResWords>
</ResWordSet>
</ResWordSets>
<Expressions>
<string>[a-zA-Z_][a-zA-Z0-9_]*</string>
</Expressions>
<Index>1</Index>
</SyntaxBlock>
<SyntaxBlock>
<Name>comment1</Name>
<LexStyle>3</LexStyle>
<LeaveState>0</LeaveState>
<Expressions>
<string>//.*</string>
</Expressions>
<Index>2</Index>
</SyntaxBlock>
<SyntaxBlock>
<Name>comment2</Name>
<LexStyle>3</LexStyle>
<LeaveState>1</LeaveState>
<Expressions>
<string>/\*</string>
</Expressions>
<Index>3</Index>
</SyntaxBlock>
<SyntaxBlock>
<Name>numbers</Name>
<LexStyle>1</LexStyle>
<LeaveState>0</LeaveState>
<Expressions>
<string>([0-9]+\.[0-9]*(e|E)(\+|\-)?[0-9]+)|([0-9]+\.[0-9]*)|(0(x|X)[0-9a-fA-F]+)|([0-9]+)</string>
</Expressions>
<Index>4</Index>
</SyntaxBlock>
<SyntaxBlock>
<Name>string1</Name>
<LexStyle>5</LexStyle>
<LeaveState>0</LeaveState>
<Expressions>
<string>('')|'((((\\')|('')|[^'])*')|(((\\')|('')|[^'])*))</string>
</Expressions>
<Index>5</Index>
</SyntaxBlock>
<SyntaxBlock>
<Name>string2</Name>
<LexStyle>5</LexStyle>
<LeaveState>0</LeaveState>
<Expressions>
<string>("")|"((((\\")|("")|[^"])*")|(((\\")|("")|[^"])*))</string>
</Expressions>
<Index>6</Index>
</SyntaxBlock>
<SyntaxBlock>
<Name>whitespace</Name>
<LexStyle>4</LexStyle>
<LeaveState>0</LeaveState>
<Expressions>
<string>(\s)*</string>
</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>
<string>\*/</string>
</Expressions>
<Index>0</Index>
</SyntaxBlock>
<SyntaxBlock>
<Name>comment22</Name>
<LexStyle>3</LexStyle>
<LeaveState>1</LeaveState>
<Expressions>
<string>((?!\*/).)+</string>
</Expressions>
<Index>1</Index>
</SyntaxBlock>
</SyntaxBlocks>
<Index>1</Index>
</State>
</States>
</LexScheme>
[edit] 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!
