| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -78,35 +78,3 @@ editor.eolmarkers.color = #999999 | |||
| 78 | 78 | # bracket/brace highlighting | |
| 79 | 79 | editor.brackethighlight = true | |
| 80 | 80 | editor.brackethighlight.color = #006699 | |
| 81 | - | ||
| 82 | - | ||
| 83 | - # TEXT - KEYWORDS, LITERALS | ||
| 84 | - # For an explanation of these tags, see Token.java | ||
| 85 | - # trunk/processing/app/src/processing/app/syntax/Token.java | ||
| 86 | - | ||
| 87 | - editor.function1.style = #006699,plain | ||
| 88 | - editor.function2.style = #006699,plain | ||
| 89 | - editor.function3.style = #669933,plain | ||
| 90 | - editor.keyword1.style = #996633,plain | ||
| 91 | - editor.keyword2.style = #996633,plain | ||
| 92 | - editor.keyword3.style = #669933,plain | ||
| 93 | - editor.keyword4.style = #ff6699,plain | ||
| 94 | - editor.keyword5.style = #cc6633,plain | ||
| 95 | - editor.literal1.style = #7D4793,plain | ||
| 96 | - editor.literal2.style = #666666,plain | ||
| 97 | - editor.function3.style = #627516,plain | ||
| 98 | - | ||
| 99 | - editor.keyword4.style = #627516,plain | ||
| 100 | - editor.keyword5.style = #627516,plain | ||
| 101 | - | ||
| 102 | - # e.g. + - = / | ||
| 103 | - editor.operator.style = #000000,plain | ||
| 104 | - | ||
| 105 | - # ?? maybe this is for words followed by a colon | ||
| 106 | - # like in case statements or goto | ||
| 107 | - editor.label.style = #7e7e7e,bold | ||
| 108 | - | ||
| 109 | - #editor.comment1.style = #7e7e7e,plain | ||
| 110 | - #editor.comment2.style = #7e7e7e,plain | ||
| 111 | - editor.comment1.style = #666666,plain | ||
| 112 | - editor.comment2.style = #666666,plain | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -275,7 +275,9 @@ public void windowGainedFocus(WindowEvent e) { | |||
| 275 | 275 | ||
| 276 | 276 | // Open the document that was passed in | |
| 277 | 277 | boolean loaded = handleOpenInternal(path); | |
| 278 | - if (!loaded) sketch = null; | ||
| 278 | + if (!loaded) { | ||
| 279 | + sketch = null; | ||
| 280 | + } | ||
| 279 | 281 | } | |
| 280 | 282 | ||
| 281 | 283 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -863,13 +863,22 @@ public Font getFont(String attribute) { | |||
| 863 | 863 | ||
| 864 | 864 | ||
| 865 | 865 | public SyntaxStyle getStyle(String attribute) { | |
| 866 | - SyntaxStyle style = theme.getStyle(attribute); | ||
| 867 | - if (style == null) { | ||
| 868 | - // System.err.println("No style coloring found for " + attribute); | ||
| 869 | - // style = new SyntaxStyle(Color.BLACK, false, false); | ||
| 866 | + String str = Preferences.get("editor.token." + attribute + ".style"); | ||
| 867 | + if (str == null) { | ||
| 870 | 868 | throw new IllegalArgumentException("No style found for " + attribute); | |
| 871 | 869 | } | |
| 872 | - return style; | ||
| 870 | + | ||
| 871 | + StringTokenizer st = new StringTokenizer(str, ","); | ||
| 872 | + | ||
| 873 | + String s = st.nextToken(); | ||
| 874 | + if (s.indexOf("#") == 0) s = s.substring(1); | ||
| 875 | + Color color = new Color(Integer.parseInt(s, 16)); | ||
| 876 | + | ||
| 877 | + s = st.nextToken(); | ||
| 878 | + boolean bold = (s.indexOf("bold") != -1); | ||
| 879 | + boolean italic = (s.indexOf("italic") != -1); | ||
| 880 | + | ||
| 881 | + return new SyntaxStyle(color, italic, bold); | ||
| 873 | 882 | } | |
| 874 | 883 | ||
| 875 | 884 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -27,7 +27,6 @@ | |||
| 27 | 27 | import java.io.*; | |
| 28 | 28 | import java.util.*; | |
| 29 | 29 | ||
| 30 | - import processing.app.syntax.*; | ||
| 31 | 30 | import processing.core.*; | |
| 32 | 31 | ||
| 33 | 32 | ||
@@ -210,21 +209,4 @@ public Font getFont(String attr) { | |||
| 210 | 209 | ||
| 211 | 210 | return font; | |
| 212 | 211 | } | |
| 213 | - | ||
| 214 | - | ||
| 215 | - public SyntaxStyle getStyle(String what) { | ||
| 216 | - String str = get("editor." + what + ".style"); | ||
| 217 | - | ||
| 218 | - StringTokenizer st = new StringTokenizer(str, ","); | ||
| 219 | - | ||
| 220 | - String s = st.nextToken(); | ||
| 221 | - if (s.indexOf("#") == 0) s = s.substring(1); | ||
| 222 | - Color color = new Color(Integer.parseInt(s, 16)); | ||
| 223 | - | ||
| 224 | - s = st.nextToken(); | ||
| 225 | - boolean bold = (s.indexOf("bold") != -1); | ||
| 226 | - boolean italic = (s.indexOf("italic") != -1); | ||
| 227 | - | ||
| 228 | - return new SyntaxStyle(color, italic, bold); | ||
| 229 | - } | ||
| 230 | 212 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -480,7 +480,7 @@ public void actionPerformed(ActionEvent evt) | |||
| 480 | 480 | else | |
| 481 | 481 | { | |
| 482 | 482 | String noWordSep = (String)textArea.getDocument().getProperty("noWordSep"); | |
| 483 | - caret = TextUtilities.findWordStart(lineText,caret,noWordSep); | ||
| 483 | + caret = findWordStart(lineText,caret,noWordSep); | ||
| 484 | 484 | } | |
| 485 | 485 | ||
| 486 | 486 | try | |
@@ -563,7 +563,7 @@ public void actionPerformed(ActionEvent evt) | |||
| 563 | 563 | else | |
| 564 | 564 | { | |
| 565 | 565 | String noWordSep = (String)textArea.getDocument().getProperty("noWordSep"); | |
| 566 | - caret = TextUtilities.findWordEnd(lineText,caret,noWordSep); | ||
| 566 | + caret = findWordEnd(lineText,caret,noWordSep); | ||
| 567 | 567 | } | |
| 568 | 568 | ||
| 569 | 569 | try | |
@@ -914,7 +914,7 @@ public void actionPerformed(ActionEvent evt) | |||
| 914 | 914 | else | |
| 915 | 915 | { | |
| 916 | 916 | String noWordSep = (String)textArea.getDocument().getProperty("noWordSep"); | |
| 917 | - caret = TextUtilities.findWordEnd(lineText,caret,noWordSep); | ||
| 917 | + caret = findWordEnd(lineText,caret,noWordSep); | ||
| 918 | 918 | } | |
| 919 | 919 | ||
| 920 | 920 | if(select) | |
@@ -1075,7 +1075,7 @@ public void actionPerformed(ActionEvent evt) | |||
| 1075 | 1075 | else | |
| 1076 | 1076 | { | |
| 1077 | 1077 | String noWordSep = (String)textArea.getDocument().getProperty("noWordSep"); | |
| 1078 | - caret = TextUtilities.findWordStart(lineText,caret,noWordSep); | ||
| 1078 | + caret = findWordStart(lineText,caret,noWordSep); | ||
| 1079 | 1079 | } | |
| 1080 | 1080 | ||
| 1081 | 1081 | if(select) | |
@@ -1162,4 +1162,64 @@ public void actionPerformed(ActionEvent evt) | |||
| 1162 | 1162 | } | |
| 1163 | 1163 | } | |
| 1164 | 1164 | } | |
| 1165 | + | ||
| 1166 | + | ||
| 1167 | + /** | ||
| 1168 | + * Locates the start of the word at the specified position. | ||
| 1169 | + * Moved from TextUtilities.java [fry 121210]. | ||
| 1170 | + * @param line The text | ||
| 1171 | + * @param pos The position | ||
| 1172 | + */ | ||
| 1173 | + public static int findWordStart(String line, int pos, String noWordSep) | ||
| 1174 | + { | ||
| 1175 | + char ch = line.charAt(pos - 1); | ||
| 1176 | + | ||
| 1177 | + if(noWordSep == null) | ||
| 1178 | + noWordSep = ""; | ||
| 1179 | + boolean selectNoLetter = (!Character.isLetterOrDigit(ch) | ||
| 1180 | + && noWordSep.indexOf(ch) == -1); | ||
| 1181 | + | ||
| 1182 | + int wordStart = 0; | ||
| 1183 | + for(int i = pos - 1; i >= 0; i--) | ||
| 1184 | + { | ||
| 1185 | + ch = line.charAt(i); | ||
| 1186 | + if(selectNoLetter ^ (!Character.isLetterOrDigit(ch) && | ||
| 1187 | + noWordSep.indexOf(ch) == -1)) | ||
| 1188 | + { | ||
| 1189 | + wordStart = i + 1; | ||
| 1190 | + break; | ||
| 1191 | + } | ||
| 1192 | + } | ||
| 1193 | + | ||
| 1194 | + return wordStart; | ||
| 1195 | + } | ||
| 1196 | + | ||
| 1197 | + /** | ||
| 1198 | + * Locates the end of the word at the specified position. | ||
| 1199 | + * Moved from TextUtilities.java [fry 121210]. | ||
| 1200 | + * @param line The text | ||
| 1201 | + * @param pos The position | ||
| 1202 | + */ | ||
| 1203 | + public static int findWordEnd(String line, int pos, String noWordSep) | ||
| 1204 | + { | ||
| 1205 | + char ch = line.charAt(pos); | ||
| 1206 | + | ||
| 1207 | + if(noWordSep == null) | ||
| 1208 | + noWordSep = ""; | ||
| 1209 | + boolean selectNoLetter = (!Character.isLetterOrDigit(ch) | ||
| 1210 | + && noWordSep.indexOf(ch) == -1); | ||
| 1211 | + | ||
| 1212 | + int wordEnd = line.length(); | ||
| 1213 | + for(int i = pos; i < line.length(); i++) | ||
| 1214 | + { | ||
| 1215 | + ch = line.charAt(i); | ||
| 1216 | + if(selectNoLetter ^ (!Character.isLetterOrDigit(ch) && | ||
| 1217 | + noWordSep.indexOf(ch) == -1)) | ||
| 1218 | + { | ||
| 1219 | + wordEnd = i; | ||
| 1220 | + break; | ||
| 1221 | + } | ||
| 1222 | + } | ||
| 1223 | + return wordEnd; | ||
| 1224 | + } | ||
| 1165 | 1225 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -29,7 +29,7 @@ | |||
| 29 | 29 | ||
| 30 | 30 | public class PdeTextAreaDefaults extends TextAreaDefaults { | |
| 31 | 31 | ||
| 32 | - public PdeTextAreaDefaults(Mode theme) { | ||
| 32 | + public PdeTextAreaDefaults(Mode mode) { | ||
| 33 | 33 | inputHandler = new DefaultInputHandler(); | |
| 34 | 34 | //inputHandler.addDefaultKeyBindings(); // 0122 | |
| 35 | 35 | ||
@@ -199,38 +199,39 @@ public PdeTextAreaDefaults(Mode theme) { | |||
| 199 | 199 | ||
| 200 | 200 | styles = new SyntaxStyle[Token.ID_COUNT]; | |
| 201 | 201 | ||
| 202 | - styles[Token.COMMENT1] = theme.getStyle("comment1"); | ||
| 203 | - styles[Token.COMMENT2] = theme.getStyle("comment2"); | ||
| 202 | + styles[Token.COMMENT1] = mode.getStyle("comment1"); | ||
| 203 | + styles[Token.COMMENT2] = mode.getStyle("comment2"); | ||
| 204 | 204 | ||
| 205 | - styles[Token.KEYWORD1] = theme.getStyle("keyword1"); | ||
| 206 | - styles[Token.KEYWORD2] = theme.getStyle("keyword2"); | ||
| 207 | - styles[Token.KEYWORD3] = theme.getStyle("keyword3"); | ||
| 208 | - styles[Token.KEYWORD4] = theme.getStyle("keyword4"); | ||
| 209 | - styles[Token.KEYWORD5] = theme.getStyle("keyword5"); | ||
| 205 | + styles[Token.KEYWORD1] = mode.getStyle("keyword1"); | ||
| 206 | + styles[Token.KEYWORD2] = mode.getStyle("keyword2"); | ||
| 207 | + styles[Token.KEYWORD3] = mode.getStyle("keyword3"); | ||
| 208 | + styles[Token.KEYWORD4] = mode.getStyle("keyword4"); | ||
| 209 | + styles[Token.KEYWORD5] = mode.getStyle("keyword5"); | ||
| 210 | 210 | ||
| 211 | - styles[Token.FUNCTION1] = theme.getStyle("function1"); | ||
| 212 | - styles[Token.FUNCTION2] = theme.getStyle("function2"); | ||
| 213 | - styles[Token.FUNCTION3] = theme.getStyle("function3"); | ||
| 211 | + styles[Token.FUNCTION1] = mode.getStyle("function1"); | ||
| 212 | + styles[Token.FUNCTION2] = mode.getStyle("function2"); | ||
| 213 | + styles[Token.FUNCTION3] = mode.getStyle("function3"); | ||
| 214 | + styles[Token.FUNCTION4] = mode.getStyle("function4"); | ||
| 214 | 215 | ||
| 215 | - styles[Token.LITERAL1] = theme.getStyle("literal1"); | ||
| 216 | - styles[Token.LITERAL2] = theme.getStyle("literal2"); | ||
| 216 | + styles[Token.LITERAL1] = mode.getStyle("literal1"); | ||
| 217 | + styles[Token.LITERAL2] = mode.getStyle("literal2"); | ||
| 217 | 218 | ||
| 218 | - styles[Token.LABEL] = theme.getStyle("label"); | ||
| 219 | - styles[Token.OPERATOR] = theme.getStyle("operator"); | ||
| 219 | + styles[Token.LABEL] = mode.getStyle("label"); | ||
| 220 | + styles[Token.OPERATOR] = mode.getStyle("operator"); | ||
| 220 | 221 | ||
| 221 | 222 | // area that's not in use by the text (replaced with tildes) | |
| 222 | - styles[Token.INVALID] = theme.getStyle("invalid"); | ||
| 223 | - | ||
| 224 | - fgcolor = theme.getColor("editor.fgcolor"); | ||
| 225 | - bgcolor = theme.getColor("editor.bgcolor"); | ||
| 226 | - | ||
| 227 | - caretColor = theme.getColor("editor.caret.color"); | ||
| 228 | - selectionColor = theme.getColor("editor.selection.color"); | ||
| 229 | - lineHighlight = theme.getBoolean("editor.linehighlight"); | ||
| 230 | - lineHighlightColor = theme.getColor("editor.linehighlight.color"); | ||
| 231 | - bracketHighlight = theme.getBoolean("editor.brackethighlight"); | ||
| 232 | - bracketHighlightColor = theme.getColor("editor.brackethighlight.color"); | ||
| 233 | - eolMarkers = theme.getBoolean("editor.eolmarkers"); | ||
| 234 | - eolMarkerColor = theme.getColor("editor.eolmarkers.color"); | ||
| 223 | + styles[Token.INVALID] = mode.getStyle("invalid"); | ||
| 224 | + | ||
| 225 | + fgcolor = mode.getColor("editor.fgcolor"); | ||
| 226 | + bgcolor = mode.getColor("editor.bgcolor"); | ||
| 227 | + | ||
| 228 | + caretColor = mode.getColor("editor.caret.color"); | ||
| 229 | + selectionColor = mode.getColor("editor.selection.color"); | ||
| 230 | + lineHighlight = mode.getBoolean("editor.linehighlight"); | ||
| 231 | + lineHighlightColor = mode.getColor("editor.linehighlight.color"); | ||
| 232 | + bracketHighlight = mode.getBoolean("editor.brackethighlight"); | ||
| 233 | + bracketHighlightColor = mode.getColor("editor.brackethighlight.color"); | ||
| 234 | + eolMarkers = mode.getBoolean("editor.eolmarkers"); | ||
| 235 | + eolMarkerColor = mode.getColor("editor.eolmarkers.color"); | ||
| 235 | 236 | } | |
| 236 | 237 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -66,19 +66,22 @@ public class Token { | |||
| 66 | 66 | /** Loop/function-like blocks (for, while, etc.) */ | |
| 67 | 67 | public static final byte FUNCTION3 = 13; | |
| 68 | 68 | ||
| 69 | + /** Built-in Processing functions (setup, draw, mouseDragged). */ | ||
| 70 | + public static final byte FUNCTION4 = 13; | ||
| 71 | + | ||
| 69 | 72 | /** | |
| 70 | 73 | * Operator token id. This can be used to mark an | |
| 71 | 74 | * operator. (eg, SQL mode marks +, -, etc with this | |
| 72 | 75 | * token type) | |
| 73 | 76 | */ | |
| 74 | - public static final byte OPERATOR = 14; | ||
| 77 | + public static final byte OPERATOR = 15; | ||
| 75 | 78 | ||
| 76 | 79 | /** | |
| 77 | 80 | * Invalid token id. This can be used to mark invalid | |
| 78 | 81 | * or incomplete tokens, so the user can easily spot | |
| 79 | 82 | * syntax errors. | |
| 80 | 83 | */ | |
| 81 | - public static final byte INVALID = 15; | ||
| 84 | + public static final byte INVALID = 16; | ||
| 82 | 85 | ||
| 83 | 86 | /** The total number of defined token ids. */ | |
| 84 | 87 | public static final byte ID_COUNT = INVALID + 1; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments