diff --git a/android/theme/theme.txt b/android/theme/theme.txt index d22d58903..e1c4c94ba 100644 --- a/android/theme/theme.txt +++ b/android/theme/theme.txt @@ -78,35 +78,3 @@ editor.eolmarkers.color = #999999 # bracket/brace highlighting editor.brackethighlight = true editor.brackethighlight.color = #006699 - - -# TEXT - KEYWORDS, LITERALS -# For an explanation of these tags, see Token.java -# trunk/processing/app/src/processing/app/syntax/Token.java - -editor.function1.style = #006699,plain -editor.function2.style = #006699,plain -editor.function3.style = #669933,plain -editor.keyword1.style = #996633,plain -editor.keyword2.style = #996633,plain -editor.keyword3.style = #669933,plain -editor.keyword4.style = #ff6699,plain -editor.keyword5.style = #cc6633,plain -editor.literal1.style = #7D4793,plain -editor.literal2.style = #666666,plain -editor.function3.style = #627516,plain - -editor.keyword4.style = #627516,plain -editor.keyword5.style = #627516,plain - -# e.g. + - = / -editor.operator.style = #000000,plain - -# ?? maybe this is for words followed by a colon -# like in case statements or goto -editor.label.style = #7e7e7e,bold - -#editor.comment1.style = #7e7e7e,plain -#editor.comment2.style = #7e7e7e,plain -editor.comment1.style = #666666,plain -editor.comment2.style = #666666,plain diff --git a/app/src/processing/app/Editor.java b/app/src/processing/app/Editor.java index 099c8b4a5..4b89f0ec3 100644 --- a/app/src/processing/app/Editor.java +++ b/app/src/processing/app/Editor.java @@ -275,7 +275,9 @@ public abstract class Editor extends JFrame implements RunnerListener { // Open the document that was passed in boolean loaded = handleOpenInternal(path); - if (!loaded) sketch = null; + if (!loaded) { + sketch = null; + } } diff --git a/app/src/processing/app/Mode.java b/app/src/processing/app/Mode.java index d4adb6f87..43744ec79 100644 --- a/app/src/processing/app/Mode.java +++ b/app/src/processing/app/Mode.java @@ -863,13 +863,22 @@ public abstract class Mode { public SyntaxStyle getStyle(String attribute) { - SyntaxStyle style = theme.getStyle(attribute); - if (style == null) { -// System.err.println("No style coloring found for " + attribute); -// style = new SyntaxStyle(Color.BLACK, false, false); + String str = Preferences.get("editor.token." + attribute + ".style"); + if (str == null) { throw new IllegalArgumentException("No style found for " + attribute); } - return style; + + StringTokenizer st = new StringTokenizer(str, ","); + + String s = st.nextToken(); + if (s.indexOf("#") == 0) s = s.substring(1); + Color color = new Color(Integer.parseInt(s, 16)); + + s = st.nextToken(); + boolean bold = (s.indexOf("bold") != -1); + boolean italic = (s.indexOf("italic") != -1); + + return new SyntaxStyle(color, italic, bold); } diff --git a/app/src/processing/app/Settings.java b/app/src/processing/app/Settings.java index 98365b8f0..1d19dbc41 100644 --- a/app/src/processing/app/Settings.java +++ b/app/src/processing/app/Settings.java @@ -27,7 +27,6 @@ import java.awt.*; import java.io.*; import java.util.*; -import processing.app.syntax.*; import processing.core.*; @@ -210,21 +209,4 @@ public class Settings { return font; } - - - public SyntaxStyle getStyle(String what) { - String str = get("editor." + what + ".style"); - - StringTokenizer st = new StringTokenizer(str, ","); - - String s = st.nextToken(); - if (s.indexOf("#") == 0) s = s.substring(1); - Color color = new Color(Integer.parseInt(s, 16)); - - s = st.nextToken(); - boolean bold = (s.indexOf("bold") != -1); - boolean italic = (s.indexOf("italic") != -1); - - return new SyntaxStyle(color, italic, bold); - } } \ No newline at end of file diff --git a/app/src/processing/app/syntax/InputHandler.java b/app/src/processing/app/syntax/InputHandler.java index fd671be5b..8f8fc471d 100644 --- a/app/src/processing/app/syntax/InputHandler.java +++ b/app/src/processing/app/syntax/InputHandler.java @@ -480,7 +480,7 @@ public abstract class InputHandler extends KeyAdapter else { String noWordSep = (String)textArea.getDocument().getProperty("noWordSep"); - caret = TextUtilities.findWordStart(lineText,caret,noWordSep); + caret = findWordStart(lineText,caret,noWordSep); } try @@ -563,7 +563,7 @@ public abstract class InputHandler extends KeyAdapter else { String noWordSep = (String)textArea.getDocument().getProperty("noWordSep"); - caret = TextUtilities.findWordEnd(lineText,caret,noWordSep); + caret = findWordEnd(lineText,caret,noWordSep); } try @@ -914,7 +914,7 @@ public abstract class InputHandler extends KeyAdapter else { String noWordSep = (String)textArea.getDocument().getProperty("noWordSep"); - caret = TextUtilities.findWordEnd(lineText,caret,noWordSep); + caret = findWordEnd(lineText,caret,noWordSep); } if(select) @@ -1075,7 +1075,7 @@ public abstract class InputHandler extends KeyAdapter else { String noWordSep = (String)textArea.getDocument().getProperty("noWordSep"); - caret = TextUtilities.findWordStart(lineText,caret,noWordSep); + caret = findWordStart(lineText,caret,noWordSep); } if(select) @@ -1162,4 +1162,64 @@ public abstract class InputHandler extends KeyAdapter } } } + + + /** + * Locates the start of the word at the specified position. + * Moved from TextUtilities.java [fry 121210]. + * @param line The text + * @param pos The position + */ + public static int findWordStart(String line, int pos, String noWordSep) + { + char ch = line.charAt(pos - 1); + + if(noWordSep == null) + noWordSep = ""; + boolean selectNoLetter = (!Character.isLetterOrDigit(ch) + && noWordSep.indexOf(ch) == -1); + + int wordStart = 0; + for(int i = pos - 1; i >= 0; i--) + { + ch = line.charAt(i); + if(selectNoLetter ^ (!Character.isLetterOrDigit(ch) && + noWordSep.indexOf(ch) == -1)) + { + wordStart = i + 1; + break; + } + } + + return wordStart; + } + + /** + * Locates the end of the word at the specified position. + * Moved from TextUtilities.java [fry 121210]. + * @param line The text + * @param pos The position + */ + public static int findWordEnd(String line, int pos, String noWordSep) + { + char ch = line.charAt(pos); + + if(noWordSep == null) + noWordSep = ""; + boolean selectNoLetter = (!Character.isLetterOrDigit(ch) + && noWordSep.indexOf(ch) == -1); + + int wordEnd = line.length(); + for(int i = pos; i < line.length(); i++) + { + ch = line.charAt(i); + if(selectNoLetter ^ (!Character.isLetterOrDigit(ch) && + noWordSep.indexOf(ch) == -1)) + { + wordEnd = i; + break; + } + } + return wordEnd; + } } diff --git a/app/src/processing/app/syntax/PdeTextAreaDefaults.java b/app/src/processing/app/syntax/PdeTextAreaDefaults.java index 1d9255f62..16ba8a876 100644 --- a/app/src/processing/app/syntax/PdeTextAreaDefaults.java +++ b/app/src/processing/app/syntax/PdeTextAreaDefaults.java @@ -29,7 +29,7 @@ import processing.app.*; public class PdeTextAreaDefaults extends TextAreaDefaults { - public PdeTextAreaDefaults(Mode theme) { + public PdeTextAreaDefaults(Mode mode) { inputHandler = new DefaultInputHandler(); //inputHandler.addDefaultKeyBindings(); // 0122 @@ -199,38 +199,39 @@ public class PdeTextAreaDefaults extends TextAreaDefaults { styles = new SyntaxStyle[Token.ID_COUNT]; - styles[Token.COMMENT1] = theme.getStyle("comment1"); - styles[Token.COMMENT2] = theme.getStyle("comment2"); + styles[Token.COMMENT1] = mode.getStyle("comment1"); + styles[Token.COMMENT2] = mode.getStyle("comment2"); - styles[Token.KEYWORD1] = theme.getStyle("keyword1"); - styles[Token.KEYWORD2] = theme.getStyle("keyword2"); - styles[Token.KEYWORD3] = theme.getStyle("keyword3"); - styles[Token.KEYWORD4] = theme.getStyle("keyword4"); - styles[Token.KEYWORD5] = theme.getStyle("keyword5"); + styles[Token.KEYWORD1] = mode.getStyle("keyword1"); + styles[Token.KEYWORD2] = mode.getStyle("keyword2"); + styles[Token.KEYWORD3] = mode.getStyle("keyword3"); + styles[Token.KEYWORD4] = mode.getStyle("keyword4"); + styles[Token.KEYWORD5] = mode.getStyle("keyword5"); - styles[Token.FUNCTION1] = theme.getStyle("function1"); - styles[Token.FUNCTION2] = theme.getStyle("function2"); - styles[Token.FUNCTION3] = theme.getStyle("function3"); + styles[Token.FUNCTION1] = mode.getStyle("function1"); + styles[Token.FUNCTION2] = mode.getStyle("function2"); + styles[Token.FUNCTION3] = mode.getStyle("function3"); + styles[Token.FUNCTION4] = mode.getStyle("function4"); - styles[Token.LITERAL1] = theme.getStyle("literal1"); - styles[Token.LITERAL2] = theme.getStyle("literal2"); + styles[Token.LITERAL1] = mode.getStyle("literal1"); + styles[Token.LITERAL2] = mode.getStyle("literal2"); - styles[Token.LABEL] = theme.getStyle("label"); - styles[Token.OPERATOR] = theme.getStyle("operator"); + styles[Token.LABEL] = mode.getStyle("label"); + styles[Token.OPERATOR] = mode.getStyle("operator"); // area that's not in use by the text (replaced with tildes) - styles[Token.INVALID] = theme.getStyle("invalid"); + styles[Token.INVALID] = mode.getStyle("invalid"); - fgcolor = theme.getColor("editor.fgcolor"); - bgcolor = theme.getColor("editor.bgcolor"); + fgcolor = mode.getColor("editor.fgcolor"); + bgcolor = mode.getColor("editor.bgcolor"); - caretColor = theme.getColor("editor.caret.color"); - selectionColor = theme.getColor("editor.selection.color"); - lineHighlight = theme.getBoolean("editor.linehighlight"); - lineHighlightColor = theme.getColor("editor.linehighlight.color"); - bracketHighlight = theme.getBoolean("editor.brackethighlight"); - bracketHighlightColor = theme.getColor("editor.brackethighlight.color"); - eolMarkers = theme.getBoolean("editor.eolmarkers"); - eolMarkerColor = theme.getColor("editor.eolmarkers.color"); + caretColor = mode.getColor("editor.caret.color"); + selectionColor = mode.getColor("editor.selection.color"); + lineHighlight = mode.getBoolean("editor.linehighlight"); + lineHighlightColor = mode.getColor("editor.linehighlight.color"); + bracketHighlight = mode.getBoolean("editor.brackethighlight"); + bracketHighlightColor = mode.getColor("editor.brackethighlight.color"); + eolMarkers = mode.getBoolean("editor.eolmarkers"); + eolMarkerColor = mode.getColor("editor.eolmarkers.color"); } } diff --git a/app/src/processing/app/syntax/TextUtilities.java b/app/src/processing/app/syntax/TextUtilities.java deleted file mode 100644 index 55cf94bcf..000000000 --- a/app/src/processing/app/syntax/TextUtilities.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * TextUtilities.java - Utility functions used by the text area classes - * Copyright (C) 1999 Slava Pestov - * - * You may use and modify this package for any purpose. Redistribution is - * permitted, in both source and binary form, provided that this notice - * remains intact in all source distributions of this package. - */ - -package processing.app.syntax; - - -/** - * Class with several utility functions used by the text area component. - * @author Slava Pestov - * @version $Id$ - */ -public class TextUtilities -{ - /** - * Locates the start of the word at the specified position. - * @param line The text - * @param pos The position - */ - public static int findWordStart(String line, int pos, String noWordSep) - { - char ch = line.charAt(pos - 1); - - if(noWordSep == null) - noWordSep = ""; - boolean selectNoLetter = (!Character.isLetterOrDigit(ch) - && noWordSep.indexOf(ch) == -1); - - int wordStart = 0; - for(int i = pos - 1; i >= 0; i--) - { - ch = line.charAt(i); - if(selectNoLetter ^ (!Character.isLetterOrDigit(ch) && - noWordSep.indexOf(ch) == -1)) - { - wordStart = i + 1; - break; - } - } - - return wordStart; - } - - /** - * Locates the end of the word at the specified position. - * @param line The text - * @param pos The position - */ - public static int findWordEnd(String line, int pos, String noWordSep) - { - char ch = line.charAt(pos); - - if(noWordSep == null) - noWordSep = ""; - boolean selectNoLetter = (!Character.isLetterOrDigit(ch) - && noWordSep.indexOf(ch) == -1); - - int wordEnd = line.length(); - for(int i = pos; i < line.length(); i++) - { - ch = line.charAt(i); - if(selectNoLetter ^ (!Character.isLetterOrDigit(ch) && - noWordSep.indexOf(ch) == -1)) - { - wordEnd = i; - break; - } - } - return wordEnd; - } -} diff --git a/app/src/processing/app/syntax/Token.java b/app/src/processing/app/syntax/Token.java index c67383e45..afdeb9e73 100644 --- a/app/src/processing/app/syntax/Token.java +++ b/app/src/processing/app/syntax/Token.java @@ -66,19 +66,22 @@ public class Token { /** Loop/function-like blocks (for, while, etc.) */ public static final byte FUNCTION3 = 13; + /** Built-in Processing functions (setup, draw, mouseDragged). */ + public static final byte FUNCTION4 = 13; + /** * 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 = 14; + public static final byte OPERATOR = 15; /** * 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 = 15; + public static final byte INVALID = 16; /** The total number of defined token ids. */ public static final byte ID_COUNT = INVALID + 1; diff --git a/build/shared/lib/preferences.txt b/build/shared/lib/preferences.txt index 79d9b81b4..32258eaec 100644 --- a/build/shared/lib/preferences.txt +++ b/build/shared/lib/preferences.txt @@ -227,6 +227,37 @@ editor.laf.linux = com.sun.java.swing.plaf.gtk.GTKLookAndFeel # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +# TEXT - KEYWORDS, LITERALS +# For an explanation of these tags, see Token.java: +# processing/app/src/processing/app/syntax/Token.java + +editor.token.function1.style = #006699,plain +editor.token.function2.style = #006699,plain +editor.token.function3.style = #669933,plain +editor.token.function4.style = #669933,plain + +editor.token.keyword1.style = #996633,plain +editor.token.keyword2.style = #996633,plain +editor.token.keyword3.style = #669933,plain +editor.token.keyword4.style = #ff6699,plain +editor.token.keyword5.style = #cc6633,plain + +editor.token.literal1.style = #7D4793,plain +editor.token.literal2.style = #666666,plain + +editor.token.operator.style = #006699,plain + +editor.token.label.style = #7e7e7e,bold + +editor.token.comment1.style = #7e7e7e,plain +editor.token.comment2.style = #7e7e7e,plain + +editor.token.invalid.style = #7e7e7e,bold + + +# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + + #history.recording = true # for advanced users, enable option to export a library diff --git a/core/todo.txt b/core/todo.txt index 4288fe225..858d1ec31 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -166,6 +166,10 @@ _ so that it could avoid quitting if the sketch hasn't been stopped _ or if the sketch window is foremost _ maybe a hack where a new menubar is added? +_ when using loadFont(), don't enable native fonts unless hint() in use +_ but on createFont(), we're probably OK +_ might need to make reference notes about the two behaviors + _ splice() throws ClassCastException when used with objects like PVector _ http://code.google.com/p/processing/issues/detail?id=1407 diff --git a/experimental/theme/theme.txt b/experimental/theme/theme.txt index c6c561e1d..838d43666 100755 --- a/experimental/theme/theme.txt +++ b/experimental/theme/theme.txt @@ -72,45 +72,6 @@ editor.brackethighlight = true editor.brackethighlight.color = #006699 -# TEXT - KEYWORDS - -# e.g. Functions -editor.function1.style = #006699,plain - -# e.g. Methods (functions inside a class) -editor.function2.style = #006699,plain - -# e.g. Datatypes and keywords (void, int, boolean, etc.) -editor.keyword1.style = #D86736,plain - -# e.g. Processing fields [variables within a class] -editor.keyword2.style = #EE3C96,plain - -# e.g. Processing variables (width, height, focused, etc.) -editor.keyword3.style = #EE3C96,plain - - -# TEXT - LITERALS - -# e.g. Strings (text in quotes) -editor.literal1.style = #7D4793,plain - -# e.g. Constants (QUARTER_PI, CORNERS, etc.) -editor.literal2.style = #669933,plain - -# e.g. + - = / -editor.operator.style = #006699,plain - -# ?? maybe this is for words followed by a colon -# like in case statements or goto -editor.label.style = #7e7e7e,bold - - -# TEXT - COMMENTS -editor.comment1.style = #7e7e7e,plain -editor.comment2.style = #7e7e7e,plain - - # LINE STATUS - editor line number status bar at the bottom of the screen linestatus.font = SansSerif,plain,10 #linestatus.font.macosx = Helvetica,plain,10 diff --git a/java/theme/theme.txt b/java/theme/theme.txt index 97c1e25c1..10f6e220c 100644 --- a/java/theme/theme.txt +++ b/java/theme/theme.txt @@ -71,32 +71,6 @@ editor.eolmarkers.color = #999999 editor.brackethighlight = true editor.brackethighlight.color = #006699 -# TEXT - KEYWORDS, LITERALS -# For an explanation of these tags, see Token.java -# trunk/processing/app/src/processing/app/syntax/Token.java - -editor.function1.style = #006699,plain -editor.function2.style = #006699,plain -editor.function3.style = #669933,plain -editor.keyword1.style = #996633,plain -editor.keyword2.style = #996633,plain -editor.keyword3.style = #669933,plain -editor.keyword4.style = #ff6699,plain -editor.keyword5.style = #cc6633,plain -editor.literal1.style = #7D4793,plain -editor.literal2.style = #666666,plain - -# e.g. + - = / -editor.operator.style = #006699,plain - -# ?? maybe this is for words followed by a colon -# like in case statements or goto -editor.label.style = #7e7e7e,bold - -# TEXT - COMMENTS -editor.comment1.style = #7e7e7e,plain -editor.comment2.style = #7e7e7e,plain - # LINE STATUS - editor line number status bar at the bottom of the screen linestatus.font = SansSerif,plain,10 #linestatus.font.macosx = Helvetica,plain,10 diff --git a/todo.txt b/todo.txt index 617c8b398..4c2248b95 100644 --- a/todo.txt +++ b/todo.txt @@ -17,6 +17,8 @@ X error checker broken in experimental mode (fix from Manindra) X http://code.google.com/p/processing/issues/detail?id=1449 X Color coding for if/else in Processing IDE doesn't match X http://code.google.com/p/processing/issues/detail?id=1457 +X add ESC and cmd/ctrl-W to the Examples window +X move token/syntax coloring out of theme.txt and back into preferences earlier X include debug mode as 'experimental'?