11 package net.sf.gridarta.textedit.textarea;
13 import java.awt.Color;
15 import java.awt.Graphics;
16 import javax.swing.text.Segment;
17 import javax.swing.text.TabExpander;
18 import javax.swing.text.Utilities;
42 public static boolean regionMatches(
final boolean ignoreCase,
final Segment text,
final int offset,
final CharSequence match) {
43 final int length = offset + match.length();
44 final char[] textArray = text.array;
45 if (length > text.offset + text.count) {
49 for (
int i = offset, j = 0; i < length; i++, j++) {
50 char c1 = textArray[i];
51 char c2 = match.charAt(j);
53 c1 = Character.toUpperCase(c1);
54 c2 = Character.toUpperCase(c2);
99 public static int paintSyntaxLine(
final Segment line,
final Iterable<Token> tokens,
final SyntaxStyles styles,
final TabExpander expander,
final Graphics gfx,
final int x,
final int y) {
100 final Font defaultFont = gfx.getFont();
101 final Color defaultColor = gfx.getColor();
104 for (
final Token token : tokens) {
105 final byte
id = token.getId();
107 final int length = token.getLength();
109 if (!defaultColor.equals(gfx.getColor())) {
110 gfx.setColor(defaultColor);
112 if (!defaultFont.equals(gfx.getFont())) {
113 gfx.setFont(defaultFont);
120 xPos = Utilities.drawTabbedText(line, xPos, y, gfx, expander, 0);
121 line.offset += length;
static final byte COMMENT2
Comment 2 token id.
A set of SyntaxStyle instances for painting colorized text.
static final byte COMMENT1
Comment 1 token id.
static final byte LITERAL1
Literal 1 token id.
static final byte KEYWORD3
Keyword 3 token id.
SyntaxStyle getStyle(final byte id)
Returns a style for a token id.
static final byte OPERATOR
Operator token id.
SyntaxUtilities()
Private constructor to prevent instantiation.
Class with several utility functions used by jEdit's syntax colorizing subsystem. ...
static final byte LITERAL2
Literal 2 token id.
static boolean regionMatches(final boolean ignoreCase, final Segment text, final int offset, final CharSequence match)
Checks if a sub-region of a.
static final byte NULL
Normal text token id.
static final byte KEYWORD2
Keyword 2 token id.
static int paintSyntaxLine(final Segment line, final Iterable< Token > tokens, final SyntaxStyles styles, final TabExpander expander, final Graphics gfx, final int x, final int y)
Paints the specified line onto the graphics context.
static final byte KEYWORD1
Keyword 1 token id.
A simple text style class.
static final byte ID_COUNT
The total number of defined token ids.
static SyntaxStyles getDefaultSyntaxStyles()
Returns the default styles.
static final byte INVALID
Invalid token id.
static final byte LABEL
Label token id.
void setGraphicsFlags(final Graphics gfx, final Font font)
Sets the text color and font of the specified graphics context to that specified in this style...