1 /*******************************************************************************
2 * Copyright (c) 2000, 2003 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package net.sourceforge.phpdt.internal.ui.text;
16 * Describes a run of similar typing changes.
18 * XXX to be extended with further information, e.g. offset, length, and
24 public final class TypingRun {
26 * A change of type <code>DELETE</code> deletes one single character (through delete or
27 * backspace or empty paste).
29 public static final ChangeType DELETE= new ChangeType(true, "DELETE"); //$NON-NLS-1$
31 * A change of type <code>INSERT</code> inserts one single character
34 public static final ChangeType INSERT= new ChangeType(true, "INSERT"); //$NON-NLS-1$
36 * A change of type <code>NO_CHANGE</code> does not change anything.
38 public static final ChangeType NO_CHANGE= new ChangeType(false, "NO_CHANGE"); //$NON-NLS-1$
40 * A change of type <code>OVERTYPE</code> replaces one single character
41 * (overwrite mode, pasting a single character).
43 public static final ChangeType OVERTYPE= new ChangeType(true, "OVERTYPE"); //$NON-NLS-1$
45 * A change of type <code>SELECTION</code> does not change text, but
46 * changes the focus, or selection. Such a change ends all typing runs.
48 public static final ChangeType SELECTION= new ChangeType(false, "SELECTION"); //$NON-NLS-1$
50 * A change of type <code>UNKNOWN</code> modifies text in an
51 * unspecified way. An example is pasting more than one character, or
52 * deleting an entire selection, or reverting a file. Such a change ends
53 * all typing runs and cannot form a typing run with any other change,
54 * including a change of type <code>UNKNOWN</code>.
56 public static final ChangeType UNKNOWN= new ChangeType(true, "UNKNOWN"); //$NON-NLS-1$
60 * Enumeration of change types.
64 public static final class ChangeType {
65 private final boolean fIsModification;
66 private final String fName;
68 /** Private ctor for type safe enumeration. */
69 private ChangeType(boolean isRunPart, String name) {
70 fIsModification= isRunPart;
75 * Returns <code>true</code> if changes of this type modify text.
77 * @return <code>true</code> if changes of this type modify text,
78 * <code>false</code> otherwise
80 boolean isModification() {
81 return fIsModification;
85 * @see java.lang.Object#toString()
87 public String toString() {
95 * @param type the type of the run
97 TypingRun(ChangeType type) {
101 /** The change type of this run. */
102 public final ChangeType type;