diff --git a/app/src/processing/app/syntax/HtmlSelection.java b/app/src/processing/app/syntax/HtmlSelection.java
index d8e906604..d7a016aa5 100644
--- a/app/src/processing/app/syntax/HtmlSelection.java
+++ b/app/src/processing/app/syntax/HtmlSelection.java
@@ -9,12 +9,14 @@ import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;
+
public class HtmlSelection implements Transferable {
- private static List flavors = new ArrayList();
+ private static List flavors;
static {
try {
+ flavors = new ArrayList();
flavors.add(DataFlavor.stringFlavor);
flavors.add(new DataFlavor("text/html;class=java.lang.String"));
flavors.add(new DataFlavor("text/html;class=java.io.Reader"));
@@ -26,18 +28,22 @@ public class HtmlSelection implements Transferable {
private String html;
+
public HtmlSelection(String html) {
this.html = html;
}
+
public DataFlavor[] getTransferDataFlavors() {
return flavors.toArray(new DataFlavor[flavors.size()]);
}
+
public boolean isDataFlavorSupported(DataFlavor flavor) {
return flavors.contains(flavor);
}
+
public Object getTransferData(DataFlavor flavor)
throws UnsupportedFlavorException {
if (flavor.equals(DataFlavor.stringFlavor)) {
diff --git a/app/src/processing/app/syntax/KeywordMap.java b/app/src/processing/app/syntax/KeywordMap.java
index b8b66871d..cfa4caa68 100644
--- a/app/src/processing/app/syntax/KeywordMap.java
+++ b/app/src/processing/app/syntax/KeywordMap.java
@@ -76,7 +76,7 @@ public class KeywordMap {
// continue;
// }
if (length == k.keyword.length) {
- if (SyntaxUtilities.regionMatches(ignoreCase, text, offset, k.keyword)) {
+ if (regionMatches(ignoreCase, text, offset, k.keyword)) {
return k.id;
}
}
@@ -84,6 +84,36 @@ public class KeywordMap {
}
return Token.NULL;
}
+
+
+ /**
+ * Checks if a subregion of a Segment is equal to a
+ * character array.
+ * @param ignoreCase True if case should be ignored, false otherwise
+ * @param text The segment
+ * @param offset The offset into the segment
+ * @param match The character array to match
+ */
+ static public boolean regionMatches(boolean ignoreCase, Segment text,
+ int offset, char[] match) {
+ int length = offset + match.length;
+ char[] textArray = text.array;
+ if(length > text.offset + text.count)
+ return false;
+ for(int i = offset, j = 0; i < length; i++, j++)
+ {
+ char c1 = textArray[i];
+ char c2 = match[j];
+ if(ignoreCase)
+ {
+ c1 = Character.toUpperCase(c1);
+ c2 = Character.toUpperCase(c2);
+ }
+ if(c1 != c2)
+ return false;
+ }
+ return true;
+ }
/**
diff --git a/app/src/processing/app/syntax/PdeTextAreaDefaults.java b/app/src/processing/app/syntax/PdeTextAreaDefaults.java
index 0ffe9072e..5e010f153 100644
--- a/app/src/processing/app/syntax/PdeTextAreaDefaults.java
+++ b/app/src/processing/app/syntax/PdeTextAreaDefaults.java
@@ -197,9 +197,11 @@ public class PdeTextAreaDefaults extends TextAreaDefaults {
rows = 5;
//font = Preferences.getFont("editor.font");
- font = new Font(Preferences.get("editor.font.family"),
- Font.PLAIN, Preferences.getInteger("editor.font.size"));
- System.out.println("font is " + font.getFamily() + " / " + font.getName() + " / " + font.getFontName() + " / " + font.getPSName());
+ String fontFamily = Preferences.get("editor.font.family");
+ int fontSize = Preferences.getInteger("editor.font.size");
+ plainFont = new Font(fontFamily, Font.PLAIN, fontSize);
+ boldFont = new Font(fontFamily, Font.BOLD, fontSize);
+ //System.out.println("font is " + plainFont.getFamily() + " / " + plainFont.getName() + " / " + plainFont.getFontName() + " / " + plainFont.getPSName());
antialias = Preferences.getBoolean("editor.antialias");
styles = new SyntaxStyle[Token.ID_COUNT];
diff --git a/app/src/processing/app/syntax/SyntaxStyle.java b/app/src/processing/app/syntax/SyntaxStyle.java
index 3d5d19425..277640fba 100644
--- a/app/src/processing/app/syntax/SyntaxStyle.java
+++ b/app/src/processing/app/syntax/SyntaxStyle.java
@@ -14,8 +14,8 @@ import javax.swing.JComponent;
/**
- * A simple text style class. It can specify the color, italic flag,
- * and bold flag of a run of text.
+ * A simple text style class.
+ * It can specify the color and bold flag of a run of text.
* @author Slava Pestov
* @version $Id$
*/
@@ -27,6 +27,7 @@ public class SyntaxStyle {
private Font lastStyledFont;
private FontMetrics fontMetrics;
+
/**
* Creates a new SyntaxStyle.
* @param color The text color
diff --git a/app/src/processing/app/syntax/SyntaxUtilities.java b/app/src/processing/app/syntax/SyntaxUtilities.java
index 1e40ac831..5d6e983ec 100644
--- a/app/src/processing/app/syntax/SyntaxUtilities.java
+++ b/app/src/processing/app/syntax/SyntaxUtilities.java
@@ -22,64 +22,34 @@ import java.awt.*;
*/
public class SyntaxUtilities {
- /**
- * Checks if a subregion of a Segment is equal to a
- * string.
- * @param ignoreCase True if case should be ignored, false otherwise
- * @param text The segment
- * @param offset The offset into the segment
- * @param match The string to match
- */
- public static boolean regionMatches(boolean ignoreCase, Segment text,
- int offset, String match) {
- int length = offset + match.length();
- char[] textArray = text.array;
- if(length > text.offset + text.count)
- return false;
- for(int i = offset, j = 0; i < length; i++, j++)
- {
- char c1 = textArray[i];
- char c2 = match.charAt(j);
- if(ignoreCase)
- {
- c1 = Character.toUpperCase(c1);
- c2 = Character.toUpperCase(c2);
- }
- if(c1 != c2)
- return false;
- }
- return true;
- }
-
-
- /**
- * Checks if a subregion of a Segment is equal to a
- * character array.
- * @param ignoreCase True if case should be ignored, false otherwise
- * @param text The segment
- * @param offset The offset into the segment
- * @param match The character array to match
- */
- public static boolean regionMatches(boolean ignoreCase, Segment text,
- int offset, char[] match) {
- int length = offset + match.length;
- char[] textArray = text.array;
- if(length > text.offset + text.count)
- return false;
- for(int i = offset, j = 0; i < length; i++, j++)
- {
- char c1 = textArray[i];
- char c2 = match[j];
- if(ignoreCase)
- {
- c1 = Character.toUpperCase(c1);
- c2 = Character.toUpperCase(c2);
- }
- if(c1 != c2)
- return false;
- }
- return true;
- }
+// /**
+// * Checks if a subregion of a Segment is equal to a
+// * string.
+// * @param ignoreCase True if case should be ignored, false otherwise
+// * @param text The segment
+// * @param offset The offset into the segment
+// * @param match The string to match
+// */
+// public static boolean regionMatches(boolean ignoreCase, Segment text,
+// int offset, String match) {
+// int length = offset + match.length();
+// char[] textArray = text.array;
+// if(length > text.offset + text.count)
+// return false;
+// for(int i = offset, j = 0; i < length; i++, j++)
+// {
+// char c1 = textArray[i];
+// char c2 = match.charAt(j);
+// if(ignoreCase)
+// {
+// c1 = Character.toUpperCase(c1);
+// c2 = Character.toUpperCase(c2);
+// }
+// if(c1 != c2)
+// return false;
+// }
+// return true;
+// }
// /**
@@ -107,50 +77,7 @@ public class SyntaxUtilities {
// }
- /**
- * Paints the specified line onto the graphics context. Note that this
- * method munges the offset and count values of the segment.
- * @param line The line segment
- * @param tokens The token list for the line
- * @param styles The syntax style list
- * @param expander The tab expander used to determine tab stops. May
- * be null
- * @param gfx The graphics context
- * @param x The x co-ordinate
- * @param y The y co-ordinate
- * @return The x co-ordinate, plus the width of the painted string
- */
- public static int paintSyntaxLine(Segment line, Token tokens,
- SyntaxStyle[] styles,
- TabExpander expander, Graphics gfx,
- int x, int y) {
- Font defaultFont = gfx.getFont();
- Color defaultColor = gfx.getColor();
-
- for (;;) {
- byte id = tokens.id;
- if(id == Token.END)
- break;
-
- int length = tokens.length;
- if (id == Token.NULL) {
- if(!defaultColor.equals(gfx.getColor()))
- gfx.setColor(defaultColor);
- if(!defaultFont.equals(gfx.getFont()))
- gfx.setFont(defaultFont);
- } else {
- styles[id].setGraphicsFlags(gfx,defaultFont);
- }
- line.count = length;
- x = Utilities.drawTabbedText(line,x,y,gfx,expander,0);
- line.offset += length;
-
- tokens = tokens.next;
- }
-
- return x;
- }
// private members
- private SyntaxUtilities() {}
+// private SyntaxUtilities() {}
}
diff --git a/app/src/processing/app/syntax/TextAreaDefaults.java b/app/src/processing/app/syntax/TextAreaDefaults.java
index 9401c4e32..ac856102b 100644
--- a/app/src/processing/app/syntax/TextAreaDefaults.java
+++ b/app/src/processing/app/syntax/TextAreaDefaults.java
@@ -41,7 +41,8 @@ public class TextAreaDefaults {
public boolean paintInvalid;
// moved from TextAreaPainter [fry]
- public Font font;
+ public Font plainFont;
+ public Font boldFont;
public Color fgcolor;
public Color bgcolor;
public boolean antialias;
diff --git a/app/src/processing/app/syntax/TextAreaPainter.java b/app/src/processing/app/syntax/TextAreaPainter.java
index 2cef5962a..30b0f6200 100644
--- a/app/src/processing/app/syntax/TextAreaPainter.java
+++ b/app/src/processing/app/syntax/TextAreaPainter.java
@@ -15,6 +15,7 @@ import processing.app.syntax.im.CompositionTextPainter;
import javax.swing.ToolTipManager;
import javax.swing.text.*;
import javax.swing.JComponent;
+
import java.awt.event.MouseEvent;
import java.awt.*;
import java.awt.print.*;
@@ -54,7 +55,7 @@ implements TabExpander, Printable {
setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
// unfortunately probably can't just do setDefaults() since things aren't quite set up
- setFont(defaults.font);
+ setFont(defaults.plainFont);
// System.out.println("defaults font is " + defaults.font);
setForeground(defaults.fgcolor);
setBackground(defaults.bgcolor);
@@ -611,6 +612,7 @@ implements TabExpander, Printable {
gfx.drawString(".",x,y);
}
}
+
protected void paintSyntaxLine(Graphics gfx, TokenMarker tokenMarker,
int line, Font defaultFont,
@@ -624,7 +626,7 @@ implements TabExpander, Printable {
gfx.setFont(defaultFont);
gfx.setColor(defaultColor);
y += fm.getHeight();
- x = SyntaxUtilities.paintSyntaxLine(currentLine,
+ x = paintSyntaxLine(currentLine,
currentLineTokens,
styles, this, gfx, x, y);
/*
@@ -638,6 +640,51 @@ implements TabExpander, Printable {
gfx.drawString(".",x,y);
}
}
+
+
+ /**
+ * Paints the specified line onto the graphics context. Note that this
+ * method munges the offset and count values of the segment.
+ * @param line The line segment
+ * @param tokens The token list for the line
+ * @param styles The syntax style list
+ * @param expander The tab expander used to determine tab stops. May
+ * be null
+ * @param gfx The graphics context
+ * @param x The x co-ordinate
+ * @param y The y co-ordinate
+ * @return The x co-ordinate, plus the width of the painted string
+ */
+ static public int paintSyntaxLine(Segment line, Token tokens,
+ SyntaxStyle[] styles,
+ TabExpander expander, Graphics gfx,
+ int x, int y) {
+ Font defaultFont = gfx.getFont();
+ Color defaultColor = gfx.getColor();
+
+ for (;;) {
+ byte id = tokens.id;
+ if(id == Token.END)
+ break;
+
+ int length = tokens.length;
+ if (id == Token.NULL) {
+ if(!defaultColor.equals(gfx.getColor()))
+ gfx.setColor(defaultColor);
+ if(!defaultFont.equals(gfx.getFont()))
+ gfx.setFont(defaultFont);
+ } else {
+ styles[id].setGraphicsFlags(gfx,defaultFont);
+ }
+ line.count = length;
+ x = Utilities.drawTabbedText(line,x,y,gfx,expander,0);
+ line.offset += length;
+
+ tokens = tokens.next;
+ }
+
+ return x;
+ }
protected void paintHighlight(Graphics gfx, int line, int y) {