diff --git a/app/src/processing/app/syntax/KeywordMap.java b/app/src/processing/app/syntax/KeywordMap.java
index 31a63768d..d91268b2a 100644
--- a/app/src/processing/app/syntax/KeywordMap.java
+++ b/app/src/processing/app/syntax/KeywordMap.java
@@ -23,31 +23,39 @@ import javax.swing.text.Segment;
* @version $Id$
*/
public class KeywordMap {
- private Keyword[] map;
- private boolean ignoreCase;
+// private Keyword[] map;
+// protected int mapLength;
+ private boolean ignoreCase;
+ private Keyword[] literalMap;
+ private Keyword[] parenMap;
+
+ // A value of 52 will give good performance for most maps.
+ static private int MAP_LENGTH = 52;
/**
* Creates a new KeywordMap.
* @param ignoreCase True if keys are case insensitive
*/
public KeywordMap(boolean ignoreCase) {
- this(ignoreCase, 52);
+// this(ignoreCase, 52);
this.ignoreCase = ignoreCase;
+ literalMap = new Keyword[MAP_LENGTH];
+ parenMap = new Keyword[MAP_LENGTH];
}
- /**
- * Creates a new KeywordMap.
- * @param ignoreCase True if the keys are case insensitive
- * @param mapLength The number of `buckets' to create.
- * A value of 52 will give good performance for most maps.
- */
- public KeywordMap(boolean ignoreCase, int mapLength) {
- this.mapLength = mapLength;
- this.ignoreCase = ignoreCase;
- map = new Keyword[mapLength];
- }
+// /**
+// * Creates a new KeywordMap.
+// * @param ignoreCase True if the keys are case insensitive
+// * @param mapLength The number of `buckets' to create.
+// * A value of 52 will give good performance for most maps.
+// */
+// public KeywordMap(boolean ignoreCase, int mapLength) {
+// this.mapLength = mapLength;
+// this.ignoreCase = ignoreCase;
+// map = new Keyword[mapLength];
+// }
/**
@@ -56,18 +64,21 @@ public class KeywordMap {
* @param offset The offset of the substring within the text segment
* @param length The length of the substring
*/
- public byte lookup(Segment text, int offset, int length) {
+ public byte lookup(Segment text, int offset, int length, boolean paren) {
if (length == 0) {
return Token.NULL;
}
- Keyword k = map[getSegmentMapKey(text, offset, length)];
- while(k != null) {
- if (length != k.keyword.length) {
- k = k.next;
- continue;
- }
- if (SyntaxUtilities.regionMatches(ignoreCase,text,offset, k.keyword)) {
- return k.id;
+ int key = getSegmentMapKey(text, offset, length);
+ Keyword k = paren ? parenMap[key] : literalMap[key];
+ while (k != null) {
+// if (length != k.keyword.length) {
+// k = k.next;
+// continue;
+// }
+ if (length == k.keyword.length) {
+ if (SyntaxUtilities.regionMatches(ignoreCase,text,offset, k.keyword)) {
+ return k.id;
+ }
}
k = k.next;
}
@@ -80,9 +91,10 @@ public class KeywordMap {
* @param keyword The key
* @param id The value
*/
- public void add(String keyword, byte id) {
+ public void add(String keyword, byte id, boolean paren) {
int key = getStringMapKey(keyword);
- map[key] = new Keyword(keyword.toCharArray(),id,map[key]);
+ Keyword[] map = paren ? parenMap : literalMap;
+ map[key] = new Keyword(keyword.toCharArray(), id, map[key]);
}
@@ -105,20 +117,17 @@ public class KeywordMap {
}
- // protected members
- protected int mapLength;
-
protected int getStringMapKey(String s) {
return (Character.toUpperCase(s.charAt(0)) +
Character.toUpperCase(s.charAt(s.length()-1)))
- % mapLength;
+ % MAP_LENGTH;
}
protected int getSegmentMapKey(Segment s, int off, int len) {
return (Character.toUpperCase(s.array[off]) +
Character.toUpperCase(s.array[off + len - 1]))
- % mapLength;
+ % MAP_LENGTH;
}
diff --git a/app/src/processing/app/syntax/PdeKeywords.java b/app/src/processing/app/syntax/PdeKeywords.java
index e8a62907b..833dba47d 100644
--- a/app/src/processing/app/syntax/PdeKeywords.java
+++ b/app/src/processing/app/syntax/PdeKeywords.java
@@ -34,70 +34,14 @@ import javax.swing.text.Segment;
public class PdeKeywords extends TokenMarker {
private KeywordMap keywordColoring;
- // lookup table for the TokenMarker subclass, handles coloring
-// private static final KeywordMap keywordColoring;
- // lookup table that maps keywords to their html reference pages
-// private static final Hashtable keywordToReference;
-// private HashMap keywordToReference;
-
- // used internally
private int lastOffset;
private int lastKeyword;
- /*
- public PdeKeywords(File file) throws IOException {
- //super(false, getKeywords());
-// this.cpp = cpp;
-// this.keywordColoring = keywordColoring;
-// try {
- BufferedReader reader = PApplet.createReader(file);
-
- keywordColoring = new KeywordMap(false);
- keywordToReference = new HashMap();
-
- // InputStream input = Base.getLibStream("keywords.txt");
- // InputStreamReader isr = new InputStreamReader(input);
- // BufferedReader reader = new BufferedReader(isr);
-
- String line = null;
- while ((line = reader.readLine()) != null) {
- String pieces[] = processing.core.PApplet.split(line, '\t');
- if (pieces.length >= 2) {
- String keyword = pieces[0].trim();
- String coloring = pieces[1].trim();
-
- if (coloring.length() > 0) {
- // text will be KEYWORD or LITERAL
- boolean isKey = (coloring.charAt(0) == 'K');
- // KEYWORD1 -> 0, KEYWORD2 -> 1, etc
- int num = coloring.charAt(coloring.length() - 1) - '1';
- byte id = (byte) ((isKey ? Token.KEYWORD1 : Token.LITERAL1) + num);
- //System.out.println("got " + (isKey ? "keyword" : "literal") +
- // (num+1) + " for " + keyword);
- keywordColoring.add(keyword, id);
- }
- if (pieces.length >= 3) {
- String htmlFilename = pieces[2].trim();
- if (htmlFilename.length() > 0) {
- keywordToReference.put(keyword, htmlFilename);
- }
- }
- }
- }
- reader.close();
-
-// } catch (Exception e) {
-// Base.showError("Problem loading keywords",
-// "Could not load keywords.txt,\n" +
-// "please re-install Processing.", e);
-// }
- }
- */
-
-
/**
- * Add a keyword, and the associated coloring.
+ * Add a keyword, and the associated coloring. KEYWORD2 and KEYWORD3
+ * should only be used with functions (where parens are present).
+ * This is done for the extra paren handling.
* @param coloring one of KEYWORD1, KEYWORD2, LITERAL1, etc.
*/
public void addColoring(String keyword, String coloring) {
@@ -109,7 +53,9 @@ public class PdeKeywords extends TokenMarker {
// KEYWORD1 -> 0, KEYWORD2 -> 1, etc
int num = coloring.charAt(coloring.length() - 1) - '1';
byte id = (byte) ((isKey ? Token.KEYWORD1 : Token.LITERAL1) + num);
- keywordColoring.add(keyword, id);
+ // Making an assumption (..., you, me) that KEYWORD2 and KEYWORD3
+ // are the functions (at least that's what we're doing in P5 right now)
+ keywordColoring.add(keyword, id, id == Token.KEYWORD2 || id == Token.KEYWORD3);
}
@@ -324,7 +270,7 @@ public class PdeKeywords extends TokenMarker {
//// new String(line.array, i, line.array.length - i));
// }
- byte id = keywordColoring.lookup(line, lastKeyword, len);
+ byte id = keywordColoring.lookup(line, lastKeyword, len, paren);
if (id != Token.NULL) {
if (lastKeyword != lastOffset) {
addToken(lastKeyword - lastOffset, Token.NULL);
diff --git a/app/src/processing/app/syntax/Token.java b/app/src/processing/app/syntax/Token.java
index 1873d50da..403e263b3 100644
--- a/app/src/processing/app/syntax/Token.java
+++ b/app/src/processing/app/syntax/Token.java
@@ -76,24 +76,28 @@ public class Token
*/
public static final byte KEYWORD3 = 8;
+ public static final byte KEYWORD4 = 9;
+
+ public static final byte KEYWORD5 = 10;
+
/**
* Operator token id. This can be used to mark an
* operator. (eg, SQL mode marks +, -, etc with this
* token type)
*/
- public static final byte OPERATOR = 9;
+ public static final byte OPERATOR = 11;
/**
* Invalid token id. This can be used to mark invalid
* or incomplete tokens, so the user can easily spot
* syntax errors.
*/
- public static final byte INVALID = 10;
+ public static final byte INVALID = 12;
/**
* The total number of defined token ids.
*/
- public static final byte ID_COUNT = 11;
+ public static final byte ID_COUNT = 13;
/**
* The first id that can be used for internal state
diff --git a/build/shared/revisions.txt b/build/shared/revisions.txt
index 92bcf43f4..0edb1b284 100644
--- a/build/shared/revisions.txt
+++ b/build/shared/revisions.txt
@@ -147,6 +147,12 @@ PROCESSING 2.0b7 (REV 0215) - 25 November 2012
+ Shaders are passed wrong defaults when calling "filter" on a PGraphics object
http://code.google.com/p/processing/issues/detail?id=1301
++ beginContour() behaves differently in immediate and retained modes
+ http://code.google.com/p/processing/issues/detail?id=1417
+
++ P2D/P3D crashes when trying to display unicode text
+ http://code.google.com/p/processing/issues/detail?id=1308
+
+ Fix for PMatrix3D.mult() when vectors are identical
http://code.google.com/p/processing/issues/detail?id=921
diff --git a/core/todo.txt b/core/todo.txt
index 077eb7884..9e20552f0 100644
--- a/core/todo.txt
+++ b/core/todo.txt
@@ -62,6 +62,10 @@ A P2D/P3D PGraphics buffer fails to draw if larger than main surface
A http://code.google.com/p/processing/issues/detail?id=1255
A image(pgraphics, x,y, w, h) only draw once when shrinking
A http://code.google.com/p/processing/issues/detail?id=1382
+A P2D/P3D crashes when trying to display unicode text
+A http://code.google.com/p/processing/issues/detail?id=1308
+A beginContour() behaves differently in immediate and retained modes
+A http://code.google.com/p/processing/issues/detail?id=1417
_ implement mousePressed(Event) etc
_ better to do this instead of bringing back the magic event
diff --git a/todo.txt b/todo.txt
index 29f7a3f51..be37b6566 100644
--- a/todo.txt
+++ b/todo.txt
@@ -47,6 +47,20 @@ X mousePressed() coloring now different from mousePressed
X i.e. mousePressed() is red but mouseMoved() is brown
X http://code.google.com/p/processing/issues/detail?id=41
X Token.KEYWORD / KEYWORD1/2 / LITERAL1/2/3
+X casey requests
+X change keyword coloring so that KEYWORD2 and KEYWORD3 are for functions
+X change syntax highlighting so it differentiates keyPressed and keyPressed()
+X syntax highlight with parens also helps "String line" vs "line()"
+X although nothing in here to prevent "String line" from coloring
+X try to make KEYWORD4 and KEYWORD5 work
+
+
+2.0 FINAL / casey requests
+_ errors that cannot be placed (i.e. missing brace)
+_ this makes things to jump to the last tab
+_ also happens with stray characters sometimes...
+_ casey: accidentally typing a letter at the top of the tab
+_ throws you onto the end of the last tab... exactly the worst location
earlier
X The sketch name can't begin with '_' (underscore)
@@ -132,17 +146,6 @@ _ when creating a sketch within non-java mode, should write the settings file
_ so that it re-loads in the proper environment
-2.0 FINAL / casey requests
-_ try to make KEYWORD4 and KEYWORD5 work
-_ change syntax highlighting so it differentiates keyPressed and keyPressed()
-_ syntax highlight with parens also helps "String line" vs "line()"
-_ errors that cannot be placed (i.e. missing brace)
-_ this makes things to jump to the last tab
-_ also happens with stray characters sometimes...
-_ casey: accidentally typing a letter at the top of the tab
-_ throws you onto the end of the last tab... exactly the worst location
-
-
2.0 FINAL / libraries & classpaths
_ need to deal with classpath conflicts
_ avoid garbage that people have installed on their machines