KTextEditor
smartcursor.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef KDELIBS_KTEXTEDITOR_SMARTCURSOR_H
00020 #define KDELIBS_KTEXTEDITOR_SMARTCURSOR_H
00021
00022 #include <ktexteditor/ktexteditor_export.h>
00023 #include <ktexteditor/cursor.h>
00024
00025 namespace KTextEditor
00026 {
00027 class SmartRange;
00028
00029 class SmartCursorWatcher;
00030 class SmartCursorNotifier;
00031
00065 class KTEXTEDITOR_EXPORT SmartCursor : public Cursor
00066 {
00067 friend class SmartRange;
00068
00069 public:
00076 virtual ~SmartCursor();
00077
00081 virtual bool isSmartCursor() const;
00082
00086 virtual SmartCursor* toSmartCursor() const;
00087
00093 SmartRange* smartRange() const;
00094
00095
00106 Document* document() const;
00107
00113 virtual bool atEndOfLine() const;
00114
00120 virtual bool atEndOfDocument() const;
00121
00126 virtual bool isValid() const;
00127
00132 QChar character() const;
00133
00142 virtual bool insertText(const QStringList &text, bool block = false);
00143
00149 enum AdvanceMode {
00151 ByCharacter,
00153 ByCursorPosition
00154 };
00155
00175 virtual bool advance(int distance, AdvanceMode mode = ByCharacter);
00176
00177
00178
00187 enum InsertBehavior {
00188 StayOnInsert = 0,
00189 MoveOnInsert
00190 };
00195 InsertBehavior insertBehavior() const;
00196
00202 void setInsertBehavior(InsertBehavior insertBehavior);
00203
00204
00205
00220 virtual bool hasNotifier() const = 0;
00221
00234 virtual SmartCursorNotifier* notifier() = 0;
00235
00242 virtual void deleteNotifier() = 0;
00243
00249 virtual SmartCursorWatcher* watcher() const = 0;
00250
00257 virtual void setWatcher(SmartCursorWatcher* watcher = 0L) = 0;
00259
00260
00274 inline SmartCursor& operator=(const SmartCursor& cursor)
00275 { setPosition(cursor); return *this; }
00276
00277 protected:
00291 SmartCursor(const Cursor& position, Document* doc, InsertBehavior insertBehavior);
00292
00293 private:
00298 SmartCursor(const SmartCursor&);
00299
00305 Document* m_doc;
00306
00312 bool m_moveOnInsert : 1;
00313 };
00314
00315 }
00316
00317 #endif
00318
00319