• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kate
 

kate

  • kate
  • part
katesupercursor.h
1 /* This file is part of the KDE libraries
2  Copyright (C) 2003 Hamish Rodda <rodda@kde.org>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License version 2 as published by the Free Software Foundation.
7 
8  This library is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  Library General Public License for more details.
12 
13  You should have received a copy of the GNU Library General Public License
14  along with this library; see the file COPYING.LIB. If not, write to
15  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16  Boston, MA 02110-1301, USA.
17 */
18 
19 #ifndef KATESUPERCURSOR_H
20 #define KATESUPERCURSOR_H
21 
22 #include "katecursor.h"
23 
24 class KateDocument;
25 class KateView;
26 
45 class KateSuperCursor : public TQObject, public KateDocCursor, public Kate::Cursor
46 {
47  Q_OBJECT
48 
49 public:
55  KateSuperCursor(KateDocument* doc, bool privateC, const KateTextCursor& cursor, TQObject* parent = 0L, const char* name = 0L);
56  KateSuperCursor(KateDocument* doc, bool privateC, int lineNum = 0, int col = 0, TQObject* parent = 0L, const char* name = 0L);
57 
58  ~KateSuperCursor ();
59 
60  public:
61  // KTextEditor::Cursor interface
62  void position(uint *line, uint *col) const;
63  bool setPosition(uint line, uint col);
64  bool insertText(const TQString& text);
65  bool removeText(uint numberOfCharacters);
66  TQChar currentChar() const;
67 
71  bool atStartOfLine() const;
72 
76  bool atEndOfLine() const;
77 
82  bool moveOnInsert() const;
83 
89  void setMoveOnInsert(bool moveOnInsert);
90 
94  operator TQString();
95 
96  // Reimplementations;
97  virtual void setLine(int lineNum);
98  virtual void setCol(int colNum);
99  virtual void setPos(const KateTextCursor& pos);
100  virtual void setPos(int lineNum, int colNum);
101 
102  signals:
106  void positionDirectlyChanged();
107 
111  void positionChanged();
112 
116  void positionUnChanged();
117 
122  void positionDeleted();
123 
132  void charInsertedAt();
133 
137  void charDeletedBefore();
138 
142  void charDeletedAfter();
143 
144  //BEGIN METHODES TO CALL FROM KATE DOCUMENT TO KEEP CURSOR UP TO DATE
145  public:
146  void editTextInserted ( uint line, uint col, uint len);
147  void editTextRemoved ( uint line, uint col, uint len);
148 
149  void editLineWrapped ( uint line, uint col, bool newLine = true );
150  void editLineUnWrapped ( uint line, uint col, bool removeLine = true, uint length = 0 );
151 
152  void editLineInserted ( uint line );
153  void editLineRemoved ( uint line );
154  //END
155 
156  private:
157  KateDocument *m_doc;
158  bool m_moveOnInsert : 1;
159  bool m_lineRemoved : 1;
160  bool m_privateCursor : 1;
161 };
162 
168 class KateSuperRange : public TQObject, public KateRange
169 {
170  friend class KateSuperRangeList;
171 
172  Q_OBJECT
173 
174 public:
176  enum InsertBehaviour {
178  DoNotExpand = 0,
180  ExpandLeft = 0x1,
182  ExpandRight = 0x2
183  };
184 
188  KateSuperRange(KateSuperCursor* start, KateSuperCursor* end, TQObject* parent = 0L, const char* name = 0L);
189  KateSuperRange(KateDocument* doc, const KateRange& range, TQObject* parent = 0L, const char* name = 0L);
190  KateSuperRange(KateDocument* doc, const KateTextCursor& start, const KateTextCursor& end, TQObject* parent = 0L, const char* name = 0L);
191 
192  virtual ~KateSuperRange();
193 
194  // fulfill KateRange requirements
195  virtual KateTextCursor& start();
196  virtual KateTextCursor& end();
197  virtual const KateTextCursor& start() const;
198  virtual const KateTextCursor& end() const;
199 
200  void allowZeroLength(bool yes=true){m_allowZeroLength=yes;}
204  KateSuperCursor& superStart();
205  const KateSuperCursor& superStart() const;
206 
210  KateSuperCursor& superEnd();
211  const KateSuperCursor& superEnd() const;
212 
216  int behaviour() const;
217 
226  void setBehaviour(int behaviour);
227 
231  virtual bool isValid() const;
232 
244  bool owns(const KateTextCursor& cursor) const;
245 
250  bool includes(const KateTextCursor& cursor) const;
251 
255  bool includes(uint lineNum) const;
256 
260  bool includesWholeLine(uint lineNum) const;
261 
265  bool boundaryAt(const KateTextCursor& cursor) const;
266 
270  bool boundaryOn(uint lineNum) const;
271 
272 signals:
282  void positionChanged();
283 
287  void positionUnChanged();
288 
292  void contentsChanged();
293 
297  void boundaryDeleted();
298 
305  void eliminated();
306 
310  void tagRange(KateSuperRange* range);
311 
312 public slots:
313  void slotTagRange();
314 
315 private slots:
316  void slotEvaluateChanged();
317  void slotEvaluateUnChanged();
318 
319 private:
320  void init();
321  void evaluateEliminated();
322  void evaluatePositionChanged();
323 
324  KateSuperCursor* m_start;
325  KateSuperCursor* m_end;
326  bool m_evaluate;
327  bool m_startChanged;
328  bool m_endChanged;
329  bool m_deleteCursors;
330  bool m_allowZeroLength;
331 };
332 
333 class KateSuperCursorList : public TQPtrList<KateSuperCursor>
334 {
335 protected:
336  virtual int compareItems(TQPtrCollection::Item item1, TQPtrCollection::Item item2);
337 };
338 
339 class KateSuperRangeList : public TQObject, public TQPtrList<KateSuperRange>
340 {
341  Q_OBJECT
342 
343 public:
347  KateSuperRangeList(bool autoManage = true, TQObject* parent = 0L, const char* name = 0L);
348 
358  KateSuperRangeList(const TQPtrList<KateSuperRange>& rangeList, TQObject* parent = 0L, const char* name = 0L);
359 
360  virtual ~KateSuperRangeList() {}
366  void appendList(const TQPtrList<KateSuperRange>& rangeList);
367 
372  void connectAll();
373 
377  virtual void clear();
378 
383  bool autoManage() const;
384 
388  void setAutoManage(bool autoManage);
389 
394  TQPtrList<KateSuperRange> rangesIncluding(const KateTextCursor& cursor);
395  TQPtrList<KateSuperRange> rangesIncluding(uint line);
396 
401  bool rangesInclude(const KateTextCursor& cursor);
402 
409  KateSuperCursor* firstBoundary(const KateTextCursor* start = 0L);
410 
414  KateSuperCursor* nextBoundary();
415 
419  KateSuperCursor* currentBoundary();
420 
421 signals:
426  void rangeEliminated(KateSuperRange* range);
427 
431  void listEmpty();
432 
436  void tagRange(KateSuperRange* range);
437 
438 protected:
442  virtual int compareItems(TQPtrCollection::Item item1, TQPtrCollection::Item item2);
443 
447  virtual TQPtrCollection::Item newItem(TQPtrCollection::Item d);
448 
449 private slots:
450  void slotEliminated();
451  void slotDeleted(TQObject* range);
452 
453 private:
454  bool m_autoManage;
455  bool m_connect;
456 
457  KateSuperCursorList m_columnBoundaries;
458  bool m_trackingBoundaries;
459 };
460 
461 #endif
KateTextCursor
Simple cursor class with no document pointer.
Definition: katecursor.h:33
KateDocCursor
Cursor class with a pointer to its document.
Definition: katecursor.h:92
KateSuperRange
Represents a range of text, from the start() to the end().
Definition: katesupercursor.h:168
KStdAction::clear
TDEAction * clear(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
KateSuperCursor::moveOnInsert
bool moveOnInsert() const
Returns how this cursor behaves when text is inserted at the cursor.
Definition: katesupercursor.cpp:95
KateSuperCursor::KateSuperCursor
KateSuperCursor(KateDocument *doc, bool privateC, const KateTextCursor &cursor, TQObject *parent=0L, const char *name=0L)
bool privateC says: if private, than don't show to apps using the cursorinterface in the list...
Definition: katesupercursor.cpp:28
KateSuperRange::InsertBehaviour
InsertBehaviour
Determine how the range reacts to characters inserted immediately outside the range.
Definition: katesupercursor.h:176
KateSuperRange::isValid
virtual bool isValid() const
Start and end must be valid and start <= end.
Definition: katesupercursor.cpp:404
KateSuperRange::ExpandRight
Expand to encapsulate new characters to the right of the range.
Definition: katesupercursor.h:182
KateSuperRange::behaviour
int behaviour() const
Returns how this range reacts to characters inserted immediately outside the range.
Definition: katesupercursor.cpp:393
KateSuperCursor::charDeletedBefore
void charDeletedBefore()
The character immediately before the cursor was deleted.
KateSuperRange::includes
bool includes(const KateTextCursor &cursor) const
Returns true if the range includes cursor 's character.
Definition: katesupercursor.cpp:422
KateSuperRange::boundaryAt
bool boundaryAt(const KateTextCursor &cursor) const
Returns whether cursor is the site of a boundary of this range.
Definition: katesupercursor.cpp:437
KateSuperRange::DoNotExpand
Don't expand to encapsulate new characters in either direction. This is the default.
Definition: katesupercursor.h:178
KateSuperRange::boundaryOn
bool boundaryOn(uint lineNum) const
Returns whether there is a boundary of this range on line.
Definition: katesupercursor.cpp:442
KateSuperRange::boundaryDeleted
void boundaryDeleted()
Either cursor's surrounding characters were both deleted.
KateSuperCursor::positionUnChanged
void positionUnChanged()
Athough an edit took place, the cursor's position was unchanged.
KateSuperCursor::positionChanged
void positionChanged()
The cursor's position was changed.
KateSuperRange::contentsChanged
void contentsChanged()
The contents of the range changed.
KateSuperCursor::atEndOfLine
bool atEndOfLine() const
Definition: katesupercursor.cpp:90
KateSuperCursor::atStartOfLine
bool atStartOfLine() const
Definition: katesupercursor.cpp:85
KateSuperRange::superEnd
KateSuperCursor & superEnd()
Returns the super end cursor.
Definition: katesupercursor.cpp:383
KateSuperRange::positionUnChanged
void positionUnChanged()
The range's position was unchanged.
KateSuperCursor::positionDirectlyChanged
void positionDirectlyChanged()
The cursor's position was directly changed by the program.
KateSuperCursor::charDeletedAfter
void charDeletedAfter()
The character immediately after the cursor was deleted.
KateSuperRange::positionChanged
void positionChanged()
More interesting signals that aren't worth implementing here: firstCharDeleted: start()::charDeleted(...
KateSuperRange::owns
bool owns(const KateTextCursor &cursor) const
This is for use where the ranges are used in a heirachy, ie.
Definition: katesupercursor.cpp:409
KateSuperCursor
Possible additional features:
Definition: katesupercursor.h:45
KateSuperCursor::charInsertedAt
void charInsertedAt()
A character was inserted immediately before the cursor.
KateSuperRange::ExpandLeft
Expand to encapsulate new characters to the left of the range.
Definition: katesupercursor.h:180
KateSuperRange::includesWholeLine
bool includesWholeLine(uint lineNum) const
Returns true if the range totally encompasses line.
Definition: katesupercursor.cpp:432
KateSuperCursor::positionDeleted
void positionDeleted()
The cursor's surrounding characters were both deleted simultaneously.
KateSuperRange::superStart
KateSuperCursor & superStart()
Returns the super start cursor.
Definition: katesupercursor.cpp:373
KateSuperRange::tagRange
void tagRange(KateSuperRange *range)
Indicates the region needs re-drawing.
KateSuperCursor::setMoveOnInsert
void setMoveOnInsert(bool moveOnInsert)
Change the behavior of the cursor when text is inserted at the cursor.
Definition: katesupercursor.cpp:100
KateSuperRange::KateSuperRange
KateSuperRange(KateSuperCursor *start, KateSuperCursor *end, TQObject *parent=0L, const char *name=0L)
Constructor.
Definition: katesupercursor.cpp:280
KateSuperRange::eliminated
void eliminated()
The range now contains no characters (ie.
KateSuperRange::setBehaviour
void setBehaviour(int behaviour)
Determine how the range should react to characters inserted immediately outside the range...
Definition: katesupercursor.cpp:398

kate

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

kate

Skip menu "kate"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  •     tdecore
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  • tdeioslave
  •   http
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for kate by doxygen 1.8.8
This website is maintained by Timothy Pearson.