A text viewer connects a text widget with an
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
org.eclipse.jface.text.ITextViewerExtension, this mechanism has been
replaced with the support for
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
org.eclipse.jface.text.ITextViewerExtension5 the visible region
support 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
org.eclipse.jface.text.ITextViewerExtension5 are
potentially 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:
-
org.eclipse.jface.text.ITextViewerExtension since version 2.0
replacing the event consumer mechanism and introducing the concept of rewrite
targets and means to manage the viewer's redraw behavior
-
org.eclipse.jface.text.ITextViewerExtension2since version 2.1
adding a way to invalidate a viewer's presentation and setters for hovers.
-
org.eclipse.jface.text.ITextViewerExtension3 since version 2.1
which itself was replaced by
org.eclipse.jface.text.ITextViewerExtension5 in version 3.0
-
org.eclipse.jface.text.ITextViewerExtension4 since version 3.0
introducing focus handling for widget token keepers and the concept of text
presentation listeners.
-
org.eclipse.jface.text.ITextViewerExtension5 since version 3.0
extending the visible region concept with explicit handling and conversion
of widget and model coordinates.
-
org.eclipse.jface.text.ITextViewerExtension6 since version 3.1
extending the text viewer with the ability to detect hyperlinks and access the undo manager.
-
org.eclipse.jface.text.ITextViewerExtension7 since version 3.3
extending the text viewer with the ability to install tabs to spaces conversion.
-
org.eclipse.jface.text.ITextViewerExtension8 since version 3.4
extending 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
org.eclipse.jface.text.TextViewer.