mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-06 14:00:55 +03: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;
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
<style token="LITERAL_BOOLEAN" fg="871094"/>
|
||||
<style token="LITERAL_NUMBER_DECIMAL_INT" fg="1750EB"/>
|
||||
<style token="LITERAL_NUMBER_FLOAT" fg="1750EB"/>
|
||||
<style token="LITERAL_NUMBER_HEXADECIMAL" fg="1750EB" bg="f2f2f2"/>
|
||||
<style token="LITERAL_NUMBER_HEXADECIMAL" fg="1750EB"/>
|
||||
<style token="LITERAL_STRING_DOUBLE_QUOTE" fg="008000"/>
|
||||
<style token="LITERAL_CHAR" fg="DC009C"/>
|
||||
<style token="LITERAL_BACKQUOTE" fg="DC009C"/>
|
||||
@@ -66,7 +66,7 @@
|
||||
<style token="PREPROCESSOR" fg="808080"/>
|
||||
<style token="REGEX" fg="008040"/>
|
||||
<style token="SEPARATOR" fg="ff0000"/>
|
||||
<style token="VARIABLE" fg="000000" bg="EDFCED"/>
|
||||
<style token="VARIABLE" fg="000000"/>
|
||||
<style token="WHITESPACE" fg="000000"/>
|
||||
|
||||
<style token="ERROR_IDENTIFIER" fg="000000" bg="ffcccc"/>
|
||||
|
||||
Reference in New Issue
Block a user