classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] FYI: Implemented GapContent.replace()


From: Roman Kennke
Subject: [cp-patches] FYI: Implemented GapContent.replace()
Date: Fri, 22 Jul 2005 09:20:47 +0200
User-agent: Mozilla Thunderbird 1.0.2 (X11/20050317)

Yesterday I forgot to send this message. I implemented the replace() method in javax.swing.text.GapContent.

2005-07-21  Roman Kennke  <address@hidden>

        * javax/swing/text/GapContent.java
        (replace): New method. Replaces a chunk of the buffer with
        another chunk.

/Roman
Index: javax/swing/text/GapContent.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/text/GapContent.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- javax/swing/text/GapContent.java    2 Jul 2005 20:32:51 -0000       1.12
+++ javax/swing/text/GapContent.java    21 Jul 2005 15:05:45 -0000      1.13
@@ -353,4 +353,28 @@
   {
     return buffer;
   }
+
+  /**
+   * Replaces a portion of the storage with the specified items.
+   *
+   * @param position the position at which to remove items
+   * @param rmSize the number of items to remove
+   * @param addItems the items to add at location
+   * @param addSize the number of items to add
+   */
+  protected void replace(int position, int rmSize, Object addItems,
+                         int addSize)
+  {
+    // Remove content
+    shiftGap(position);
+    gapEnd += rmSize;
+
+    // If gap is too small, enlarge the gap.
+    if ((gapEnd - gapStart) < addSize)
+      shiftEnd(addSize);
+
+    // Add new items to the buffer.
+    System.arraycopy(addItems, 0, buffer, gapStart, addSize);
+    gapStart += addSize;
+  }
 }

reply via email to

[Prev in Thread] Current Thread [Next in Thread]