Package org.eclipse.swt.custom

Examples of org.eclipse.swt.custom.StyleRange


   
    Time time = new Time(System.currentTimeMillis());
   
    styledText.append(nickName + " [" + time + "]\n  " + message + "\n");
   
    StyleRange sr = new StyleRange(
        contentLength,
        nickName.length(),
        null,
        null,
        SWT.BOLD);
View Full Code Here


          } catch (RuntimeException e) {
            System.err.println("OH TEH NOES!");
          }
          if (stylesToModify == null || stylesToModify.length == 0)
            {
            stylesToModify = new StyleRange[] { new StyleRange(region.getOffset(),region.getLength(), null, null) };
            }
          else
            {
            Vector styles = new Vector();
            int start = region.getOffset();
            if (stylesToModify[0].start != 0)
              styles.add(new StyleRange(start,stylesToModify[0].start - start, null, null));
            for (int s = 0; s < stylesToModify.length; ++s)
              {
              styles.add(stylesToModify[s]);
              if (s + 1 < stylesToModify.length && stylesToModify[s+1].start > (stylesToModify[s].start + stylesToModify[s].length))
                {
                styles.add(new StyleRange(stylesToModify[s].start + stylesToModify[s].length, stylesToModify[s+1].start - (stylesToModify[s].start + stylesToModify[s].length), null, null));
                }
              }
            int actualLastOffset = region.getOffset() + region.getLength();
            int currentEnd = stylesToModify[stylesToModify.length - 1].start + stylesToModify[stylesToModify.length - 1].length;
            if (currentEnd < actualLastOffset)
              styles.add(new StyleRange(currentEnd, actualLastOffset - currentEnd, null, null));
            stylesToModify = new StyleRange[styles.size()];
            for (int s = 0; s < stylesToModify.length; ++s)
              stylesToModify[s] = (StyleRange)styles.get(s);
            }

          //build the color for the user
          Color bg = new Color(widget.getDisplay(), newColor);
         
          //iterate through all the styles in the set of styles retrieved from the document that cover
          //the selection range
          for (int styleNum = 0; styleNum < stylesToModify.length; ++styleNum)
            {
            StyleRange styleRange = (StyleRange)stylesToModify[styleNum].clone();
            styleRange.background = bg;
            //if the editor does not have an entry yet, give it a vector to store things in
            if (!editorToStyledText.containsKey(editor))
              {
              Vector tempVec = new Vector();
View Full Code Here

            int offset,
            int length,
            TextAttribute attr) {
        if (attr != null) {
            presentation.addStyleRange(
                    new StyleRange(
                            offset,
                            length,
                            attr.getForeground(),
                            attr.getBackground(),
                            attr.getStyle()));
View Full Code Here

   
    Time time = new Time(System.currentTimeMillis());
   
    styledText.append(nickName + " [" + time + "]\n  " + message + "\n");
   
    StyleRange sr = new StyleRange(
        contentLength,
        nickName.length(),
        null,
        null,
        SWT.BOLD);
View Full Code Here

   
    Time time = new Time(System.currentTimeMillis());
   
    styledText.append(nickName + " [" + time + "]\n  " + message + "\n");
   
    StyleRange sr = new StyleRange(
        contentLength,
        nickName.length(),
        null,
        null,
        SWT.BOLD);
View Full Code Here

      Color colorComment   = ClickPlugin.getDefault().getColorManager().get(ClickPlugin.PREF_COLOR_CMT);

        IStructuredDocument document = getDocument();

        for(Iterator ite = results.iterator(); ite.hasNext();){
            StyleRange styleRange = (StyleRange)ite.next();

            IStructuredDocumentRegion region = document.getRegionAtCharacterOffset(styleRange.start);
            String text = region.getText();
            int mStart = styleRange.start - region.getStartOffset();
            int mEnd = mStart + styleRange.length;
            for(IStructuredDocumentRegion chkRegion = region.getPrevious(); chkRegion != null; chkRegion = chkRegion.getPrevious()){
                String type = chkRegion.getType();
                if(!type.equals(DOMRegionContext.XML_CONTENT) && !type.equals(DOMRegionContext.UNDEFINED)){
                    break;
                }
                text = chkRegion.getText() + text;
                mStart += chkRegion.getLength();
                mEnd   += chkRegion.getLength();
            }

            for(IStructuredDocumentRegion chkRegion = region.getNext(); chkRegion != null; chkRegion = chkRegion.getNext()){
                String type = chkRegion.getType();
                if(!type.equals(DOMRegionContext.XML_CONTENT) && !type.equals(DOMRegionContext.UNDEFINED)){
                    break;
                }
                text = (new StringBuilder(String.valueOf(text))).append(chkRegion.getText()).toString();
            }

            Pattern p = Pattern.compile("##.*|#[a-z]+|\\$((\\{.*?\\})|([a-zA-Z0-9\\-_]*))");
            Matcher m = p.matcher(text);
            int pos = 0;
            while(m.find()) {
              Color color = m.group().startsWith("##") ? colorComment :
                          m.group().startsWith("#") ? colorDirective : colorVariable;

                if(m.start() < mStart){
                    if(m.end() < mStart){
                        continue;
                    }
                    StyleRange curr;
                    if(m.end() < mEnd){
                        curr = (StyleRange)styleRange.clone();
                        curr.start = styleRange.start;
                        curr.length = m.end() - mStart;
                        curr.foreground = color;
                        styleRanges.add(curr);
                        pos = m.end() - mStart;
                        continue;
                    }
                    curr = (StyleRange)styleRange.clone();
                    curr.foreground = color;
                    styleRanges.add(curr);
                    pos = m.end();
                    break;
                }
                if(m.start() >= mEnd){
                    break;
                }
                if(m.start() > mStart && pos == 0){
                    StyleRange prev = (StyleRange)styleRange.clone();
                    prev.start = styleRange.start;
                    prev.length = m.start() - mStart;
                    styleRanges.add(prev);
                    pos = m.end() - mStart;
                }
                if(m.end() < mEnd){
                    StyleRange curr = (StyleRange)styleRange.clone();
                    curr.start = (styleRange.start + m.start()) - mStart;
                    curr.length = m.end() - m.start();
                    curr.foreground = color;
                    styleRanges.add(curr);
                    pos = m.end() - mStart;
                } else {
                    StyleRange curr = (StyleRange)styleRange.clone();
                    curr.start = (styleRange.start + m.start()) - mStart;
                    curr.length = (styleRange.length - m.start()) + mStart;
                    curr.foreground = color;
                    styleRanges.add(curr);
                    pos = m.end() - mStart;
                }
            }
            if(pos < styleRange.length){
                StyleRange post = (StyleRange)styleRange.clone();
                post.start = styleRange.start + pos;
                post.length = styleRange.length - pos;
                styleRanges.add(post);
            }
            //styleRanges.remove(styleRange);
View Full Code Here

          int groupCount = match.groupCount();
          System.out.println("groupCount" + match.groupCount());
          for(int i=0; i<=groupCount; i++){
            System.out.println("start(" + i + "):" + match.start(i));
            System.out.println("end(" + i + "):" + match.end(i));
            StyleRange style = new StyleRange();
            style.start = match.start(i);
            style.length = match.end(i) - match.start(i);
            System.out.println("style.length:" + style.length);
            if(i==0){
              style.fontStyle = SWT.BOLD;
View Full Code Here

   *            the EmbeddedLink
   * @param offset
   *            the position in text of the link
   */
  private void addLink(final EmbeddedLink link, int offset) {
    StyleRange style = new StyleRange();
    style.start = offset;
    style.length = 1;
    link.setBackground(this.getBackground());
    link.setFont(this.getFont());
    link.pack();
View Full Code Here

    return new PaintObjectListener() {
      public void paintObject(final PaintObjectEvent event) {

        if (debug == true)
          System.out.println("paintObject");
        StyleRange style = event.style;
        int start = style.start;
        for (Integer offset : offsets) {
          if (start == offset) {
            try {
              EmbeddedLink link = offsetLinkMap.get(offset);
View Full Code Here

   * @param swtColorConst a constant for a SWT color
   * @return the created StyleRange
   */
  private StyleRange createFoundStyleRange(int start, int length,
      int swtColorConst) {
    return new StyleRange(start, length, null, Display.getDefault()
        .getSystemColor(swtColorConst));
  }
View Full Code Here

TOP

Related Classes of org.eclipse.swt.custom.StyleRange

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.