KTextEditor
smartrange.cpp
Go to the documentation of this file.
130 static int lowerBoundRange(const QList<SmartRange*>& ranges, const Cursor& pos, const SmartRange* range)
157 static int findIndex(const QList<SmartRange*>& ranges, const SmartRange* smartRange, const Range* range) {
178 SmartRange::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
452 SmartRange * SmartRange::deepestRangeContaining( const Cursor & pos, QStack<SmartRange*>* rangesEntered, QStack<SmartRange*>* rangesExited ) const
469 SmartRange * 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);
678 //range.end() <= start(), The range does not overlap, and the same applies for all earlier ranges
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
789 //range.end() <= start(), The range does not overlap, and the same applies for all earlier ranges
void clear()
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
SmartRange * childAfter(const SmartRange *range) const
Find the child after range, if any.
Definition: smartrange.cpp:259
bool hasParent(SmartRange *parent) const
Determine whether parent is a parent of this range.
Definition: smartrange.cpp:875
virtual void parentRangeChanged(SmartRange *range, SmartRange *newParent, SmartRange *oldParent)
The range's parent was changed.
Definition: rangefeedback.cpp:106
void parentRangeChanged(KTextEditor::SmartRange *range, KTextEditor::SmartRange *newParent, KTextEditor::SmartRange *oldParent)
The range's parent was changed.
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
virtual void setParentRange(SmartRange *r)
Set this range's parent range.
Definition: smartrange.cpp:594
void append(const T &value)
InsertBehavior insertBehavior() const
Returns how this cursor behaves when text is inserted at the cursor.
Definition: smartcursor.cpp:78
virtual bool confineToRange(const Range &range)
Definition: smartrange.cpp:208
void push(const T &t)
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
void childRangeInserted(KTextEditor::SmartRange *range, KTextEditor::SmartRange *child)
The range child was inserted as a child range into the current range.
void rebuildChildStructure()
Is called after child-ranges have changed internally without the rangeChanged() notification, for example after translations.
Definition: smartrange.cpp:660
A Range which is bound to a specific Document, and maintains its position.
Definition: smartrange.h:94
void rangeAttributeChanged(KTextEditor::SmartRange *range, KTextEditor::Attribute::Ptr currentAttribute, KTextEditor::Attribute::Ptr previousAttribute)
The highlighting attribute of range was changed from previousAttribute to currentAttribute.
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 confineToRange(const Range &range)
Confine this range if necessary to fit within range.
Definition: range.cpp:192
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
int size() const
Expand to encapsulate new characters to the right of the range.
Definition: smartrange.h:106
void deletePrimaryNotifier()
When finished with the primaryNotifier(), call this method to save memory by having the SmartRangeNot...
Definition: smartrange.cpp:932
void dissociateAction(KAction *action)
Remove the association with an action from this range; it will no longer be managed.
Definition: smartrange.cpp:543
int indexOf(const T &value, int from) const
void associateAction(KAction *action)
Associate an action with this range.
Definition: smartrange.cpp:528
int count(const T &value) const
void append(const T &value)
void rangeContentsChanged(KTextEditor::SmartRange *range)
The contents of the range changed.
Attribute::Ptr attribute() const
Gets the active Attribute for this range.
Definition: smartrange.cpp:636
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 expandToRange(const Range &range)
Definition: smartrange.cpp:220
virtual void setRange(const Range &range)
Set the start and end cursors to range.start() and range.end() respectively.
Definition: smartrange.cpp:232
virtual bool removeText(const Range &range, bool block=false)=0
Remove the text specified in range.
virtual void rangeChanged(Cursor *cursor, const Range &from)
Definition: smartrange.cpp:687
A KParts derived class representing a text document.
Definition: document.h:111
void setAttribute(Attribute::Ptr attribute)
Sets the currently active attribute for this range.
Definition: smartrange.cpp:620
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
const QList< SmartRangeWatcher * > & watchers() const
Returns a list of registered SmartRangeWatchers.
Definition: smartrange.cpp:886
bool isEmpty() const
int removeAll(const T &value)
virtual void childRangeInserted(SmartRange *range, SmartRange *child)
The range child was inserted as a child range into the current range.
Definition: rangefeedback.cpp:94
A Cursor which is bound to a specific Document, and maintains its position.
Definition: smartcursor.h:65
virtual bool replaceText(const QStringList &text, bool block=false)
Replace text in this range with text.
Definition: smartrange.cpp:646
virtual SmartRangeNotifier * createNotifier()=0
virtual bool isSmartRange() const
Returns that this range is a SmartRange.
Definition: smartrange.cpp:865
void removeWatcher(SmartRangeWatcher *watcher)
Stop delivery of notifications to a SmartRangeWatcher.
Definition: smartrange.cpp:899
SmartRange * childBefore(const SmartRange *range) const
Find the child before range, if any.
Definition: smartrange.cpp:249
static bool rangeEndLessThan(const SmartRange *s1, const SmartRange *s2)
Definition: smartrange.cpp:656
Expand to encapsulate new characters to the left of the range.
Definition: smartrange.h:104
virtual QStringList text(bool block=false) const
Retrieve the text which is contained within this range.
Definition: smartrange.cpp:641
virtual void rangeEliminated(SmartRange *range)
The range now contains no characters (ie.
Definition: rangefeedback.cpp:86
An object representing a section of text, from one Cursor to another.
Definition: range.h:54
InsertBehaviors insertBehavior() const
Returns how this range reacts to characters inserted immediately outside the range.
Definition: smartrange.cpp:556
QList< SmartRange * > deepestRangesContaining(const Cursor &pos) const
Definition: smartrange.cpp:426
iterator end()
SmartRange(SmartCursor *start, SmartCursor *end, SmartRange *parent=0L, InsertBehaviors insertBehavior=DoNotExpand)
Constructor for subclasses to utilise.
Definition: smartrange.cpp:178
virtual bool expandToRange(const Range &range)
Expand this range if necessary to contain range.
Definition: range.cpp:207
bool wantsDirectChanges() const
Returns whether this watcher will be notified of changes that happen directly to the range...
Definition: rangefeedback.cpp:48
A class which provides notifications of state changes to a SmartRange via virtual inheritance...
Definition: smartrangewatcher.h:50
A class which provides notifications of state changes to a SmartRange via QObject signals...
Definition: smartrangenotifier.h:48
SmartRangeNotifier * primaryNotifier()
Connect to a notifier to receive signals indicating change of state of this range.
Definition: smartrange.cpp:905
bool isEmpty() const
virtual void rangeContentsChanged(SmartRange *range)
The contents of the range changed.
Definition: rangefeedback.cpp:62
bool wantsDirectChanges() const
Returns whether this notifier will notify of changes that happen directly to the range, e.g.
Definition: rangefeedback.cpp:33
void rangeEliminated(KTextEditor::SmartRange *range)
The range now contains no characters (ie.
const QList< SmartRange * > & childRanges() const
Get the ordered list of child ranges.
Definition: smartrange.cpp:244
void rangePositionChanged(KTextEditor::SmartRange *range)
The range's position changed.
SmartRange * mostSpecificRange(const Range &input) const
Finds the most specific range in a heirachy for the given input range (ie.
Definition: smartrange.cpp:363
virtual SmartRange * toSmartRange() const
Returns this range as a SmartRange, if it is one.
Definition: smartrange.cpp:870
void addWatcher(SmartRangeWatcher *watcher)
Register a SmartRangeWatcher to receive calls indicating change of state of this range.
Definition: smartrange.cpp:891
void deleteChildRanges()
Deletes child ranges - i.e., deletes the SmartRange objects only.
Definition: smartrange.cpp:573
void addNotifier(SmartRangeNotifier *notifier)
Register a notifier to receive signals indicating change of state of this range.
Definition: smartrange.cpp:918
bool contains(const Range &range) const
Check whether the this range wholly encompasses range.
Definition: range.cpp:160
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
void removeNotifier(SmartRangeNotifier *notifier)
Deregister a notifier and no longer deliver signals indicating change of state of this range...
Definition: smartrange.cpp:926
A text widget with KXMLGUIClient that represents a Document.
Definition: view.h:145
Document * document() const
Retrieve the document associated with this SmartRange.
Definition: smartrange.cpp:523
SmartRange * firstRangeContaining(const Cursor &pos) const
Finds the first child range which contains position pos.
Definition: smartrange.cpp:402
void setInsertBehavior(InsertBehaviors behavior)
Determine how the range should react to characters inserted immediately outside the range...
Definition: smartrange.cpp:561
virtual bool removeText(bool block=false)
Remove text contained within this range.
Definition: smartrange.cpp:651
const KShortcut & end()
virtual QStringList textLines(const Range &range, bool block=false) const =0
Get the document content within the given range.
SmartRange * parentRange() const
Returns this range's parent range, if one exists.
Definition: smartrange.h:277
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 rangePositionChanged(SmartRange *range)
The range's position changed.
Definition: rangefeedback.cpp:58
virtual bool replaceText(const Range &range, const QString &text, bool block=false)
Replace text from range with specified text.
Definition: document.cpp:179
void setEnabled(bool)
Don't expand to encapsulate new characters in either direction. This is the default.
Definition: smartrange.h:102
Document * document() const
Returns the document to which this cursor is attached.
Definition: smartcursor.cpp:68
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
void clearChildRanges()
Clears child ranges - i.e., removes the text that is covered by the ranges.
Definition: smartrange.cpp:567
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
const KShortcut & begin()
void clearAssociatedActions()
Clears all associations between KActions and this range.
Definition: smartrange.cpp:550
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:27:17 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:27:17 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.