Exemplo n.º 1
0
 void pairDraw(GC gc, StyledRegion sr, int start, int end) {
   if (start > text.getCharCount() || end > text.getCharCount()) return;
   if (gc != null) {
     Point left = text.getLocationAtOffset(start);
     Point right = text.getLocationAtOffset(end);
     if (sr != null) {
       if (highlightStyle == HLS_XOR) {
         int resultColor = sr.fore ^ cm.getColor(text.getBackground());
         if (text.getLineAtOffset(text.getCaretOffset()) == text.getLineAtOffset(start)
             && horzCross
             && horzCrossColor != null
             && ((StyledRegion) horzCrossColor).bback)
           resultColor = sr.fore ^ ((StyledRegion) horzCrossColor).back;
         Color color = cm.getColor(sr.bfore, resultColor);
         gc.setBackground(color);
         gc.setXORMode(true);
         gc.fillRectangle(left.x, left.y, right.x - left.x, gc.getFontMetrics().getHeight());
       } else if (highlightStyle == HLS_OUTLINE) {
         Color color = cm.getColor(sr.bfore, sr.fore);
         gc.setForeground(color);
         gc.drawRectangle(
             left.x, left.y, right.x - left.x - 1, gc.getFontMetrics().getHeight() - 1);
       } else if (highlightStyle == HLS_OUTLINE2) {
         Color color = cm.getColor(sr.bfore, sr.fore);
         gc.setForeground(color);
         gc.setLineWidth(2);
         gc.drawRectangle(
             left.x + 1, left.y + 1, right.x - left.x - 2, gc.getFontMetrics().getHeight() - 2);
       }
     }
   } else {
     text.redrawRange(start, end - start, true);
   }
 }
Exemplo n.º 2
0
 /**
  * Changes style/coloring scheme into the specified.
  *
  * @param name Name of color scheme (HRD name).
  * @param useBackground If true, native HRD background properties would be assigned to colored
  *     StyledText.
  */
 public void setRegionMapper(String name, boolean useBackground) {
   baseEditor.setRegionMapper("rgb", name);
   StyledRegion sr = (StyledRegion) baseEditor.getBackground();
   text.setForeground(null);
   text.setBackground(null);
   if (useBackground) {
     text.setForeground(cm.getColor(sr.bfore, sr.fore));
     text.setBackground(cm.getColor(sr.bback, sr.back));
   }
   ;
   /*
   if ((sr.style & StyledRegion.BOLD) != 0){
     Font cf = text.getFont();
     FontData fdata[] = cf.getFontData();
     fdata[0].setStyle(SWT.BOLD);
     text.setFont(new Font(text.getDisplay(), fdata));
     System.out.println("font!");
   };
   */
   setCross(vertCross, horzCross);
 };