# class KTextEditor.MarkInterface

### abstract class

Table of contents
Modules
ktexteditor Classes
All Classes

Module | ktexteditor
Namespace | ktexteditor
Class | KTextEditor.MarkInterface
Inherits |

The line that contains the mark. The mark types in the line, combined with logical OR. Mark extension interface for the Document.

Introduction

The MarkInterface provides methods to enable and disable marks in a Document, a marked line can be visualized for example with a shaded background color and/or a pixmap in the iconborder of the Document's View. There are a number of predefined mark types, specified in reservedMarkersCount(). Additionally it is possible to add custom marks and set custom pixmaps.

Accessing the Interface

The MarkInterface is supposed to be an extension interface for a Document, i.e. the Document inherits the interface provided that the KTextEditor library in use implements the interface. Use qobject_cast to access the interface:

    // doc is of type KTextEditor.Document*
    KTextEditor.MarkInterface *iface =
    qobject_cast<KTextEditor.MarkInterface*>( doc );

    if( iface ) {
    // the implementation supports the interface
    // do stuff
    }

Handling Marks

Get all marks in the document by calling marks(). Use clearMarks() to remove all marks in the entire document. A single mark can be retrieved with mark(). To remove all marks from a line call clearMark(). To add and remove marks from a given line use addMark() and removeMark(). It is also possible to replace all marks with setMark(), i.e. setMark() is the same as a call of clearMark() followed by addMark(). The signals marksChanged() and markChanged() are emitted whenever a line's marks changed.

\attention A mark type is represented as an uint. An uint can have several mark types combined (see above: logical OR). That means for all functions/signals with an uint parameter, e.g. setMark(), removeMark(), etc, the uint may contain multiple marks, i.e. you can add and remove multiple marks simultaneously.

User Defined Marks

All marks that should be editable by the user can be specified with a mark mask via setEditableMarks(). To set a description and pixmap of a mark type call setMarkDescription() and setMarkPixmap().

See also KTextEditor.Document, KTextEditor.Mark Author Christoph Cullmann \<cullmann@kde.org\>

### enums

- MarkChangeAction = { MarkAdded, MarkRemoved }
- MarkTypes = { markType01, markType02, markType03, markType04, markType05, markType06, markType07, markType08, markType09, markType10, markType11, markType12, markType13, markType14, markType15, markType16, markType17, markType18, markType19, markType20, markType21, markType22, markType23, markType24, markType25, markType26, markType27, markType28, markType29, markType30, markType31, markType32, Bookmark, BreakpointActive, BreakpointReached, BreakpointDisabled, Execution, Warning, Error }

enum details

### methods

- MarkInterface ()

  returns nothing

  Virtual destructor.

- addMark (line, markType)

  returns nothing
  pure virtual

  Argument | Type | Default
  --- | --- | ---
  line | int |
  markType | uint |

  Add marks of type markType to line. Existing marks on this line are preserved. If the mark markType already is set, nothing happens.

  line - line to set the mark

  markType - mark type

  See also removeMark(), setMark()

- clearMark (line)

  returns nothing
  pure virtual

  Argument | Type | Default
  --- | --- | ---
  line | int |

  Clear all marks set in the line.

  line - line to clear marks

  See also clearMarks(), removeMark(), addMark()

- clearMarks ()

  returns nothing
  pure virtual

  Clear all marks in the entire document.

  See also clearMark(), removeMark() TODO : dominik : add argument unit mask = 0

- editableMarks ()

  returns (uint)
  pure virtual

  Get, which marks can be toggled by the user. The returned value is a mark mask containing all editable marks combined with a logical OR. Returns mark mask containing all editable marks

  See also setEditableMarks()

- mark (line)

  returns (uint)
  pure virtual

  Argument | Type | Default
  --- | --- | ---
  line | int |

  Get all marks set on the line.

  line - requested line Returns a uint representing of the marks set in line concatenated by logical OR

  See also addMark(), removeMark()

- markChanged (document, mark, action)

  returns nothing
  pure virtual

  Argument | Type | Default
  --- | --- | ---
  document | KTextEditor.Document |
  mark | KTextEditor.Mark |
  action | KTextEditor.MarkInterface.MarkChangeAction |

  The document emits this signal whenever the mark changes.

  document - the document which emitted the signal

  mark - changed mark

  action - action, either removed or added

  See also marksChanged()

- markDescription (mark)

  returns (QString)
  pure virtual

  Argument | Type | Default
  --- | --- | ---
  mark | KTextEditor.MarkInterface.MarkTypes |

  Get the mark's description to text.

  mark - mark to set the description Returns text of the given mark or QString(), if the entry does not exist

  See also setMarkDescription(), setMarkPixmap()

- markPixmap (mark)

  returns (QPixmap)
  pure virtual

  Argument | Type | Default
  --- | --- | ---
  mark | KTextEditor.MarkInterface.MarkTypes |

  Get the mark's pixmap.

  mark - mark type. If the pixmap does not exist the resulting is null (check with QPixmap.isNull()).

  See also setMarkDescription()

- marks ()

  returns (dict of (int, KTextEditor.Mark))
  pure virtual

  Get a hash holding all marks in the document. The hash key for a mark is its line. Returns a hash holding all marks in the document

- marksChanged (document)

  returns nothing
  pure virtual

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

  The document emits this signal whenever a mark mask changed.

  document - document which emitted this signal

  See also markChanged()

- removeMark (line, markType)

  returns nothing
  pure virtual

  Argument | Type | Default
  --- | --- | ---
  line | int |
  markType | uint |

  Remove the mark mask of type markType from line.

  line - line to remove the mark

  markType - mark type to be removed

  See also clearMark()

- reservedMarkersCount ()

  returns (int)
  static

  Get the number of predefined mark types we have so far. FIXME: If you change this you have to make sure katepart supports the new size! Returns number of reserved marker types

- setEditableMarks (markMask)

  returns nothing
  pure virtual

  Argument | Type | Default
  --- | --- | ---
  markMask | uint |

  Set the mark mask the user is allowed to toggle to markMask. I.e. concatenate all editable marks with a logical OR. If the user should be able to add a bookmark and set a breakpoint with the context menu in the icon pane, you have to call

      // iface is of Type KTextEditor.MarkInterface*
      // only make bookmark and breakpoint editable
      iface->setEditableMarks( MarkInterface.Bookmark |
      MarkInterface.BreakpointActive );

      // or preserve last settings, and add bookmark and breakpoint
      iface->setEditableMarks( iface->editableMarks() |
      MarkInterface.Bookmark |
      MarkInterface.BreakpointActive );

  markMask - bitmap pattern

  See also editableMarks(), setMarkPixmap(), setMarkDescription()

- setMark (line, markType)

  returns nothing
  pure virtual

  Argument | Type | Default
  --- | --- | ---
  line | int |
  markType | uint |

  Set the line's mark types to markType. If line already contains a mark of the given type it has no effect. All other marks are deleted before the mark is set. You can achieve the same by calling

      clearMark(line);
      addMark(line, markType);

  line - line to set the mark

  markType - mark type

  See also clearMark(), addMark(), mark()

- setMarkDescription (mark, text)

  returns nothing
  pure virtual

  Argument | Type | Default
  --- | --- | ---
  mark | KTextEditor.MarkInterface.MarkTypes |
  text | QString |

  Set the mark's description to text.

  mark - mark to set the description

  text - new descriptive text

  See also markDescription(), setMarkPixmap()

- setMarkPixmap (mark, pixmap)

  returns nothing
  pure virtual

  Argument | Type | Default
  --- | --- | ---
  mark | KTextEditor.MarkInterface.MarkTypes |
  pixmap | QPixmap |

  Set the mark's pixmap to pixmap.

  mark - mark to which the pixmap will be attached

  pixmap - new pixmap

  See also setMarkDescription()

### enums - detail

- MarkChangeAction = { MarkAdded, MarkRemoved }

  | MarkAdded | - | MarkAdded=0, < action: a mark was added.
  | MarkRemoved | - | MarkRemoved=1 < action: a mark was removed.

- MarkTypes = { markType01, markType02, markType03, markType04, markType05, markType06, markType07, markType08, markType09, markType10, markType11, markType12, markType13, markType14, markType15, markType16, markType17, markType18, markType19, markType20, markType21, markType22, markType23, markType24, markType25, markType26, markType27, markType28, markType29, markType30, markType31, markType32, Bookmark, BreakpointActive, BreakpointReached, BreakpointDisabled, Execution, Warning, Error }

  | markType01 | - | Bookmark
  | markType02 | - | Breakpoint active
  | markType03 | - | Breakpoint reached
  | markType04 | - | Breakpoint disabled
  | markType05 | - | Execution mark
  | markType06 | - | Warning
  | markType07 | - | Error
  | markType08 | - |
  | markType09 | - |
  | markType10 | - |
  | markType11 | - |
  | markType12 | - |
  | markType13 | - |
  | markType14 | - |
  | markType15 | - |
  | markType16 | - |
  | markType17 | - |
  | markType18 | - |
  | markType19 | - |
  | markType20 | - |
  | markType21 | - |
  | markType22 | - |
  | markType23 | - |
  | markType24 | - |
  | markType25 | - |
  | markType26 | - |
  | markType27 | - |
  | markType28 | - |
  | markType29 | - |
  | markType30 | - |
  | markType31 | - |
  | markType32 | - |
  | Bookmark | - |
  | BreakpointActive | - |
  | BreakpointReached | - |
  | BreakpointDisabled | - |
  | Execution | - |
  | Warning | - |
  | Error | - |