當前位置: 首頁>>代碼示例>>Java>>正文


Java SimpleTextAttributes.STYLE_SEARCH_MATCH屬性代碼示例

本文整理匯總了Java中com.intellij.ui.SimpleTextAttributes.STYLE_SEARCH_MATCH屬性的典型用法代碼示例。如果您正苦於以下問題:Java SimpleTextAttributes.STYLE_SEARCH_MATCH屬性的具體用法?Java SimpleTextAttributes.STYLE_SEARCH_MATCH怎麽用?Java SimpleTextAttributes.STYLE_SEARCH_MATCH使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在com.intellij.ui.SimpleTextAttributes的用法示例。


在下文中一共展示了SimpleTextAttributes.STYLE_SEARCH_MATCH屬性的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: appendFragmentsForSpeedSearch

public static void appendFragmentsForSpeedSearch(@NotNull JComponent speedSearchEnabledComponent,
                                                 @NotNull String text,
                                                 @NotNull SimpleTextAttributes attributes,
                                                 boolean selected,
                                                 @NotNull SimpleColoredComponent simpleColoredComponent) {
  final SpeedSearchSupply speedSearch = SpeedSearchSupply.getSupply(speedSearchEnabledComponent);
  if (speedSearch != null) {
    final Iterable<TextRange> fragments = speedSearch.matchingFragments(text);
    if (fragments != null) {
      final Color fg = attributes.getFgColor();
      final Color bg = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground();
      final int style = attributes.getStyle();
      final SimpleTextAttributes plain = new SimpleTextAttributes(style, fg);
      final SimpleTextAttributes highlighted = new SimpleTextAttributes(bg, fg, null, style | SimpleTextAttributes.STYLE_SEARCH_MATCH);
      appendColoredFragments(simpleColoredComponent, text, fragments, plain, highlighted);
      return;
    }
  }
  simpleColoredComponent.append(text, attributes);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:20,代碼來源:SpeedSearchUtil.java

示例2: appendColoredFragmentForMatcher

public static void appendColoredFragmentForMatcher(@NotNull String text,
                                                   SimpleColoredComponent component,
                                                   @NotNull final SimpleTextAttributes attributes,
                                                   Matcher matcher,
                                                   Color selectedBg,
                                                   boolean selected) {
  if (!(matcher instanceof MinusculeMatcher) || (Registry.is("ide.highlight.match.in.selected.only") && !selected)) {
    component.append(text, attributes);
    return;
  }

  final Iterable<TextRange> iterable = ((MinusculeMatcher)matcher).matchingFragments(text);
  if (iterable != null) {
    final Color fg = attributes.getFgColor();
    final int style = attributes.getStyle();
    final SimpleTextAttributes plain = new SimpleTextAttributes(style, fg);
    final SimpleTextAttributes highlighted = new SimpleTextAttributes(selectedBg, fg, null, style | SimpleTextAttributes.STYLE_SEARCH_MATCH);
    appendColoredFragments(component, text, iterable, plain, highlighted);
  }
  else {
    component.append(text, attributes);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:23,代碼來源:SpeedSearchUtil.java

示例3: InspectionListCellRenderer

public InspectionListCellRenderer() {
  mySelected = new SimpleTextAttributes(UIUtil.getListSelectionBackground(),
                                        UIUtil.getListSelectionForeground(),
                                        JBColor.RED,
                                        SimpleTextAttributes.STYLE_PLAIN);
  myPlain = new SimpleTextAttributes(UIUtil.getListBackground(),
                                     UIUtil.getListForeground(),
                                     JBColor.RED,
                                     SimpleTextAttributes.STYLE_PLAIN);
  myHighlighted = new SimpleTextAttributes(UIUtil.getListBackground(),
                                           UIUtil.getListForeground(),
                                           null,
                                           SimpleTextAttributes.STYLE_SEARCH_MATCH);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:14,代碼來源:InspectionListCellRenderer.java

示例4: applySpeedSearchHighlighting

public static void applySpeedSearchHighlighting(@NotNull JComponent speedSearchEnabledComponent,
                                                @NotNull SimpleColoredComponent coloredComponent,
                                                boolean mainTextOnly,
                                                boolean selected) {
  SpeedSearchSupply speedSearch = SpeedSearchSupply.getSupply(speedSearchEnabledComponent);
  // The bad thing is that SpeedSearch model is decoupled from UI presentation so we don't know the real matched text.
  // Our best guess is to get strgin from the ColoredComponent. We can only provide main-text-only option.
  Iterable<TextRange> ranges = speedSearch == null ? null : speedSearch.matchingFragments(coloredComponent.getCharSequence(mainTextOnly).toString());
  Iterator<TextRange> rangesIterator = ranges != null ? ranges.iterator() : null;
  if (rangesIterator == null || !rangesIterator.hasNext()) return;
  Color bg = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground();

  SimpleColoredComponent.ColoredIterator coloredIterator = coloredComponent.iterator();
  TextRange range = rangesIterator.next();
  main: while (coloredIterator.hasNext()) {
    coloredIterator.next();
    int offset = coloredIterator.getOffset();
    int endOffset = coloredIterator.getEndOffset();
    if (!range.intersectsStrict(offset, endOffset)) continue;
    SimpleTextAttributes attributes = coloredIterator.getTextAttributes();
    SimpleTextAttributes highlighted = new SimpleTextAttributes(bg, attributes.getFgColor(), null, attributes.getStyle() | SimpleTextAttributes.STYLE_SEARCH_MATCH);
    if (range.getStartOffset() > offset) {
      offset = coloredIterator.split(range.getStartOffset() - offset, attributes);
    }
    do {
      if (range.getEndOffset() <= endOffset) {
        offset = coloredIterator.split(range.getEndOffset() - offset, highlighted);
        if (rangesIterator.hasNext()) {
          range = rangesIterator.next();
        }
        else {
          break main;
        }
      }
      else {
        coloredIterator.split(endOffset - offset, highlighted);
        continue main;
      }
    }
    while (range.intersectsStrict(offset, endOffset));
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:42,代碼來源:SpeedSearchUtil.java


注:本文中的com.intellij.ui.SimpleTextAttributes.STYLE_SEARCH_MATCH屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。