kate Library API Documentation

katesupercursor.h

00001 /* This file is part of the KDE libraries 00002 Copyright (C) 2003 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., 59 Temple Place - Suite 330, 00016 Boston, MA 02111-1307, USA. 00017 */ 00018 00019 #ifndef KATESUPERCURSOR_H 00020 #define KATESUPERCURSOR_H 00021 00022 #include "katecursor.h" 00023 00024 class KateDocument; 00025 class KateView; 00026 00045 class KateSuperCursor : public QObject, public KateDocCursor, public Kate::Cursor 00046 { 00047 Q_OBJECT 00048 00049 public: 00055 KateSuperCursor(KateDocument* doc, bool privateC, const KateTextCursor& cursor, QObject* parent = 0L, const char* name = 0L); 00056 KateSuperCursor(KateDocument* doc, bool privateC, int lineNum = 0, int col = 0, QObject* parent = 0L, const char* name = 0L); 00057 00058 ~KateSuperCursor (); 00059 00060 public: 00061 // KTextEditor::Cursor interface 00062 void position(uint *line, uint *col) const; 00063 bool setPosition(uint line, uint col); 00064 bool insertText(const QString& text); 00065 bool removeText(uint numberOfCharacters); 00066 QChar currentChar() const; 00067 00071 bool atStartOfLine() const; 00072 00076 bool atEndOfLine() const; 00077 00082 bool moveOnInsert() const; 00083 00089 void setMoveOnInsert(bool moveOnInsert); 00090 00094 operator QString(); 00095 00096 // Reimplementations; 00097 virtual void setLine(int lineNum); 00098 virtual void setCol(int colNum); 00099 virtual void setPos(const KateTextCursor& pos); 00100 virtual void setPos(int lineNum, int colNum); 00101 00102 signals: 00106 void positionDirectlyChanged(); 00107 00111 void positionChanged(); 00112 00116 void positionUnChanged(); 00117 00122 void positionDeleted(); 00123 00132 void charInsertedAt(); 00133 00137 void charDeletedBefore(); 00138 00142 void charDeletedAfter(); 00143 00144 // BEGIN METHODES TO CALL FROM KATE DOCUMENT TO KEEP CURSOR UP TO DATE 00145 public: 00146 void editTextInserted ( uint line, uint col, uint len); 00147 void editTextRemoved ( uint line, uint col, uint len); 00148 00149 void editLineWrapped ( uint line, uint col, bool newLine = true ); 00150 void editLineUnWrapped ( uint line, uint col, bool removeLine = true, uint length = 0 ); 00151 00152 void editLineInserted ( uint line ); 00153 void editLineRemoved ( uint line ); 00154 // END 00155 00156 private: 00157 KateDocument *m_doc; 00158 bool m_moveOnInsert : 1; 00159 bool m_lineRemoved : 1; 00160 bool m_privateCursor : 1; 00161 }; 00162 00168 class KateSuperRange : public QObject, public KateRange 00169 { 00170 friend class KateSuperRangeList; 00171 00172 Q_OBJECT 00173 00174 public: 00176 enum InsertBehaviour { 00178 DoNotExpand = 0, 00180 ExpandLeft = 0x1, 00182 ExpandRight = 0x2 00183 }; 00184 00188 KateSuperRange(KateSuperCursor* start, KateSuperCursor* end, QObject* parent = 0L, const char* name = 0L); 00189 KateSuperRange(KateDocument* doc, const KateRange& range, QObject* parent = 0L, const char* name = 0L); 00190 KateSuperRange(KateDocument* doc, const KateTextCursor& start, const KateTextCursor& end, QObject* parent = 0L, const char* name = 0L); 00191 00192 virtual ~KateSuperRange(); 00193 00194 // fulfill KateRange requirements 00195 virtual KateTextCursor& start(); 00196 virtual KateTextCursor& end(); 00197 virtual const KateTextCursor& start() const; 00198 virtual const KateTextCursor& end() const; 00199 00203 KateSuperCursor& superStart(); 00204 const KateSuperCursor& superStart() const; 00205 00209 KateSuperCursor& superEnd(); 00210 const KateSuperCursor& superEnd() const; 00211 00215 int behaviour() const; 00216 00225 void setBehaviour(int behaviour); 00226 00230 virtual bool isValid() const; 00231 00243 bool owns(const KateTextCursor& cursor) const; 00244 00249 bool includes(const KateTextCursor& cursor) const; 00250 00254 bool includes(uint lineNum) const; 00255 00259 bool includesWholeLine(uint lineNum) const; 00260 00264 bool boundaryAt(const KateTextCursor& cursor) const; 00265 00269 bool boundaryOn(uint lineNum) const; 00270 00271 signals: 00281 void positionChanged(); 00282 00286 void positionUnChanged(); 00287 00291 void contentsChanged(); 00292 00296 void boundaryDeleted(); 00297 00304 void eliminated(); 00305 00309 void tagRange(KateSuperRange* range); 00310 00311 public slots: 00312 void slotTagRange(); 00313 00314 private slots: 00315 void slotEvaluateChanged(); 00316 void slotEvaluateUnChanged(); 00317 00318 private: 00319 void init(); 00320 void evaluateEliminated(); 00321 void evaluatePositionChanged(); 00322 00323 KateSuperCursor* m_start; 00324 KateSuperCursor* m_end; 00325 bool m_evaluate; 00326 bool m_startChanged; 00327 bool m_endChanged; 00328 bool m_deleteCursors; 00329 }; 00330 00331 class KateSuperCursorList : public QPtrList<KateSuperCursor> 00332 { 00333 protected: 00334 virtual int compareItems(QPtrCollection::Item item1, QPtrCollection::Item item2); 00335 }; 00336 00337 class KateSuperRangeList : public QObject, public QPtrList<KateSuperRange> 00338 { 00339 Q_OBJECT 00340 00341 public: 00345 KateSuperRangeList(bool autoManage = true, QObject* parent = 0L, const char* name = 0L); 00346 00356 KateSuperRangeList(const QPtrList<KateSuperRange>& rangeList, QObject* parent = 0L, const char* name = 0L); 00357 00363 void appendList(const QPtrList<KateSuperRange>& rangeList); 00364 00369 void connectAll(); 00370 00374 virtual void clear(); 00375 00380 bool autoManage() const; 00381 00385 void setAutoManage(bool autoManage); 00386 00391 QPtrList<KateSuperRange> rangesIncluding(const KateTextCursor& cursor); 00392 QPtrList<KateSuperRange> rangesIncluding(uint line); 00393 00398 bool rangesInclude(const KateTextCursor& cursor); 00399 00406 KateSuperCursor* firstBoundary(const KateTextCursor* start = 0L); 00407 00411 KateSuperCursor* nextBoundary(); 00412 00416 KateSuperCursor* currentBoundary(); 00417 00418 signals: 00423 void rangeEliminated(KateSuperRange* range); 00424 00428 void listEmpty(); 00429 00433 void tagRange(KateSuperRange* range); 00434 00435 protected: 00439 virtual int compareItems(QPtrCollection::Item item1, QPtrCollection::Item item2); 00440 00444 virtual QPtrCollection::Item newItem(QPtrCollection::Item d); 00445 00446 private slots: 00447 void slotEliminated(); 00448 void slotDeleted(QObject* range); 00449 00450 private: 00451 bool m_autoManage; 00452 bool m_connect; 00453 00454 KateSuperCursorList m_columnBoundaries; 00455 bool m_trackingBoundaries; 00456 }; 00457 00458 #endif
KDE Logo
This file is part of the documentation for kate Library Version 3.2.3.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sun Oct 10 18:56:23 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003