Package org.eclipse.jface.text

Examples of org.eclipse.jface.text.ITypedRegion


    IRegion damage= null;
    try {
      int offset= e.getOffset();
      if (isDeletion)
        offset= Math.max(0, offset - 1);
      ITypedRegion partition= getPartition(e.getDocument(), offset);
      IPresentationDamager damager= getDamager(partition.getType());
      if (damager == null)
        return null;

      IRegion r= damager.getDamageRegion(partition, e, fDocumentPartitioningChanged);
View Full Code Here


      length= e.getText().length();
      if (length > 0)
        -- length;
    }

    ITypedRegion partition= getPartition(d, e.getOffset() + length);
    int endOffset= partition.getOffset() + partition.getLength();
    if (endOffset == e.getOffset())
      return -1;

    int end= fRememberedPosition == null ? -1 : fRememberedPosition.getOffset() + fRememberedPosition.getLength();
    if (endOffset < end && end < d.getLength())
      partition= getPartition(d, end);

    IPresentationDamager damager= getDamager(partition.getType());
    if (damager == null)
      return -1;

    IRegion r= damager.getDamageRegion(partition, e, fDocumentPartitioningChanged);
View Full Code Here

     *
     * @param pos an offset within this document
     * @return true if the offset is within this document's partition
     */
    public boolean inPartition(int pos) {
      final ITypedRegion partition= getPartition(pos);
      return partition != null && partition.getType().equals(fPartition);
    }
View Full Code Here

     * @param pos an offset within the document
     * @param searchForward the direction of the search
     * @return the next position to query
     */
    public int getNextPosition(int pos, boolean searchForward) {
      final ITypedRegion partition= getPartition(pos);
      if (partition == null || fPartition.equals(partition.getType()))
        return simpleIncrement(pos, searchForward);
      if (searchForward) {
        int end= partition.getOffset() + partition.getLength();
        if (pos < end)
          return end;
      } else {
        int offset= partition.getOffset();
        if (pos > offset)
          return offset - 1;
      }
      return simpleIncrement(pos, searchForward);
    }
View Full Code Here

      fDocumentChanging= true;
      if (fCachedRedrawState) {
        try {
          int offset= e.getOffset() + e.getLength();
          ITypedRegion region= getPartition(e.getDocument(), offset);
          fRememberedPosition= new TypedPosition(region);
          e.getDocument().addPosition(fPositionCategory, fRememberedPosition);
        } catch (BadLocationException x) {
          // can not happen
        } catch (BadPositionCategoryException x) {
View Full Code Here

   (non-Javadoc)
   * @see org.eclipse.jface.text.IDocumentPartitioner#getPartition(int)
   */
  public ITypedRegion getPartition(int offset) {
    for (int i = 0; i < partitions.size(); i++) {
      ITypedRegion partition = (ITypedRegion) partitions.get(i);
      int start = partition.getOffset();
      int end = start + partition.getLength();
      if (offset >= start && offset < end) {
        return partition;
      }
    }
   
View Full Code Here

            try
            {
                LdifParser parser = new LdifParser();
                IDocument document = viewer.getDocument();
                ITypedRegion partition = document.getPartition( cursorPos );

                // now use position relative to partition
                int offset = partition.getOffset();
                int relativePos = cursorPos - offset;

                // parse partition
                String s = document.get( partition.getOffset(), partition.getLength() );
                LdifFile model = parser.parse( s );
                LdifContainer container = LdifFile.getContainer( model, relativePos );
                if ( container != null )
                {
                    LdifPart part = LdifFile.getContainerContent( container, relativePos );
View Full Code Here

                public void documentAboutToBeChanged(DocumentEvent event) {
                    //only report when we have a new line
                    if (event.fText.indexOf('\r') != -1 || event.fText.indexOf('\n') != -1) {
                        try {
                            ITypedRegion partition = event.fDocument.getPartition(event.fOffset);
                            if (partition instanceof IOConsolePartition) {
                                IOConsolePartition p = (IOConsolePartition) partition;

                                //we only communicate about inputs (because we only care about what the user writes)
                                if (p.getType().equals(IOConsolePartition.INPUT_PARTITION_TYPE)) {
                                    if (event.fText.length() <= 2) {
                                        //the user typed something
                                        final String inputFound = p.getString();
                                        for (IConsoleInputListener listener : participants) {
                                            listener.newLineReceived(inputFound, target);
                                        }
                                    }

                                }
                            }
                        } catch (Exception e) {
                            Log.log(e);
                        }
                    }

                }

                public void documentChanged(DocumentEvent event) {
                    //only report when we have a new line
                    if (event.fText.indexOf('\r') != -1 || event.fText.indexOf('\n') != -1) {
                        try {
                            ITypedRegion partition = event.fDocument.getPartition(event.fOffset);
                            if (partition instanceof IOConsolePartition) {
                                IOConsolePartition p = (IOConsolePartition) partition;

                                //we only communicate about inputs (because we only care about what the user writes)
                                if (p.getType().equals(IOConsolePartition.INPUT_PARTITION_TYPE)) {
View Full Code Here

        int[] segments = new int[size * 2 + 1];

        int j = 0;
        for (int i = 0; i < size; i++) {
            // ITypedRegion segment= (ITypedRegion) segmentation.get(i);
            ITypedRegion segment = linePartitioning[i];

            if (i == 0)
                segments[j++] = 0;

            int offset = segment.getOffset() - lineOffset;
            if (offset > segments[j - 1])
                segments[j++] = offset;

            if (offset + segment.getLength() >= line.getLength())
                break;

            segments[j++] = offset + segment.getLength();
        }

        if (j < segments.length) {
            int[] result = new int[j];
            System.arraycopy(segments, 0, result, 0, j);
View Full Code Here

            default:
                return;
            }

            ITypedRegion partition =
                    TextUtilities.getPartition(document, IJavaPartitions.JAVA_PARTITIONING, offset, true);
            if (!IDocument.DEFAULT_CONTENT_TYPE.equals(partition.getType()))
                return;

            if (!editor.validateEditorInputState())
                return;
View Full Code Here

TOP

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

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.