A text viewer connects a text widget with an {@link org.eclipse.jface.text.IDocument}. The document is used as the widget's text model.
It supports the following kinds of listeners:
- view port listeners to inform about changes of the viewer's view port
- text listeners to inform about changes of the document and the subsequent viewer change
- text input listeners to inform about changes of the viewer's input document.
A text viewer supports a set of configuration options and plug-ins defining its behavior:
- undo manager
- double click behavior
- auto indentation
- text hover
Installed plug-ins are not automatically activated. Plug-ins must be activated with the
activatePlugins
call. Most plug-ins can be defined per content type. Content types are derived from a partitioning of the text viewer's input document. In case of documents that support multiple partitionings, the implementer is responsible for determining the partitioning to use.
A text viewer also provides the concept of event consumption. Events handled by the viewer can be filtered and processed by a dynamic event consumer. With {@link org.eclipse.jface.text.ITextViewerExtension}, this mechanism has been replaced with the support for {@link org.eclipse.swt.custom.VerifyKeyListener}.
A text viewer provides several text editing functions, some of them are configurable, through a text operation target interface. It also supports a presentation mode in which it only shows a specified section of its document. By calling setVisibleRegion
clients define which section is visible. Clients can get access to this section by calling getVisibleRegion
. The viewer's presentation mode does not affect any client of the viewer other than text listeners. With {@link org.eclipse.jface.text.ITextViewerExtension5} the visible regionsupport has been reworked. With that extension interface, text viewers are allowed to show fractions of their input document. I.e. a widget selection of two visually neighboring characters is no longer guaranteed to be two neighboring characters in the viewer's input document. Thus, viewers implementing {@link org.eclipse.jface.text.ITextViewerExtension5} arepotentially forced to change the fractions of the input document that are shown when clients ask for the visible region.
In order to provide backward compatibility for clients of ITextViewer
, extension interfaces are used as a means of evolution. The following extension interfaces exist:
- {@link org.eclipse.jface.text.ITextViewerExtension} since version 2.0replacing the event consumer mechanism and introducing the concept of rewrite targets and means to manage the viewer's redraw behavior
- {@link org.eclipse.jface.text.ITextViewerExtension2}since version 2.1 adding a way to invalidate a viewer's presentation and setters for hovers.
- {@link org.eclipse.jface.text.ITextViewerExtension3} since version 2.1which itself was replaced by {@link org.eclipse.jface.text.ITextViewerExtension5} in version 3.0
- {@link org.eclipse.jface.text.ITextViewerExtension4} since version 3.0introducing focus handling for widget token keepers and the concept of text presentation listeners.
- {@link org.eclipse.jface.text.ITextViewerExtension5} since version 3.0extending the visible region concept with explicit handling and conversion of widget and model coordinates.
- {@link org.eclipse.jface.text.ITextViewerExtension6} since version 3.1extending the text viewer with the ability to detect hyperlinks and access the undo manager.
- {@link org.eclipse.jface.text.ITextViewerExtension7} since version 3.3extending the text viewer with the ability to install tabs to spaces conversion.
- {@link org.eclipse.jface.text.ITextViewerExtension8} since version 3.4extending the text viewer with the ability to print and rich hover support.
Clients may implement this interface and its extension interfaces or use the standard implementation {@link org.eclipse.jface.text.TextViewer}.
@see org.eclipse.jface.text.ITextViewerExtension
@see org.eclipse.jface.text.ITextViewerExtension2
@see org.eclipse.jface.text.ITextViewerExtension3
@see org.eclipse.jface.text.ITextViewerExtension4
@see org.eclipse.jface.text.ITextViewerExtension5
@see org.eclipse.jface.text.ITextViewerExtension6
@see org.eclipse.jface.text.ITextViewerExtension7
@see org.eclipse.jface.text.ITextViewerExtension8
@see org.eclipse.jface.text.IDocument
@see org.eclipse.jface.text.ITextInputListener
@see org.eclipse.jface.text.IViewportListener
@see org.eclipse.jface.text.ITextListener
@see org.eclipse.jface.text.IEventConsumer