1 Clazz.declarePackage ("javax.swing.text");
2 c$ = Clazz.decorateAsClass (function () {
6 Clazz.instantialize (this, arguments);
7 }, javax.swing.text, "GapVector");
8 Clazz.makeConstructor (c$,
12 Clazz.makeConstructor (c$,
13 function (initialLength) {
14 this.array = this.allocateArray (initialLength);
16 this.g1 = initialLength;
18 Clazz.defineMethod (c$, "getArray",
22 Clazz.defineMethod (c$, "getGapStart",
26 Clazz.defineMethod (c$, "getGapEnd",
30 Clazz.defineMethod (c$, "replace",
31 function (position, rmSize, addItems, addSize) {
34 this.close (position, rmSize);
36 } else if (rmSize > addSize) {
37 this.close (position + addSize, rmSize - addSize);
39 var endSize = addSize - rmSize;
40 var end = this.open (position + rmSize, endSize);
41 System.arraycopy (addItems, rmSize, this.array, end, endSize);
43 }System.arraycopy (addItems, addOffset, this.array, position, addSize);
45 Clazz.defineMethod (c$, "close",
46 function (position, nItems) {
47 if (nItems == 0) return;
48 var end = position + nItems;
49 var new_gs = (this.g1 - this.g0) + nItems;
53 }this.shiftGapStartDown (this.g0 - nItems);
54 } else if (position >= this.g0) {
55 if (this.g0 != position) {
56 this.shiftGap (position);
57 }this.shiftGapEndUp (this.g0 + new_gs);
59 this.shiftGapStartDown (position);
60 this.shiftGapEndUp (this.g0 + new_gs);
62 Clazz.defineMethod (c$, "open",
63 function (position, nItems) {
64 var gapSize = this.g1 - this.g0;
66 if (position > this.g0) position += gapSize;
68 }this.shiftGap (position);
69 if (nItems >= gapSize) {
70 this.shiftEnd (this.getArrayLength () - gapSize + nItems);
71 gapSize = this.g1 - this.g0;
72 }this.g0 = this.g0 + nItems;
75 Clazz.defineMethod (c$, "resize",
77 var narray = this.allocateArray (nsize);
78 System.arraycopy (this.array, 0, narray, 0, Math.min (nsize, this.getArrayLength ()));
81 Clazz.defineMethod (c$, "shiftEnd",
83 var oldSize = this.getArrayLength ();
84 var oldGapEnd = this.g1;
85 var upperSize = oldSize - oldGapEnd;
86 var arrayLength = this.getNewArraySize (newSize);
87 var newGapEnd = arrayLength - upperSize;
88 this.resize (arrayLength);
91 System.arraycopy (this.array, oldGapEnd, this.array, newGapEnd, upperSize);
93 Clazz.defineMethod (c$, "getNewArraySize",
95 return (reqSize + 1) * 2;
97 Clazz.defineMethod (c$, "shiftGap",
98 function (newGapStart) {
99 if (newGapStart == this.g0) {
101 }var oldGapStart = this.g0;
102 var dg = newGapStart - oldGapStart;
103 var oldGapEnd = this.g1;
104 var newGapEnd = oldGapEnd + dg;
105 var gapSize = oldGapEnd - oldGapStart;
106 this.g0 = newGapStart;
109 System.arraycopy (this.array, oldGapEnd, this.array, oldGapStart, dg);
111 System.arraycopy (this.array, newGapStart, this.array, newGapEnd, -dg);
113 Clazz.defineMethod (c$, "shiftGapStartDown",
114 function (newGapStart) {
115 this.g0 = newGapStart;
117 Clazz.defineMethod (c$, "shiftGapEndUp",
118 function (newGapEnd) {