00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
#ifndef _KATE_TEMPLATE_HANDLER_H_
00019
#define _KATE_TEMPLATE_HANDLER_H_
00020
00021
#include "katesupercursor.h"
00022
#include "katekeyinterceptorfunctor.h"
00023
#include <qobject.h>
00024
#include <qmap.h>
00025
#include <qdict.h>
00026
#include <qptrlist.h>
00027
#include <qstring.h>
00028
00029
class KateDocument;
00030
00031
class KateTemplateHandler:
public QObject,
public KateKeyInterceptorFunctor {
00032 Q_OBJECT
00033
public:
00034 KateTemplateHandler(KateDocument *doc,uint line,uint column,
const QString &templateString,
const QMap<QString,QString> &initialValues);
00035
virtual ~KateTemplateHandler();
00036
inline bool initOk() {
return m_initOk;}
00037
virtual bool operator()(
KKey key);
00038
private:
00039
struct KateTemplatePlaceHolder {
00040 KateSuperRangeList ranges;
00041
bool isCursor;
00042
bool isInitialValue;
00043 };
00044
class KateTemplateHandlerPlaceHolderInfo{
00045
public:
00046 KateTemplateHandlerPlaceHolderInfo():begin(0),len(0),placeholder(""){};
00047 KateTemplateHandlerPlaceHolderInfo(uint begin_,uint len_,
const QString& placeholder_):begin(begin_),len(len_),placeholder(placeholder_){}
00048 uint begin;
00049 uint len;
00050
QString placeholder;
00051 };
00052
class KateSuperRangeList *m_ranges;
00053
class KateDocument *m_doc;
00054
QPtrList<KateTemplatePlaceHolder> m_tabOrder;
00055
QDict<KateTemplatePlaceHolder> m_dict;
00056
void generateRangeTable(uint insertLine,uint insertCol,
const QString& insertString,
const QValueList<KateTemplateHandlerPlaceHolderInfo> &buildList);
00057
int m_currentTabStop;
00058
KateSuperRange *m_currentRange;
00059
void locateRange(
const KateTextCursor &cursor );
00060
bool m_initOk;
00061
bool m_recursion;
00062
private slots:
00063
void slotTextInserted(
int,
int);
00064
void slotDocumentDestroyed();
00065
void slotAboutToRemoveText(
const KateTextRange &range);
00066
void slotTextRemoved();
00067 };
00068
#endif