# class KTextEditor.Editor

### abstract class

Table of contents
Modules
ktexteditor Classes
All Classes

Module | ktexteditor
Namespace | ktexteditor
Class | KTextEditor.Editor
Inherits | QObject

Accessor interface for Editor part.

Topics: - editor_intro - editor_config - editor_notes - editor_extensions

Introduction

The Editor part can be accessed via the KTextEditor.Factory or the KTextEditor.EditorChooser and provides general information and configuration methods for the Editor implementation, for example KAboutData by using aboutData().

The Editor implementation has a list of all opened documents. Get this list with documents(). To create a new Document call createDocument(). The signal documentCreated() is emitted whenever the Editor created a new document.

Editor Configuration

If the Editor implementation supports a config dialog configDialogSupported() returns true, then the config dialog can be shown with configDialog(). Instead of using the config dialog, the config pages can be embedded into the application's config dialog. To do this, configPages() returns the number of config pages the Editor implementation provides and configPage() returns the requested page. Further, a config page has a short descriptive name, get it with configPageName(). You can get more detailed name by using configPageFullName(). Also every config page has a pixmap, get it with configPagePixmap(). The configuration can be saved and loaded with readConfig() and writeConfig().

We recommend to embedd the config pages into the main application's config dialog instead of using a separate config dialog, if the config dialog does not look cluttered then. This way, all settings are grouped together in one place.

Implementation Notes

Usually only one instance of the Editor exists. The Kate Part implementation internally uses a static accessor to make sure that only one Kate Part Editor object exists. So several factories still use the same Editor.

readConfig() and writeConfig() should be forwarded to all loaded plugins as well, see KTextEditor.Plugin.readConfig() and KTextEditor.Plugin.writeConfig().

Editor Extension Interfaces

There is only a single extension interface for the Editor: the CommandInterface. With the CommandInterface it is possible to add and remove new command line commands which are valid for all documents. Common use cases are for example commands like find or setting document variables. For further details read the detailed descriptions in the class KTextEditor.CommandInterface.

See also KTextEditor.Factory, KTextEditor.Document, KTextEditor.ConfigPage KTextEditor.Plugin, KTextEditor.CommandInterface Author Christoph Cullmann \<cullmann@kde.org\>

### methods

- Editor (parent)

  returns nothing

  Argument | Type | Default
  --- | --- | ---
  parent | QObject |

  Constructor.

  Create the Editor object with parent.

  parent - parent object

- aboutData ()

  returns (KAboutData)
  pure virtual

  Get the about data of this Editor part. Returns about data

- configDialog (parent)

  returns nothing
  pure virtual

  Argument | Type | Default
  --- | --- | ---
  parent | QWidget |

  Show the editor's config dialog, changes will be applied to the editor, but not saved anywhere automagically, call writeConfig() to save them.

  Instead of using the config dialog, the config pages can be embedded into your own config dialog by using configPages() and configPage().

  parent - parent widget

  See also configDialogSupported()

- configDialogSupported ()

  returns (bool)
  pure virtual

  Check, whether this editor has a configuration dialog. Returns true, if the editor has a configuration dialog, otherwise false

  See also configDialog()

- configPage (number, parent)

  returns (KTextEditor.ConfigPage)
  pure virtual

  Argument | Type | Default
  --- | --- | ---
  number | int |
  parent | QWidget |

  Get the config page with the number, config pages from 0 to configPages()-1 are available if configPages() > 0.

  number - index of config page

  parent - parent widget for config page Returns created config page or 0, if the number is out of bounds

  See also configPages()

- configPageFullName (number)

  returns (QString)
  pure virtual

  Argument | Type | Default
  --- | --- | ---
  number | int |

  Get a readable full name for the config page number. The name should be translated.

  Example: If the name is "Filetypes", the full name could be "Filetype Specific Settings". For "Shortcuts" the full name would be something like "Shortcut Configuration".

  number - index of config page Returns full name of given page index

  See also configPageName(), configPagePixmap()

- configPageIcon (number)

  returns (KIcon)
  pure virtual

  Argument | Type | Default
  --- | --- | ---
  number | int |

  Get a pixmap with size for the config page number.

  number - index of config page Returns pixmap for the given page index

  See also configPageName(), configPageFullName()

- configPageName (number)

  returns (QString)
  pure virtual

  Argument | Type | Default
  --- | --- | ---
  number | int |

  Get a readable name for the config page number. The name should be translated.

  number - index of config page Returns name of given page index

  See also configPageFullName(), configPagePixmap()

- configPages ()

  returns (int)
  pure virtual

  Get the number of available config pages. If the editor returns a number < 1, it does not support config pages and the embedding application should use configDialog() instead. Returns number of config pages

  See also configPage(), configDialog()

- createDocument (parent)

  returns (KTextEditor.Document)
  pure virtual

  Argument | Type | Default
  --- | --- | ---
  parent | QObject |

  Create a new document object with parent.

  parent - parent object Returns new KTextEditor.Document object

  See also documents()

- documentCreated (editor, document) signal

  returns nothing
  SIGNAL ("documentCreated (KTextEditor.Editor*, KTextEditor.Document*)")

  Argument | Type | Default
  --- | --- | ---
  editor | KTextEditor.Editor |
  document | KTextEditor.Document |

  The editor emits this signal whenever a document was successfully created.

  editor - editor which created the new document

  document - the newly created document instance

  See also createDocument()

- documents ()

  returns (list of KTextEditor.Document)
  pure virtual

  Get a list of all documents of this editor. Returns list of all existing documents

  See also createDocument()

- readConfig (config)

  returns nothing
  pure virtual

  Argument | Type | Default
  --- | --- | ---
  config | KConfig | None

  Read editor configuration from KConfig config.

  Implementation Notes: If config is 0 you should use KApplication.kApplication ()->config() as a fallback solution. Additionally the readConfig() call should be forwarded to every loaded plugin.

  config - config object

  See also writeConfig()

- writeConfig (config)

  returns nothing
  pure virtual

  Argument | Type | Default
  --- | --- | ---
  config | KConfig | None

  Write editor configuration to KConfig config.

  Implementation Notes: If config is 0 you should use KApplication.kApplication ()->config() as a fallback solution. Additionally the writeConfig() call should be forwarded to every loaded plugin.

  config - config object

  See also readConfig()