KTextEditor
smartcursor.h
Go to the documentation of this file.
00001 /* This file is part of the KDE project 00002 Copyright (C) 2003-2005 Hamish Rodda <rodda@kde.org> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License version 2 as published by the Free Software Foundation. 00007 00008 This library is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00011 Library General Public License for more details. 00012 00013 You should have received a copy of the GNU Library General Public License 00014 along with this library; see the file COPYING.LIB. If not, write to 00015 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00016 Boston, MA 02110-1301, USA. 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 //BEGIN Functionality present from having this cursor associated with a Document 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 //END 00177 00178 //BEGIN Behavior methods 00187 enum InsertBehavior { 00188 StayOnInsert = 0, 00189 MoveOnInsert 00190 }; 00195 InsertBehavior insertBehavior() const; 00196 00202 void setInsertBehavior(InsertBehavior insertBehavior); 00203 //END 00204 00205 //BEGIN Notification methods 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 //END 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 // kate: space-indent on; indent-width 2; replace-tabs on;
KDE 4.6 API Reference