class KTextEditor.Document


abstract class

Table of contents
Modules
ktexteditor Classes
All Classes
Module ktexteditor
Namespace ktexteditor
Class KTextEditor.Document
Inherits KParts.ReadWritePart

A KParts derived class representing a text document.

Topics: - doc_intro - doc_manipulation - doc_views - doc_extensions

Introduction

The Document class represents a pure text document providing methods to modify the content and create views. A document can have any number of views, each view representing the same content, i.e. all views are synchronized. Support for text selection is handeled by a View and text format attribues by the Attribute class.

To load a document call KParts.ReadOnlyPart.openUrl(). To reload a document from a file call documentReload(), to save the document call documentSave() or documentSaveAs(). Whenever the modified state of the document changes the signal modifiedChanged() is emitted. Check the modified state with KParts.ReadWritePart.isModified(). Further signals are documentUrlChanged(). The encoding can be specified with setEncoding(), however this will only take effect on file reload and file save.

Text Manipulation

Get the whole content with text() and set new content with setText(). Call insertText() or insertLine() to insert new text or removeText() and removeLine() to remove content. Whenever the document's content changed the signal textChanged() is emitted. Additional signals are textInserted() and textRemoved().

If the editor part supports it a document provides full undo/redo history. Text manipulation actions can be grouped together using startEditing() and endEditing(). All actions inbetween are grouped together to only one undo/redo action. Due to internal reference counting you can call startEditing() and endEditing() as often as you wish, but make sure you call endEditing() exactly as often as you call startEditing(), otherwise the reference counter gets confused.

Document Views

A View displays the document's content. As already mentioned a document can have any number of views, all synchronized. Get a list of all views with views(). Only one of the views can be active (i.e. has focus), get it by using activeView(). Create a new view with createView(). Everytime a new view is created the signal viewCreated() is emitted.

Document Extension Interfaces

A simple document represents text and provides text manipulation methods. However, a real text editor should support advanced concepts like session support, textsearch support, bookmark/general mark support etc. That is why the KTextEditor library provides several additional interfaces to extend a document's capabilities via multiple inheritance.

More information about interfaces for the document can be found in kte_group_doc_extensions.

See also KParts.ReadWritePart, KTextEditor.Editor, KTextEditor.View, KTextEditor.MarkInterface, KTextEditor.ModificationInterface, KTextEditor.SearchInterface, KTextEditor.SessionConfigInterface, KTextEditor.SmartInterface, KTextEditor.VariableInterface Author Christoph Cullmann \



methods