KTextEditor
smartrange.cpp
Go to the documentation of this file.
130static int lowerBoundRange(const QList<SmartRange*>& ranges, const Cursor& pos, const SmartRange* range)
157static int findIndex(const QList<SmartRange*>& ranges, const SmartRange* smartRange, const Range* range) {
178SmartRange::SmartRange(SmartCursor* start, SmartCursor* end, SmartRange * parent, InsertBehaviors insertBehavior )
289 //range.end() <= start(), The range does not overlap, and the same applies for all earlier ranges
331 //Reduce the overlap with all previously overlapping ranges(parentChildren is still sorted by the old end-position)
336 break; //This range did not overlap before, the same applies for all earlier ranges because of the order
452SmartRange * SmartRange::deepestRangeContaining( const Cursor & pos, QStack<SmartRange*>* rangesEntered, QStack<SmartRange*>* rangesExited ) const
469SmartRange * SmartRange::deepestRangeContainingInternal( const Cursor & pos, QStack<SmartRange*>* rangesEntered, QStack<SmartRange*>* rangesExited, bool first ) const
484 SmartRange* candidateRange = r->deepestRangeContainingInternal(pos, rangesEntered ? &candidateStack : 0, 0);
490 ((candidateRange->end() - candidateRange->start()) < (mostSpecific->end() - mostSpecific->start())) ||
558 return ((smartStart().insertBehavior() == SmartCursor::MoveOnInsert) ? DoNotExpand : ExpandLeft) | ((smartEnd().insertBehavior() == SmartCursor::MoveOnInsert) ? ExpandRight : DoNotExpand);
563 static_cast<SmartCursor*>(m_start)->setInsertBehavior((behavior & ExpandLeft) ? SmartCursor::StayOnInsert : SmartCursor::MoveOnInsert);
564 static_cast<SmartCursor*>(m_end)->setInsertBehavior((behavior & ExpandRight) ? SmartCursor::MoveOnInsert : SmartCursor::StayOnInsert);
732 //Reduce the overlap with all previously overlapping ranges(parentChildren is still sorted by the old end-position)
737// break; //This range did not overlap before, the same applies for all earlier ranges because of the order
749 //Decrease this ranges overlap from existing ranges behind, since it may be moved so it isn't overlapped any more
virtual bool isValid() const
Returns whether the current position of this cursor is a valid position (line + column must both be >...
Definition cursor.cpp:47
virtual bool removeText(const Range &range, bool block=false)=0
Remove the text specified in range.
virtual bool replaceText(const Range &range, const QString &text, bool block=false)
Replace text from range with specified text.
Definition document.cpp:179
virtual QStringList textLines(const Range &range, bool block=false) const =0
Get the document content within the given range.
An object representing a section of text, from one Cursor to another.
Definition range.h:55
virtual void rangeChanged(Cursor *cursor, const Range &from)
Notify this range that one or both of the cursors' position has changed directly.
Definition range.cpp:222
bool contains(const Range &range) const
Check whether the this range wholly encompasses range.
Definition range.cpp:160
virtual bool confineToRange(const Range &range)
Confine this range if necessary to fit within range.
Definition range.cpp:192
virtual void setRange(const Range &range)
Set the start and end cursors to range.start() and range.end() respectively.
Definition range.cpp:126
virtual bool expandToRange(const Range &range)
Expand this range if necessary to contain range.
Definition range.cpp:207
Document * document() const
Returns the document to which this cursor is attached.
Definition smartcursor.cpp:68
InsertBehavior insertBehavior() const
Returns how this cursor behaves when text is inserted at the cursor.
Definition smartcursor.cpp:78
A class which provides notifications of state changes to a SmartRange via QObject signals.
Definition smartrangenotifier.h:49
bool wantsDirectChanges() const
Returns whether this notifier will notify of changes that happen directly to the range,...
Definition rangefeedback.cpp:33
void rangeEliminated(KTextEditor::SmartRange *range)
The range now contains no characters (ie.
void rangeAttributeChanged(KTextEditor::SmartRange *range, KTextEditor::Attribute::Ptr currentAttribute, KTextEditor::Attribute::Ptr previousAttribute)
The highlighting attribute of range was changed from previousAttribute to currentAttribute.
void rangeContentsChanged(KTextEditor::SmartRange *range)
The contents of the range changed.
void childRangeInserted(KTextEditor::SmartRange *range, KTextEditor::SmartRange *child)
The range child was inserted as a child range into the current range.
void parentRangeChanged(KTextEditor::SmartRange *range, KTextEditor::SmartRange *newParent, KTextEditor::SmartRange *oldParent)
The range's parent was changed.
void rangePositionChanged(KTextEditor::SmartRange *range)
The range's position changed.
A class which provides notifications of state changes to a SmartRange via virtual inheritance.
Definition smartrangewatcher.h:51
bool wantsDirectChanges() const
Returns whether this watcher will be notified of changes that happen directly to the range,...
Definition rangefeedback.cpp:48
virtual void childRangeInserted(SmartRange *range, SmartRange *child)
The range child was inserted as a child range into the current range.
Definition rangefeedback.cpp:94
virtual void rangeAttributeChanged(SmartRange *range, Attribute::Ptr currentAttribute, Attribute::Ptr previousAttribute)
The highlighting attribute of range was changed from previousAttribute to currentAttribute.
Definition rangefeedback.cpp:102
virtual void rangePositionChanged(SmartRange *range)
The range's position changed.
Definition rangefeedback.cpp:58
virtual void rangeEliminated(SmartRange *range)
The range now contains no characters (ie.
Definition rangefeedback.cpp:86
virtual void rangeContentsChanged(SmartRange *range)
The contents of the range changed.
Definition rangefeedback.cpp:62
virtual void parentRangeChanged(SmartRange *range, SmartRange *newParent, SmartRange *oldParent)
The range's parent was changed.
Definition rangefeedback.cpp:106
A Range which is bound to a specific Document, and maintains its position.
Definition smartrange.h:95
const QList< SmartRange * > & childRanges() const
Get the ordered list of child ranges.
Definition smartrange.cpp:244
Attribute::Ptr attribute() const
Gets the active Attribute for this range.
Definition smartrange.cpp:636
void dissociateAction(KAction *action)
Remove the association with an action from this range; it will no longer be managed.
Definition smartrange.cpp:543
@ ExpandRight
Expand to encapsulate new characters to the right of the range.
Definition smartrange.h:106
@ ExpandLeft
Expand to encapsulate new characters to the left of the range.
Definition smartrange.h:104
@ DoNotExpand
Don't expand to encapsulate new characters in either direction. This is the default.
Definition smartrange.h:102
void rebuildChildStructure()
Is called after child-ranges have changed internally without the rangeChanged() notification,...
Definition smartrange.cpp:660
void deleteChildRanges()
Deletes child ranges - i.e., deletes the SmartRange objects only.
Definition smartrange.cpp:573
virtual void rangeChanged(Cursor *cursor, const Range &from)
Definition smartrange.cpp:687
void removeWatcher(SmartRangeWatcher *watcher)
Stop delivery of notifications to a SmartRangeWatcher.
Definition smartrange.cpp:899
virtual QStringList text(bool block=false) const
Retrieve the text which is contained within this range.
Definition smartrange.cpp:641
SmartRange * parentRange() const
Returns this range's parent range, if one exists.
Definition smartrange.h:277
SmartRange(SmartCursor *start, SmartCursor *end, SmartRange *parent=0L, InsertBehaviors insertBehavior=DoNotExpand)
Constructor for subclasses to utilise.
Definition smartrange.cpp:178
void clearAndDeleteChildRanges()
Clears child ranges - i.e., clears the text that is covered by the ranges, and deletes the SmartRange...
Definition smartrange.cpp:582
virtual void setParentRange(SmartRange *r)
Set this range's parent range.
Definition smartrange.cpp:594
virtual void setRange(const Range &range)
Set the start and end cursors to range.start() and range.end() respectively.
Definition smartrange.cpp:232
int overlapCount() const
Returns the count of ranges within the parent-range that end behind this range, and that overlap this...
Definition smartrange.cpp:421
SmartRange * mostSpecificRange(const Range &input) const
Finds the most specific range in a heirachy for the given input range (ie.
Definition smartrange.cpp:363
void addNotifier(SmartRangeNotifier *notifier)
Register a notifier to receive signals indicating change of state of this range.
Definition smartrange.cpp:918
QList< SmartRange * > deepestRangesContaining(const Cursor &pos) const
Definition smartrange.cpp:426
virtual bool replaceText(const QStringList &text, bool block=false)
Replace text in this range with text.
Definition smartrange.cpp:646
void deletePrimaryNotifier()
When finished with the primaryNotifier(), call this method to save memory by having the SmartRangeNot...
Definition smartrange.cpp:932
virtual bool isSmartRange() const
Returns that this range is a SmartRange.
Definition smartrange.cpp:865
SmartRange * deepestRangeContaining(const Cursor &pos, QStack< SmartRange * > *rangesEntered=0L, QStack< SmartRange * > *rangesExited=0L) const
Finds the deepest range in the heirachy which contains position pos.
Definition smartrange.cpp:452
const QList< SmartRangeNotifier * > notifiers() const
Returns a list of notifiers which are receiving signals indicating change of state of this range.
Definition smartrange.cpp:913
SmartRange * childBefore(const SmartRange *range) const
Find the child before range, if any.
Definition smartrange.cpp:249
Document * document() const
Retrieve the document associated with this SmartRange.
Definition smartrange.cpp:523
const QList< SmartRangeWatcher * > & watchers() const
Returns a list of registered SmartRangeWatchers.
Definition smartrange.cpp:886
bool hasParent(SmartRange *parent) const
Determine whether parent is a parent of this range.
Definition smartrange.cpp:875
SmartRangeNotifier * primaryNotifier()
Connect to a notifier to receive signals indicating change of state of this range.
Definition smartrange.cpp:905
InsertBehaviors insertBehavior() const
Returns how this range reacts to characters inserted immediately outside the range.
Definition smartrange.cpp:556
SmartRange * firstRangeContaining(const Cursor &pos) const
Finds the first child range which contains position pos.
Definition smartrange.cpp:402
void clearChildRanges()
Clears child ranges - i.e., removes the text that is covered by the ranges.
Definition smartrange.cpp:567
virtual SmartRange * toSmartRange() const
Returns this range as a SmartRange, if it is one.
Definition smartrange.cpp:870
void clearAssociatedActions()
Clears all associations between KActions and this range.
Definition smartrange.cpp:550
virtual bool removeText(bool block=false)
Remove text contained within this range.
Definition smartrange.cpp:651
void setAttribute(Attribute::Ptr attribute)
Sets the currently active attribute for this range.
Definition smartrange.cpp:620
SmartRange * childAfter(const SmartRange *range) const
Find the child after range, if any.
Definition smartrange.cpp:259
virtual bool expandToRange(const Range &range)
Definition smartrange.cpp:220
void associateAction(KAction *action)
Associate an action with this range.
Definition smartrange.cpp:528
void removeNotifier(SmartRangeNotifier *notifier)
Deregister a notifier and no longer deliver signals indicating change of state of this range.
Definition smartrange.cpp:926
void addWatcher(SmartRangeWatcher *watcher)
Register a SmartRangeWatcher to receive calls indicating change of state of this range.
Definition smartrange.cpp:891
virtual bool confineToRange(const Range &range)
Definition smartrange.cpp:208
void setInsertBehavior(InsertBehaviors behavior)
Determine how the range should react to characters inserted immediately outside the range.
Definition smartrange.cpp:561
virtual SmartRangeNotifier * createNotifier()=0
static bool rangeEndLessThan(const SmartRange *s1, const SmartRange *s2)
Definition smartrange.cpp:656
static int findIndex(const QList< SmartRange * > &ranges, const SmartRange *smartRange, const Range *range)
Finds the index of the given SmartRange in the sorted list using binary search. Uses.
Definition smartrange.cpp:157
static int lowerBound(const QList< SmartRange * > &ranges, const Cursor &pos)
Returns the index of the first range that ends behind pos The list must be sorted by the ranges end-p...
Definition smartrange.cpp:107
static int lowerBoundRange(const QList< SmartRange * > &ranges, const Cursor &pos, const SmartRange *range)
Searches for the given range, or a lower bound for the given position.
Definition smartrange.cpp:130
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 17 2025 00:00:00 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 17 2025 00:00:00 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.