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.IFindReplaceTarget;
|
|
14
|
|
15 import dwt.dwthelper.utils;
|
|
16
|
|
17
|
|
18 import dwt.graphics.Point;
|
|
19
|
|
20
|
|
21 /**
|
|
22 * Defines the target for finding and replacing strings.
|
|
23 * <p>
|
|
24 * The two main methods are <code>findAndSelect</code> and
|
|
25 * <code>replaceSelection</code>. The target does not provide any way to
|
|
26 * modify the content other than replacing the selection.
|
|
27 * <p>
|
|
28 *
|
|
29 * In order to provide backward compatibility for clients of
|
|
30 * <code>IFindReplaceTarget</code>, extension interfaces are used as a means
|
|
31 * of evolution. The following extension interfaces exist:
|
|
32 * <ul>
|
|
33 * <li>{@link dwtx.jface.text.IFindReplaceTargetExtension} since version
|
|
34 * 2.0 introducing the notion of find/replace session and of a find/replace
|
|
35 * scope. In additions, in allows clients to replace all occurrences of a given
|
|
36 * find query.</li>
|
|
37 * <li>{@link dwtx.jface.text.IFindReplaceTargetExtension3} since
|
|
38 * version 3.0 allowing clients to specify search queries as regular
|
|
39 * expressions.</li>
|
|
40 * </ul>
|
|
41 * <p>
|
|
42 * Clients of a <code>IFindReplaceTarget</code> that also implements the
|
|
43 * <code>IFindReplaceTargetExtension</code> have to indicate the start of a find/replace
|
|
44 * session before using the target and to indicate the end of the session when the
|
|
45 * target is no longer used.
|
|
46 *
|
|
47 * @see dwtx.jface.text.IFindReplaceTargetExtension
|
|
48 * @see dwtx.jface.text.IFindReplaceTargetExtension3
|
|
49 */
|
|
50 public interface IFindReplaceTarget {
|
|
51
|
|
52 /**
|
|
53 * Returns whether a find operation can be performed.
|
|
54 *
|
|
55 * @return whether a find operation can be performed
|
|
56 */
|
|
57 bool canPerformFind();
|
|
58
|
|
59 /**
|
|
60 * Searches for a string starting at the given widget offset and using the specified search
|
|
61 * directives. If a string has been found it is selected and its start offset is
|
|
62 * returned.
|
|
63 * <p>
|
|
64 * Replaced by {@link IFindReplaceTargetExtension3#findAndSelect(int, String, bool, bool, bool, bool)}.
|
|
65 *
|
|
66 * @param widgetOffset the widget offset at which searching starts
|
|
67 * @param findString the string which should be found
|
|
68 * @param searchForward <code>true</code> searches forward, <code>false</code> backwards
|
|
69 * @param caseSensitive <code>true</code> performs a case sensitive search, <code>false</code> an insensitive search
|
|
70 * @param wholeWord if <code>true</code> only occurrences are reported in which the findString stands as a word by itself
|
|
71 * @return the position of the specified string, or -1 if the string has not been found
|
|
72 */
|
|
73 int findAndSelect(int widgetOffset, String findString, bool searchForward, bool caseSensitive, bool wholeWord);
|
|
74
|
|
75 /**
|
|
76 * Returns the currently selected range of characters as a offset and length in widget coordinates.
|
|
77 *
|
|
78 * @return the currently selected character range in widget coordinates
|
|
79 */
|
|
80 Point getSelection();
|
|
81
|
|
82 /**
|
|
83 * Returns the currently selected characters as a string.
|
|
84 *
|
|
85 * @return the currently selected characters
|
|
86 */
|
|
87 String getSelectionText();
|
|
88
|
|
89 /**
|
|
90 * Returns whether this target can be modified.
|
|
91 *
|
|
92 * @return <code>true</code> if target can be modified
|
|
93 */
|
|
94 bool isEditable();
|
|
95
|
|
96 /**
|
|
97 * Replaces the currently selected range of characters with the given text.
|
|
98 * This target must be editable. Otherwise nothing happens.
|
|
99 * <p>
|
|
100 * Replaced by {@link IFindReplaceTargetExtension3#replaceSelection(String, bool)}.
|
|
101 *
|
|
102 * @param text the substitution text
|
|
103 */
|
|
104 void replaceSelection(String text);
|
|
105 }
|