129
|
1 /*******************************************************************************
|
|
2 * Copyright (c) 2000, 2008 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.jface.text.projection.Segment;
|
|
14
|
131
|
15 import dwtx.jface.text.projection.ProjectionMapping; // packageimport
|
|
16 import dwtx.jface.text.projection.ChildDocumentManager; // packageimport
|
|
17 import dwtx.jface.text.projection.SegmentUpdater; // packageimport
|
|
18 import dwtx.jface.text.projection.ProjectionDocument; // packageimport
|
|
19 import dwtx.jface.text.projection.FragmentUpdater; // packageimport
|
|
20 import dwtx.jface.text.projection.ProjectionDocumentEvent; // packageimport
|
|
21 import dwtx.jface.text.projection.ChildDocument; // packageimport
|
|
22 import dwtx.jface.text.projection.IMinimalMapping; // packageimport
|
|
23 import dwtx.jface.text.projection.Fragment; // packageimport
|
|
24 import dwtx.jface.text.projection.ProjectionTextStore; // packageimport
|
|
25 import dwtx.jface.text.projection.ProjectionDocumentManager; // packageimport
|
|
26
|
|
27
|
129
|
28 import dwt.dwthelper.utils;
|
|
29
|
|
30 import dwtx.jface.text.Position;
|
|
31
|
|
32
|
|
33 /**
|
|
34 * Internal class. Do not use. Only public for testing purposes.
|
|
35 * <p>
|
|
36 * A segment is the image of a master document fragment in a projection
|
|
37 * document.
|
|
38 *
|
|
39 * @since 3.0
|
|
40 * @noinstantiate This class is not intended to be instantiated by clients.
|
|
41 * @noextend This class is not intended to be subclassed by clients.
|
|
42 */
|
|
43 public class Segment : Position {
|
|
44
|
|
45 /** The corresponding fragment for this segment. */
|
|
46 public Fragment fragment;
|
|
47 /** A flag indicating that the segment updater should stretch this segment when a change happens at its boundaries. */
|
|
48 public bool isMarkedForStretch;
|
|
49 /** A flag indicating that the segment updater should shift this segment when a change happens at its boundaries. */
|
|
50 public bool isMarkedForShift;
|
|
51
|
|
52 /**
|
|
53 * Creates a new segment covering the given range.
|
|
54 *
|
|
55 * @param offset the offset of the segment
|
|
56 * @param length the length of the segment
|
|
57 */
|
|
58 public Segment(int offset, int length) {
|
|
59 super(offset, length);
|
|
60 }
|
|
61
|
|
62 /**
|
|
63 * Sets the stretching flag.
|
|
64 */
|
|
65 public void markForStretch() {
|
|
66 isMarkedForStretch= true;
|
|
67 }
|
|
68
|
|
69 /**
|
|
70 * Returns <code>true</code> if the stretching flag is set, <code>false</code> otherwise.
|
|
71 * @return <code>true</code> if the stretching flag is set, <code>false</code> otherwise
|
|
72 */
|
|
73 public bool isMarkedForStretch() {
|
|
74 return isMarkedForStretch;
|
|
75 }
|
|
76
|
|
77 /**
|
|
78 * Sets the shifting flag.
|
|
79 */
|
|
80 public void markForShift() {
|
|
81 isMarkedForShift= true;
|
|
82 }
|
|
83
|
|
84 /**
|
|
85 * Returns <code>true</code> if the shifting flag is set, <code>false</code> otherwise.
|
|
86 * @return <code>true</code> if the shifting flag is set, <code>false</code> otherwise
|
|
87 */
|
|
88 public bool isMarkedForShift() {
|
|
89 return isMarkedForShift;
|
|
90 }
|
|
91
|
|
92 /**
|
|
93 * Clears the shifting and the stretching flag.
|
|
94 */
|
|
95 public void clearMark() {
|
|
96 isMarkedForStretch= false;
|
|
97 isMarkedForShift= false;
|
|
98 }
|
|
99 }
|