private MarkupIterator(
     @NotNull CharSequence charSequence,
     @NotNull RangeIterator rangeIterator,
     @NotNull EditorColorsScheme colorsScheme) {
   myRangeIterator = rangeIterator;
   mySegmentIterator =
       new SegmentIterator(
           charSequence, colorsScheme.getEditorFontName(), colorsScheme.getEditorFontSize());
 }
 Context(
     @NotNull CharSequence charSequence,
     @NotNull EditorColorsScheme scheme,
     int indentSymbolsToStrip) {
   myText = charSequence;
   myDefaultForeground = scheme.getDefaultForeground();
   myDefaultBackground = scheme.getDefaultBackground();
   builder =
       new SyntaxInfo.Builder(
           myDefaultForeground, myDefaultBackground, scheme.getEditorFontSize());
   myIndentSymbolsToStrip = indentSymbolsToStrip;
 }
Пример #3
0
  private void setupStyle() {
    Document document = myHTMLViewer.getDocument();
    if (!(document instanceof StyledDocument)) {
      return;
    }

    StyledDocument styledDocument = (StyledDocument) document;

    EditorColorsManager colorsManager = EditorColorsManager.getInstance();
    EditorColorsScheme scheme = colorsManager.getGlobalScheme();

    Style style = styledDocument.addStyle("active", null);
    StyleConstants.setFontFamily(style, scheme.getEditorFontName());
    StyleConstants.setFontSize(style, scheme.getEditorFontSize());
    styledDocument.setCharacterAttributes(0, document.getLength(), style, false);
  }
 @Override
 public Component getListCellRendererComponent(
     JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
   if (value == ChooseByNameBase.NON_PREFIX_SEPARATOR) {
     Object previousElement = index > 0 ? list.getModel().getElementAt(index - 1) : null;
     return ChooseByNameBase.renderNonPrefixSeparatorComponent(
         getBackgroundColor(previousElement));
   } else {
     Component component =
         super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
     EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
     Font editorFont =
         new Font(scheme.getEditorFontName(), Font.PLAIN, scheme.getEditorFontSize());
     setFont(editorFont);
     return component;
   }
 }
  @Nullable
  private String createHtmlWithCodeHighlighting(
      @NotNull final String content, @NotNull StudyToolWindowConfigurator configurator) {
    String template = null;
    InputStream stream = getClass().getResourceAsStream("/code-mirror/template.html");
    try {
      template = StreamUtil.readText(stream, "utf-8");
    } catch (IOException e) {
      LOG.warn(e.getMessage());
    } finally {
      try {
        stream.close();
      } catch (IOException e) {
        LOG.warn(e.getMessage());
      }
    }

    if (template == null) {
      LOG.warn("Code mirror template is null");
      return null;
    }

    final EditorColorsScheme editorColorsScheme =
        EditorColorsManager.getInstance().getGlobalScheme();
    int fontSize = editorColorsScheme.getEditorFontSize();

    template = template.replace("${font_size}", String.valueOf(fontSize - 2));
    template =
        template.replace(
            "${highlight_mode}", getClass().getResource("/code-mirror/clike.js").toExternalForm());
    template =
        template.replace(
            "${codemirror}", getClass().getResource("/code-mirror/codemirror.js").toExternalForm());
    template =
        template.replace(
            "${python}", getClass().getResource("/code-mirror/python.js").toExternalForm());
    template =
        template.replace(
            "${runmode}", getClass().getResource("/code-mirror/runmode.js").toExternalForm());
    template =
        template.replace(
            "${colorize}", getClass().getResource("/code-mirror/colorize.js").toExternalForm());
    template =
        template.replace(
            "${javascript}", getClass().getResource("/code-mirror/javascript.js").toExternalForm());
    if (LafManager.getInstance().getCurrentLookAndFeel() instanceof DarculaLookAndFeelInfo) {
      template =
          template.replace(
              "${css_oldcodemirror}",
              getClass().getResource("/code-mirror/codemirror-old-darcula.css").toExternalForm());
      template =
          template.replace(
              "${css_codemirror}",
              getClass().getResource("/code-mirror/codemirror-darcula.css").toExternalForm());
    } else {
      template =
          template.replace(
              "${css_oldcodemirror}",
              getClass().getResource("/code-mirror/codemirror-old.css").toExternalForm());
      template =
          template.replace(
              "${css_codemirror}",
              getClass().getResource("/code-mirror/codemirror.css").toExternalForm());
    }
    template = template.replace("${default-mode}", configurator.getDefaultHighlightingMode());
    template = template.replace("${code}", content);

    return template;
  }
 public CellRenderer(String name) {
   myName = name;
   EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
   FONT = new Font(scheme.getEditorFontName(), Font.PLAIN, scheme.getEditorFontSize());
   setOpaque(true);
 }