Mercurial > projects > dwt-win
annotate dwt/custom/StyledTextContent.d @ 212:ab60f3309436
reverted the char[] to String and use the an alias.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 05 May 2008 00:12:38 +0200 |
parents | a5afe31f5cdd |
children | fd9c62a2998e |
rev | line source |
---|---|
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
155
diff
changeset
|
1 /******************************************************************************* |
155 | 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 dwt.custom.StyledTextContent; | |
14 | |
15 import dwt.custom.TextChangeListener; | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
155
diff
changeset
|
16 import dwt.dwthelper.utils; |
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
155
diff
changeset
|
17 |
155 | 18 /** |
19 * Clients may implement the StyledTextContent interface to provide a | |
20 * custom store for the StyledText widget content. The StyledText widget | |
21 * interacts with its StyledTextContent in order to access and update | |
22 * the text that is being displayed and edited in the widget. | |
23 * A custom content implementation can be set in the widget using the | |
24 * StyledText.setContent API. | |
25 */ | |
26 public interface StyledTextContent { | |
27 | |
28 /** | |
29 * Called by StyledText to add itself as an Observer to content changes. | |
30 * See TextChangeListener for a description of the listener methods that | |
31 * are called when text changes occur. | |
32 * <p> | |
33 * | |
34 * @param listener the listener | |
35 * @exception IllegalArgumentException <ul> | |
36 * <li>ERROR_NULL_ARGUMENT when listener is null</li> | |
37 * </ul> | |
38 */ | |
39 public void addTextChangeListener(TextChangeListener listener); | |
40 | |
41 /** | |
42 * Return the number of characters in the content. | |
43 * <p> | |
44 * | |
45 * @return the number of characters in the content. | |
46 */ | |
47 public int getCharCount(); | |
48 | |
49 /** | |
50 * Return the line at the given line index without delimiters. | |
51 * <p> | |
52 * | |
53 * @param lineIndex index of the line to return. Does not include | |
54 * delimiters of preceding lines. Index 0 is the first line of the | |
55 * content. | |
56 * @return the line text without delimiters | |
57 */ | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
155
diff
changeset
|
58 public String getLine(int lineIndex); |
155 | 59 |
60 /** | |
61 * Return the line index at the given character offset. | |
62 * <p> | |
63 * | |
64 * @param offset offset of the line to return. The first character of the | |
65 * document is at offset 0. An offset of getLength() is valid and should | |
66 * answer the number of lines. | |
67 * @return the line index. The first line is at index 0. If the character | |
68 * at offset is a delimiter character, answer the line index of the line | |
69 * that is delimited. | |
70 * For example, if text = "\r\n\r\n", and delimiter = "\r\n", then: | |
71 * <ul> | |
72 * <li>getLineAtOffset(0) is 0 | |
73 * <li>getLineAtOffset(1) is 0 | |
74 * <li>getLineAtOffset(2) is 1 | |
75 * <li>getLineAtOffset(3) is 1 | |
76 * <li>getLineAtOffset(4) is 2 | |
77 * </ul> | |
78 */ | |
79 public int getLineAtOffset(int offset); | |
80 | |
81 /** | |
82 * Return the number of lines. Should answer 1 when no text is specified. | |
83 * The StyledText widget relies on this behavior for drawing the cursor. | |
84 * <p> | |
85 * | |
86 * @return the number of lines. For example: | |
87 * <ul> | |
88 * <li> text value is> getLineCount | |
89 * <li> null is> 1 | |
90 * <li> "" is> 1 | |
91 * <li> "a\n" is> 2 | |
92 * <li> "\n\n" is> 3 | |
93 * </ul> | |
94 */ | |
95 public int getLineCount(); | |
96 | |
97 /** | |
98 * Return the line delimiter that should be used by the StyledText | |
99 * widget when inserting new lines. New lines entered using key strokes | |
100 * and paste operations use this line delimiter. | |
101 * Implementors may use System.getProperty("line.separator") to return | |
102 * the platform line delimiter. | |
103 * <p> | |
104 * | |
105 * @return the line delimiter that should be used by the StyledText widget | |
106 * when inserting new lines. | |
107 */ | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
155
diff
changeset
|
108 public String getLineDelimiter(); |
155 | 109 |
110 /** | |
111 * Return the character offset of the first character of the given line. | |
112 * <p> | |
113 * <b>NOTE:</b> When there is no text (i.e., no lines), getOffsetAtLine(0) | |
114 * is a valid call that should return 0. | |
115 * </p> | |
116 * | |
117 * @param lineIndex index of the line. The first line is at index 0. | |
118 * @return offset offset of the first character of the line. The first | |
119 * character of the document is at offset 0. The return value should | |
120 * include line delimiters. | |
121 * For example, if text = "\r\ntest\r\n" and delimiter = "\r\n", then: | |
122 * <ul> | |
123 * <li>getOffsetAtLine(0) is 0 | |
124 * <li>getOffsetAtLine(1) is 2 | |
125 * <li>getOffsetAtLine(2) is 8 | |
126 * </ul> | |
127 */ | |
128 public int getOffsetAtLine(int lineIndex); | |
129 | |
130 /** | |
131 * Returns a string representing the content at the given range. | |
132 * <p> | |
133 * | |
134 * @param start the start offset of the text to return. Offset 0 is the | |
135 * first character of the document. | |
136 * @param length the length of the text to return | |
137 * @return the text at the given range | |
138 */ | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
155
diff
changeset
|
139 public String getTextRange(int start, int length); |
155 | 140 |
141 /** | |
142 * Remove the specified text changed listener. | |
143 * <p> | |
144 * | |
145 * @param listener the listener | |
146 * @exception IllegalArgumentException <ul> | |
147 * <li>ERROR_NULL_ARGUMENT when listener is null</li> | |
148 * </ul> | |
149 */ | |
150 public void removeTextChangeListener(TextChangeListener listener); | |
151 | |
152 /** | |
153 * Replace the text with "newText" starting at position "start" | |
154 * for a length of "replaceLength". | |
155 * <p> | |
156 * Implementors have to notify the TextChangeListeners that were added | |
157 * using <code>addTextChangeListener</code> before and after the content | |
158 * is changed. A <code>TextChangingEvent</code> has to be sent to the | |
159 * textChanging method before the content is changed and a | |
160 * <code>TextChangedEvent</code> has to be sent to the textChanged method | |
161 * after the content has changed. | |
162 * The text change that occurs after the <code>TextChangingEvent</code> | |
163 * has been sent has to be consistent with the data provided in the | |
164 * <code>TextChangingEvent</code>. | |
165 * This data will be cached by the widget and will be used when the | |
166 * <code>TextChangedEvent</code> is received. | |
167 * <p> | |
168 * The <code>TextChangingEvent</code> should be set as follows: | |
169 * <ul> | |
170 * <li>event.start = start of the replaced text | |
171 * <li>event.newText = text that is going to be inserted or empty String | |
172 * if no text will be inserted | |
173 * <li>event.replaceCharCount = length of text that is going to be replaced | |
174 * <li>event.newCharCount = length of text that is going to be inserted | |
175 * <li>event.replaceLineCount = number of lines that are going to be replaced | |
176 * <li>event.newLineCount = number of new lines that are going to be inserted | |
177 * </ul> | |
178 * <b>NOTE:</b> newLineCount is the number of inserted lines and replaceLineCount | |
179 * is the number of deleted lines based on the change that occurs visually. | |
180 * For example: | |
181 * <ul> | |
182 * <li>(replaceText, newText) is> (replaceLineCount, newLineCount) | |
183 * <li>("", "\n") is> (0, 1) | |
184 * <li>("\n\n", "a") is> (2, 0) | |
185 * <li>("a", "\n\n") is> (0, 2) | |
186 * <li>("\n", "") is> (1, 0) | |
187 * </ul> | |
188 * </p> | |
189 * | |
190 * @param start start offset of text to replace, none of the offsets include | |
191 * delimiters of preceding lines, offset 0 is the first character of the | |
192 * document | |
193 * @param replaceLength length of text to replace | |
194 * @param text text to replace | |
195 * @see TextChangeListener | |
196 */ | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
155
diff
changeset
|
197 public void replaceTextRange(int start, int replaceLength, String text); |
155 | 198 |
199 /** | |
200 * Set text to "text". | |
201 * Implementors have to send a <code>TextChangedEvent</code> to the | |
202 * textSet method of the TextChangeListeners that were added using | |
203 * <code>addTextChangeListener</code>. | |
204 * <p> | |
205 * | |
206 * @param text the new text | |
207 * @see TextChangeListener | |
208 */ | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
155
diff
changeset
|
209 public void setText(String text); |
155 | 210 } |