34 inline int anchor()
const {
return anchor_; }
35 inline int caret()
const {
return caret_; }
38 inline int min()
const {
return qMin( caret_, anchor_ ); }
39 inline int max()
const {
return qMax( caret_, anchor_ ); }
42 inline int&
minVar() {
return caret_ < anchor_ ? caret_ : anchor_; }
43 inline int&
maxVar() {
return caret_ < anchor_ ? anchor_: caret_; }
45 inline int length()
const {
return qAbs(caret_ - anchor_ ); }
59 void reset() { anchor_ = caret_; }
61 bool isEmpty()
const {
return anchor_==caret_; }
116 virtual int rangeCount()
const = 0;
118 virtual const TextRange& constRange(
int idx)
const = 0;
119 virtual void addRange(
int anchor,
int caret ) = 0;
120 virtual void addRange(
const TextRange& range ) = 0;
121 virtual void removeRange(
int idx ) = 0;
122 virtual void clear() = 0;
123 virtual void toSingleRange() = 0;
124 virtual void sortRanges() = 0;
129 int rangeIndexAtOffset(
int offset );
130 bool rangesBetweenOffsets(
int offsetBegin,
int offsetEnd,
int& firstIndex,
int& lastIndex );
131 bool rangesBetweenOffsetsExlusiveEnd(
int offsetBegin,
int offsetEnd,
int& firstIndex,
int& lastIndex );
132 bool rangesAtLine(
int line,
int& firstIndex,
int& lastIndex );
138 QString getSelectedText();
139 QString getSelectedTextExpandedToFullLines();
141 QString rangesAsString()
const;
146 void endChangesWithoutProcessing();
147 bool changing()
const;
154 void substractRange(
int min,
int max );
158 void expandToFullLines(
int amount);
159 void expandToWords(
const QString& whitespace,
const QStringList& characterGroups);
160 void selectWordAt(
int offset ,
const QString& whitespace,
const QStringList& characterGroups);
161 void toggleWordSelectionAt(
int offset,
const QString& whitespace,
const QStringList& characterGroups);
164 void moveCarets(
int amount );
165 void moveCaretsOrDeselect(
int amount );
166 void moveCaretsByCharGroup(
int amount,
const QString& whitespace,
const QStringList& charGroups );
167 void moveCaretsToLineBoundary(
int direction,
const QString& whitespace );
168 void moveCaretsByLine(
int amount );
173 void changeSpatial(
int pos,
int length,
int newLength,
bool sticky=
false,
bool performDelete=
false);
175 void setRange(
int anchor,
int caret,
int index = 0 );
176 void setRange(
const TextRange& range ,
int index = 0 );
178 virtual void processChangesIfRequired(
bool joinBorders=
false);
185 void mergeOverlappingRanges(
bool joinBorders );
209 virtual int rangeCount()
const {
return selectionRanges_.size(); }
211 virtual const TextRange& constRange(
int idx )
const;
213 virtual void addRange(
const TextRange& range );
214 virtual void removeRange(
int idx);
215 virtual void clear();
216 virtual void toSingleRange();
217 virtual void sortRanges();
221 QVector<TextRange> selectionRanges_;
247 void setStickyMode(
bool mode );
248 bool stickyMode()
const;
250 void setDeleteMode(
bool mode );
251 bool deleteMode()
const;
This is the base and abstract class of a text document A TextDocument is the model part of the editor...
Definition: textdocument.h:40
This abstract class represents a set of textranges The ranges are kept ordered and will not contain o...
Definition: textrange.h:105
void expandToFullLine(TextDocument *doc, int amount)
Expands the selection range so it only consists of full lines amount specifies the amount (and the di...
Definition: textrange.cpp:253
This clas represents a text buffer change and is used to pass around between events This is a sharedd...
Definition: textbuffer.h:45
void moveCaretOrDeselect(TextDocument *doc, int amount)
move the caret or deselect the given amount
Definition: textrange.cpp:86
void reset()
Definition: textrange.h:59
A smart QObject implemenation of a TextRangeSet which listens to changes in the document. When a change happens it's changes the spatial of the ranges.
Definition: textrange.h:237
void moveCaretByCharGroup(TextDocument *doc, int amount, const QString &whitespace, const QStringList &characterGroups)
This method moves the caret to/from the given seperator.
Definition: textrange.cpp:166
void expandToIncludeRange(TextRange &range)
Definition: textrange.cpp:352
bool isEmpty() const
Definition: textrange.h:61
void moveCaretToLineBoundary(TextDocument *doc, int amount, const QString &whitespace)
This moves the caret to a line boundary.
Definition: textrange.cpp:220
void setAnchorBounded(TextDocument *doc, int anchor)
Sets the anchor to the given location, and forces the anchor to say between the document bounds...
Definition: textrange.cpp:42
void moveCaretWhileChar(TextDocument *doc, int amount, const QString &chars)
moves the caret while a character is moving
Definition: textrange.cpp:141
int max() const
Definition: textrange.h:39
int & maxVar()
Definition: textrange.h:43
TextDocument * textDocumentRef_
The reference to the textbuffer.
Definition: textrange.h:189
int & minVar()
returns the minimal variable reference
Definition: textrange.h:42
void deselectTrailingNewLine(TextDocument *doc)
This method deselects the last character if it's a newline.
Definition: textrange.cpp:299
int changing_
A (integer) boolean for handling changes between beginChagnes and endChanges.
Definition: textrange.h:190
void forceBounds(TextDocument *doc)
Sets the bounds.
Definition: textrange.cpp:361
Copyright 2011-2013 - Reliable Bits Software by Blommers IT.
Definition: commentcommand.cpp:22
int min() const
returns the minimal value
Definition: textrange.h:38
int caret() const
Definition: textrange.h:35
void expandToWord(TextDocument *doc, const QString &whitespace, const QStringList &characterGroups)
Expands the selection to a words.
Definition: textrange.cpp:325
void setAnchor(int anchor)
Definition: textrange.h:50
void moveCaret(TextDocument *doc, int amount)
Moves the caret the given amount.
Definition: textrange.cpp:76
int length() const
Definition: textrange.h:45
bool equals(const TextRange &range)
This method checks if the two ranges are equal.
Definition: textrange.cpp:369
int anchor() const
Definition: textrange.h:34
void setCaretBounded(TextDocument *doc, int caret)
Sets the caret to the given location, and forces the caret to say between the document bounds...
Definition: textrange.cpp:51
bool hasSelection() const
Definition: textrange.h:60
static bool lessThan(TextRange &r1, TextRange &r2)
This method compares selection ranges.
Definition: textrange.cpp:15
virtual ~TextRangeSetBase()
Definition: textrange.h:109
The basic textrange class. A simple class of textrange with a simple vector implementation.
Definition: textrange.h:198
void moveAnchorUntilChar(TextDocument *doc, int amount, const QString &chars)
Definition: textrange.cpp:159
void clearSelection()
Definition: textrange.h:62
virtual int rangeCount() const
Definition: textrange.h:209
void fixCaretForUnicode(TextDocument *doc, int direction)
Makes sure the caret isn't in-between a unicode boundary refs #19 - Dirty hack to improve caret-movem...
Definition: textrange.cpp:23
int moveUntilChar(TextDocument *doc, int pos, int amount, const QString &chars)
This method charactes until the given chargroup is found When moving to the LEFT the cursor is placed...
Definition: textrange.cpp:126
void moveCaretUntilChar(TextDocument *doc, int amount, const QString &chars)
Definition: textrange.cpp:147
bool touches(TextRange &range)
Checks if two ranges touch eachother. Touching means that the start and end of two ranges are onto ea...
Definition: textrange.cpp:377
void moveAnchortWhileChar(TextDocument *doc, int amount, const QString &chars)
Definition: textrange.cpp:153
A single text region A region constists of an anchor and a caret: The anchor defines the 'start' of t...
Definition: textrange.h:29
QString toString() const
This method converts a text-selection range to a string helpfull with debuggin.
Definition: textrange.cpp:67
virtual ~TextRangeSet()
Definition: textrange.h:204
void setLength(int newLength)
Changes the length by modifying the max-variable.
Definition: textrange.cpp:58
TextRange(int anchor=0, int caret=0)
Definition: textrange.h:32
int moveWhileChar(TextDocument *doc, int pos, int amount, const QString &chars)
This method charactes after the given char group When moving to the left the cursor is placed AFTER t...
Definition: textrange.cpp:110
void setCaret(int caret)
Definition: textrange.h:52