Package org.eclipse.swt.custom

Examples of org.eclipse.swt.custom.StyledTextContent


   * @param gc the GC
   * @param startOffset inclusive start index
   * @param endOffset exclusive end index
   */
  private void drawCharRange(GC gc, int startOffset, int endOffset) {
    StyledTextContent content= fTextWidget.getContent();
    int length= endOffset - startOffset;
    String text= content.getTextRange(startOffset, length);
    StyleRange styleRange= null;
    Color fg= null;
    StringBuffer visibleChar= new StringBuffer(10);
    for (int textOffset= 0; textOffset <= length; ++textOffset) {
      int delta= 0;
      boolean eol= false;
      if (textOffset < length) {
        delta= 1;
        char c= text.charAt(textOffset);
        switch (c) {
        //case ' ' :
        //  visibleChar.append(SPACE_SIGN);
          // 'continue' would improve performance but may produce drawing errors
          // for long runs of space if width of space and dot differ
        //  break;
        case '\u3000' : // ideographic whitespace
          visibleChar.append(IDEOGRAPHIC_SPACE_SIGN);
          // 'continue' would improve performance but may produce drawing errors
          // for long runs of space if width of space and dot differ
          break;
        case '\t' :
          visibleChar.append(TAB_SIGN);
          break;
        case '\r' :
          visibleChar.append(CARRIAGE_RETURN_SIGN);
          if (textOffset >= length - 1 || text.charAt(textOffset + 1) != '\n') {
            eol= true;
            break;
          }
          continue;
        case '\n' :
          visibleChar.append(LINE_FEED_SIGN);
          eol= true;
          break;
        default :
          delta= 0;
          break;
        }
      }
      if (visibleChar.length() > 0) {
        int widgetOffset= startOffset + textOffset - visibleChar.length() + delta;
        if (!eol || !isFoldedLine(content.getLineAtOffset(widgetOffset))) {
          /*
           * Block selection is drawn using alpha and no selection-inverting
           * takes place, we always draw as 'unselected' in block selection mode.
           */
          if (!fTextWidget.getBlockSelection() && isOffsetSelected(fTextWidget, widgetOffset)) {
View Full Code Here


        ProjectionAnnotation projectionAnnotation= (ProjectionAnnotation) annotation;
        if (projectionAnnotation.isCollapsed()) {

          if (gc != null) {

            StyledTextContent content= textWidget.getContent();
            int line= content.getLineAtOffset(offset);
            int lineStart= content.getOffsetAtLine(line);
            String text= content.getLine(line);
            int lineLength= text == null ? 0 : text.length();
            int lineEnd= lineStart + lineLength;
            Point p= textWidget.getLocationAtOffset(lineEnd);

            Color c= gc.getForeground();
View Full Code Here

   * @param gc the GC
   * @param startOffset inclusive start index
   * @param endOffset exclusive end index
   */
  private void drawCharRange(GC gc, int startOffset, int endOffset) {
    StyledTextContent content= fTextWidget.getContent();
    int length= endOffset - startOffset;
    String text= content.getTextRange(startOffset, length);
    StyleRange styleRange= null;
    Color fg= null;
    Point selection= fTextWidget.getSelection();
    StringBuffer visibleChar= new StringBuffer(10);
    for (int textOffset= 0; textOffset <= length; ++textOffset) {
      int delta= 0;
      boolean eol= false;
      if (textOffset < length) {
        delta= 1;
        char c= text.charAt(textOffset);
        switch (c) {
        case ' ' :
          visibleChar.append(SPACE_SIGN);
          // 'continue' would improve performance but may produce drawing errors
          // for long runs of space if width of space and dot differ
          break;
        case '\u3000' : // ideographic whitespace
          visibleChar.append(IDEOGRAPHIC_SPACE_SIGN);
          // 'continue' would improve performance but may produce drawing errors
          // for long runs of space if width of space and dot differ
          break;
        case '\t' :
          visibleChar.append(TAB_SIGN);
          break;
        case '\r' :
          visibleChar.append(CARRIAGE_RETURN_SIGN);
          if (textOffset >= length - 1 || text.charAt(textOffset + 1) != '\n') {
            eol= true;
            break;
          }
          continue;
        case '\n' :
          visibleChar.append(LINE_FEED_SIGN);
          eol= true;
          break;
        default :
          delta= 0;
          break;
        }
      }
      if (visibleChar.length() > 0) {
        int widgetOffset= startOffset + textOffset - visibleChar.length() + delta;
        if (!eol || !isFoldedLine(content.getLineAtOffset(widgetOffset))) {
          if (widgetOffset >= selection.x && widgetOffset < selection.y) {
            fg= fTextWidget.getSelectionForeground();
          } else if (styleRange == null || styleRange.start + styleRange.length <= widgetOffset) {
            styleRange= fTextWidget.getStyleRangeAtOffset(widgetOffset);
            if (styleRange == null || styleRange.foreground == null) {
View Full Code Here

// return;
// }
//   
// viewer.m`getProjectionAnnotationModel();

    StyledTextContent content = textWidget.getContent();
    int line = content.getLineAtOffset(offset);
    int lineStart = content.getOffsetAtLine(line);
    String text = content.getLine(line);
    if (text == null)
      text = "";

    int lineLength = text.length();
    int lineEnd = lineStart + lineLength;
View Full Code Here

  public static void drawCollapsedHolder(Annotation annotation, GC gc, StyledText textWidget,
          int offset, int length, Color color) {

    color = new Color(gc.getDevice(), 0xA0, 0xA0, 0xA0);

    StyledTextContent content = textWidget.getContent();
    int line = content.getLineAtOffset(offset);
    int lineStart = content.getOffsetAtLine(line);
    String text = content.getLine(line);
    int lineLength = text == null ? 0 : text.length();
    int lineEnd = lineStart + lineLength - 2;
    Point p = textWidget.getLocationAtOffset(lineEnd);

    Color c = gc.getForeground();
View Full Code Here

   * @param endOffset exclusive end index of the drawing range
   * @param lineOffset inclusive start index of the line
   * @param lineEndOffset exclusive end index of the line
   */
  private void drawCharRange(GC gc, int startOffset, int endOffset, int lineOffset, int lineEndOffset) {
    StyledTextContent content= fTextWidget.getContent();
    String lineText= content.getTextRange(lineOffset, lineEndOffset - lineOffset);
    int startOffsetInLine= startOffset - lineOffset;
    int endOffsetInLine= endOffset - lineOffset;

    int textBegin= -1;
    for (int i= 0; i < lineText.length(); ++i) {
      if (!isWhitespaceCharacter(lineText.charAt(i))) {
        textBegin= i;
        break;
      }
    }
    boolean isEmptyLine= textBegin == -1;
    int textEnd= lineText.length() - 1;
    if (!isEmptyLine) {
      for (int i= lineText.length() - 1; i >= 0; --i) {
        if (!isWhitespaceCharacter(lineText.charAt(i))) {
          textEnd= i;
          break;
        }
      }
    }

    StyleRange styleRange= null;
    Color fg= null;
    StringBuffer visibleChar= new StringBuffer(10);
    for (int textOffset= startOffsetInLine; textOffset <= endOffsetInLine; ++textOffset) {
      int delta= 0;
      boolean eol= false;
      if (textOffset < endOffsetInLine) {
        delta= 1;
        char c= lineText.charAt(textOffset);
        switch (c) {
          case ' ':
            if (isEmptyLine) {
              if (fShowLeadingSpaces || fShowEnclosedSpace || fShowTrailingSpaces) {
                visibleChar.append(SPACE_SIGN);
              }
            } else if (textOffset < textBegin) {
              if (fShowLeadingSpaces) {
                visibleChar.append(SPACE_SIGN);
              }
            } else if (textOffset < textEnd) {
              if (fShowEnclosedSpace) {
                visibleChar.append(SPACE_SIGN);
              }
            } else {
              if (fShowTrailingSpaces) {
                visibleChar.append(SPACE_SIGN);
              }
            }
            // 'continue' would improve performance but may produce drawing errors
            // for long runs of space if width of space and dot differ
            break;
          case '\u3000': // ideographic whitespace
            if (isEmptyLine) {
              if (fShowLeadingIdeographicSpaces || fShowEnclosedIdeographicSpaces || fShowTrailingIdeographicSpaces) {
                visibleChar.append(IDEOGRAPHIC_SPACE_SIGN);
              }
            } else if (textOffset < textBegin) {
              if (fShowLeadingIdeographicSpaces) {
                visibleChar.append(IDEOGRAPHIC_SPACE_SIGN);
              }
            } else if (textOffset < textEnd) {
              if (fShowEnclosedIdeographicSpaces) {
                visibleChar.append(IDEOGRAPHIC_SPACE_SIGN);
              }
            } else {
              if (fShowTrailingIdeographicSpaces) {
                visibleChar.append(IDEOGRAPHIC_SPACE_SIGN);
              }
            }
            // 'continue' would improve performance but may produce drawing errors
            // for long runs of space if width of space and dot differ
            break;
          case '\t':
            if (isEmptyLine) {
              if (fShowLeadingTabs || fShowEnclosedTabs || fShowTrailingTabs) {
                visibleChar.append(TAB_SIGN);
              }
            } else if (textOffset < textBegin) {
              if (fShowLeadingTabs) {
                visibleChar.append(TAB_SIGN);
              }
            } else if (textOffset < textEnd) {
              if (fShowEnclosedTabs) {
                visibleChar.append(TAB_SIGN);
              }
            } else {
              if (fShowTrailingTabs) {
                visibleChar.append(TAB_SIGN);
              }
            }
            break;
          case '\r':
            if (fShowCarriageReturn) {
              visibleChar.append(CARRIAGE_RETURN_SIGN);
            }
            if (textOffset >= endOffsetInLine - 1 || lineText.charAt(textOffset + 1) != '\n') {
              eol= true;
              break;
            }
            continue;
          case '\n':
            if (fShowLineFeed) {
              visibleChar.append(LINE_FEED_SIGN);
            }
            eol= true;
            break;
          default:
            delta= 0;
            break;
        }
      }
      if (visibleChar.length() > 0) {
        int widgetOffset= startOffset + textOffset - startOffsetInLine - visibleChar.length() + delta;
        if (!eol || !isFoldedLine(content.getLineAtOffset(widgetOffset))) {
          /*
           * Block selection is drawn using alpha and no selection-inverting
           * takes place, we always draw as 'unselected' in block selection mode.
           */
          if (!fTextWidget.getBlockSelection() && fIsFullSelectionStyle && isOffsetSelected(fTextWidget, widgetOffset)) {
View Full Code Here

        ProjectionAnnotation projectionAnnotation= (ProjectionAnnotation) annotation;
        if (projectionAnnotation.isCollapsed()) {

          if (gc != null) {

            StyledTextContent content= textWidget.getContent();
            int line= content.getLineAtOffset(offset);
            int lineStart= content.getOffsetAtLine(line);
            String text= content.getLine(line);
            int lineLength= text == null ? 0 : text.length();
            int lineEnd= lineStart + lineLength;
            Point p= textWidget.getLocationAtOffset(lineEnd);

            Color c= gc.getForeground();
View Full Code Here

            }

            GC gc = (GC) parameters[0];
            Color styledTextForeground = (Color) parameters[1];
            Point size = (Point) parameters[2];
            StyledTextContent content = (StyledTextContent) parameters[3];
            int lineCount = (Integer) parameters[4];
            int marginCols = (Integer) parameters[5];
            Color marginColor = (Color) parameters[6];
            int spacing = (Integer) parameters[7];
            int imageHeight = (Integer) parameters[8];
View Full Code Here

            if (document != null) {
                final StyledText styledText = fTextViewer.getTextWidget();
                final Point size = fCanvas.getSize();
                if (size.x != 0 && size.y != 0) {

                    final StyledTextContent content = styledText.getContent();
                    final int lineCount = content.getLineCount();
                    IPreferenceStore preferenceStore = EditorsUI.getPreferenceStore();
                    final int marginCols = preferenceStore
                            .getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN);
                    String strColor = preferenceStore
                            .getString(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR);
View Full Code Here

        ProjectionAnnotation projectionAnnotation= (ProjectionAnnotation) annotation;
        if (projectionAnnotation.isCollapsed()) {

          if (gc != null) {

            StyledTextContent content= textWidget.getContent();
            int line= content.getLineAtOffset(offset);
            int lineStart= content.getOffsetAtLine(line);
            String text= content.getLine(line);
            int lineLength= text == null ? 0 : text.length();
            int lineEnd= lineStart + lineLength;
            Point p= textWidget.getLocationAtOffset(lineEnd);

            Color c= gc.getForeground();
View Full Code Here

TOP

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

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.