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;
14 * Describes a run of similar typing changes.
16 * XXX to be extended with further information, e.g. offset, length, and content
22 public final class TypingRun {
24 * A change of type <code>DELETE</code> deletes one single character
25 * (through delete or backspace or empty paste).
27 public static final ChangeType DELETE = new ChangeType(true, "DELETE"); //$NON-NLS-1$
30 * A change of type <code>INSERT</code> inserts one single character
33 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,
39 "NO_CHANGE"); //$NON-NLS-1$
42 * A change of type <code>OVERTYPE</code> replaces one single character
43 * (overwrite mode, pasting a single character).
45 public static final ChangeType OVERTYPE = new ChangeType(true, "OVERTYPE"); //$NON-NLS-1$
48 * A change of type <code>SELECTION</code> does not change text, but
49 * changes the focus, or selection. Such a change ends all typing runs.
51 public static final ChangeType SELECTION = new ChangeType(false,
52 "SELECTION"); //$NON-NLS-1$
55 * A change of type <code>UNKNOWN</code> modifies text in an unspecified
56 * way. An example is pasting more than one character, or deleting an entire
57 * selection, or reverting a file. Such a change ends all typing runs and
58 * cannot form a typing run with any other change, including a change of
59 * type <code>UNKNOWN</code>.
61 public static final ChangeType UNKNOWN = new ChangeType(true, "UNKNOWN"); //$NON-NLS-1$
64 * Enumeration of change types.
68 public static final class ChangeType {
69 private final boolean fIsModification;
71 private final String fName;
73 /** Private ctor for type safe enumeration. */
74 private ChangeType(boolean isRunPart, String name) {
75 fIsModification = isRunPart;
80 * Returns <code>true</code> if changes of this type modify text.
82 * @return <code>true</code> if changes of this type modify text,
83 * <code>false</code> otherwise
85 boolean isModification() {
86 return fIsModification;
90 * @see java.lang.Object#toString()
92 public String toString() {
101 * the type of the run
103 TypingRun(ChangeType type) {
107 /** The change type of this run. */
108 public final ChangeType type;