Commit 74c9dd5e authored by Arpad Lovassy's avatar Arpad Lovassy
Browse files

Bracket coloring: added 3 more colors, colors are cyclic after the last color,...


Bracket coloring: added 3 more colors, colors are cyclic after the last color, added missing buttons to preferences, fixed typos
Signed-off-by: Arpad Lovassy's avatarzlovarp <arpad.lovassy@semcon.com>
parent cee3498d
......@@ -51,16 +51,6 @@ public abstract class Module extends Scope implements IOutlineElement, ILocateab
}
public enum SyntaxDecoration {
Bracket0, /* different levels of brackets */
Bracket1,
Bracket2,
Bracket3,
Bracket4,
Bracket5,
Bracket6,
Bracket7,
Bracket8,
Bracket9,
Constant, /* TTCN3 constant */
DefType, /* own type defined with the 'type' keyword */
Deprecated, /* object marked as 'deprecated' in the status field of document comment */
......
......@@ -7,7 +7,9 @@
******************************************************************************/
package org.eclipse.titan.designer.editors;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.collections.api.map.sorted.MutableSortedMap;
......@@ -28,28 +30,16 @@ import org.eclipse.titan.designer.productUtilities.ProductConstants;
* and also keeps track of bracket depths at certain offsets
*
* @author Miklos Magyari
* @author Arpad Lovassy
*
*/
public final class AstSyntaxHighlightTokens {
private static Map<String, IntObjectHashMap<IToken>> offsetMaps = new HashMap<>();
private static Map<String, MutableSortedMap<Integer,Integer>> depthMaps = new HashMap<>();
private static final int MAX_BRACKET_DEPTH = 4;
private static final int MAX_BRACKET_COLORS = 8;
private static SyntaxDecoration[] brackets = {
SyntaxDecoration.Bracket0,
SyntaxDecoration.Bracket1,
SyntaxDecoration.Bracket2,
SyntaxDecoration.Bracket3,
SyntaxDecoration.Bracket4,
SyntaxDecoration.Bracket5,
SyntaxDecoration.Bracket6,
SyntaxDecoration.Bracket7,
SyntaxDecoration.Bracket8,
SyntaxDecoration.Bracket9
};
private static Map<SyntaxDecoration, IToken> tokenMap = new HashMap<>();
private static List<IToken> bracketcolors = new ArrayList<IToken>();
static {
final IPreferencesService prefs = Platform.getPreferencesService();
......@@ -73,11 +63,14 @@ public final class AstSyntaxHighlightTokens {
private static void addTokens() {
final ColorManager colorManager = new ColorManager();
tokenMap.put(SyntaxDecoration.Bracket0, colorManager.createTokenFromPreference(PreferenceConstants.BRACKETCOLOR0));
tokenMap.put(SyntaxDecoration.Bracket1, colorManager.createTokenFromPreference(PreferenceConstants.BRACKETCOLOR1));
tokenMap.put(SyntaxDecoration.Bracket2, colorManager.createTokenFromPreference(PreferenceConstants.BRACKETCOLOR2));
tokenMap.put(SyntaxDecoration.Bracket3, colorManager.createTokenFromPreference(PreferenceConstants.BRACKETCOLOR3));
tokenMap.put(SyntaxDecoration.Bracket4, colorManager.createTokenFromPreference(PreferenceConstants.BRACKETCOLOR4));
bracketcolors.add(colorManager.createTokenFromPreference(PreferenceConstants.BRACKETCOLOR0));
bracketcolors.add(colorManager.createTokenFromPreference(PreferenceConstants.BRACKETCOLOR1));
bracketcolors.add(colorManager.createTokenFromPreference(PreferenceConstants.BRACKETCOLOR2));
bracketcolors.add(colorManager.createTokenFromPreference(PreferenceConstants.BRACKETCOLOR3));
bracketcolors.add(colorManager.createTokenFromPreference(PreferenceConstants.BRACKETCOLOR4));
bracketcolors.add(colorManager.createTokenFromPreference(PreferenceConstants.BRACKETCOLOR5));
bracketcolors.add(colorManager.createTokenFromPreference(PreferenceConstants.BRACKETCOLOR6));
bracketcolors.add(colorManager.createTokenFromPreference(PreferenceConstants.BRACKETCOLOR7));
}
/** no instantiation */
......@@ -115,13 +108,13 @@ public final class AstSyntaxHighlightTokens {
final IntObjectHashMap<IToken> tokens = getOffsetMap(module);
final MutableSortedMap<Integer,Integer> depths = getDepthMap(actualFile.getFullPath().toOSString());
if (depth > MAX_BRACKET_DEPTH || depth < 0) {
if (depth < 0) {
tokens.remove(offset);
depths.remove(offset);
return;
}
tokens.put(offset, tokenMap.get(brackets[depth]));
tokens.put(offset, bracketcolors.size() > 0 ? bracketcolors.get(depth % MAX_BRACKET_COLORS) : null);
depths.put(offset, depth);
}
......
......@@ -65,6 +65,9 @@ public final class PreferenceConstantValues {
put(PreferenceConstants.COLOR_PREFIX + ".bracketcolor2" + PreferenceConstants.FOREGROUND, SEAGREEN);
put(PreferenceConstants.COLOR_PREFIX + ".bracketcolor3" + PreferenceConstants.FOREGROUND, VIOLETRED4);
put(PreferenceConstants.COLOR_PREFIX + ".bracketcolor4" + PreferenceConstants.FOREGROUND, CHOCOLATE);
put(PreferenceConstants.COLOR_PREFIX + ".bracketcolor5" + PreferenceConstants.FOREGROUND, GREY30);
put(PreferenceConstants.COLOR_PREFIX + ".bracketcolor6" + PreferenceConstants.FOREGROUND, LIGHTRED);
put(PreferenceConstants.COLOR_PREFIX + ".bracketcolor7" + PreferenceConstants.FOREGROUND, LIGHTGREEN);
// asn1 specific
put(PreferenceConstants.COLOR_ASN1_KEYWORDS + PreferenceConstants.FOREGROUND, BLACK);
......@@ -202,6 +205,9 @@ public final class PreferenceConstantValues {
put(PreferenceConstants.COLOR_PREFIX + ".bracketcolor2" + PreferenceConstants.FOREGROUND, SEAGREEN);
put(PreferenceConstants.COLOR_PREFIX + ".bracketcolor3" + PreferenceConstants.FOREGROUND, VIOLETRED4);
put(PreferenceConstants.COLOR_PREFIX + ".bracketcolor4" + PreferenceConstants.FOREGROUND, CHOCOLATE);
put(PreferenceConstants.COLOR_PREFIX + ".bracketcolor5" + PreferenceConstants.FOREGROUND, GREY30);
put(PreferenceConstants.COLOR_PREFIX + ".bracketcolor6" + PreferenceConstants.FOREGROUND, LIGHTRED);
put(PreferenceConstants.COLOR_PREFIX + ".bracketcolor7" + PreferenceConstants.FOREGROUND, LIGHTGREEN);
// asn1 specific
put(PreferenceConstants.COLOR_ASN1_KEYWORDS + PreferenceConstants.FOREGROUND, WHITE);
......
......@@ -185,11 +185,17 @@ public final class PreferenceConstants {
public static final String BRACKETCOLOR2 = COLOR_PREFIX + ".bracketcolor2";
public static final String BRACKETCOLOR3 = COLOR_PREFIX + ".bracketcolor3";
public static final String BRACKETCOLOR4 = COLOR_PREFIX + ".bracketcolor4";
public static final String BRACKETCOLOR5 = COLOR_PREFIX + ".bracketcolor5";
public static final String BRACKETCOLOR6 = COLOR_PREFIX + ".bracketcolor6";
public static final String BRACKETCOLOR7 = COLOR_PREFIX + ".bracketcolor7";
public static final String BRACKET_COLOR_FOREGROUND_0 = BRACKETCOLOR0 + PreferenceConstants.FOREGROUND;
public static final String BRACKET_COLOR_FOREGROUND_1 = BRACKETCOLOR1 + PreferenceConstants.FOREGROUND;
public static final String BRACKET_COLOR_FOREGROUND_2 = BRACKETCOLOR2 + PreferenceConstants.FOREGROUND;
public static final String BRACKET_COLOR_FOREGROUND_3 = BRACKETCOLOR3 + PreferenceConstants.FOREGROUND;
public static final String BRACKET_COLOR_FOREGROUND_4 = BRACKETCOLOR4 + PreferenceConstants.FOREGROUND;
public static final String BRACKET_COLOR_FOREGROUND_5 = BRACKETCOLOR5 + PreferenceConstants.FOREGROUND;
public static final String BRACKET_COLOR_FOREGROUND_6 = BRACKETCOLOR6 + PreferenceConstants.FOREGROUND;
public static final String BRACKET_COLOR_FOREGROUND_7 = BRACKETCOLOR7 + PreferenceConstants.FOREGROUND;
// semantic highlighting
public static final String COLOR_AST_CONSTANT = COLOR_PREFIX + ".ast_constant";
......
......@@ -25,7 +25,7 @@ import org.eclipse.ui.IWorkbenchPreferencePage;
*/
public final class ShowMatchingBracketPage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
static final String DESCRIPTION = "Preferences for the editor's matching brackets";
static final String HIGHLIGHT_MATCHING_BRACKETS = "Highligh matching brackets";
static final String HIGHLIGHT_MATCHING_BRACKETS = "Highlight matching brackets";
static final String MATCHING_BRACKETS_COLORING = "Enable colorizing of matching brackets (EXPERIMENTAL)";
static final String COLOR = "color:";
......@@ -37,6 +37,9 @@ public final class ShowMatchingBracketPage extends FieldEditorPreferencePage imp
private ColorFieldEditor bracketColor2;
private ColorFieldEditor bracketColor3;
private ColorFieldEditor bracketColor4;
private ColorFieldEditor bracketColor5;
private ColorFieldEditor bracketColor6;
private ColorFieldEditor bracketColor7;
public ShowMatchingBracketPage() {
super(GRID);
......@@ -66,15 +69,24 @@ public final class ShowMatchingBracketPage extends FieldEditorPreferencePage imp
bracketColor1 = new ColorFieldEditor(PreferenceConstants.BRACKET_COLOR_FOREGROUND_1, "Bracket color level 2",
getFieldEditorParent());
addField(bracketColor1);
bracketColor2 = new ColorFieldEditor(PreferenceConstants.BRACKET_COLOR_FOREGROUND_2, "Bracket color level 2",
bracketColor2 = new ColorFieldEditor(PreferenceConstants.BRACKET_COLOR_FOREGROUND_2, "Bracket color level 3",
getFieldEditorParent());
addField(bracketColor2);
bracketColor3 = new ColorFieldEditor(PreferenceConstants.BRACKET_COLOR_FOREGROUND_3, "Bracket color level 2",
bracketColor3 = new ColorFieldEditor(PreferenceConstants.BRACKET_COLOR_FOREGROUND_3, "Bracket color level 4",
getFieldEditorParent());
addField(bracketColor3);
bracketColor4 = new ColorFieldEditor(PreferenceConstants.BRACKET_COLOR_FOREGROUND_4, "Bracket color level 2",
bracketColor4 = new ColorFieldEditor(PreferenceConstants.BRACKET_COLOR_FOREGROUND_4, "Bracket color level 5",
getFieldEditorParent());
addField(bracketColor4);
bracketColor5 = new ColorFieldEditor(PreferenceConstants.BRACKET_COLOR_FOREGROUND_5, "Bracket color level 6",
getFieldEditorParent());
addField(bracketColor5);
bracketColor6 = new ColorFieldEditor(PreferenceConstants.BRACKET_COLOR_FOREGROUND_6, "Bracket color level 7",
getFieldEditorParent());
addField(bracketColor6);
bracketColor7 = new ColorFieldEditor(PreferenceConstants.BRACKET_COLOR_FOREGROUND_7, "Bracket color level 8",
getFieldEditorParent());
addField(bracketColor7);
}
@Override
......@@ -97,5 +109,8 @@ public final class ShowMatchingBracketPage extends FieldEditorPreferencePage imp
bracketColor2.dispose();
bracketColor3.dispose();
bracketColor4.dispose();
bracketColor5.dispose();
bracketColor6.dispose();
bracketColor7.dispose();
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment