src/Tools/jEdit/patches/scriptstyles
changeset 43394 47e60a27a496
parent 43390 7ee98a3802af
child 43446 9064e1a72c5d
equal deleted inserted replaced
43393:f4141da52e92 43394:47e60a27a496
     1 diff -r jEdit/org/gjt/sp/jedit/syntax/Token.java jEdit-patched/org/gjt/sp/jedit/syntax/Token.java
     1 diff -ru jEdit/org/gjt/sp/jedit/syntax/Token.java jEdit-patched/org/gjt/sp/jedit/syntax/Token.java
     2 60c60
     2 --- jEdit/org/gjt/sp/jedit/syntax/Token.java	2010-05-09 14:29:24.000000000 +0200
     3 < 		return (token == Token.END) ? "END" : TOKEN_TYPES[token];
     3 +++ jEdit-patched/org/gjt/sp/jedit/syntax/Token.java	2011-06-15 13:48:42.000000000 +0200
     4 ---
     4 @@ -57,7 +57,7 @@
     5 > 		return (token == Token.END) ? "END" : TOKEN_TYPES[(token >= ID_COUNT) ? 0 : token];
     5  	 */
     6 diff -r jEdit/org/gjt/sp/util/SyntaxUtilities.java jEdit-patched/org/gjt/sp/util/SyntaxUtilities.java
     6  	public static String tokenToString(byte token)
     7 196a197,207
     7  	{
     8 > 	 * Style with sub/superscript font attribute.
     8 -		return (token == Token.END) ? "END" : TOKEN_TYPES[token];
     9 > 	 */
     9 +		return (token == Token.END) ? "END" : TOKEN_TYPES[token % ID_COUNT];
    10 > 	public static SyntaxStyle scriptStyle(String family, int size, int script)
    10  	} //}}}
    11 > 	{
    11  
    12 > 		Font font = new Font(family, 0, size);
    12  	//{{{ Token types
    13 > 		java.util.Map attributes = new java.util.HashMap();
    13 diff -ru jEdit/org/gjt/sp/util/SyntaxUtilities.java jEdit-patched/org/gjt/sp/util/SyntaxUtilities.java
    14 > 		attributes.put(java.awt.font.TextAttribute.SUPERSCRIPT, new Integer(script));
    14 --- jEdit/org/gjt/sp/util/SyntaxUtilities.java	2010-05-09 14:29:29.000000000 +0200
    15 > 		return new SyntaxStyle(Color.black, null, font.deriveFont(attributes));
    15 +++ jEdit-patched/org/gjt/sp/util/SyntaxUtilities.java	2011-06-15 14:11:30.000000000 +0200
    16 > 	}
    16 @@ -26,6 +26,7 @@
    17 > 	
    17  //{{{ Imports
    18 > 	/**
    18  import java.awt.Color;
    19 206c217
    19  import java.awt.Font;
    20 < 		SyntaxStyle[] styles = new SyntaxStyle[Token.ID_COUNT];
    20 +import java.awt.font.TextAttribute;
    21 ---
    21  import java.util.Locale;
    22 > 		SyntaxStyle[] styles = new SyntaxStyle[Token.ID_COUNT + 2];
    22  import java.util.StringTokenizer;
    23 209c220
    23  import org.gjt.sp.jedit.syntax.SyntaxStyle;
    24 < 		for(int i = 1; i < styles.length; i++)
    24 @@ -194,6 +195,17 @@
    25 ---
    25  	}
    26 > 		for(int i = 1; i < Token.ID_COUNT; i++)
    26  	
    27 225a237,239
    27  	/**
    28 > 		styles[Token.ID_COUNT] = scriptStyle(family, size, -1);
    28 +	 * Style with sub/superscript font attribute.
    29 > 		styles[Token.ID_COUNT + 1] = scriptStyle(family, size, 1);
    29 +	 */
    30 > 
    30 +	public static SyntaxStyle scriptStyle(SyntaxStyle style, int script)
       
    31 +	{
       
    32 +		java.util.Map attributes = new java.util.HashMap();
       
    33 +		attributes.put(TextAttribute.SUPERSCRIPT, new Integer(script));
       
    34 +		return new SyntaxStyle(style.getForegroundColor(), style.getBackgroundColor(),
       
    35 +                  style.getFont().deriveFont(attributes));
       
    36 +	}
       
    37 +	
       
    38 +	/**
       
    39  	 * Loads the syntax styles from the properties, giving them the specified
       
    40  	 * base font family and size.
       
    41  	 * @param family The font family
       
    42 @@ -203,10 +215,10 @@
       
    43  	 */
       
    44  	public static SyntaxStyle[] loadStyles(String family, int size, boolean color)
       
    45  	{
       
    46 -		SyntaxStyle[] styles = new SyntaxStyle[Token.ID_COUNT];
       
    47 +		SyntaxStyle[] styles = new SyntaxStyle[3 * Token.ID_COUNT + 1];
       
    48  
       
    49  		// start at 1 not 0 to skip Token.NULL
       
    50 -		for(int i = 1; i < styles.length; i++)
       
    51 +		for(int i = 1; i < Token.ID_COUNT; i++)
       
    52  		{
       
    53  			try
       
    54  			{
       
    55 @@ -223,6 +235,16 @@
       
    56  			}
       
    57  		}
       
    58  
       
    59 +		styles[0] = new SyntaxStyle(Color.black, null, new Font(family, 0, size));
       
    60 +		for(int i = 0; i < Token.ID_COUNT; i++)
       
    61 +		{
       
    62 +			styles[i + Token.ID_COUNT] = scriptStyle(styles[i], -1);
       
    63 +			styles[i + 2 * Token.ID_COUNT] = scriptStyle(styles[i], 1);
       
    64 +		}
       
    65 +		styles[0] = null;
       
    66 +		styles[3 * Token.ID_COUNT] =
       
    67 +			new SyntaxStyle(Color.black, null, new Font(family, 0, 1));
       
    68 +
       
    69  		return styles;
       
    70  	} //}}}
       
    71