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.CopyingRangeMarker;
|
|
14
|
|
15 import dwt.dwthelper.utils;
|
|
16
|
|
17 import dwtx.jface.text.BadLocationException;
|
|
18 import dwtx.jface.text.IDocument;
|
|
19
|
|
20 /**
|
|
21 * A <code>CopyingRangeMarker</code> can be used to track positions when executing
|
|
22 * text edits. Additionally a copying range marker stores a local copy of the
|
|
23 * text it captures when it gets executed.
|
|
24 *
|
|
25 * @since 3.0
|
|
26 */
|
|
27 public final class CopyingRangeMarker : TextEdit {
|
|
28
|
|
29 private String fText;
|
|
30
|
|
31 /**
|
|
32 * Creates a new <tt>CopyRangeMarker</tt> for the given
|
|
33 * offset and length.
|
|
34 *
|
|
35 * @param offset the marker's offset
|
|
36 * @param length the marker's length
|
|
37 */
|
130
|
38 public this(int offset, int length) {
|
129
|
39 super(offset, length);
|
|
40 }
|
|
41
|
|
42 /*
|
|
43 * Copy constructor
|
|
44 */
|
130
|
45 private this(CopyingRangeMarker other) {
|
129
|
46 super(other);
|
|
47 fText= other.fText;
|
|
48 }
|
|
49
|
|
50 /*
|
|
51 * @see TextEdit#doCopy
|
|
52 */
|
|
53 protected TextEdit doCopy() {
|
|
54 return new CopyingRangeMarker(this);
|
|
55 }
|
|
56
|
|
57 /*
|
|
58 * @see TextEdit#accept0
|
|
59 */
|
|
60 protected void accept0(TextEditVisitor visitor) {
|
|
61 bool visitChildren= visitor.visit(this);
|
|
62 if (visitChildren) {
|
|
63 acceptChildren(visitor);
|
|
64 }
|
|
65 }
|
|
66
|
|
67 /*
|
|
68 * @see TextEdit#performDocumentUpdating
|
|
69 */
|
|
70 int performDocumentUpdating(IDocument document) throws BadLocationException {
|
|
71 fText= document.get(getOffset(), getLength());
|
|
72 fDelta= 0;
|
|
73 return fDelta;
|
|
74 }
|
|
75
|
|
76 /*
|
|
77 * @see TextEdit#deleteChildren
|
|
78 */
|
|
79 bool deleteChildren() {
|
|
80 return false;
|
|
81 }
|
|
82 }
|