The core of the KTextEditor interfaces consists of three main interfaces:
- KTextEditor::Editor (singleton)
The Editor is a singleton accessed through KTextEditor::Editor::instance(). This singleton allows to create documents, get a document list, and a be informed when a new document is created.
The Document interface represents a single document and enables the creation of views, access to and manipulation of document contents, and access to document extension interfaces.
The View provides a widget that displays the contents of a Document, and its interface allows for manipulation of text selection, position of the cursor and mouse, text selections, and behavior of the view. Additionally it provides access to the view extension interfaces.
The hierarchy can be illustrated as follows:
If linking to KF5::TextEditor is not an option, you can also access the KTextEditor framework as follows
The KTextEditor::Editor has a list of all opened documents and can create new documents. A Document's content is visualized by a KTextEditor::View. A Document can have any number of views (or none). When the content of the document is changed, the change is reflected in all views.