本文整理匯總了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);
}
示例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);
}
}
示例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);
}
示例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));
}
}