A single text region A region constists of an anchor and a caret: The anchor defines the 'start' of the range. Then caret the end. More...
#include <textrange.h>
Public Member Functions | |
TextRange (int anchor=0, int caret=0) | |
int | anchor () const |
int | caret () const |
int | min () const |
returns the minimal value | |
int | max () const |
int & | minVar () |
returns the minimal variable reference | |
int & | maxVar () |
int | length () const |
void | fixCaretForUnicode (TextDocument *doc, int direction) |
Makes sure the caret isn't in-between a unicode boundary refs #19 - Dirty hack to improve caret-movement by skipping non-BMP characters. | |
void | setAnchor (int anchor) |
void | setAnchorBounded (TextDocument *doc, int anchor) |
Sets the anchor to the given location, and forces the anchor to say between the document bounds. | |
void | setCaret (int caret) |
void | setCaretBounded (TextDocument *doc, int caret) |
Sets the caret to the given location, and forces the caret to say between the document bounds. | |
void | setLength (int newLength) |
Changes the length by modifying the max-variable. | |
void | set (int anchor, int caret) |
void | reset () |
bool | hasSelection () const |
bool | isEmpty () const |
void | clearSelection () |
QString | toString () const |
This method converts a text-selection range to a string helpfull with debuggin. | |
void | moveCaret (TextDocument *doc, int amount) |
Moves the caret the given amount. | |
void | moveCaretOrDeselect (TextDocument *doc, int amount) |
move the caret or deselect the given amount | |
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 the last character. | |
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 AFTER the found character. | |
void | moveCaretWhileChar (TextDocument *doc, int amount, const QString &chars) |
moves the caret while a character is moving | |
void | moveCaretUntilChar (TextDocument *doc, int amount, const QString &chars) |
void | moveAnchortWhileChar (TextDocument *doc, int amount, const QString &chars) |
void | moveAnchorUntilChar (TextDocument *doc, int amount, const QString &chars) |
void | moveCaretByCharGroup (TextDocument *doc, int amount, const QString &whitespace, const QStringList &characterGroups) |
This method moves the caret to/from the given seperator. | |
void | moveCaretToLineBoundary (TextDocument *doc, int amount, const QString &whitespace) |
This moves the caret to a line boundary. | |
void | moveCaretToWordBoundaryAtOffset (TextDocument *doc, int offset) |
Moves the caret to a word boundary (used for word dragging selections) | |
void | moveCaretToLineBoundaryAtOffset (TextDocument *doc, int offset) |
Moves the caret to a word boundary (used for word dragging selections) | |
void | expandToFullLine (TextDocument *doc, int amount) |
Expands the selection range so it only consists of full lines amount specifies the amount (and the direction) of the expansions -1 means expand lines to top (and add extra lines) 1 means expand lines at the bottom (and add extras lines) 0 is a special case, it moves the caret to the start of the current line and expands to the end of the line. It does not add lines. | |
void | deselectTrailingNewLine (TextDocument *doc) |
This method deselects the last character if it's a newline. | |
void | expandToWord (TextDocument *doc, const QString &whitespace, const QStringList &characterGroups) |
Expands the selection to a words. | |
void | expandToIncludeRange (TextRange &range) |
void | forceBounds (TextDocument *doc) |
Sets the bounds. | |
bool | equals (const TextRange &range) |
This method checks if the two ranges are equal. | |
bool | touches (TextRange &range) |
Checks if two ranges touch eachother. Touching means that the start and end of two ranges are onto eachother Possible situations ( [ = anchor, > = caret, ( = don't care ) (A)(B) or (B)(A) | |
bool | contains (int pos) |
checks if the given position is in this textrange | |
Static Public Member Functions | |
static bool | lessThan (TextRange &r1, TextRange &r2) |
This method compares selection ranges. | |
A single text region A region constists of an anchor and a caret: The anchor defines the 'start' of the range. Then caret the end.
Some definitions:
samples ( [ = anchor, > = caret ) a[>bcdef (anchor=1, caret=1) => "" a[b>cdef (anchor=1, caret=2) => "b" a<b]cdef (anchor=2, caret=1) => "b"
|
inline |
|
inline |
|
inline |
|
inline |
bool edbee::TextRange::contains | ( | int | pos | ) |
checks if the given position is in this textrange
void edbee::TextRange::deselectTrailingNewLine | ( | TextDocument * | doc | ) |
This method deselects the last character if it's a newline.
bool edbee::TextRange::equals | ( | const TextRange & | range | ) |
This method checks if the two ranges are equal.
range | the range to compare it to |
void edbee::TextRange::expandToFullLine | ( | TextDocument * | doc, |
int | amount ) |
Expands the selection range so it only consists of full lines amount specifies the amount (and the direction) of the expansions -1 means expand lines to top (and add extra lines) 1 means expand lines at the bottom (and add extras lines) 0 is a special case, it moves the caret to the start of the current line and expands to the end of the line. It does not add lines.
void edbee::TextRange::expandToIncludeRange | ( | TextRange & | range | ) |
void edbee::TextRange::expandToWord | ( | TextDocument * | doc, |
const QString & | whitespace, | ||
const QStringList & | characterGroups ) |
Expands the selection to a words.
void edbee::TextRange::fixCaretForUnicode | ( | TextDocument * | doc, |
int | direction ) |
Makes sure the caret isn't in-between a unicode boundary refs #19 - Dirty hack to improve caret-movement by skipping non-BMP characters.
void edbee::TextRange::forceBounds | ( | TextDocument * | doc | ) |
Sets the bounds.
|
inline |
|
inline |
|
inline |
This method compares selection ranges.
|
inline |
|
inline |
|
inline |
returns the minimal value
|
inline |
returns the minimal variable reference
void edbee::TextRange::moveAnchortWhileChar | ( | TextDocument * | doc, |
int | amount, | ||
const QString & | chars ) |
void edbee::TextRange::moveAnchorUntilChar | ( | TextDocument * | doc, |
int | amount, | ||
const QString & | chars ) |
void edbee::TextRange::moveCaret | ( | TextDocument * | doc, |
int | amount ) |
Moves the caret the given amount.
doc | the document to move the caret for |
amount | the amount to move |
void edbee::TextRange::moveCaretByCharGroup | ( | TextDocument * | doc, |
int | amount, | ||
const QString & | whitespace, | ||
const QStringList & | characterGroups ) |
This method moves the caret to/from the given seperator.
void edbee::TextRange::moveCaretOrDeselect | ( | TextDocument * | doc, |
int | amount ) |
move the caret or deselect the given amount
doc | the document to move the caret in |
amount | the amount to move |
void edbee::TextRange::moveCaretToLineBoundary | ( | TextDocument * | doc, |
int | amount, | ||
const QString & | whitespace ) |
This moves the caret to a line boundary.
doc | the document this range operates on |
amount | the direction to move to |
void edbee::TextRange::moveCaretToLineBoundaryAtOffset | ( | TextDocument * | doc, |
int | offset ) |
Moves the caret to a word boundary (used for word dragging selections)
void edbee::TextRange::moveCaretToWordBoundaryAtOffset | ( | TextDocument * | doc, |
int | offset ) |
Moves the caret to a word boundary (used for word dragging selections)
void edbee::TextRange::moveCaretUntilChar | ( | TextDocument * | doc, |
int | amount, | ||
const QString & | chars ) |
void edbee::TextRange::moveCaretWhileChar | ( | TextDocument * | doc, |
int | amount, | ||
const QString & | chars ) |
moves the caret while a character is moving
int edbee::TextRange::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 AFTER the found character.
int edbee::TextRange::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 the last character.
doc | the text document |
var | the initial position |
amount | the amount to move |
|
inline |
|
inline |
|
inline |
void edbee::TextRange::setAnchorBounded | ( | TextDocument * | doc, |
int | anchor ) |
Sets the anchor to the given location, and forces the anchor to say between the document bounds.
doc | document to set the anchor for |
anchor | the anchor location to set |
|
inline |
void edbee::TextRange::setCaretBounded | ( | TextDocument * | doc, |
int | caret ) |
Sets the caret to the given location, and forces the caret to say between the document bounds.
doc | the document (used for checking the document bounds) |
caret | the caret position to set |
void edbee::TextRange::setLength | ( | int | newLength | ) |
Changes the length by modifying the max-variable.
QString edbee::TextRange::toString | ( | ) | const |
This method converts a text-selection range to a string helpfull with debuggin.
bool edbee::TextRange::touches | ( | TextRange & | range | ) |
Checks if two ranges touch eachother. Touching means that the start and end of two ranges are onto eachother Possible situations ( [ = anchor, > = caret, ( = don't care ) (A)(B) or (B)(A)