• Skip to content
  • Skip to link menu
KDE 4.6 API Reference
  • KDE API Reference
  • kdelibs
  • KDE Home
  • Contact Us
 

Kate

Classes | Public Member Functions | Protected Member Functions

KateTemplateHandler Class Reference

Inserts a template and offers advanced snippet features, like navigation and mirroring. More...

#include <katetemplatehandler.h>

Inheritance diagram for KateTemplateHandler:
Inheritance graph
[legend]

List of all members.

Classes

class  MirrorBehaviour

Public Member Functions

 KateTemplateHandler (KateView *view, const KTextEditor::Cursor &position, const QString &templateString, const QMap< QString, QString > &initialValues, KateUndoManager *undoManager, KateTemplateScript *templateScript)
virtual ~KateTemplateHandler ()
KateView * view ()

Protected Member Functions

virtual bool eventFilter (QObject *object, QEvent *event)

Detailed Description

Inserts a template and offers advanced snippet features, like navigation and mirroring.

For each template inserted a new KateTemplateHandler will be created.

The handler has the following features:

  • It inserts the template string into the document at the requested position.
  • When the template contains at least one variable, the cursor will be placed at the start of the first variable and its range gets selected.
  • When more than one variable exists,TAB and SHIFT TAB can be used to navigate to the next/previous variable.
  • When a variable occurs more than once in the template, edits to any of the occurrences will be mirroed to the other ones.
  • When ESC is pressed, the template handler closes.
  • When ALT + RETURN is pressed and a %{cursor} variable exists in the template,the cursor will be placed there. Else the cursor will be placed at the end of the template.
See also:
KateDocument::insertTemplateTextImplementation(), KTextEditor::TemplateInterface
Author:
Milian Wolff <mail@milianw.de>

Definition at line 73 of file katetemplatehandler.h.


Constructor & Destructor Documentation

KateTemplateHandler::KateTemplateHandler ( KateView *  view,
const KTextEditor::Cursor &  position,
const QString &  templateString,
const QMap< QString, QString > &  initialValues,
KateUndoManager *  undoManager,
KateTemplateScript *  templateScript 
)

Setup the template handler, insert the template string.

NOTE: The handler deletes itself when required, you do not need to keep track of it.

TODO: maybe use Kate::CutCopyPasteEdit or similar?

TODO: maybe support delayed actions, i.e.:

  • create doc
  • insert template
  • create view => ranges are added for now simply "just insert" the code when we have no active view

Definition at line 60 of file katetemplatehandler.cpp.

KateTemplateHandler::~KateTemplateHandler ( ) [virtual]

Cancels the template handler and cleans everything up.

Definition at line 155 of file katetemplatehandler.cpp.


Member Function Documentation

bool KateTemplateHandler::eventFilter ( QObject *  object,
QEvent *  event 
) [protected, virtual]

Provide keyboard interaction for the template handler.

The event filter handles the following shortcuts:

TAB: jump to next editable (i.e. not mirrored) range. NOTE: this prevents indenting via TAB. SHIFT + TAB: jump to previous editable (i.e. not mirrored) range. NOTE: this prevents un-indenting via SHIFT + TAB. ESC: terminate template handler (only when no completion is active). ALT + RETURN: accept template and jump to the end-cursor. if %{cursor} was given in the template, that will be the end-cursor. else just jump to the end of the inserted text.

Definition at line 244 of file katetemplatehandler.cpp.

KateView * KateTemplateHandler::view ( )

Definition at line 1004 of file katetemplatehandler.cpp.


The documentation for this class was generated from the following files:
  • katetemplatehandler.h
  • katetemplatehandler.cpp

Kate

Skip menu "Kate"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.7.3
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal