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.ITextViewer;
|
|
14
|
131
|
15 import dwtx.jface.text.IDocumentPartitioningListener; // packageimport
|
|
16 import dwtx.jface.text.DefaultTextHover; // packageimport
|
|
17 import dwtx.jface.text.AbstractInformationControl; // packageimport
|
|
18 import dwtx.jface.text.TextUtilities; // packageimport
|
|
19 import dwtx.jface.text.IInformationControlCreatorExtension; // packageimport
|
|
20 import dwtx.jface.text.AbstractInformationControlManager; // packageimport
|
|
21 import dwtx.jface.text.ITextViewerExtension2; // packageimport
|
|
22 import dwtx.jface.text.IDocumentPartitioner; // packageimport
|
|
23 import dwtx.jface.text.DefaultIndentLineAutoEditStrategy; // packageimport
|
|
24 import dwtx.jface.text.ITextSelection; // packageimport
|
|
25 import dwtx.jface.text.Document; // packageimport
|
|
26 import dwtx.jface.text.FindReplaceDocumentAdapterContentProposalProvider; // packageimport
|
|
27 import dwtx.jface.text.ITextListener; // packageimport
|
|
28 import dwtx.jface.text.BadPartitioningException; // packageimport
|
|
29 import dwtx.jface.text.ITextViewerExtension5; // packageimport
|
|
30 import dwtx.jface.text.IDocumentPartitionerExtension3; // packageimport
|
|
31 import dwtx.jface.text.IUndoManager; // packageimport
|
|
32 import dwtx.jface.text.ITextHoverExtension2; // packageimport
|
|
33 import dwtx.jface.text.IRepairableDocument; // packageimport
|
|
34 import dwtx.jface.text.IRewriteTarget; // packageimport
|
|
35 import dwtx.jface.text.DefaultPositionUpdater; // packageimport
|
|
36 import dwtx.jface.text.RewriteSessionEditProcessor; // packageimport
|
|
37 import dwtx.jface.text.TextViewerHoverManager; // packageimport
|
|
38 import dwtx.jface.text.DocumentRewriteSession; // packageimport
|
|
39 import dwtx.jface.text.TextViewer; // packageimport
|
|
40 import dwtx.jface.text.ITextViewerExtension8; // packageimport
|
|
41 import dwtx.jface.text.RegExMessages; // packageimport
|
|
42 import dwtx.jface.text.IDelayedInputChangeProvider; // packageimport
|
|
43 import dwtx.jface.text.ITextOperationTargetExtension; // packageimport
|
|
44 import dwtx.jface.text.IWidgetTokenOwner; // packageimport
|
|
45 import dwtx.jface.text.IViewportListener; // packageimport
|
|
46 import dwtx.jface.text.GapTextStore; // packageimport
|
|
47 import dwtx.jface.text.MarkSelection; // packageimport
|
|
48 import dwtx.jface.text.IDocumentPartitioningListenerExtension; // packageimport
|
|
49 import dwtx.jface.text.IDocumentAdapterExtension; // packageimport
|
|
50 import dwtx.jface.text.IInformationControlExtension; // packageimport
|
|
51 import dwtx.jface.text.IDocumentPartitioningListenerExtension2; // packageimport
|
|
52 import dwtx.jface.text.DefaultDocumentAdapter; // packageimport
|
|
53 import dwtx.jface.text.ITextViewerExtension3; // packageimport
|
|
54 import dwtx.jface.text.IInformationControlCreator; // packageimport
|
|
55 import dwtx.jface.text.TypedRegion; // packageimport
|
|
56 import dwtx.jface.text.ISynchronizable; // packageimport
|
|
57 import dwtx.jface.text.IMarkRegionTarget; // packageimport
|
|
58 import dwtx.jface.text.TextViewerUndoManager; // packageimport
|
|
59 import dwtx.jface.text.IRegion; // packageimport
|
|
60 import dwtx.jface.text.IInformationControlExtension2; // packageimport
|
|
61 import dwtx.jface.text.IDocumentExtension4; // packageimport
|
|
62 import dwtx.jface.text.IDocumentExtension2; // packageimport
|
|
63 import dwtx.jface.text.IDocumentPartitionerExtension2; // packageimport
|
|
64 import dwtx.jface.text.Assert; // packageimport
|
|
65 import dwtx.jface.text.DefaultInformationControl; // packageimport
|
|
66 import dwtx.jface.text.IWidgetTokenOwnerExtension; // packageimport
|
|
67 import dwtx.jface.text.DocumentClone; // packageimport
|
|
68 import dwtx.jface.text.DefaultUndoManager; // packageimport
|
|
69 import dwtx.jface.text.IFindReplaceTarget; // packageimport
|
|
70 import dwtx.jface.text.IAutoEditStrategy; // packageimport
|
|
71 import dwtx.jface.text.ILineTrackerExtension; // packageimport
|
|
72 import dwtx.jface.text.IUndoManagerExtension; // packageimport
|
|
73 import dwtx.jface.text.TextSelection; // packageimport
|
|
74 import dwtx.jface.text.DefaultAutoIndentStrategy; // packageimport
|
|
75 import dwtx.jface.text.IAutoIndentStrategy; // packageimport
|
|
76 import dwtx.jface.text.IPainter; // packageimport
|
|
77 import dwtx.jface.text.IInformationControl; // packageimport
|
|
78 import dwtx.jface.text.IInformationControlExtension3; // packageimport
|
|
79 import dwtx.jface.text.ITextViewerExtension6; // packageimport
|
|
80 import dwtx.jface.text.IInformationControlExtension4; // packageimport
|
|
81 import dwtx.jface.text.DefaultLineTracker; // packageimport
|
|
82 import dwtx.jface.text.IDocumentInformationMappingExtension; // packageimport
|
|
83 import dwtx.jface.text.IRepairableDocumentExtension; // packageimport
|
|
84 import dwtx.jface.text.ITextHover; // packageimport
|
|
85 import dwtx.jface.text.FindReplaceDocumentAdapter; // packageimport
|
|
86 import dwtx.jface.text.ILineTracker; // packageimport
|
|
87 import dwtx.jface.text.Line; // packageimport
|
|
88 import dwtx.jface.text.ITextViewerExtension; // packageimport
|
|
89 import dwtx.jface.text.IDocumentAdapter; // packageimport
|
|
90 import dwtx.jface.text.TextEvent; // packageimport
|
|
91 import dwtx.jface.text.BadLocationException; // packageimport
|
|
92 import dwtx.jface.text.AbstractDocument; // packageimport
|
|
93 import dwtx.jface.text.AbstractLineTracker; // packageimport
|
|
94 import dwtx.jface.text.TreeLineTracker; // packageimport
|
|
95 import dwtx.jface.text.ITextPresentationListener; // packageimport
|
|
96 import dwtx.jface.text.Region; // packageimport
|
|
97 import dwtx.jface.text.IDocumentInformationMapping; // packageimport
|
|
98 import dwtx.jface.text.MarginPainter; // packageimport
|
|
99 import dwtx.jface.text.IPaintPositionManager; // packageimport
|
|
100 import dwtx.jface.text.TextPresentation; // packageimport
|
|
101 import dwtx.jface.text.IFindReplaceTargetExtension; // packageimport
|
|
102 import dwtx.jface.text.ISlaveDocumentManagerExtension; // packageimport
|
|
103 import dwtx.jface.text.ISelectionValidator; // packageimport
|
|
104 import dwtx.jface.text.IDocumentExtension; // packageimport
|
|
105 import dwtx.jface.text.PropagatingFontFieldEditor; // packageimport
|
|
106 import dwtx.jface.text.ConfigurableLineTracker; // packageimport
|
|
107 import dwtx.jface.text.SlaveDocumentEvent; // packageimport
|
|
108 import dwtx.jface.text.IDocumentListener; // packageimport
|
|
109 import dwtx.jface.text.PaintManager; // packageimport
|
|
110 import dwtx.jface.text.IFindReplaceTargetExtension3; // packageimport
|
|
111 import dwtx.jface.text.ITextDoubleClickStrategy; // packageimport
|
|
112 import dwtx.jface.text.IDocumentExtension3; // packageimport
|
|
113 import dwtx.jface.text.Position; // packageimport
|
|
114 import dwtx.jface.text.TextMessages; // packageimport
|
|
115 import dwtx.jface.text.CopyOnWriteTextStore; // packageimport
|
|
116 import dwtx.jface.text.WhitespaceCharacterPainter; // packageimport
|
|
117 import dwtx.jface.text.IPositionUpdater; // packageimport
|
|
118 import dwtx.jface.text.DefaultTextDoubleClickStrategy; // packageimport
|
|
119 import dwtx.jface.text.ListLineTracker; // packageimport
|
|
120 import dwtx.jface.text.ITextInputListener; // packageimport
|
|
121 import dwtx.jface.text.BadPositionCategoryException; // packageimport
|
|
122 import dwtx.jface.text.IWidgetTokenKeeperExtension; // packageimport
|
|
123 import dwtx.jface.text.IInputChangedListener; // packageimport
|
|
124 import dwtx.jface.text.ITextOperationTarget; // packageimport
|
|
125 import dwtx.jface.text.IDocumentInformationMappingExtension2; // packageimport
|
|
126 import dwtx.jface.text.ITextViewerExtension7; // packageimport
|
|
127 import dwtx.jface.text.IInformationControlExtension5; // packageimport
|
|
128 import dwtx.jface.text.IDocumentRewriteSessionListener; // packageimport
|
|
129 import dwtx.jface.text.JFaceTextUtil; // packageimport
|
|
130 import dwtx.jface.text.AbstractReusableInformationControlCreator; // packageimport
|
|
131 import dwtx.jface.text.TabsToSpacesConverter; // packageimport
|
|
132 import dwtx.jface.text.CursorLinePainter; // packageimport
|
|
133 import dwtx.jface.text.ITextHoverExtension; // packageimport
|
|
134 import dwtx.jface.text.IEventConsumer; // packageimport
|
|
135 import dwtx.jface.text.IDocument; // packageimport
|
|
136 import dwtx.jface.text.IWidgetTokenKeeper; // packageimport
|
|
137 import dwtx.jface.text.DocumentCommand; // packageimport
|
|
138 import dwtx.jface.text.TypedPosition; // packageimport
|
|
139 import dwtx.jface.text.IEditingSupportRegistry; // packageimport
|
|
140 import dwtx.jface.text.IDocumentPartitionerExtension; // packageimport
|
|
141 import dwtx.jface.text.AbstractHoverInformationControlManager; // packageimport
|
|
142 import dwtx.jface.text.IEditingSupport; // packageimport
|
|
143 import dwtx.jface.text.IMarkSelection; // packageimport
|
|
144 import dwtx.jface.text.ISlaveDocumentManager; // packageimport
|
|
145 import dwtx.jface.text.DocumentEvent; // packageimport
|
|
146 import dwtx.jface.text.DocumentPartitioningChangedEvent; // packageimport
|
|
147 import dwtx.jface.text.ITextStore; // packageimport
|
|
148 import dwtx.jface.text.JFaceTextMessages; // packageimport
|
|
149 import dwtx.jface.text.DocumentRewriteSessionEvent; // packageimport
|
|
150 import dwtx.jface.text.SequentialRewriteTextStore; // packageimport
|
|
151 import dwtx.jface.text.DocumentRewriteSessionType; // packageimport
|
|
152 import dwtx.jface.text.TextAttribute; // packageimport
|
|
153 import dwtx.jface.text.ITextViewerExtension4; // packageimport
|
|
154 import dwtx.jface.text.ITypedRegion; // packageimport
|
|
155
|
|
156
|
129
|
157 import dwt.dwthelper.utils;
|
|
158
|
|
159
|
|
160
|
|
161 import dwt.custom.StyledText;
|
|
162 import dwt.graphics.Color;
|
|
163 import dwt.graphics.Point;
|
|
164 import dwtx.jface.viewers.ISelectionProvider;
|
|
165
|
|
166
|
|
167 /**
|
|
168 * A text viewer connects a text widget with an
|
|
169 * {@link dwtx.jface.text.IDocument}. The document is used as the
|
|
170 * widget's text model.
|
|
171 * <p>
|
|
172 * It supports the following kinds of listeners:
|
|
173 * <ul>
|
|
174 * <li>view port listeners to inform about changes of the viewer's view port</li>
|
|
175 * <li>text listeners to inform about changes of the document and the
|
|
176 * subsequent viewer change</li>
|
|
177 * <li>text input listeners to inform about changes of the viewer's input
|
|
178 * document.</li>
|
|
179 * </ul>
|
|
180 * A text viewer supports a set of configuration options and plug-ins defining
|
|
181 * its behavior:
|
|
182 * <ul>
|
|
183 * <li>undo manager</li>
|
|
184 * <li>double click behavior</li>
|
|
185 * <li>auto indentation</li>
|
|
186 * <li>text hover</li>
|
|
187 * </ul>
|
|
188 * Installed plug-ins are not automatically activated. Plug-ins must be
|
|
189 * activated with the <code>activatePlugins</code> call. Most plug-ins can be
|
|
190 * defined per content type. Content types are derived from a partitioning of
|
|
191 * the text viewer's input document. In case of documents that support multiple
|
|
192 * partitionings, the implementer is responsible for determining the
|
|
193 * partitioning to use.
|
|
194 * <p>
|
|
195 * A text viewer also provides the concept of event consumption. Events handled
|
|
196 * by the viewer can be filtered and processed by a dynamic event consumer. With
|
|
197 * {@link dwtx.jface.text.ITextViewerExtension}, this mechanism has been
|
|
198 * replaced with the support for
|
|
199 * {@link dwt.custom.VerifyKeyListener}.
|
|
200 * <p>
|
|
201 * A text viewer provides several text editing functions, some of them are
|
|
202 * configurable, through a text operation target interface. It also supports a
|
|
203 * presentation mode in which it only shows a specified section of its document.
|
|
204 * By calling <code>setVisibleRegion</code> clients define which section is
|
|
205 * visible. Clients can get access to this section by calling
|
|
206 * <code>getVisibleRegion</code>. The viewer's presentation mode does not
|
|
207 * affect any client of the viewer other than text listeners. With
|
|
208 * {@link dwtx.jface.text.ITextViewerExtension5} the visible region
|
|
209 * support has been reworked. With that extension interface, text viewers are
|
|
210 * allowed to show fractions of their input document. I.e. a widget selection of
|
|
211 * two visually neighboring characters is no longer guaranteed to be two
|
|
212 * neighboring characters in the viewer's input document. Thus, viewers
|
|
213 * implementing {@link dwtx.jface.text.ITextViewerExtension5} are
|
|
214 * potentially forced to change the fractions of the input document that are
|
|
215 * shown when clients ask for the visible region.
|
|
216 * <p>
|
|
217 *
|
|
218 * In order to provide backward compatibility for clients of
|
|
219 * <code>ITextViewer</code>, extension interfaces are used as a means of
|
|
220 * evolution. The following extension interfaces exist:
|
|
221 * <ul>
|
|
222 * <li>{@link dwtx.jface.text.ITextViewerExtension} since version 2.0
|
|
223 * replacing the event consumer mechanism and introducing the concept of rewrite
|
|
224 * targets and means to manage the viewer's redraw behavior</li>
|
|
225 * <li>{@link dwtx.jface.text.ITextViewerExtension2}since version 2.1
|
|
226 * adding a way to invalidate a viewer's presentation and setters for hovers.
|
|
227 * </li>
|
|
228 * <li>{@link dwtx.jface.text.ITextViewerExtension3} since version 2.1
|
|
229 * which itself was replaced by
|
|
230 * {@link dwtx.jface.text.ITextViewerExtension5} in version 3.0</li>
|
|
231 * <li>{@link dwtx.jface.text.ITextViewerExtension4} since version 3.0
|
|
232 * introducing focus handling for widget token keepers and the concept of text
|
|
233 * presentation listeners.</li>
|
|
234 * <li>{@link dwtx.jface.text.ITextViewerExtension5} since version 3.0
|
|
235 * extending the visible region concept with explicit handling and conversion
|
|
236 * of widget and model coordinates.</li>
|
|
237 * <li>{@link dwtx.jface.text.ITextViewerExtension6} since version 3.1
|
|
238 * extending the text viewer with the ability to detect hyperlinks and access the undo manager.</li>
|
|
239 * <li>{@link dwtx.jface.text.ITextViewerExtension7} since version 3.3
|
|
240 * extending the text viewer with the ability to install tabs to spaces conversion.</li>
|
|
241 * <li>{@link dwtx.jface.text.ITextViewerExtension8} since version 3.4
|
|
242 * extending the text viewer with the ability to print and rich hover support.</li>
|
|
243 * </ul></p>
|
|
244 * <p>
|
|
245 * Clients may implement this interface and its extension interfaces or use the
|
|
246 * standard implementation {@link dwtx.jface.text.TextViewer}.</p>
|
|
247 *
|
|
248 * @see dwtx.jface.text.ITextViewerExtension
|
|
249 * @see dwtx.jface.text.ITextViewerExtension2
|
|
250 * @see dwtx.jface.text.ITextViewerExtension3
|
|
251 * @see dwtx.jface.text.ITextViewerExtension4
|
|
252 * @see dwtx.jface.text.ITextViewerExtension5
|
|
253 * @see dwtx.jface.text.ITextViewerExtension6
|
|
254 * @see dwtx.jface.text.ITextViewerExtension7
|
|
255 * @see dwtx.jface.text.ITextViewerExtension8
|
|
256 * @see dwtx.jface.text.IDocument
|
|
257 * @see dwtx.jface.text.ITextInputListener
|
|
258 * @see dwtx.jface.text.IViewportListener
|
|
259 * @see dwtx.jface.text.ITextListener
|
|
260 * @see dwtx.jface.text.IEventConsumer
|
|
261 */
|
|
262 public interface ITextViewer {
|
|
263
|
|
264
|
|
265 /* ---------- widget --------- */
|
|
266
|
|
267 /**
|
|
268 * Returns this viewer's DWT control, <code>null</code> if the control is disposed.
|
|
269 * <p>
|
|
270 * <em>Calling API directly on the widget can interfere with features provided
|
|
271 * by a text viewer. Clients who call API directly on the widget are responsible
|
|
272 * to resolve such conflicts on their side.</em>
|
|
273 * </p>
|
|
274 *
|
|
275 * @return the DWT control or <code>null</code>
|
|
276 */
|
|
277 StyledText getTextWidget();
|
|
278
|
|
279
|
|
280 /* --------- plug-ins --------- */
|
|
281
|
|
282 /**
|
|
283 * Sets this viewer's undo manager.
|
|
284 *
|
|
285 * @param undoManager the new undo manager. <code>null</code> is a valid argument.
|
|
286 */
|
|
287 void setUndoManager(IUndoManager undoManager);
|
|
288
|
|
289 /**
|
|
290 * Sets this viewer's text double click strategy for the given content type.
|
|
291 *
|
|
292 * @param strategy the new double click strategy. <code>null</code> is a valid argument.
|
|
293 * @param contentType the type for which the strategy is registered
|
|
294 */
|
|
295 void setTextDoubleClickStrategy(ITextDoubleClickStrategy strategy, String contentType);
|
|
296
|
|
297 /**
|
|
298 * Sets this viewer's auto indent strategy for the given content type. If
|
|
299 * the given strategy is <code>null</code> any installed strategy for the
|
|
300 * content type is removed. This method has been replaced by
|
|
301 * {@link ITextViewerExtension2#prependAutoEditStrategy(IAutoEditStrategy, String)} and
|
|
302 * {@link ITextViewerExtension2#removeAutoEditStrategy(IAutoEditStrategy, String)}.
|
|
303 * It is now equivalent to
|
|
304 * <pre>
|
|
305 * ITextViewerExtension2 extension= (ITextViewerExtension2) viewer;
|
|
306 * extension.removeAutoEditStrategy(oldStrategy, contentType);
|
|
307 * extension.prependAutoEditStrategy(strategy, contentType);
|
|
308 * </pre>
|
|
309 *
|
|
310 * @param strategy the new auto indent strategy. <code>null</code> is a
|
|
311 * valid argument.
|
|
312 * @param contentType the type for which the strategy is registered
|
|
313 * @deprecated since 3.1, use
|
|
314 * {@link ITextViewerExtension2#prependAutoEditStrategy(IAutoEditStrategy, String)} and
|
|
315 * {@link ITextViewerExtension2#removeAutoEditStrategy(IAutoEditStrategy, String)} instead
|
|
316 */
|
|
317 void setAutoIndentStrategy(IAutoIndentStrategy strategy, String contentType);
|
|
318
|
|
319 /**
|
|
320 * Sets this viewer's text hover for the given content type.
|
|
321 * <p>
|
|
322 * This method has been replaced by {@link ITextViewerExtension2#setTextHover(ITextHover, String, int)}.
|
|
323 * It is now equivalent to
|
|
324 * <pre>
|
|
325 * ITextViewerExtension2 extension= (ITextViewerExtension2) document;
|
|
326 * extension.setTextHover(textViewerHover, contentType, ITextViewerExtension2#DEFAULT_HOVER_STATE_MASK);
|
|
327 * </pre>
|
|
328 *
|
|
329 *
|
|
330 * @param textViewerHover the new hover. <code>null</code> is a valid
|
|
331 * argument.
|
|
332 * @param contentType the type for which the hover is registered
|
|
333 */
|
|
334 void setTextHover(ITextHover textViewerHover, String contentType);
|
|
335
|
|
336 /**
|
|
337 * Activates the installed plug-ins. If the plug-ins are already activated
|
|
338 * this call has no effect.
|
|
339 */
|
|
340 void activatePlugins();
|
|
341
|
|
342 /**
|
|
343 * Resets the installed plug-ins. If plug-ins change their state or
|
|
344 * behavior over the course of time, this method causes them to be set
|
|
345 * back to their initial state and behavior. E.g., if an {@link IUndoManager}
|
|
346 * has been installed on this text viewer, the manager's list of remembered
|
|
347 * text editing operations is removed.
|
|
348 */
|
|
349 void resetPlugins();
|
|
350
|
|
351
|
|
352
|
|
353 /* ---------- listeners ------------- */
|
|
354
|
|
355 /**
|
|
356 * Adds the given view port listener to this viewer. The listener
|
|
357 * is informed about all changes to the visible area of this viewer.
|
|
358 * If the listener is already registered with this viewer, this call
|
|
359 * has no effect.
|
|
360 *
|
|
361 * @param listener the listener to be added
|
|
362 */
|
|
363 void addViewportListener(IViewportListener listener);
|
|
364
|
|
365 /**
|
|
366 * Removes the given listener from this viewer's set of view port listeners.
|
|
367 * If the listener is not registered with this viewer, this call has
|
|
368 * no effect.
|
|
369 *
|
|
370 * @param listener the listener to be removed
|
|
371 */
|
|
372 void removeViewportListener(IViewportListener listener);
|
|
373
|
|
374 /**
|
|
375 * Adds a text listener to this viewer. If the listener is already registered
|
|
376 * with this viewer, this call has no effect.
|
|
377 *
|
|
378 * @param listener the listener to be added
|
|
379 */
|
|
380 void addTextListener(ITextListener listener);
|
|
381
|
|
382 /**
|
|
383 * Removes the given listener from this viewer's set of text listeners.
|
|
384 * If the listener is not registered with this viewer, this call has
|
|
385 * no effect.
|
|
386 *
|
|
387 * @param listener the listener to be removed
|
|
388 */
|
|
389 void removeTextListener(ITextListener listener);
|
|
390
|
|
391 /**
|
|
392 * Adds a text input listener to this viewer. If the listener is already registered
|
|
393 * with this viewer, this call has no effect.
|
|
394 *
|
|
395 * @param listener the listener to be added
|
|
396 */
|
|
397 void addTextInputListener(ITextInputListener listener);
|
|
398
|
|
399 /**
|
|
400 * Removes the given listener from this viewer's set of text input listeners.
|
|
401 * If the listener is not registered with this viewer, this call has
|
|
402 * no effect.
|
|
403 *
|
|
404 * @param listener the listener to be removed
|
|
405 */
|
|
406 void removeTextInputListener(ITextInputListener listener);
|
|
407
|
|
408
|
|
409
|
|
410 /* -------------- model manipulation ------------- */
|
|
411
|
|
412 /**
|
|
413 * Sets the given document as the text viewer's model and updates the
|
|
414 * presentation accordingly. An appropriate <code>TextEvent</code> is
|
|
415 * issued. This text event does not carry a related document event.
|
|
416 *
|
|
417 * @param document the viewer's new input document <code>null</code> if none
|
|
418 */
|
|
419 void setDocument(IDocument document);
|
|
420
|
|
421 /**
|
|
422 * Returns the text viewer's input document.
|
|
423 *
|
|
424 * @return the viewer's input document or <code>null</code> if none
|
|
425 */
|
|
426 IDocument getDocument();
|
|
427
|
|
428
|
|
429 /* -------------- event handling ----------------- */
|
|
430
|
|
431 /**
|
|
432 * Registers an event consumer with this viewer. This method has been
|
|
433 * replaces with the {@link dwt.custom.VerifyKeyListener}
|
|
434 * management methods in {@link ITextViewerExtension}.
|
|
435 *
|
|
436 * @param consumer the viewer's event consumer. <code>null</code> is a
|
|
437 * valid argument.
|
|
438 */
|
|
439 void setEventConsumer(IEventConsumer consumer);
|
|
440
|
|
441 /**
|
|
442 * Sets the editable state.
|
|
443 *
|
|
444 * @param editable the editable state
|
|
445 */
|
|
446 void setEditable(bool editable);
|
|
447
|
|
448 /**
|
|
449 * Returns whether the shown text can be manipulated.
|
|
450 *
|
|
451 * @return the viewer's editable state
|
|
452 */
|
|
453 bool isEditable();
|
|
454
|
|
455
|
|
456 /* ----------- visible region support ------------- */
|
|
457
|
|
458 /**
|
|
459 * Sets the given document as this viewer's model and
|
|
460 * exposes the specified region. An appropriate
|
|
461 * <code>TextEvent</code> is issued. The text event does not carry a
|
|
462 * related document event. This method is a convenience method for
|
|
463 * <code>setDocument(document);setVisibleRegion(offset, length)</code>.
|
|
464 *
|
|
465 * @param document the new input document or <code>null</code> if none
|
|
466 * @param modelRangeOffset the offset of the model range
|
|
467 * @param modelRangeLength the length of the model range
|
|
468 */
|
|
469 void setDocument(IDocument document, int modelRangeOffset, int modelRangeLength);
|
|
470
|
|
471 /**
|
|
472 * Defines and sets the region of this viewer's document which will be
|
|
473 * visible in the presentation. Every character inside the specified region
|
|
474 * is supposed to be visible in the viewer's widget after that call.
|
|
475 *
|
|
476 * @param offset the offset of the visible region
|
|
477 * @param length the length of the visible region
|
|
478 */
|
|
479 void setVisibleRegion(int offset, int length);
|
|
480
|
|
481 /**
|
|
482 * Resets the region of this viewer's document which is visible in the presentation.
|
|
483 * Afterwards, the whole input document is visible.
|
|
484 */
|
|
485 void resetVisibleRegion();
|
|
486
|
|
487 /**
|
|
488 * Returns the current visible region of this viewer's document. The result
|
|
489 * may differ from the argument passed to <code>setVisibleRegion</code> if
|
|
490 * the document has been modified since then. The visible region is supposed
|
|
491 * to be a consecutive region in viewer's input document and every character
|
|
492 * inside that region is supposed to visible in the viewer's widget.
|
|
493 * <p>
|
|
494 * Viewers implementing {@link ITextViewerExtension5} may be forced to
|
|
495 * change the fractions of the input document that are shown, in order to
|
|
496 * fulfill this contract.
|
|
497 *
|
|
498 * @return this viewer's current visible region
|
|
499 */
|
|
500 IRegion getVisibleRegion();
|
|
501
|
|
502 /**
|
|
503 * Returns whether a given range overlaps with the visible region of this
|
|
504 * viewer's document.
|
|
505 * <p>
|
|
506 * Viewers implementing {@link ITextViewerExtension5}may be forced to
|
|
507 * change the fractions of the input document that are shown in order to
|
|
508 * fulfill this request. This is because the overlap is supposed to be
|
|
509 * without gaps.
|
|
510 *
|
|
511 * @param offset the offset
|
|
512 * @param length the length
|
|
513 * @return <code>true</code> if the specified range overlaps with the
|
|
514 * visible region
|
|
515 */
|
|
516 bool overlapsWithVisibleRegion(int offset, int length);
|
|
517
|
|
518
|
|
519
|
|
520 /* ------------- presentation manipulation ----------- */
|
|
521
|
|
522 /**
|
|
523 * Applies the color information encoded in the given text presentation.
|
|
524 * <code>controlRedraw</code> tells this viewer whether it should take care of
|
|
525 * redraw management or not. If, e.g., this call is one in a sequence of multiple
|
|
526 * presentation calls, it is more appropriate to explicitly control redrawing at the
|
|
527 * beginning and the end of the sequence.
|
|
528 *
|
|
529 * @param presentation the presentation to be applied to this viewer
|
|
530 * @param controlRedraw indicates whether this viewer should manage redraws
|
|
531 */
|
|
532 void changeTextPresentation(TextPresentation presentation, bool controlRedraw);
|
|
533
|
|
534 /**
|
|
535 * Marks the currently applied text presentation as invalid. It is the
|
|
536 * viewer's responsibility to take any action it can to repair the text
|
|
537 * presentation.
|
|
538 * <p>
|
|
539 * See {@link ITextViewerExtension2#invalidateTextPresentation(int, int)}
|
|
540 * for a way to invalidate specific regions rather than the presentation as
|
|
541 * a whole.
|
|
542 *
|
|
543 * @since 2.0
|
|
544 */
|
|
545 void invalidateTextPresentation();
|
|
546
|
|
547 /**
|
|
548 * Applies the given color as text foreground color to this viewer's
|
|
549 * selection.
|
|
550 *
|
|
551 * @param color the color to be applied
|
|
552 */
|
|
553 void setTextColor(Color color);
|
|
554
|
|
555 /**
|
|
556 * Applies the given color as text foreground color to the specified section
|
|
557 * of this viewer. <code>controlRedraw</code> tells this viewer whether it
|
|
558 * should take care of redraw management or not.
|
|
559 *
|
|
560 * @param color the color to be applied
|
|
561 * @param offset the offset of the range to be changed
|
|
562 * @param length the length of the range to be changed
|
|
563 * @param controlRedraw indicates whether this viewer should manage redraws
|
|
564 */
|
|
565 void setTextColor(Color color, int offset, int length, bool controlRedraw);
|
|
566
|
|
567
|
|
568 /* --------- target handling and configuration ------------ */
|
|
569
|
|
570 /**
|
|
571 * Returns the text operation target of this viewer.
|
|
572 *
|
|
573 * @return the text operation target of this viewer
|
|
574 */
|
|
575 ITextOperationTarget getTextOperationTarget();
|
|
576
|
|
577 /**
|
|
578 * Returns the find/replace operation target of this viewer.
|
|
579 *
|
|
580 * @return the find/replace operation target of this viewer
|
|
581 */
|
|
582 IFindReplaceTarget getFindReplaceTarget();
|
|
583
|
|
584 /**
|
|
585 * Sets the strings that are used as prefixes when lines of the given content type
|
|
586 * are prefixed using the prefix text operation. The prefixes are considered equivalent.
|
|
587 * Inserting a prefix always inserts the defaultPrefixes[0].
|
|
588 * Removing a prefix removes all of the specified prefixes.
|
|
589 *
|
|
590 * @param defaultPrefixes the prefixes to be used
|
|
591 * @param contentType the content type for which the prefixes are specified
|
|
592 * @since 2.0
|
|
593 */
|
|
594 void setDefaultPrefixes(String[] defaultPrefixes, String contentType);
|
|
595
|
|
596 /**
|
|
597 * Sets the strings that are used as prefixes when lines of the given content type
|
|
598 * are shifted using the shift text operation. The prefixes are considered equivalent.
|
|
599 * Thus "\t" and " " can both be used as prefix characters.
|
|
600 * Shift right always inserts the indentPrefixes[0].
|
|
601 * Shift left removes all of the specified prefixes.
|
|
602 *
|
|
603 * @param indentPrefixes the prefixes to be used
|
|
604 * @param contentType the content type for which the prefixes are specified
|
|
605 */
|
|
606 void setIndentPrefixes(String[] indentPrefixes, String contentType);
|
|
607
|
|
608
|
|
609
|
|
610 /* --------- selection handling -------------- */
|
|
611
|
|
612 /**
|
|
613 * Sets the selection to the specified range.
|
|
614 *
|
|
615 * @param offset the offset of the selection range
|
|
616 * @param length the length of the selection range. A negative length places
|
|
617 * the caret at the visual start of the selection.
|
|
618 */
|
|
619 void setSelectedRange(int offset, int length);
|
|
620
|
|
621 /**
|
|
622 * Returns the range of the current selection in coordinates of this viewer's document.
|
|
623 *
|
|
624 * @return a <code>Point</code> with x as the offset and y as the length of the current selection
|
|
625 */
|
|
626 Point getSelectedRange();
|
|
627
|
|
628 /**
|
|
629 * Returns a selection provider dedicated to this viewer. Subsequent
|
|
630 * calls to this method return always the same selection provider.
|
|
631 *
|
|
632 * @return this viewer's selection provider
|
|
633 */
|
|
634 ISelectionProvider getSelectionProvider();
|
|
635
|
|
636
|
|
637 /* ------------- appearance manipulation --------------- */
|
|
638
|
|
639 /**
|
|
640 * Ensures that the given range is visible.
|
|
641 *
|
|
642 * @param offset the offset of the range to be revealed
|
|
643 * @param length the length of the range to be revealed
|
|
644 */
|
|
645 void revealRange(int offset, int length);
|
|
646
|
|
647 /**
|
|
648 * Scrolls the widget so that the given index is the line
|
|
649 * with the smallest line number of all visible lines.
|
|
650 *
|
|
651 * @param index the line which should become the top most line
|
|
652 */
|
|
653 void setTopIndex(int index);
|
|
654
|
|
655 /**
|
|
656 * Returns the visible line with the smallest line number.
|
|
657 *
|
|
658 * @return the number of the top most visible line
|
|
659 */
|
|
660 int getTopIndex();
|
|
661
|
|
662 /**
|
|
663 * Returns the document offset of the upper left corner of this viewer's view port.
|
|
664 *
|
|
665 * @return the upper left corner offset
|
|
666 */
|
|
667 int getTopIndexStartOffset();
|
|
668
|
|
669 /**
|
|
670 * Returns the visible line with the highest line number.
|
|
671 *
|
|
672 * @return the number of the bottom most line
|
|
673 */
|
|
674 int getBottomIndex();
|
|
675
|
|
676 /**
|
|
677 * Returns the document offset of the lower right
|
|
678 * corner of this viewer's view port. This is the visible character
|
|
679 * with the highest character position. If the content of this viewer
|
|
680 * is shorter, the position of the last character of the content is returned.
|
|
681 *
|
|
682 * @return the lower right corner offset
|
|
683 */
|
|
684 int getBottomIndexEndOffset();
|
|
685
|
|
686 /**
|
|
687 * Returns the vertical offset of the first visible line.
|
|
688 *
|
|
689 * @return the vertical offset of the first visible line
|
|
690 */
|
|
691 int getTopInset();
|
|
692 }
|