jdk/src/share/classes/javax/swing/text/StringContent.java
author xdono
Mon, 15 Dec 2008 16:55:25 -0800
changeset 1639 a97859015238
parent 1287 a04aca99c77a
child 5506 202f599c92aa
permissions -rw-r--r--
6785258: Update copyright year Summary: Update copyright for files that have been modified starting July 2008 to Dec 2008 Reviewed-by: katleman, ohair, tbell
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
1639
a97859015238 6785258: Update copyright year
xdono
parents: 1287
diff changeset
     2
 * Copyright 1997-2008 Sun Microsystems, Inc.  All Rights Reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
package javax.swing.text;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import java.util.Vector;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.io.Serializable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import javax.swing.undo.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import javax.swing.SwingUtilities;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * An implementation of the AbstractDocument.Content interface that is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * a brute force implementation that is useful for relatively small
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * documents and/or debugging.  It manages the character content
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * as a simple character array.  It is also quite inefficient.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * It is generally recommended that the gap buffer or piece table
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * implementations be used instead.  This buffer does not scale up
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * to large sizes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * <strong>Warning:</strong>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * Serialized objects of this class will not be compatible with
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * future Swing releases. The current serialization support is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * appropriate for short term storage or RMI between applications running
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * the same version of Swing.  As of 1.4, support for long term storage
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * of all JavaBeans<sup><font size="-2">TM</font></sup>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * has been added to the <code>java.beans</code> package.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * Please see {@link java.beans.XMLEncoder}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * @author  Timothy Prinzing
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
public final class StringContent implements AbstractDocument.Content, Serializable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     * Creates a new StringContent object.  Initial size defaults to 10.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    public StringContent() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
        this(10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * Creates a new StringContent object, with the initial
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * size specified.  If the length is < 1, a size of 1 is used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     * @param initialLength the initial size
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    public StringContent(int initialLength) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        if (initialLength < 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
            initialLength = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        data = new char[initialLength];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        data[0] = '\n';
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        count = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * Returns the length of the content.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * @return the length >= 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * @see AbstractDocument.Content#length
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    public int length() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        return count;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * Inserts a string into the content.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * @param where the starting position >= 0 && < length()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * @param str the non-null string to insert
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * @return an UndoableEdit object for undoing
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * @exception BadLocationException if the specified position is invalid
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * @see AbstractDocument.Content#insertString
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    public UndoableEdit insertString(int where, String str) throws BadLocationException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        if (where >= count || where < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
            throw new BadLocationException("Invalid location", count);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        char[] chars = str.toCharArray();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        replace(where, 0, chars, 0, chars.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        if (marks != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
            updateMarksForInsert(where, str.length());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        return new InsertUndo(where, str.length());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * Removes part of the content.  where + nitems must be < length().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * @param where the starting position >= 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * @param nitems the number of characters to remove >= 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * @return an UndoableEdit object for undoing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * @exception BadLocationException if the specified position is invalid
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * @see AbstractDocument.Content#remove
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    public UndoableEdit remove(int where, int nitems) throws BadLocationException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        if (where + nitems >= count) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
            throw new BadLocationException("Invalid range", count);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        String removedString = getString(where, nitems);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        UndoableEdit edit = new RemoveUndo(where, removedString);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        replace(where, nitems, empty, 0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        if (marks != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
            updateMarksForRemove(where, nitems);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        return edit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * Retrieves a portion of the content.  where + len must be <= length().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * @param where the starting position >= 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * @param len the length to retrieve >= 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * @return a string representing the content; may be empty
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * @exception BadLocationException if the specified position is invalid
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * @see AbstractDocument.Content#getString
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    public String getString(int where, int len) throws BadLocationException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        if (where + len > count) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
            throw new BadLocationException("Invalid range", count);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        return new String(data, where, len);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * Retrieves a portion of the content.  where + len must be <= length()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * @param where the starting position >= 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * @param len the number of characters to retrieve >= 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * @param chars the Segment object to return the characters in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * @exception BadLocationException if the specified position is invalid
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * @see AbstractDocument.Content#getChars
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    public void getChars(int where, int len, Segment chars) throws BadLocationException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        if (where + len > count) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
            throw new BadLocationException("Invalid location", count);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        chars.array = data;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        chars.offset = where;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        chars.count = len;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * Creates a position within the content that will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     * track change as the content is mutated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * @param offset the offset to create a position for >= 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * @return the position
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * @exception BadLocationException if the specified position is invalid
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    public Position createPosition(int offset) throws BadLocationException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        // some small documents won't have any sticky positions
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        // at all, so the buffer is created lazily.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        if (marks == null) {
1287
a04aca99c77a 6722802: Code improvement and warnings removing from the javax.swing.text package
rupashka
parents: 2
diff changeset
   177
            marks = new Vector<PosRec>();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        return new StickyPosition(offset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    // --- local methods ---------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * Replaces some of the characters in the array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * @param offset  offset into the array to start the replace
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * @param length  number of characters to remove
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * @param replArray replacement array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * @param replOffset offset into the replacement array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * @param replLength number of character to use from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     *   replacement array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    void replace(int offset, int length,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                 char[] replArray, int replOffset, int replLength) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        int delta = replLength - length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        int src = offset + length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        int nmove = count - src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        int dest = src + delta;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        if ((count + delta) >= data.length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
            // need to grow the array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
            int newLength = Math.max(2*data.length, count + delta);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
            char[] newData = new char[newLength];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
            System.arraycopy(data, 0, newData, 0, offset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
            System.arraycopy(replArray, replOffset, newData, offset, replLength);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
            System.arraycopy(data, src, newData, dest, nmove);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
            data = newData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
            // patch the existing array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
            System.arraycopy(data, src, data, dest, nmove);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
            System.arraycopy(replArray, replOffset, data, offset, replLength);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        count = count + delta;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    void resize(int ncount) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        char[] ndata = new char[ncount];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        System.arraycopy(data, 0, ndata, 0, Math.min(ncount, count));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        data = ndata;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    synchronized void updateMarksForInsert(int offset, int length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        if (offset == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
            // zero is a special case where we update only
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
            // marks after it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
            offset = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        int n = marks.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        for (int i = 0; i < n; i++) {
1287
a04aca99c77a 6722802: Code improvement and warnings removing from the javax.swing.text package
rupashka
parents: 2
diff changeset
   229
            PosRec mark = marks.elementAt(i);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
            if (mark.unused) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
                // this record is no longer used, get rid of it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
                marks.removeElementAt(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
                i -= 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
                n -= 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
            } else if (mark.offset >= offset) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
                mark.offset += length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    synchronized void updateMarksForRemove(int offset, int length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        int n = marks.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        for (int i = 0; i < n; i++) {
1287
a04aca99c77a 6722802: Code improvement and warnings removing from the javax.swing.text package
rupashka
parents: 2
diff changeset
   244
            PosRec mark = marks.elementAt(i);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
            if (mark.unused) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
                // this record is no longer used, get rid of it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
                marks.removeElementAt(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
                i -= 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
                n -= 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
            } else if (mark.offset >= (offset + length)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
                mark.offset -= length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
            } else if (mark.offset >= offset) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
                mark.offset = offset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     * Returns a Vector containing instances of UndoPosRef for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     * Positions in the range
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     * <code>offset</code> to <code>offset</code> + <code>length</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     * If <code>v</code> is not null the matching Positions are placed in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     * there. The vector with the resulting Positions are returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     * This is meant for internal usage, and is generally not of interest
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * to subclasses.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     * @param v the Vector to use, with a new one created on null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     * @param offset the starting offset >= 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     * @param length the length >= 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     * @return the set of instances
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
    protected Vector getPositionsInRange(Vector v, int offset,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
                                                      int length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        int n = marks.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        int end = offset + length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        Vector placeIn = (v == null) ? new Vector() : v;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        for (int i = 0; i < n; i++) {
1287
a04aca99c77a 6722802: Code improvement and warnings removing from the javax.swing.text package
rupashka
parents: 2
diff changeset
   279
            PosRec mark = marks.elementAt(i);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
            if (mark.unused) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
                // this record is no longer used, get rid of it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
                marks.removeElementAt(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
                i -= 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
                n -= 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
            } else if(mark.offset >= offset && mark.offset <= end)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
                placeIn.addElement(new UndoPosRef(mark));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
        return placeIn;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     * Resets the location for all the UndoPosRef instances
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     * in <code>positions</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     * This is meant for internal usage, and is generally not of interest
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     * to subclasses.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     * @param positions the positions of the instances
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
    protected void updateUndoPositions(Vector positions) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
        for(int counter = positions.size() - 1; counter >= 0; counter--) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
            UndoPosRef ref = (UndoPosRef)positions.elementAt(counter);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
            // Check if the Position is still valid.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
            if(ref.rec.unused) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
                positions.removeElementAt(counter);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
            else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
                ref.resetLocation();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
    private static final char[] empty = new char[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
    private char[] data;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
    private int count;
1287
a04aca99c77a 6722802: Code improvement and warnings removing from the javax.swing.text package
rupashka
parents: 2
diff changeset
   315
    transient Vector<PosRec> marks;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     * holds the data for a mark... separately from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     * the real mark so that the real mark can be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     * collected if there are no more references to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     * it.... the update table holds only a reference
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     * to this grungy thing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
    final class PosRec {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
        PosRec(int offset) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
            this.offset = offset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
        int offset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
        boolean unused;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     * This really wants to be a weak reference but
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
     * in 1.1 we don't have a 100% pure solution for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
     * this... so this class trys to hack a solution
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
     * to causing the marks to be collected.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
    final class StickyPosition implements Position {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
        StickyPosition(int offset) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
            rec = new PosRec(offset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
            marks.addElement(rec);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
        public int getOffset() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
            return rec.offset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
        protected void finalize() throws Throwable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
            // schedule the record to be removed later
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
            // on another thread.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
            rec.unused = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
        public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
            return Integer.toString(getOffset());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
        PosRec rec;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
     * Used to hold a reference to a Position that is being reset as the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
     * result of removing from the content.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
    final class UndoPosRef {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
        UndoPosRef(PosRec rec) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
            this.rec = rec;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
            this.undoLocation = rec.offset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
         * Resets the location of the Position to the offset when the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
         * receiver was instantiated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
        protected void resetLocation() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
            rec.offset = undoLocation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
        /** Location to reset to when resetLocatino is invoked. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
        protected int undoLocation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
        /** Position to reset offset. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
        protected PosRec rec;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
     * UnoableEdit created for inserts.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
    class InsertUndo extends AbstractUndoableEdit {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
        protected InsertUndo(int offset, int length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
            super();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
            this.offset = offset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
            this.length = length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
        public void undo() throws CannotUndoException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
            super.undo();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
                synchronized(StringContent.this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
                    // Get the Positions in the range being removed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
                    if(marks != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
                        posRefs = getPositionsInRange(null, offset, length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
                    string = getString(offset, length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
                    remove(offset, length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
            } catch (BadLocationException bl) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
              throw new CannotUndoException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
        public void redo() throws CannotRedoException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
            super.redo();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
                synchronized(StringContent.this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
                    insertString(offset, string);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
                    string = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
                    // Update the Positions that were in the range removed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
                    if(posRefs != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
                        updateUndoPositions(posRefs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
                        posRefs = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
            } catch (BadLocationException bl) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
              throw new CannotRedoException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
        // Where the string goes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
        protected int offset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
        // Length of the string.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
        protected int length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
        // The string that was inserted. To cut down on space needed this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
        // will only be valid after an undo.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
        protected String string;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
        // An array of instances of UndoPosRef for the Positions in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
        // range that was removed, valid after undo.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
        protected Vector posRefs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
     * UndoableEdit created for removes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
    class RemoveUndo extends AbstractUndoableEdit {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
        protected RemoveUndo(int offset, String string) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
            super();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
            this.offset = offset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
            this.string = string;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
            this.length = string.length();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
            if(marks != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
                posRefs = getPositionsInRange(null, offset, length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
        public void undo() throws CannotUndoException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
            super.undo();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
                synchronized(StringContent.this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
                    insertString(offset, string);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
                    // Update the Positions that were in the range removed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
                    if(posRefs != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
                        updateUndoPositions(posRefs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
                        posRefs = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
                    string = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
            } catch (BadLocationException bl) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
              throw new CannotUndoException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
        public void redo() throws CannotRedoException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
            super.redo();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
                synchronized(StringContent.this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
                    string = getString(offset, length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
                    // Get the Positions in the range being removed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
                    if(marks != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
                        posRefs = getPositionsInRange(null, offset, length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
                    remove(offset, length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
            } catch (BadLocationException bl) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
              throw new CannotRedoException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
        // Where the string goes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
        protected int offset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
        // Length of the string.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
        protected int length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
        // The string that was inserted. This will be null after an undo.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
        protected String string;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
        // An array of instances of UndoPosRef for the Positions in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
        // range that was removed, valid before undo.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
        protected Vector posRefs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
}