Esempio n. 1
0
 private StyleRange createRange(Match match, boolean selection) {
   Display display = composite.getDisplay();
   Color fgColor, bgColor;
   if (selection) {
     // Lighten to avoid search selection on system selection
     fgColor = ColorManager.lighten(display.getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT), 50);
     bgColor = ColorManager.getInstance().getSelectedBackgroundColor();
   } else {
     // To avoid white text on light-green background
     fgColor = display.getSystemColor(SWT.COLOR_BLACK);
     bgColor = ColorManager.getInstance().getBackgroundColor();
   }
   return new StyleRange(match.getOffset(), match.getLength(), fgColor, bgColor);
 }
Esempio n. 2
0
  public static void applyStyles(
      final TextPresentation presentation, final Match[] matches, final Match selected) {

    final StyleRange[] ranges =
        createStyleRanges(
            presentation.getExtent(), matches, ColorManager.getInstance().getBackgroundColor());

    presentation.mergeStyleRanges(ranges);

    if (selected != null) {
      final StyleRange[] selectedRanges =
          createStyleRanges(
              presentation.getExtent(),
              new Match[] {selected},
              ColorManager.getInstance().getSelectedBackgroundColor());
      presentation.mergeStyleRanges(selectedRanges);
    }
  }