/[classpath]/classpath/javax/swing/text/GapContent.java
ViewVC logotype

Diff of /classpath/javax/swing/text/GapContent.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.24 by langel, Wed Sep 7 18:07:57 2005 UTC revision 1.25 by rabbit78, Thu Sep 8 09:54:30 2005 UTC
# Line 39  exception statement from your version. * Line 39  exception statement from your version. *
39  package javax.swing.text;  package javax.swing.text;
40    
41  import java.io.Serializable;  import java.io.Serializable;
42    import java.util.ArrayList;
43  import java.util.Collections;  import java.util.Collections;
 import java.util.LinkedList;  
44  import java.util.ListIterator;  import java.util.ListIterator;
45    
46  import javax.swing.undo.UndoableEdit;  import javax.swing.undo.UndoableEdit;
# Line 59  import javax.swing.undo.UndoableEdit; Line 59  import javax.swing.undo.UndoableEdit;
59  public class GapContent  public class GapContent
60      implements AbstractDocument.Content, Serializable      implements AbstractDocument.Content, Serializable
61  {  {
   
62    /**    /**
63     * A {@link Position} implementation for <code>GapContent</code>.     * A {@link Position} implementation for <code>GapContent</code>.
64     */     */
# Line 114  public class GapContent Line 113  public class GapContent
113       */       */
114      public int getOffset()      public int getOffset()
115      {      {
116        if (mark <= gapEnd)        // Check precondition.
117          assert(mark <= gapStart || mark > gapEnd);
118    
119          if (mark <= gapStart)
120          return mark;          return mark;
121        else        else
122          return mark - (gapEnd - gapStart);          return mark - (gapEnd - gapStart);
123      }      }
124    }    }
125    
126    private static final long serialVersionUID = 8374645204155842629L;    /** The serialization UID (compatible with JDK1.5). */
127      private static final long serialVersionUID = -6226052713477823730L;
128    
129    /**    /**
130     * This is the default buffer size and the amount of bytes that a buffer is     * This is the default buffer size and the amount of bytes that a buffer is
# Line 148  public class GapContent Line 151  public class GapContent
151     * The positions generated by this GapContent. They are kept in an ordered     * The positions generated by this GapContent. They are kept in an ordered
152     * fashion, so they can be looked up easily.     * fashion, so they can be looked up easily.
153     */     */
154    LinkedList positions;    ArrayList positions;
155    
156    /**    /**
157     * Creates a new GapContent object.     * Creates a new GapContent object.
# Line 169  public class GapContent Line 172  public class GapContent
172      gapStart = 0;      gapStart = 0;
173      gapEnd = size - 1;      gapEnd = size - 1;
174      buffer[size - 1] = '\n';      buffer[size - 1] = '\n';
175      positions = new LinkedList();      positions = new ArrayList();
176    }    }
177    
178    /**    /**
# Line 415  public class GapContent Line 418  public class GapContent
418     */     */
419    protected void shiftGap(int newGapStart)    protected void shiftGap(int newGapStart)
420    {    {
421        if (newGapStart == gapStart)
422          return;
423    
424      int newGapEnd = newGapStart + (gapEnd - gapStart);      int newGapEnd = newGapStart + (gapEnd - gapStart);
425    
426      // Update the positions between newGapEnd and (old) gapEnd. The marks      // Update the positions between newGapEnd and (old) gapEnd. The marks
# Line 437  public class GapContent Line 443  public class GapContent
443            }            }
444        }        }
445    
446      if (newGapStart == gapStart)      if (newGapStart < gapStart)
       return;  
     else if (newGapStart < gapStart)  
447        {        {
448          System.arraycopy(buffer, newGapStart, buffer, newGapEnd, gapStart          System.arraycopy(buffer, newGapStart, buffer, newGapEnd, gapStart
449                           - newGapStart);                           - newGapStart);

Legend:
Removed from v.1.24  
changed lines
  Added in v.1.25

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26