33 inline int anchor()
const {
return anchor_; }
34 inline int caret()
const {
return caret_; }
37 inline int min()
const {
return qMin( caret_, anchor_ ); }
38 inline int max()
const {
return qMax( caret_, anchor_ ); }
41 inline int&
minVar() {
return caret_ < anchor_ ? caret_ : anchor_; }
42 inline int&
maxVar() {
return caret_ < anchor_ ? anchor_: caret_; }
44 inline int length()
const {
return qAbs(caret_ - anchor_ ); }
46 void fixCaretForUnicode(
TextDocument* doc,
int direction );
53 void setLength(
int newLength );
58 void reset() { anchor_ = caret_; }
60 bool isEmpty()
const {
return anchor_==caret_; }
63 QString toString()
const;
66 void moveCaretOrDeselect(
TextDocument* doc,
int amount );
67 int moveWhileChar(
TextDocument* doc,
int pos,
int amount,
const QString& chars );
68 int moveUntilChar(
TextDocument* doc,
int pos,
int amount,
const QString& chars );
69 void moveCaretWhileChar(
TextDocument* doc,
int amount,
const QString& chars );
70 void moveCaretUntilChar(
TextDocument* doc,
int amount,
const QString& chars );
71 void moveAnchortWhileChar(
TextDocument* doc,
int amount,
const QString& chars );
72 void moveAnchorUntilChar(
TextDocument* doc,
int amount,
const QString& chars );
73 void moveCaretByCharGroup(
TextDocument* doc,
int amount,
const QString& whitespace,
const QStringList& characterGroups );
74 void moveCaretToLineBoundary(
TextDocument* doc,
int amount,
const QString& whitespace );
75 void moveCaretToWordBoundaryAtOffset(
TextDocument* doc,
int offset );
76 void moveCaretToLineBoundaryAtOffset(
TextDocument* doc,
int offset );
81 void expandToWord(
TextDocument* doc,
const QString& whitespace,
const QStringList& characterGroups );
82 void expandToIncludeRange(
TextRange& range );
88 bool contains(
int pos );
121 virtual void addRange(
int anchor,
int caret ) = 0;
134 bool rangesAtLine(
int line,
int& firstIndex,
int& lastIndex );
162 void expandToWords(
const QString& whitespace,
const QStringList& characterGroups);
163 void selectWordAt(
int offset ,
const QString& whitespace,
const QStringList& characterGroups);
164 void toggleWordSelectionAt(
int offset,
const QString& whitespace,
const QStringList& characterGroups);
176 void changeSpatial(
int pos,
int length,
int newLength,
bool sticky=
false,
bool performDelete=
false);
178 void setRange(
int anchor,
int caret,
int index = 0 );
212 virtual int rangeCount()
const {
return selectionRanges_.size(); }
214 virtual const TextRange& constRange(
int idx )
const;
215 virtual void addRange(
int anchor,
int caret);
216 virtual void addRange(
const TextRange& range );
217 virtual void removeRange(
int idx);
218 virtual void clear();
219 virtual void toSingleRange();
220 virtual void sortRanges();
224 QVector<TextRange> selectionRanges_;
DynamicTextRangeSet(TextDocument *doc, bool stickyMode=false, bool deleteMode=false, QObject *parent=0)
Constructs the dynamic textrange set with a document.
Definition textrange.cpp:1156
bool deleteMode() const
Returns the current delete mode.
Definition textrange.cpp:1224
void textChanged(edbee::TextBufferChange change, QString oldText=QString())
This method is notified if a change happens to the textbuffer.
Definition textrange.cpp:1231
void setStickyMode(bool mode)
Is the stickymode enabled.
Definition textrange.cpp:1203
bool stickyMode() const
returns the current stickymode
Definition textrange.cpp:1210
void setDeleteMode(bool mode)
Sets the delete mode.
Definition textrange.cpp:1217
This clas represents a text buffer change and is used to pass around between events This is a sharedd...
Definition textbuffer.h:45
This is the base and abstract class of a text document A TextDocument is the model part of the editor...
Definition textdocument.h:42
A single text region A region constists of an anchor and a caret: The anchor defines the 'start' of t...
Definition textrange.h:29
int max() const
Definition textrange.h:38
bool hasSelection() const
Definition textrange.h:59
void clearSelection()
Definition textrange.h:61
TextRange(int anchor=0, int caret=0)
Definition textrange.h:31
int anchor() const
Definition textrange.h:33
int & maxVar()
Definition textrange.h:42
void reset()
Definition textrange.h:58
int length() const
Definition textrange.h:44
int & minVar()
returns the minimal variable reference
Definition textrange.h:41
void setAnchor(int anchor)
Definition textrange.h:49
void set(int anchor, int caret)
Definition textrange.h:56
void setCaret(int caret)
Definition textrange.h:51
int min() const
returns the minimal value
Definition textrange.h:37
int caret() const
Definition textrange.h:34
bool isEmpty() const
Definition textrange.h:60
bool rangesAtLine(int line, int &firstIndex, int &lastIndex)
Returns the range indices that are being used on the given line.
Definition textrange.cpp:521
int rangeIndexAtOffset(int offset)
This method returns the range index at the given offset.
Definition textrange.cpp:456
QString getSelectedTextExpandedToFullLines()
Returns ALL lines that are touched by the selection. This means Full lines are always returned.
Definition textrange.cpp:594
bool rangesBetweenOffsets(int offsetBegin, int offsetEnd, int &firstIndex, int &lastIndex)
returns the range indices that are being overlapped by the given offsetBegin and offsetEnd
Definition textrange.cpp:477
virtual const TextRange & constRange(int idx) const =0
void beginChanges()
This method starts the changes.
Definition textrange.cpp:654
TextRangeSetBase(TextDocument *doc)
Definition textrange.cpp:434
virtual void addRange(int anchor, int caret)=0
void setRange(int anchor, int caret, int index=0)
This method sets the first range item.
Definition textrange.cpp:941
void moveCaretsByCharGroup(int amount, const QString &whitespace, const QStringList &charGroups)
This method moves the carets.
Definition textrange.cpp:840
void endChanges()
Definition textrange.cpp:661
void replaceAll(const TextRangeSetBase &base)
Replaces all ranges with the supplied ranges.
Definition textrange.cpp:562
virtual void toSingleRange()=0
TextDocument * textDocument() const
Returns the associated textdocument.
Definition textrange.cpp:972
virtual void sortRanges()=0
QString rangesAsString() const
This method converts the selection ranges as a string, in the format: anchor>caret,...
Definition textrange.cpp:620
bool equals(TextRangeSetBase &sel)
This method checks if two selections are equal.
Definition textrange.cpp:551
virtual TextRange & range(int idx)=0
TextRange & lastRange()
this method returns the last range
Definition textrange.cpp:441
void expandToFullLines(int amount)
Expands the selection so it selects full lines.
Definition textrange.cpp:758
virtual void addRange(const TextRange &range)=0
virtual ~TextRangeSetBase()
Definition textrange.h:111
QString getSelectedText()
This method returns all selected text For every filled selection range a line is returned.
Definition textrange.cpp:574
bool rangesBetweenOffsetsExlusiveEnd(int offsetBegin, int offsetEnd, int &firstIndex, int &lastIndex)
returns the range indices that are being overlapped by the given offsetBegin and offsetEnd
Definition textrange.cpp:501
void clearSelection()
This method moves all carets to the anchor positions.
Definition textrange.cpp:644
void toggleWordSelectionAt(int offset, const QString &whitespace, const QStringList &characterGroups)
Toggles a word selection at the given location The idea is the following, double-click an empty place...
Definition textrange.cpp:792
virtual void removeRange(int idx)=0
void moveCaretsOrDeselect(int amount)
This method moves the carets or deslects the given character.
Definition textrange.cpp:830
int changing_
A (integer) boolean for handling changes between beginChagnes and endChanges.
Definition textrange.h:193
bool rangesAtLineExclusiveEnd(int line, int &firstIndex, int &lastIndex)
Returns the range indices that are being used on the given line (Excluding the last offset)
Definition textrange.cpp:530
TextDocument * textDocumentRef_
The reference to the textbuffer.
Definition textrange.h:192
virtual void processChangesIfRequired(bool joinBorders=false)
This method process the changes if required.
Definition textrange.cpp:959
void substractRange(int min, int max)
This method substracts a single range from the ranges list.
Definition textrange.cpp:713
void endChangesWithoutProcessing()
Ends the changes without processing. WARNING, you should ONLY call this method if the operation you p...
Definition textrange.cpp:672
void selectWordAt(int offset, const QString &whitespace, const QStringList &characterGroups)
Selects the word at the given offset.
Definition textrange.cpp:780
virtual int rangeCount() const =0
void moveCaretsToLineBoundary(int direction, const QString &whitespace)
Moves all carets to the given line boundary (line-boundary automatically switches between column 0 an...
Definition textrange.cpp:852
TextRange & firstRange()
the first range
Definition textrange.cpp:447
void moveCarets(int amount)
This method moves the carets by character.
Definition textrange.cpp:820
void changeSpatial(int pos, int length, int newLength, bool sticky=false, bool performDelete=false)
This method adds (or removes) the given spatial length at the given location.
Definition textrange.cpp:987
void addTextRanges(const TextRangeSetBase &sel)
An union operation This method adds all text selection-items. Merges all ranges.
Definition textrange.cpp:689
void expandToWords(const QString &whitespace, const QStringList &characterGroups)
Expands the selection to full words.
Definition textrange.cpp:769
bool changing() const
Checks if the current rangeset is in a changing state.
Definition textrange.cpp:680
void substractTextRanges(const TextRangeSetBase &sel)
The difference operation This method substracts the text-selection from the current selection.
Definition textrange.cpp:700
bool hasSelection()
This method checks if there's a selection available A selection is an range with a different anchor t...
Definition textrange.cpp:541
void resetAnchors()
This method resets all anchors to the positions of the carets.
Definition textrange.cpp:635
void mergeOverlappingRanges(bool joinBorders)
This method merges overlapping ranges.
Definition textrange.cpp:864
The basic textrange class. A simple class of textrange with a simple vector implementation.
Definition textrange.h:202
virtual ~TextRangeSet()
Definition textrange.h:207
virtual int rangeCount() const
Definition textrange.h:212
TextRangeSet(TextDocument *doc)
Constructs a textrange set.
Definition textrange.cpp:1043
#define EDBEE_EXPORT
Definition exports.h:15
QT Acessibility has an issue with reporting blank lines between elements lines. defining 'WINDOWS_EMP...
Definition commentcommand.cpp:20