katesupercursor.h
/* This file is part of the KDE libraries
Copyright (C) 2003 Hamish Rodda <rodda@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef KATESUPERCURSOR_H
#define KATESUPERCURSOR_H
#include "katecursor.h"
class KateDocument;
class KateView;
class KateSuperCursor : public QObject, public KateDocCursor, public Kate::Cursor
{
Q_OBJECT
public:
KateSuperCursor(KateDocument* doc, bool privateC, const KateTextCursor& cursor, QObject* parent = 0L, const char* name = 0L);
KateSuperCursor(KateDocument* doc, bool privateC, int lineNum = 0, int col = 0, QObject* parent = 0L, const char* name = 0L);
~KateSuperCursor ();
public:
// KTextEditor::Cursor interface
void position(uint *line, uint *col) const;
bool setPosition(uint line, uint col);
bool insertText(const QString& text);
bool removeText(uint numberOfCharacters);
QChar currentChar() const;
bool atStartOfLine() const;
bool atEndOfLine() const;
bool moveOnInsert() const;
void setMoveOnInsert(bool moveOnInsert);
operator QString();
// Reimplementations;
virtual void setLine(int lineNum);
virtual void setCol(int colNum);
virtual void setPos(const KateTextCursor& pos);
virtual void setPos(int lineNum, int colNum);
signals:
void positionDirectlyChanged();
void positionChanged();
void positionUnChanged();
void positionDeleted();
void charInsertedAt();
void charDeletedBefore();
void charDeletedAfter();
//BEGIN METHODES TO CALL FROM KATE DOCUMENT TO KEEP CURSOR UP TO DATE
public:
void editTextInserted ( uint line, uint col, uint len);
void editTextRemoved ( uint line, uint col, uint len);
void editLineWrapped ( uint line, uint col, bool newLine = true );
void editLineUnWrapped ( uint line, uint col, bool removeLine = true, uint length = 0 );
void editLineInserted ( uint line );
void editLineRemoved ( uint line );
//END
private:
KateDocument *m_doc;
bool m_moveOnInsert : 1;
bool m_lineRemoved : 1;
bool m_privateCursor : 1;
};
class KateSuperRange : public QObject, public KateRange
{
friend class KateSuperRangeList;
Q_OBJECT
public:
enum InsertBehaviour {
DoNotExpand = 0,
ExpandLeft = 0x1,
ExpandRight = 0x2
};
KateSuperRange(KateSuperCursor* start, KateSuperCursor* end, QObject* parent = 0L, const char* name = 0L);
KateSuperRange(KateDocument* doc, const KateRange& range, QObject* parent = 0L, const char* name = 0L);
KateSuperRange(KateDocument* doc, const KateTextCursor& start, const KateTextCursor& end, QObject* parent = 0L, const char* name = 0L);
virtual ~KateSuperRange();
// fulfill KateRange requirements
virtual KateTextCursor& start();
virtual KateTextCursor& end();
virtual const KateTextCursor& start() const;
virtual const KateTextCursor& end() const;
void allowZeroLength(bool yes=true){m_allowZeroLength=yes;}
KateSuperCursor& superStart();
const KateSuperCursor& superStart() const;
KateSuperCursor& superEnd();
const KateSuperCursor& superEnd() const;
int behaviour() const;
void setBehaviour(int behaviour);
virtual bool isValid() const;
bool owns(const KateTextCursor& cursor) const;
bool includes(const KateTextCursor& cursor) const;
bool includes(uint lineNum) const;
bool includesWholeLine(uint lineNum) const;
bool boundaryAt(const KateTextCursor& cursor) const;
bool boundaryOn(uint lineNum) const;
signals:
void positionChanged();
void positionUnChanged();
void contentsChanged();
void boundaryDeleted();
void eliminated();
void tagRange(KateSuperRange* range);
public slots:
void slotTagRange();
private slots:
void slotEvaluateChanged();
void slotEvaluateUnChanged();
private:
void init();
void evaluateEliminated();
void evaluatePositionChanged();
KateSuperCursor* m_start;
KateSuperCursor* m_end;
bool m_evaluate;
bool m_startChanged;
bool m_endChanged;
bool m_deleteCursors;
bool m_allowZeroLength;
};
class KateSuperCursorList : public QPtrList<KateSuperCursor>
{
protected:
virtual int compareItems(QPtrCollection::Item item1, QPtrCollection::Item item2);
};
class KateSuperRangeList : public QObject, public QPtrList<KateSuperRange>
{
Q_OBJECT
public:
KateSuperRangeList(bool autoManage = true, QObject* parent = 0L, const char* name = 0L);
KateSuperRangeList(const QPtrList<KateSuperRange>& rangeList, QObject* parent = 0L, const char* name = 0L);
virtual ~KateSuperRangeList() {}
void appendList(const QPtrList<KateSuperRange>& rangeList);
void connectAll();
virtual void clear();
bool autoManage() const;
void setAutoManage(bool autoManage);
QPtrList<KateSuperRange> rangesIncluding(const KateTextCursor& cursor);
QPtrList<KateSuperRange> rangesIncluding(uint line);
bool rangesInclude(const KateTextCursor& cursor);
KateSuperCursor* firstBoundary(const KateTextCursor* start = 0L);
KateSuperCursor* nextBoundary();
KateSuperCursor* currentBoundary();
signals:
void rangeEliminated(KateSuperRange* range);
void listEmpty();
void tagRange(KateSuperRange* range);
protected:
virtual int compareItems(QPtrCollection::Item item1, QPtrCollection::Item item2);
virtual QPtrCollection::Item newItem(QPtrCollection::Item d);
private slots:
void slotEliminated();
void slotDeleted(QObject* range);
private:
bool m_autoManage;
bool m_connect;
KateSuperCursorList m_columnBoundaries;
bool m_trackingBoundaries;
};
#endif
// kate: space-indent on; indent-width 2; replace-tabs on;
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
KateSuperCursor::moveOnInsert
bool moveOnInsert() const
Returns how this cursor behaves when text is inserted at the cursor.
Definition: katesupercursor.cpp:95
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.
KStdAction::clear
KAction * clear(const QObject *recvr, const char *slot, KActionCollection *parent, const char *name=0)
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::KateSuperRange
KateSuperRange(KateSuperCursor *start, KateSuperCursor *end, QObject *parent=0L, const char *name=0L)
Constructor.
Definition: katesupercursor.cpp:280
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
KateSuperCursor::KateSuperCursor
KateSuperCursor(KateDocument *doc, bool privateC, const KateTextCursor &cursor, QObject *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::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::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

KDE Home | KDE Accessibility Home | Description of Access Keys