129
|
1 /*******************************************************************************
|
|
2 * Copyright (c) 2000, 2006 IBM Corporation and others.
|
|
3 * All rights reserved. This program and the accompanying materials
|
|
4 * are made available under the terms of the Eclipse Public License v1.0
|
|
5 * which accompanies this distribution, and is available at
|
|
6 * http://www.eclipse.org/legal/epl-v10.html
|
|
7 *
|
|
8 * Contributors:
|
|
9 * IBM Corporation - initial API and implementation
|
|
10 * Port to the D programming language:
|
|
11 * Frank Benoit <benoit@tionex.de>
|
|
12 *******************************************************************************/
|
|
13 module dwtx.text.edits.DeleteEdit;
|
|
14
|
|
15 import dwt.dwthelper.utils;
|
|
16
|
|
17 import dwtx.jface.text.BadLocationException;
|
|
18 import dwtx.jface.text.IDocument;
|
|
19
|
|
20 /**
|
|
21 * Text edit to delete a range in a document.
|
|
22 * <p>
|
|
23 * A delete edit is equivalent to <code>ReplaceEdit(
|
|
24 * offset, length, "")</code>.
|
|
25 *
|
|
26 * @since 3.0
|
|
27 */
|
|
28 public final class DeleteEdit : TextEdit {
|
|
29
|
|
30 /**
|
|
31 * Constructs a new delete edit.
|
|
32 *
|
|
33 * @param offset the offset of the range to replace
|
|
34 * @param length the length of the range to replace
|
|
35 */
|
130
|
36 public this(int offset, int length) {
|
129
|
37 super(offset, length);
|
|
38 }
|
|
39
|
|
40 /*
|
|
41 * Copy constructor
|
|
42 */
|
130
|
43 private this(DeleteEdit other) {
|
129
|
44 super(other);
|
|
45 }
|
|
46
|
|
47 /*
|
|
48 * @see TextEdit#doCopy
|
|
49 */
|
|
50 protected TextEdit doCopy() {
|
|
51 return new DeleteEdit(this);
|
|
52 }
|
|
53
|
|
54 /*
|
|
55 * @see TextEdit#accept0
|
|
56 */
|
|
57 protected void accept0(TextEditVisitor visitor) {
|
|
58 bool visitChildren= visitor.visit(this);
|
|
59 if (visitChildren) {
|
|
60 acceptChildren(visitor);
|
|
61 }
|
|
62 }
|
|
63
|
|
64 /*
|
|
65 * @see TextEdit#performDocumentUpdating
|
|
66 */
|
|
67 int performDocumentUpdating(IDocument document) throws BadLocationException {
|
|
68 document.replace(getOffset(), getLength(), ""); //$NON-NLS-1$
|
|
69 fDelta= -getLength();
|
|
70 return fDelta;
|
|
71 }
|
|
72
|
|
73 /*
|
|
74 * @see TextEdit#deleteChildren
|
|
75 */
|
|
76 bool deleteChildren() {
|
|
77 return true;
|
|
78 }
|
|
79 }
|