Newer
Older
KisoJikkenNWP / src / main / java / istlab / KisoJikken / MyRSJTextArea.java
package istlab.KisoJikken;

import java.awt.Color;
import java.awt.Font;

import javax.swing.plaf.FontUIResource;

import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
import org.fife.ui.rsyntaxtextarea.Style;
import org.fife.ui.rsyntaxtextarea.SyntaxConstants;
import org.fife.ui.rsyntaxtextarea.SyntaxScheme;
import org.fife.ui.rsyntaxtextarea.Token;

public class MyRSJTextArea extends RSyntaxTextArea {
    public MyRSJTextArea(){
        setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
        setFont(new FontUIResource("sansserif", Font.PLAIN, 14));

        SyntaxScheme scheme = getSyntaxScheme();
        // for(Style s : scheme.getStyles()){
        //     System.out.println(s);

        // }
        Style baseStyle = new Style(Color.black);
        for(int i=0;i<39;i++) scheme.setStyle(i, baseStyle);
        Style commentStyle = new Style(new Color(0,128,0), new Color(255,255,0x66), new Font("SansSerif", Font.ITALIC, 14));
        Style commentStyle2 = new Style(new Color(0,128,0), new Color(0xcc,255,255), new Font("SansSerif", Font.ITALIC, 14));
        Style commentStyle3 = new Style(new Color(0xcc,0x00,0xcc), new Color(0xff,0xcc,0xff), new Font("SansSerif", Font.ITALIC, 14));
        int[] comlist = new int[]{Token.COMMENT_EOL, Token.COMMENT_KEYWORD, Token.COMMENT_MARKUP};
        for(int c: comlist) scheme.setStyle(c, commentStyle);
        int[] comlist2 = new int[]{Token.COMMENT_MULTILINE};
        for(int c: comlist2) scheme.setStyle(c, commentStyle2);
        int[] comlist3 = new int[]{Token.COMMENT_DOCUMENTATION};
        for(int c: comlist3) scheme.setStyle(c, commentStyle3);

        // scheme.getStyle(Token.COMMENT_EOL).background = Color.cyan;
        // scheme.getStyle(Token.COMMENT_DOCUMENTATION).background = Color.cyan.brighter();
        // scheme.getStyle(Token.COMMENT_KEYWORD).background = Color.green;
        // scheme.getStyle(Token.COMMENT_MARKUP).background = Color.gray;
        // scheme.getStyle(Token.COMMENT_MULTILINE).background = Color.yellow;

        // scheme.getStyle(Token.FUNCTION).foreground = Color.black;
        // scheme.getStyle(Token.IDENTIFIER).foreground = Color.black;
        // scheme.getStyle(Token.LITERAL_NUMBER_DECIMAL_INT).foreground = Color.black;
        // scheme.getStyle(Token.LITERAL_NUMBER_FLOAT).foreground = Color.black;
        // scheme.getStyle(Token.LITERAL_NUMBER_HEXADECIMAL).foreground = Color.black;
        // scheme.getStyle(Token.OPERATOR).foreground = Color.black;
        // scheme.getStyle(Token.VARIABLE).foreground = Color.black;
        // scheme.getStyle(Token.ANNOTATION).foreground = Color.black;
        // scheme.getStyle(Token.DATA_TYPE).foreground = Color.black;
        // scheme.getStyle(Token.ERROR_CHAR).foreground = Color.black;
        // scheme.getStyle(Token.LITERAL_CHAR).foreground = Color.black;



  
        setHighlightCurrentLine(false); // カーソル行のハイライトを消す
        setCodeFoldingEnabled(true);
  
    }
    
}