Package org.eclipse.jface.text

Examples of org.eclipse.jface.text.IRegion


   * @return the line end offset for the given offset
   * @exception BadLocationException if offset is invalid in the current document
   */
  protected int endOfLineOf(int offset) throws BadLocationException {

    IRegion info = fDocument.getLineInformationOfOffset(offset);
    if (offset <= info.getOffset() + info.getLength())
      return info.getOffset() + info.getLength();

    int line = fDocument.getLineOfOffset(offset);
    try {
      info = fDocument.getLineInformation(line + 1);
      return info.getOffset() + info.getLength();
    } catch (BadLocationException x) {
      return fDocument.getLength();
    }
  }
View Full Code Here


      DocumentEvent event,
      boolean documentPartitioningChanged) {
    if (!documentPartitioningChanged) {
      try {

        IRegion info =
          fDocument.getLineInformationOfOffset(event.getOffset());
        int start = Math.max(partition.getOffset(), info.getOffset());

        int end =
          event.getOffset()
          + (event.getText() == null
              ? event.getLength()
                  : event.getText().length());

        if (info.getOffset() <= end
            && end <= info.getOffset() + info.getLength()) {
          // optimize the case of the same line
          end = info.getOffset() + info.getLength();
        } else
          end = endOfLineOf(end);

        end =
          Math.min(
View Full Code Here

    }

    public static ErlBrowserInformationControlInput getHoverInfoForOffset(
            final int offset, final ErlangEditor editor) {
        final ITextViewer textViewer = editor.getViewer();
        final IRegion region = internalGetHoverRegion(offset, editor);
        if (region != null) {
            return internalGetHoverInfo(editor, textViewer, region);
        }
        return null;
    }
View Full Code Here

            Assert.isTrue(firstLine <= captionLine,
                    "first folded line is greater than the caption line"); //$NON-NLS-1$
            Assert.isTrue(captionLine <= lastLine,
                    "caption line is greater than the last folded line"); //$NON-NLS-1$

            IRegion preRegion;
            if (firstLine < captionLine) {
                // preRegion= new Region(offset + prefixEnd, contentStart -
                // prefixEnd);
                final int preOffset = document.getLineOffset(firstLine);
                final IRegion preEndLineInfo = document.getLineInformation(captionLine);
                final int preEnd = preEndLineInfo.getOffset();
                preRegion = new Region(preOffset, preEnd - preOffset);
            } else {
                preRegion = null;
            }

            if (captionLine < lastLine) {
                final int postOffset = document.getLineOffset(captionLine + 1);
                final IRegion postRegion = new Region(postOffset, offset + length
                        - postOffset);

                if (preRegion == null) {
                    return new IRegion[] { postRegion };
                }
View Full Code Here

            }
            if (captionLine > lastLine) {
                captionLine = lastLine;
            }

            IRegion preRegion;
            if (firstLine < captionLine) {
                final int preOffset = document.getLineOffset(firstLine);
                final IRegion preEndLineInfo = document.getLineInformation(captionLine);
                final int preEnd = preEndLineInfo.getOffset();
                preRegion = new Region(preOffset, preEnd - preOffset);
            } else {
                preRegion = null;
            }

            if (captionLine < lastLine) {
                final int postOffset = document.getLineOffset(captionLine + 1);
                final IRegion postRegion = new Region(postOffset, offset + length
                        - postOffset);

                if (preRegion == null) {
                    return new IRegion[] { postRegion };
                }
View Full Code Here

    }

    public static int getAbsoluteCursorOffset(final IDocument doc, final int line,
            final int col) {
        try {
            final IRegion offsetR = doc.getLineInformation(line);
            return offsetR.getOffset() + col;
        } catch (final Exception e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

    /**
     * In event of partial selection, used to select the full lines involved.
     */
    public void selectCompleteLine() {
        final IRegion endLine = getEndLine();
        final IRegion startLine = getStartLine();

        textSelection = new TextSelection(doc, startLine.getOffset(), endLine.getOffset()
                + endLine.getLength() - startLine.getOffset());
    }
View Full Code Here

     * @return the current column that is selected from the cursor.
     */
    public int getCursorColumn() {
        try {
            final int absoluteOffset = getAbsoluteCursorOffset();
            final IRegion region = doc.getLineInformationOfOffset(absoluteOffset);
            return absoluteOffset - region.getOffset();
        } catch (final BadLocationException e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

     *
     * @param i
     */
    public static void deleteLine(final IDocument doc, final int i) {
        try {
            final IRegion lineInformation = doc.getLineInformation(i);
            final int offset = lineInformation.getOffset();

            int length = -1;

            if (doc.getNumberOfLines() > i) {
                final int nextLineOffset = doc.getLineInformation(i + 1).getOffset();
                length = nextLineOffset - offset;
            } else {
                length = lineInformation.getLength();
            }

            if (length > -1) {
                doc.replace(offset, length, "");
            }
View Full Code Here

     *         of the line).
     * @throws BadLocationException
     */
    public String getLineContentsFromCursor() throws BadLocationException {
        final int lineOfOffset = getDoc().getLineOfOffset(getAbsoluteCursorOffset());
        final IRegion lineInformation = getDoc().getLineInformation(lineOfOffset);

        final String lineToCursor = getDoc().get(
                getAbsoluteCursorOffset(),
                lineInformation.getOffset() + lineInformation.getLength()
                        - getAbsoluteCursorOffset());
        return lineToCursor;
    }
View Full Code Here

TOP

Related Classes of org.eclipse.jface.text.IRegion

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.