129
|
1 /*******************************************************************************
|
|
2 * Copyright (c) 2000, 2005 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.ITextSelection;
|
|
14
|
|
15 import dwt.dwthelper.utils;
|
|
16
|
|
17
|
|
18
|
|
19 import dwtx.jface.viewers.ISelection;
|
|
20
|
|
21
|
|
22 /**
|
|
23 * This interface represents a textual selection. A text selection is a range of
|
|
24 * characters. Although a text selection is a snapshot taken at a particular
|
|
25 * point in time, it must not copy the line information and the selected text
|
|
26 * from the selection provider.
|
|
27 * <p>
|
|
28 * If, for example, the selection provider is a text viewer (
|
|
29 * {@link dwtx.jface.text.ITextViewer}), and a text selection is created
|
|
30 * for the range [5, 10], the line formation for the 5th character must not be
|
|
31 * determined and remembered at the point of creation. It can rather be
|
|
32 * determined at the point, when <code>getStartLine</code> is called. If the
|
|
33 * source viewer range [0, 15] has been changed in the meantime between the
|
|
34 * creation of the text selection object and the invocation of
|
|
35 * <code>getStartLine</code>, the returned line number may differ from the
|
|
36 * line number of the 5th character at the point of creation of the text
|
|
37 * selection object.
|
|
38 * <p>
|
|
39 * The contract of this interface is that weak in order to allow for efficient
|
|
40 * implementations.</p>
|
|
41 * <p>
|
|
42 * Clients may implement this interface or use the default implementation
|
|
43 * provided by {@link dwtx.jface.text.TextSelection}.</p>
|
|
44 *
|
|
45 * @see dwtx.jface.text.TextSelection
|
|
46 */
|
|
47 public interface ITextSelection : ISelection {
|
|
48
|
|
49 /**
|
|
50 * Returns the offset of the selected text.
|
|
51 *
|
|
52 * @return the offset of the selected text
|
|
53 */
|
|
54 int getOffset();
|
|
55
|
|
56 /**
|
|
57 * Returns the length of the selected text.
|
|
58 *
|
|
59 * @return the length of the selected text
|
|
60 */
|
|
61 int getLength();
|
|
62
|
|
63 /**
|
|
64 * Returns number of the line containing the offset of the selected text.
|
|
65 * If the underlying text has been changed between the creation of this
|
|
66 * selection object and the call of this method, the value returned might
|
|
67 * differ from what it would have been at the point of creation.
|
|
68 *
|
|
69 * @return the start line of this selection or <code>-1</code> if there is no valid line information
|
|
70 */
|
|
71 int getStartLine();
|
|
72
|
|
73 /**
|
|
74 * Returns the number of the line containing the last character of the selected text.
|
|
75 * If the underlying text has been changed between the creation of this
|
|
76 * selection object and the call of this method, the value returned might
|
|
77 * differ from what it would have been at the point of creation.
|
|
78 *
|
|
79 * @return the end line of this selection or <code>-1</code> if there is no valid line information
|
|
80 */
|
|
81 int getEndLine();
|
|
82
|
|
83 /**
|
|
84 * Returns the selected text.
|
|
85 * If the underlying text has been changed between the creation of this
|
|
86 * selection object and the call of this method, the value returned might
|
|
87 * differ from what it would have been at the point of creation.
|
|
88 *
|
|
89 * @return the selected text or <code>null</code> if there is no valid text information
|
|
90 */
|
|
91 String getText();
|
|
92 }
|
|
93
|