Esempio n. 1
0
  private void initRSTA(String syntaxstyle) {

    rsTextArea.setCodeFoldingEnabled(true);
    rsTextArea.setAntiAliasingEnabled(true);
    // rsTextArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
    rsTextArea.setSyntaxEditingStyle(syntaxstyle);

    rTextScrollPane1.setFoldIndicatorEnabled(true);
    rTextScrollPane1.setLineNumbersEnabled(true);

    // Create a toolbar with searching options.
    nextButton.setActionCommand("FindNext");
    nextButton.addActionListener(this);
    searchField.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            nextButton.doClick(0);
          }
        });
    prevButton.setActionCommand("FindPrev");
    prevButton.addActionListener(this);

    try {
      //           Theme theme =
      // Theme.load(getClass().getResourceAsStream("/jeplus/gui/themes/eclipse.xml"));
      Theme theme = Theme.load(new FileInputStream("RSyntaxTheme.xml"));
      theme.apply(rsTextArea);
    } catch (IOException ioe) { // Never happens
      logger.error("Failed to apply theme from RSyntaxTheme.xml. Default is used.", ioe);
    }
    setFont(rsTextArea, rsTextArea.getFont().deriveFont(13f));
  }
Esempio n. 2
0
 private void loadTheme(String themeName, RSyntaxTextArea source) {
   if (themesCache.containsKey(themeName)) {
     Theme theme = themesCache.get(themeName);
     if (theme != null) {
       theme.apply(source);
     }
   } else {
     try {
       Theme theme =
           Theme.load(SourceViewer.class.getResourceAsStream("themes/" + themeName + ".xml"));
       theme.apply(source);
       themesCache.put(themeName, theme);
     } catch (IOException e) {
       e.printStackTrace();
       themesCache.put(themeName, null);
     }
   }
 }
Esempio n. 3
0
  private void setTheme(String name) throws IOException {
    FileInputStream defaultXmlInputStream = null;
    try {
      defaultXmlInputStream =
          new FileInputStream(
              new File(BaseNoGui.getContentFile("lib"), "theme/syntax/" + name + ".xml"));
      Theme theme = Theme.load(defaultXmlInputStream);
      theme.apply(this);
    } finally {
      IOUtils.closeQuietly(defaultXmlInputStream);
    }

    setBackground(processing.app.Theme.getColor("editor.bgcolor"));
    setHighlightCurrentLine(processing.app.Theme.getBoolean("editor.linehighlight"));
    setCurrentLineHighlightColor(processing.app.Theme.getColor("editor.linehighlight.color"));
    setCaretColor(processing.app.Theme.getColor("editor.caret.color"));
    setSelectedTextColor(null);
    setUseSelectedTextColor(false);
    setSelectionColor(processing.app.Theme.getColor("editor.selection.color"));
    setMatchedBracketBorderColor(processing.app.Theme.getColor("editor.brackethighlight.color"));
    setHyperlinkForeground(
        (Color) processing.app.Theme.getStyledFont("url", getFont()).get("color"));

    setSyntaxTheme(TokenTypes.DATA_TYPE, "data_type");
    setSyntaxTheme(TokenTypes.FUNCTION, "function");
    setSyntaxTheme(TokenTypes.RESERVED_WORD, "reserved_word");
    setSyntaxTheme(TokenTypes.RESERVED_WORD_2, "reserved_word_2");
    setSyntaxTheme(TokenTypes.VARIABLE, "variable");
    setSyntaxTheme(TokenTypes.OPERATOR, "operator");
    setSyntaxTheme(TokenTypes.COMMENT_DOCUMENTATION, "comment1");
    setSyntaxTheme(TokenTypes.COMMENT_EOL, "comment1");
    setSyntaxTheme(TokenTypes.COMMENT_KEYWORD, "comment1");
    setSyntaxTheme(TokenTypes.COMMENT_MARKUP, "comment1");
    setSyntaxTheme(TokenTypes.COMMENT_MULTILINE, "comment2");
    setSyntaxTheme(TokenTypes.LITERAL_BOOLEAN, "literal_boolean");
    setSyntaxTheme(TokenTypes.LITERAL_CHAR, "literal_char");
    setSyntaxTheme(TokenTypes.LITERAL_STRING_DOUBLE_QUOTE, "literal_string_double_quote");
    setSyntaxTheme(TokenTypes.PREPROCESSOR, "preprocessor");

    Style style = getSyntaxScheme().getStyle(TokenTypes.IDENTIFIER);
    style.foreground = processing.app.Theme.getColor("editor.fgcolor");
    getSyntaxScheme().setStyle(TokenTypes.IDENTIFIER, style);
  }