FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

add FUNCTION1 and FUNCTION2 for better keyword coloring · orgicus/processing@1b67f5d · GitHub

Repository navigation

Commit 1b67f5d

Browse files
committed
add FUNCTION1 and FUNCTION2 for better keyword coloring
1 parent 490ca7f commit 1b67f5d

11 files changed

Lines changed: 431 additions & 407 deletions

File tree

‎android/theme/theme.txt‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ editor.brackethighlight.color = #006699
8282

8383
# TEXT - syntax highlighting
8484

85+
editor.function1.style = #627516,plain
86+
editor.function2.style = #627516,bold
87+
8588
# e.g abstract, final, private
8689
editor.keyword1.style = #627516,plain
8790
# e.g. beginShape, point, line

‎app/src/processing/app/syntax/KeywordMap.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public byte lookup(Segment text, int offset, int length, boolean paren) {
7676
// continue;
7777
// }
7878
if (length == k.keyword.length) {
79-
if (SyntaxUtilities.regionMatches(ignoreCase,text,offset, k.keyword)) {
79+
if (SyntaxUtilities.regionMatches(ignoreCase, text, offset, k.keyword)) {
8080
return k.id;
8181
}
8282
}

‎app/src/processing/app/syntax/PdeKeywords.java‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,17 @@ public void addColoring(String keyword, String coloring) {
4848
if (keywordColoring == null) {
4949
keywordColoring = new KeywordMap(false);
5050
}
51-
// text will be KEYWORD or LITERAL
52-
boolean isKey = (coloring.charAt(0) == 'K');
5351
// KEYWORD1 -> 0, KEYWORD2 -> 1, etc
5452
int num = coloring.charAt(coloring.length() - 1) - '1';
55-
byte id = (byte) ((isKey ? Token.KEYWORD1 : Token.LITERAL1) + num);
56-
// Making an assumption (..., you, me) that KEYWORD2 and KEYWORD3
57-
// are the functions (at least that's what we're doing in P5 right now)
58-
keywordColoring.add(keyword, id, id == Token.KEYWORD2 || id == Token.KEYWORD3);
53+
// byte id = (byte) ((isKey ? Token.KEYWORD1 : Token.LITERAL1) + num);
54+
int id = 0;
55+
boolean paren = false;
56+
switch (coloring.charAt(0)) {
57+
case 'K': id = Token.KEYWORD1 + num; break;
58+
case 'L': id = Token.LITERAL1 + num; break;
59+
case 'F': id = Token.FUNCTION1 + num; paren = true; break;
60+
}
61+
keywordColoring.add(keyword, (byte) id, paren);
5962
}
6063

6164

‎app/src/processing/app/syntax/PdeTextAreaDefaults.java‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,12 @@ public PdeTextAreaDefaults(Mode theme) {
212212
// byte, char, short, color
213213
styles[Token.KEYWORD3] = theme.getStyle("keyword3");
214214

215+
// beginShape, point, line
216+
styles[Token.FUNCTION1] = theme.getStyle("function1");
217+
218+
// byte, char, short, color
219+
styles[Token.FUNCTION2] = theme.getStyle("function2");
220+
215221
// constants: null, true, this, RGB, TWO_PI
216222
styles[Token.LITERAL1] = theme.getStyle("literal1");
217223

‎app/src/processing/app/syntax/SyntaxUtilities.java‎

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
* @author Slava Pestov
2121
* @version $Id$
2222
*/
23-
public class SyntaxUtilities
24-
{
23+
public class SyntaxUtilities {
24+
2525
/**
2626
* Checks if a subregion of a <code>Segment</code> is equal to a
2727
* string.
@@ -31,8 +31,7 @@ public class SyntaxUtilities
3131
* @param match The string to match
3232
*/
3333
public static boolean regionMatches(boolean ignoreCase, Segment text,
34-
int offset, String match)
35-
{
34+
int offset, String match) {
3635
int length = offset + match.length();
3736
char[] textArray = text.array;
3837
if(length > text.offset + text.count)
@@ -62,8 +61,7 @@ public static boolean regionMatches(boolean ignoreCase, Segment text,
6261
* @param match The character array to match
6362
*/
6463
public static boolean regionMatches(boolean ignoreCase, Segment text,
65-
int offset, char[] match)
66-
{
64+
int offset, char[] match) {
6765
int length = offset + match.length;
6866
char[] textArray = text.array;
6967
if(length > text.offset + text.count)
@@ -84,28 +82,29 @@ public static boolean regionMatches(boolean ignoreCase, Segment text,
8482
}
8583

8684

87-
/**
88-
* Returns the default style table. This can be passed to the
89-
* <code>setStyles()</code> method of <code>SyntaxDocument</code>
90-
* to use the default syntax styles.
91-
*/
92-
public static SyntaxStyle[] getDefaultSyntaxStyles()
93-
{
94-
SyntaxStyle[] styles = new SyntaxStyle[Token.ID_COUNT];
95-
96-
styles[Token.COMMENT1] = new SyntaxStyle(Color.black,true,false);
97-
styles[Token.COMMENT2] = new SyntaxStyle(new Color(0x990033),true,false);
98-
styles[Token.KEYWORD1] = new SyntaxStyle(Color.black,false,true);
99-
styles[Token.KEYWORD2] = new SyntaxStyle(Color.magenta,false,false);
100-
styles[Token.KEYWORD3] = new SyntaxStyle(new Color(0x009600),false,false);
101-
styles[Token.LITERAL1] = new SyntaxStyle(new Color(0x650099),false,false);
102-
styles[Token.LITERAL2] = new SyntaxStyle(new Color(0x650099),false,true);
103-
styles[Token.LABEL] = new SyntaxStyle(new Color(0x990033),false,true);
104-
styles[Token.OPERATOR] = new SyntaxStyle(Color.black,false,true);
105-
styles[Token.INVALID] = new SyntaxStyle(Color.red,false,true);
106-
107-
return styles;
108-
}
85+
// /**
86+
// * Returns the default style table. This can be passed to the
87+
// * <code>setStyles()</code> method of <code>SyntaxDocument</code>
88+
// * to use the default syntax styles.
89+
// */
90+
// public static SyntaxStyle[] getDefaultSyntaxStyles() {
91+
// SyntaxStyle[] styles = new SyntaxStyle[Token.ID_COUNT];
92+
//
93+
// styles[Token.COMMENT1] = new SyntaxStyle(Color.black,true,false);
94+
// styles[Token.COMMENT2] = new SyntaxStyle(new Color(0x990033),true,false);
95+
// styles[Token.KEYWORD1] = new SyntaxStyle(Color.black,false,true);
96+
// styles[Token.KEYWORD2] = new SyntaxStyle(Color.magenta,false,false);
97+
// styles[Token.KEYWORD3] = new SyntaxStyle(new Color(0x009600),false,false);
98+
// styles[Token.FUNCTION1] = new SyntaxStyle(Color.magenta,false,false);
99+
// styles[Token.FUNCTION2] = new SyntaxStyle(new Color(0x009600),false,false);
100+
// styles[Token.LITERAL1] = new SyntaxStyle(new Color(0x650099),false,false);
101+
// styles[Token.LITERAL2] = new SyntaxStyle(new Color(0x650099),false,true);
102+
// styles[Token.LABEL] = new SyntaxStyle(new Color(0x990033),false,true);
103+
// styles[Token.OPERATOR] = new SyntaxStyle(Color.black,false,true);
104+
// styles[Token.INVALID] = new SyntaxStyle(Color.red,false,true);
105+
//
106+
// return styles;
107+
// }
109108

110109

111110
/**

‎app/src/processing/app/syntax/Token.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ public class Token
7676
*/
7777
public static final byte KEYWORD3 = 8;
7878

79-
public static final byte KEYWORD4 = 9;
79+
public static final byte FUNCTION1 = 9;
8080

81-
public static final byte KEYWORD5 = 10;
81+
public static final byte FUNCTION2 = 10;
8282

8383
/**
8484
* Operator token id. This can be used to mark an

‎build/shared/revisions.txt‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ PROCESSING 2.0b7 (REV 0215) - 25 November 2012
8888
+ mousePressed() coloring now different from mousePressed
8989
http://code.google.com/p/processing/issues/detail?id=41
9090
Still not necessarily perfect, but it's a big improvement.
91-
Note for people implementing their own Modes: KEYWORD2 and
92-
KEYWORD3 are now reserved for functions with parens.
91+
Note for people implementing their own Modes: FUNCTION1 and
92+
FUNCTION2 have now been added for functions with parens.
9393

9494
+ Fix ugly results from resize() command on PImage:
9595
http://code.google.com/p/processing/issues/detail?id=332
@@ -102,7 +102,7 @@ PROCESSING 2.0b7 (REV 0215) - 25 November 2012
102102
+ image(pgraphics, x, y, w, h) was only drawing once when shrinking.
103103
http://code.google.com/p/processing/issues/detail?id=1382
104104

105-
+ beginShape(QUAD) was not working with Java2D
105+
+ beginShape(QUAD) was not working with Java2D.
106106
http://code.google.com/p/processing/issues/detail?id=1365
107107

108108
+ Relative coordinates not updated properly on closepath with SVG files.
@@ -179,6 +179,12 @@ PROCESSING 2.0b7 (REV 0215) - 25 November 2012
179179
+ Resizeable frame crashes sketch with AMD video card.
180180
http://code.google.com/p/processing/issues/detail?id=1175
181181

182+
+ set(x, y, PImage) doesn't work with P2D/P3D.
183+
http://code.google.com/p/processing/issues/detail?id=1185
184+
185+
+ begin/endShape with a single vertex causing crash on P2D/P3D.
186+
http://code.google.com/p/processing/issues/detail?id=1421
187+
182188
[ android ]
183189

184190
+ Like the desktop release, removed default imports. This includes:

‎core/todo.txt‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ A ortho() displays strange line widths
7474
A http://code.google.com/p/processing/issues/detail?id=1285
7575
A resizeable frame crashes sketch with AMD video card
7676
A http://code.google.com/p/processing/issues/detail?id=1175
77+
A set(x, y, PImage) doesn't work with P2D/P3D
78+
A http://code.google.com/p/processing/issues/detail?id=1185
79+
A Processing 2.0b6 p2d / p3d arraylist pvector display issues
80+
A http://code.google.com/p/processing/issues/detail?id=1421
7781

7882
_ implement mousePressed(Event) etc
7983
_ better to do this instead of bringing back the magic event

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL