blob: bf3a558c79989e2d9bfa3093ce3cddf35a4a3cd0 [file]
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-
transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<link rel="stylesheet" href="../style.css" charset="ISO-8859-1" type="text/css"/>
<title>ATL Help</title>
</head>
<body>
<h1>Highlight syntaxing coloration</h1>
<p>We have developed some tools to make the syntax coloration development easier. We will show you the steps to
add a new syntaxing lexem and its appropriate variables.</p>
<h2>New rules for new lexems</h2>
<p>If you have new lexems in your language to add, you will need to create a new rule in the <em>AtlCodeScanner
</em>. You have to put this rule in the <em>createRules</em> at the correct position, compared to the other rules
in place.</p>
<p>An other thing is to set the new lexem in the property names table to make the abstract scanner working on
styles. Thus you will notice you need to install the new lexem in the <em>IAtlLexem</em> interface.</p>
<h2>Syntax preference page</h2>
<p>The best way to begin this addon is to take an overview class. The preference page associated to the syntax is
this class.</p>
<p>Go into this class. You will see a strings table named <em>colorListModel</em> that contains pairs :
<ul>
<li>The string given by the preference messages is the displayed name in the list ;</li>
<li>The constant from the <a href="../javadoc/org/atl/eclipse/adt/ui/AtlPreferenceConstants.html">preference
constants class</a> is a symbolic value that have to be completed <a href="#styles">later</a> by style
attributes, such as bold one.
</li>
</ul>
You will notice that you need to add a new externalized string, in the <em>org.atl.eclipse.adt.ui.preferences.
PreferenceMessages.properties</em> file. The next step is to add the missing constant in the
AtlPreferenceConstants.</p>
<h2><a name="styles"></a>Preference constants</h2>
<p>Creating the new constant is not sufficient. As you add a new syntax lexem, you need to create constants that
match all the styles implemented. At this time, you need also to create bold, color and italic constants. Look at
the keyword example :</p>
<pre class="code">
public static final String SYNTAX_KEYWORD = SYNTAX + ".Keyword";
public static final String SYNTAX_KEYWORD_BOLD = SYNTAX_KEYWORD + __BOLD_SUFFIX;
public static final String SYNTAX_KEYWORD_COLOR = SYNTAX_KEYWORD + __COLOR_SUFFIX;
public static final String SYNTAX_KEYWORD_ITALIC = SYNTAX_KEYWORD + __ITALIC_SUFFIX;
</pre>
<p>By the way, two steps miss you. The preference store has to know what kind of type are the new values you added.
This is done in the <em>createStoreKeys</em> method :</p>
<pre class="code">
storeKeys.add(new AtlPreferenceStore.Key(AtlPreferenceStore.BOOLEAN, SYNTAX_KEYWORD_BOLD));
storeKeys.add(new AtlPreferenceStore.Key(AtlPreferenceStore.STRING, SYNTAX_KEYWORD_COLOR));
storeKeys.add(new AtlPreferenceStore.Key(AtlPreferenceStore.BOOLEAN, SYNTAX_KEYWORD_ITALIC));
</pre>
<p>and it also needs initialization values filled in the <em>initializeDefaultValues</em> method :</p>
<pre class="code">
store.setDefault(SYNTAX_KEYWORD_BOLD, IAtlDefaultValues.SYNTAX_KEYWORD_BOLD);
PreferenceConverter.setDefault(store, SYNTAX_KEYWORD_COLOR , IAtlDefaultValues.SYNTAX_KEYWORD_COLOR);
store.setDefault(SYNTAX_KEYWORD_ITALIC, IAtlDefaultValues.SYNTAX_KEYWORD_ITALIC);
</pre>
<p>In this last step, you will probably create a new value in the <em>IAtlDefaultValues</em> interface.</p>
<h2>Default values</h2>
<p>This is the end of this process. You have to give here default value to initialize the preference store. We use
RGB values because this class is intended to be the less modified.</p>
<pre class="code">
public static final boolean SYNTAX_KEYWORD_BOLD = true;
public static final RGB SYNTAX_KEYWORD_COLOR = new RGB(127, 0, 85);
public static final boolean SYNTAX_KEYWORD_ITALIC = false;
</pre>
</body>
</html>