Package org.eclipse.swt.custom

Examples of org.eclipse.swt.custom.StyledText


     *            the source viewer
     * @return a region denoting the current signed selection, for a resulting RtoL
     *         selections length is < 0
     */
    protected IRegion getSignedSelection(final ISourceViewer sourceViewer) {
        final StyledText text = sourceViewer.getTextWidget();
        final Point selection = text.getSelectionRange();

        if (text.getCaretOffset() == selection.x) {
            selection.x = selection.x + selection.y;
            selection.y = -selection.y;
        }

        selection.x = widgetOffset2ModelOffset(sourceViewer, selection.x);
View Full Code Here


        final ISourceViewer sourceViewer = getSourceViewer();
        if (sourceViewer == null) {
            return null;
        }

        final StyledText styledText = sourceViewer.getTextWidget();
        if (styledText == null) {
            return null;
        }

        int caret = 0;
        if (sourceViewer instanceof ITextViewerExtension5) {
            final ITextViewerExtension5 extension = (ITextViewerExtension5) sourceViewer;
            caret = extension.widgetOffset2ModelOffset(styledText.getCaretOffset());
        } else {
            final int offset = sourceViewer.getVisibleRegion().getOffset();
            caret = offset + styledText.getCaretOffset();
        }

        final IErlElement element = getElementAt(caret, false);

        if (!(element instanceof ISourceReference)) {
View Full Code Here

            }
        }

        if (reference != null) {

            StyledText textWidget = null;

            final ISourceViewer sourceViewer = getSourceViewer();
            if (sourceViewer == null) {
                return;
            }
            textWidget = sourceViewer.getTextWidget();

            if (textWidget == null) {
                return;
            }

            try {
                ISourceRange range = null;
                range = reference.getSourceRange();

                if (range == null) {
                    return;
                }

                int offset = range.getOffset();
                int length = range.getLength();

                if (offset < 0 || length < 0) {
                    return;
                }

                setHighlightRange(offset, length, moveCursor);

                if (!moveCursor) {
                    return;
                }

                offset = -1;
                length = -1;

                if (reference instanceof IErlMember) {
                    range = ((IErlMember) reference).getNameRange();
                    if (range != null) {
                        offset = range.getOffset();
                        length = range.getLength();
                    }
                } else if (reference instanceof IErlAttribute) {
                    range = ((IErlAttribute) reference).getNameRange();
                    if (range != null) {
                        offset = range.getOffset();
                        length = range.getLength();
                    }

                } else if (reference instanceof IErlFunctionClause) {
                    range = ((IErlFunctionClause) reference).getNameRange();
                    if (range != null) {
                        offset = range.getOffset();
                        length = range.getLength();
                    }
                }
                if (offset > -1 && length > 0) {

                    try {
                        textWidget.setRedraw(false);
                        sourceViewer.revealRange(offset, length);
                        sourceViewer.setSelectedRange(offset, length);
                    } finally {
                        textWidget.setRedraw(true);
                    }

                    markInNavigationHistory();
                }
View Full Code Here

    // modified version from TextViewer
    private int computeOffsetAtLocation(final ITextViewer textViewer, final int x,
            final int y) {

        final StyledText styledText = textViewer.getTextWidget();
        final IDocument document = textViewer.getDocument();

        if (document == null) {
            return -1;
        }

        try {
            final int widgetLocation = styledText.getOffsetAtLocation(new Point(x, y));
            if (textViewer instanceof ITextViewerExtension5) {
                final ITextViewerExtension5 extension = (ITextViewerExtension5) textViewer;
                return extension.widgetOffset2ModelOffset(widgetLocation);
            }
            final IRegion visibleRegion = textViewer.getVisibleRegion();
View Full Code Here

              logger.error("This should not happen", ex);
            }
          }
        }
      });
      gameInfoText = new StyledText(chatBoxHolder, SWT.WRAP | SWT.V_SCROLL | SWT.BORDER);
      GridData gameInfoTextData = new GridData(SWT.FILL, SWT.FILL, true, true);
      gameInfoTextData.widthHint = 200;
      gameInfoTextData.heightHint = 150;
      gameInfoTextData.minimumHeight = 20;
      gameInfoTextData.minimumWidth = 100;
View Full Code Here

   * Removes the editor no that it's no longer being tracked.
   *
   * @param editor The editor.
   */
  private synchronized void deregister(JavaEditor editor) {
    final StyledText widget = editor.getViewer().getTextWidget();
    if (registeredWidgets.contains(widget)) {
      PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
        @Override
        public void run() {
          widget.removeListener(SWT.KeyDown, listener);
          widget.removeListener(SWT.MouseDown, listener);
        }
      });
      registeredWidgets.remove(widget);
    }
  }
View Full Code Here

   * already registered.
   *
   * @param editor The editor.
   */
  private synchronized void register(JavaEditor editor) {
    final StyledText widget = editor.getViewer().getTextWidget();
    if (!registeredWidgets.contains(widget)) {
      PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
        @Override
        public void run() {
          widget.addListener(SWT.KeyDown, listener);
          widget.addListener(SWT.MouseDown, listener);
        }
      });
      registeredWidgets.add(widget);
    }
  }
View Full Code Here

  private void highlight(int start, int length) {
    ISourceViewer sourceViewer = getSourceViewer();

    assert sourceViewer != null;

    StyledText text = sourceViewer.getTextWidget();

    if (mCurrentStyleRange != null) {
      // reset current style range
      StyleRange resetedStyleRange = new StyleRange(mCurrentStyleRange.start,
              mCurrentStyleRange.length, null, null);

      text.setStyleRange(resetedStyleRange);
    }

    if (length != 0) {
      mCurrentStyleRange = new StyleRange(start, length, text.getSelectionForeground(), text
              .getSelectionBackground());

      text.setStyleRange(mCurrentStyleRange);
    }
  }
View Full Code Here

    }

    public ArrayList<MateAnnotation> annotationsOnLine(int line) {
        ArrayList<MateAnnotation> result = new ArrayList<MateAnnotation>();

        StyledText text = getTextWidget();
        int startOffset = text.getOffsetAtLine(line);
        int endOffset;
        if (line == text.getLineCount() - 1)
            endOffset = text.getCharCount();
        else
            endOffset = text.getOffsetAtLine(line + 1);

        Iterator i = fAnnotationModel.getAnnotationIterator(startOffset, endOffset - startOffset, false, true);
        while (i.hasNext()) {
            MateAnnotation next = (MateAnnotation) i.next();
            result.add(next);
View Full Code Here

  class AnnotationHover implements IAnnotationHover, ITextHover {
    public String getHoverInfo(ISourceViewer sourceViewer, int lineNumber) {
      Iterator ite;
      int startOffset;
      int endOffset;
      StyledText text = getTextWidget();
      try {
        if (lineNumber < 0 || lineNumber >= text.getLineCount()) return null;
        startOffset = text.getOffsetAtLine(lineNumber);
        if (lineNumber == text.getLineCount() - 1) {
          endOffset = text.getCharCount();
        } else {
          endOffset = text.getOffsetAtLine(lineNumber + 1);
        }
        ite = fAnnotationModel.getAnnotationIterator(
          startOffset, endOffset - startOffset, false, true);
      } catch(java.lang.IllegalArgumentException e) {
        System.out.printf("warning: got java.lang.IllegalArgumentException in AnnotationHover#getHoverInfo(%d). lineCount was %d\n", lineNumber, text.getLineCount());
        return "";
      }

      ArrayList all = new ArrayList();
View Full Code Here

TOP

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

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.