author | wenzelm |
Sat, 18 Jun 2011 18:31:55 +0200 | |
changeset 43446 | 9064e1a72c5d |
parent 43394 | 47e60a27a496 |
permissions | -rw-r--r-- |
43446
9064e1a72c5d
Buffer.editSyntaxStyle: mask extended syntax styles;
wenzelm
parents:
43394
diff
changeset
|
1 |
diff -ru jEdit/org/gjt/sp/jedit/Buffer.java jEdit-patched/org/gjt/sp/jedit/Buffer.java |
9064e1a72c5d
Buffer.editSyntaxStyle: mask extended syntax styles;
wenzelm
parents:
43394
diff
changeset
|
2 |
--- jEdit/org/gjt/sp/jedit/Buffer.java 2010-05-09 14:29:25.000000000 +0200 |
9064e1a72c5d
Buffer.editSyntaxStyle: mask extended syntax styles;
wenzelm
parents:
43394
diff
changeset
|
3 |
+++ jEdit-patched/org/gjt/sp/jedit/Buffer.java 2011-06-18 18:28:19.000000000 +0200 |
9064e1a72c5d
Buffer.editSyntaxStyle: mask extended syntax styles;
wenzelm
parents:
43394
diff
changeset
|
4 |
@@ -2232,7 +2232,7 @@ |
9064e1a72c5d
Buffer.editSyntaxStyle: mask extended syntax styles;
wenzelm
parents:
43394
diff
changeset
|
5 |
start = next; |
9064e1a72c5d
Buffer.editSyntaxStyle: mask extended syntax styles;
wenzelm
parents:
43394
diff
changeset
|
6 |
token = token.next; |
9064e1a72c5d
Buffer.editSyntaxStyle: mask extended syntax styles;
wenzelm
parents:
43394
diff
changeset
|
7 |
} |
9064e1a72c5d
Buffer.editSyntaxStyle: mask extended syntax styles;
wenzelm
parents:
43394
diff
changeset
|
8 |
- if (token.id == Token.END || token.id == Token.NULL) |
9064e1a72c5d
Buffer.editSyntaxStyle: mask extended syntax styles;
wenzelm
parents:
43394
diff
changeset
|
9 |
+ if (token.id == Token.END || (token.id % Token.ID_COUNT) == Token.NULL) |
9064e1a72c5d
Buffer.editSyntaxStyle: mask extended syntax styles;
wenzelm
parents:
43394
diff
changeset
|
10 |
{ |
9064e1a72c5d
Buffer.editSyntaxStyle: mask extended syntax styles;
wenzelm
parents:
43394
diff
changeset
|
11 |
JOptionPane.showMessageDialog(jEdit.getActiveView(), |
9064e1a72c5d
Buffer.editSyntaxStyle: mask extended syntax styles;
wenzelm
parents:
43394
diff
changeset
|
12 |
jEdit.getProperty("syntax-style-no-token.message"), |
9064e1a72c5d
Buffer.editSyntaxStyle: mask extended syntax styles;
wenzelm
parents:
43394
diff
changeset
|
13 |
diff -ru jEdit/org/gjt/sp/jedit/syntax/Token.java jEdit-patched/org/gjt/sp/jedit/syntax/Token.java |
9064e1a72c5d
Buffer.editSyntaxStyle: mask extended syntax styles;
wenzelm
parents:
43394
diff
changeset
|
14 |
--- jEdit/org/gjt/sp/jedit/syntax/Token.java 2010-05-09 14:29:24.000000000 +0200 |
9064e1a72c5d
Buffer.editSyntaxStyle: mask extended syntax styles;
wenzelm
parents:
43394
diff
changeset
|
15 |
+++ jEdit-patched/org/gjt/sp/jedit/syntax/Token.java 2011-06-18 18:28:10.000000000 +0200 |
9064e1a72c5d
Buffer.editSyntaxStyle: mask extended syntax styles;
wenzelm
parents:
43394
diff
changeset
|
16 |
@@ -57,7 +57,7 @@ |
43394 | 17 |
*/ |
18 |
public static String tokenToString(byte token) |
|
19 |
{ |
|
20 |
- return (token == Token.END) ? "END" : TOKEN_TYPES[token]; |
|
21 |
+ return (token == Token.END) ? "END" : TOKEN_TYPES[token % ID_COUNT]; |
|
22 |
} //}}} |
|
23 |
||
24 |
//{{{ Token types |
|
43446
9064e1a72c5d
Buffer.editSyntaxStyle: mask extended syntax styles;
wenzelm
parents:
43394
diff
changeset
|
25 |
diff -ru jEdit/org/gjt/sp/util/SyntaxUtilities.java jEdit-patched/org/gjt/sp/util/SyntaxUtilities.java |
9064e1a72c5d
Buffer.editSyntaxStyle: mask extended syntax styles;
wenzelm
parents:
43394
diff
changeset
|
26 |
--- jEdit/org/gjt/sp/util/SyntaxUtilities.java 2010-05-09 14:29:29.000000000 +0200 |
9064e1a72c5d
Buffer.editSyntaxStyle: mask extended syntax styles;
wenzelm
parents:
43394
diff
changeset
|
27 |
+++ jEdit-patched/org/gjt/sp/util/SyntaxUtilities.java 2011-06-18 18:28:10.000000000 +0200 |
9064e1a72c5d
Buffer.editSyntaxStyle: mask extended syntax styles;
wenzelm
parents:
43394
diff
changeset
|
28 |
@@ -26,6 +26,7 @@ |
43394 | 29 |
//{{{ Imports |
30 |
import java.awt.Color; |
|
31 |
import java.awt.Font; |
|
32 |
+import java.awt.font.TextAttribute; |
|
33 |
import java.util.Locale; |
|
34 |
import java.util.StringTokenizer; |
|
35 |
import org.gjt.sp.jedit.syntax.SyntaxStyle; |
|
43446
9064e1a72c5d
Buffer.editSyntaxStyle: mask extended syntax styles;
wenzelm
parents:
43394
diff
changeset
|
36 |
@@ -194,6 +195,17 @@ |
43394 | 37 |
} |
38 |
||
39 |
/** |
|
40 |
+ * Style with sub/superscript font attribute. |
|
41 |
+ */ |
|
42 |
+ public static SyntaxStyle scriptStyle(SyntaxStyle style, int script) |
|
43 |
+ { |
|
44 |
+ java.util.Map attributes = new java.util.HashMap(); |
|
45 |
+ attributes.put(TextAttribute.SUPERSCRIPT, new Integer(script)); |
|
46 |
+ return new SyntaxStyle(style.getForegroundColor(), style.getBackgroundColor(), |
|
47 |
+ style.getFont().deriveFont(attributes)); |
|
48 |
+ } |
|
49 |
+ |
|
50 |
+ /** |
|
51 |
* Loads the syntax styles from the properties, giving them the specified |
|
52 |
* base font family and size. |
|
53 |
* @param family The font family |
|
43446
9064e1a72c5d
Buffer.editSyntaxStyle: mask extended syntax styles;
wenzelm
parents:
43394
diff
changeset
|
54 |
@@ -203,10 +215,10 @@ |
43394 | 55 |
*/ |
56 |
public static SyntaxStyle[] loadStyles(String family, int size, boolean color) |
|
57 |
{ |
|
58 |
- SyntaxStyle[] styles = new SyntaxStyle[Token.ID_COUNT]; |
|
59 |
+ SyntaxStyle[] styles = new SyntaxStyle[3 * Token.ID_COUNT + 1]; |
|
60 |
||
61 |
// start at 1 not 0 to skip Token.NULL |
|
62 |
- for(int i = 1; i < styles.length; i++) |
|
63 |
+ for(int i = 1; i < Token.ID_COUNT; i++) |
|
64 |
{ |
|
65 |
try |
|
66 |
{ |
|
43446
9064e1a72c5d
Buffer.editSyntaxStyle: mask extended syntax styles;
wenzelm
parents:
43394
diff
changeset
|
67 |
@@ -223,6 +235,16 @@ |
43394 | 68 |
} |
69 |
} |
|
70 |
||
71 |
+ styles[0] = new SyntaxStyle(Color.black, null, new Font(family, 0, size)); |
|
72 |
+ for(int i = 0; i < Token.ID_COUNT; i++) |
|
73 |
+ { |
|
74 |
+ styles[i + Token.ID_COUNT] = scriptStyle(styles[i], -1); |
|
75 |
+ styles[i + 2 * Token.ID_COUNT] = scriptStyle(styles[i], 1); |
|
76 |
+ } |
|
77 |
+ styles[0] = null; |
|
78 |
+ styles[3 * Token.ID_COUNT] = |
|
79 |
+ new SyntaxStyle(Color.black, null, new Font(family, 0, 1)); |
|
80 |
+ |
|
81 |
return styles; |
|
82 |
} //}}} |
|
83 |