mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-11 22:47:13 -06:00
Theme Editor: enabled mark occurrences
This commit is contained in:
@@ -17,12 +17,14 @@
|
||||
package com.formdev.flatlaf.themeeditor;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import javax.swing.JPanel;
|
||||
import org.fife.ui.rsyntaxtextarea.AbstractTokenMakerFactory;
|
||||
import org.fife.ui.rsyntaxtextarea.FileLocation;
|
||||
import org.fife.ui.rsyntaxtextarea.SyntaxScheme;
|
||||
import org.fife.ui.rsyntaxtextarea.Theme;
|
||||
import org.fife.ui.rsyntaxtextarea.TokenMakerFactory;
|
||||
import org.fife.ui.rtextarea.RTextScrollPane;
|
||||
@@ -51,6 +53,7 @@ class FlatThemeEditorPane
|
||||
// create text area
|
||||
textArea = new FlatSyntaxTextArea();
|
||||
textArea.setSyntaxEditingStyle( FLATLAF_STYLE );
|
||||
textArea.setMarkOccurrences( true );
|
||||
|
||||
// theme
|
||||
try {
|
||||
@@ -60,6 +63,12 @@ class FlatThemeEditorPane
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
// use semitransparent token background because token background
|
||||
// is painted over mark occurrences background
|
||||
SyntaxScheme scheme = textArea.getSyntaxScheme();
|
||||
scheme.getStyle( FlatThemeTokenMaker.TOKEN_COLOR ).background = new Color( 0x0a000000, true );
|
||||
scheme.getStyle( FlatThemeTokenMaker.TOKEN_VARIABLE ).background = new Color( 0x1800cc00, true );
|
||||
|
||||
// create scroll pane
|
||||
scrollPane = new RTextScrollPane( textArea );
|
||||
scrollPane.setLineNumbersEnabled( true );
|
||||
|
||||
@@ -34,13 +34,13 @@ import org.fife.ui.rsyntaxtextarea.modes.PropertiesFileTokenMaker;
|
||||
public class FlatThemeTokenMaker
|
||||
extends PropertiesFileTokenMaker
|
||||
{
|
||||
private static final int TOKEN_PROPERTY = Token.IDENTIFIER;
|
||||
private static final int TOKEN_VARIABLE = Token.VARIABLE;
|
||||
private static final int TOKEN_NUMBER = Token.LITERAL_NUMBER_DECIMAL_INT;
|
||||
private static final int TOKEN_COLOR = Token.LITERAL_NUMBER_HEXADECIMAL;
|
||||
private static final int TOKEN_STRING = Token.LITERAL_STRING_DOUBLE_QUOTE;
|
||||
private static final int TOKEN_FUNCTION = Token.FUNCTION;
|
||||
private static final int TOKEN_TYPE = Token.DATA_TYPE;
|
||||
static final int TOKEN_PROPERTY = Token.IDENTIFIER;
|
||||
static final int TOKEN_VARIABLE = Token.VARIABLE;
|
||||
static final int TOKEN_NUMBER = Token.LITERAL_NUMBER_DECIMAL_INT;
|
||||
static final int TOKEN_COLOR = Token.LITERAL_NUMBER_HEXADECIMAL;
|
||||
static final int TOKEN_STRING = Token.LITERAL_STRING_DOUBLE_QUOTE;
|
||||
static final int TOKEN_FUNCTION = Token.FUNCTION;
|
||||
static final int TOKEN_TYPE = Token.DATA_TYPE;
|
||||
|
||||
private final TokenMap tokenMap = new TokenMap();
|
||||
|
||||
@@ -143,6 +143,21 @@ public class FlatThemeTokenMaker
|
||||
return RSyntaxUtilities.isLetterOrDigit( ch ) || ch == '.' || ch == '_' || ch == '-';
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getMarkOccurrencesOfTokenType( int type ) {
|
||||
switch( type ) {
|
||||
case TOKEN_PROPERTY:
|
||||
case TOKEN_VARIABLE:
|
||||
case TOKEN_COLOR:
|
||||
case TOKEN_FUNCTION:
|
||||
case TOKEN_TYPE:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/*debug
|
||||
private java.util.HashMap<Integer, String> tokenTypeStrMap;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user