edbee - Qt Editor Library
Public Member Functions | Static Public Member Functions | List of all members
edbee::TextRange Class Reference

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>

+ Inheritance diagram for edbee::TextRange:
+ Collaboration diagram for edbee::TextRange:

Public Member Functions

 TextRange (int anchor=0, int caret=0)
 
int anchor () const
 
int caret () const
 
int min () const
 returns the minimal value More...
 
int max () const
 
int & minVar ()
 returns the minimal variable reference More...
 
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. More...
 
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. More...
 
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. More...
 
void setLength (int newLength)
 Changes the length by modifying the max-variable. More...
 
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. More...
 
void moveCaret (TextDocument *doc, int amount)
 Moves the caret the given amount. More...
 
void moveCaretOrDeselect (TextDocument *doc, int amount)
 move the caret or deselect the given amount More...
 
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. More...
 
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. More...
 
void moveCaretWhileChar (TextDocument *doc, int amount, const QString &chars)
 moves the caret while a character is moving More...
 
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. More...
 
void moveCaretToLineBoundary (TextDocument *doc, int amount, const QString &whitespace)
 This moves the caret to a line boundary. More...
 
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. More...
 
void deselectTrailingNewLine (TextDocument *doc)
 This method deselects the last character if it's a newline. More...
 
void expandToWord (TextDocument *doc, const QString &whitespace, const QStringList &characterGroups)
 Expands the selection to a words. More...
 
void expandToIncludeRange (TextRange &range)
 
void forceBounds (TextDocument *doc)
 Sets the bounds. More...
 
bool equals (const TextRange &range)
 This method checks if the two ranges are equal. More...
 
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) More...
 

Static Public Member Functions

static bool lessThan (TextRange &r1, TextRange &r2)
 This method compares selection ranges. More...
 

Detailed Description

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"

Constructor & Destructor Documentation

◆ TextRange()

edbee::TextRange::TextRange ( int  anchor = 0,
int  caret = 0 
)
inline

Member Function Documentation

◆ anchor()

int edbee::TextRange::anchor ( ) const
inline

◆ caret()

int edbee::TextRange::caret ( ) const
inline

◆ clearSelection()

void edbee::TextRange::clearSelection ( )
inline

◆ deselectTrailingNewLine()

void edbee::TextRange::deselectTrailingNewLine ( TextDocument doc)

This method deselects the last character if it's a newline.

◆ equals()

bool edbee::TextRange::equals ( const TextRange range)

This method checks if the two ranges are equal.

Parameters
rangethe range to compare it to

◆ expandToFullLine()

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.

◆ expandToIncludeRange()

void edbee::TextRange::expandToIncludeRange ( TextRange range)

◆ expandToWord()

void edbee::TextRange::expandToWord ( TextDocument doc,
const QString &  whitespace,
const QStringList &  characterGroups 
)

Expands the selection to a words.

◆ fixCaretForUnicode()

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.

◆ forceBounds()

void edbee::TextRange::forceBounds ( TextDocument doc)

Sets the bounds.

◆ hasSelection()

bool edbee::TextRange::hasSelection ( ) const
inline

◆ isEmpty()

bool edbee::TextRange::isEmpty ( ) const
inline

◆ length()

int edbee::TextRange::length ( ) const
inline

◆ lessThan()

bool edbee::TextRange::lessThan ( TextRange r1,
TextRange r2 
)
static

This method compares selection ranges.

◆ max()

int edbee::TextRange::max ( ) const
inline

◆ maxVar()

int& edbee::TextRange::maxVar ( )
inline

◆ min()

int edbee::TextRange::min ( ) const
inline

returns the minimal value

◆ minVar()

int& edbee::TextRange::minVar ( )
inline

returns the minimal variable reference

◆ moveAnchortWhileChar()

void edbee::TextRange::moveAnchortWhileChar ( TextDocument doc,
int  amount,
const QString &  chars 
)

◆ moveAnchorUntilChar()

void edbee::TextRange::moveAnchorUntilChar ( TextDocument doc,
int  amount,
const QString &  chars 
)

◆ moveCaret()

void edbee::TextRange::moveCaret ( TextDocument doc,
int  amount 
)

Moves the caret the given amount.

Parameters
docthe document to move the caret for
amountthe amount to move

◆ moveCaretByCharGroup()

void edbee::TextRange::moveCaretByCharGroup ( TextDocument doc,
int  amount,
const QString &  whitespace,
const QStringList &  characterGroups 
)

This method moves the caret to/from the given seperator.

◆ moveCaretOrDeselect()

void edbee::TextRange::moveCaretOrDeselect ( TextDocument doc,
int  amount 
)

move the caret or deselect the given amount

Parameters
docthe document to move the caret in
amountthe amount to move

◆ moveCaretToLineBoundary()

void edbee::TextRange::moveCaretToLineBoundary ( TextDocument doc,
int  amount,
const QString &  whitespace 
)

This moves the caret to a line boundary.

Parameters
docthe document this range operates on
amountthe direction to move to
am whitespace the characters that need to be interpreted as whitespace

◆ moveCaretUntilChar()

void edbee::TextRange::moveCaretUntilChar ( TextDocument doc,
int  amount,
const QString &  chars 
)

◆ moveCaretWhileChar()

void edbee::TextRange::moveCaretWhileChar ( TextDocument doc,
int  amount,
const QString &  chars 
)

moves the caret while a character is moving

◆ moveUntilChar()

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.

◆ moveWhileChar()

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.

Parameters
docthe text document
varthe initial position
amountthe amount to move

◆ reset()

void edbee::TextRange::reset ( )
inline

◆ set()

void edbee::TextRange::set ( int  anchor,
int  caret 
)
inline

◆ setAnchor()

void edbee::TextRange::setAnchor ( int  anchor)
inline

◆ setAnchorBounded()

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.

Parameters
docdocument to set the anchor for
anchorthe anchor location to set

◆ setCaret()

void edbee::TextRange::setCaret ( int  caret)
inline

◆ setCaretBounded()

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.

Parameters
docthe document (used for checking the document bounds)
caretthe caret position to set

◆ setLength()

void edbee::TextRange::setLength ( int  newLength)

Changes the length by modifying the max-variable.

◆ toString()

QString edbee::TextRange::toString ( ) const

This method converts a text-selection range to a string helpfull with debuggin.

◆ touches()

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)


The documentation for this class was generated from the following files: