edbee - Qt Editor Library
Signals | Public Member Functions | List of all members
edbee::TextBuffer Class Referenceabstract

This class represents the textbuffer of the editor. More...

#include <textbuffer.h>

+ Inheritance diagram for edbee::TextBuffer:
+ Collaboration diagram for edbee::TextBuffer:

Signals

void textAboutToBeChanged (edbee::TextBufferChange change)
 
void textChanged (edbee::TextBufferChange change)
 

Public Member Functions

 TextBuffer (QObject *parent=0)
 The textbuffer constructor. More...
 
virtual int length () const =0
 should return the number of 'characters'. More...
 
virtual QChar charAt (int offset) const =0
 A method for returning a single char. More...
 
virtual QString textPart (int offset, int length) const =0
 return the given text. More...
 
virtual void replaceText (int offset, int length, const QChar *buffer, int bufferLength)=0
 this method should replace the given text And fire a 'text-replaced' signal More...
 
virtual int lineCount ()=0
 this method should return an array with all line offsets. A line offset pointsto the START of a line So it does NOT point to a newline character, but it points to the first character AFTER the newline character More...
 
virtual int lineFromOffset (int offset)=0
 
virtual int offsetFromLine (int line)=0
 
virtual void rawAppendBegin ()=0
 This method starts raw appending. More...
 
virtual void rawAppend (QChar c)=0
 this method should append the given character to the buffer More...
 
virtual void rawAppend (const QChar *data, int dataLength)=0
 This method should raw append the given character string. More...
 
virtual void rawAppendEnd ()=0
 the end raw append method should bring the document in a consistent state and emit the correct "replaceText" signals More...
 
virtual QChar * rawDataPointer ()=0
 This method returns the raw data buffer. WARNING this method CAN be slow because when using a gapvector the gap is moved to the end to make a full buffer Modifying the content of the data will mess up the line-offset-vector and other dependent classes. For reading it's ok :-) More...
 
virtual void replaceText (int offset, int length, const QString &text)
 Replace the given text. More...
 
QString text ()
 Returns the full text as a QString. More...
 
void setText (const QString &text)
 A convenient method for directly filling the textbuffer with the given content. More...
 
virtual int columnFromOffsetAndLine (int offset, int line=-1)
 this method translates the given position to a column number. More...
 
virtual void appendText (const QString &text)
 Appends the given text to the textbuffer. More...
 
virtual int offsetFromLineAndColumn (int line, int col)
 This method returns the offset from the give line and column If the column exceed the number of column the caret is placed just before the newline. More...
 
virtual QString line (int line)
 Returns the line at the given line position. This line INCLUDES the newline character (if it's there) More...
 
virtual QString lineWithoutNewline (int line)
 Returns the line without the newline character. More...
 
virtual int lineLength (int line)
 Returns the length of the given line. Also counting the trailing newline character if present. More...
 
virtual int lineLengthWithoutNewline (int line)
 Returns the length of the given line. Without counting a trailing newline character. More...
 
virtual void replaceText (const TextRange &range, const QString &text)
 replace the texts More...
 
virtual int findCharPos (int offset, int direction, const QString &chars, bool equals)
 See documentation at findCharPosWithinRange. More...
 
virtual int findCharPosWithinRange (int offset, int direction, const QString &chars, bool equals, int beginRange, int endRange)
 This method finds the find the first character position that equals the given char. More...
 
virtual int findCharPosOrClamp (int offset, int direction, const QString &chars, bool equals)
 See documentation at findCharPosWithinRange. This method searches a char position within the given rang (from the given ofset) More...
 
virtual int findCharPosWithinRangeOrClamp (int offset, int direction, const QString &chars, bool equals, int beginRange, int endRange)
 See documentation at findCharPosWithinRange. This method searches a char position within the given rang (from the given ofset) More...
 
virtual QString lineOffsetsAsString ()
 

Detailed Description

This class represents the textbuffer of the editor.

Constructor & Destructor Documentation

◆ TextBuffer()

edbee::TextBuffer::TextBuffer ( QObject *  parent = 0)

The textbuffer constructor.

Member Function Documentation

◆ appendText()

void edbee::TextBuffer::appendText ( const QString &  text)
virtual

Appends the given text to the textbuffer.

Parameters
textthe text to appendf

◆ charAt()

virtual QChar edbee::TextBuffer::charAt ( int  offset) const
pure virtual

A method for returning a single char.

Implemented in edbee::CharTextBuffer.

◆ columnFromOffsetAndLine()

int edbee::TextBuffer::columnFromOffsetAndLine ( int  offset,
int  line = -1 
)
virtual

this method translates the given position to a column number.

Parameters
offsetthe character offset
linethe line index this position is on. (Use this argument for optimization if you already know this)

◆ findCharPos()

int edbee::TextBuffer::findCharPos ( int  offset,
int  direction,
const QString &  chars,
bool  equals 
)
virtual

See documentation at findCharPosWithinRange.

Parameters
offsetthe offset to start searching direction the direction (left < 0, or right > 0 )
charsthe chars to search
equalswhen setting to true if will search for the first given char. When false it will stop when another char is found

◆ findCharPosOrClamp()

int edbee::TextBuffer::findCharPosOrClamp ( int  offset,
int  direction,
const QString &  chars,
bool  equals 
)
virtual

See documentation at findCharPosWithinRange. This method searches a char position within the given rang (from the given ofset)

◆ findCharPosWithinRange()

int edbee::TextBuffer::findCharPosWithinRange ( int  offset,
int  direction,
const QString &  chars,
bool  equals,
int  beginRange,
int  endRange 
)
virtual

This method finds the find the first character position that equals the given char.

Parameters
offsetthe offset to search from. A negative offset means the CURRENT character isn't used
directionthe direction to search. If the direction is multiple. the nth item is returned
charsthe character direction
equalswhen setting to true if will search for the first given char. When false it will stop when another char is found
beginRangethe start of the range to search in
endRangethe end of the range to search in (exclusive)
Returns
the offset of the first character

◆ findCharPosWithinRangeOrClamp()

int edbee::TextBuffer::findCharPosWithinRangeOrClamp ( int  offset,
int  direction,
const QString &  chars,
bool  equals,
int  beginRange,
int  endRange 
)
virtual

See documentation at findCharPosWithinRange. This method searches a char position within the given rang (from the given ofset)

◆ length()

virtual int edbee::TextBuffer::length ( ) const
pure virtual

should return the number of 'characters'.

Implemented in edbee::CharTextBuffer.

◆ line()

QString edbee::TextBuffer::line ( int  line)
virtual

Returns the line at the given line position. This line INCLUDES the newline character (if it's there)

Parameters
linethe line to return

◆ lineCount()

virtual int edbee::TextBuffer::lineCount ( )
pure virtual

this method should return an array with all line offsets. A line offset pointsto the START of a line So it does NOT point to a newline character, but it points to the first character AFTER the newline character

Implemented in edbee::CharTextBuffer.

◆ lineFromOffset()

virtual int edbee::TextBuffer::lineFromOffset ( int  offset)
pure virtual

Implemented in edbee::CharTextBuffer.

◆ lineLength()

int edbee::TextBuffer::lineLength ( int  line)
virtual

Returns the length of the given line. Also counting the trailing newline character if present.

Parameters
linethe line to retrieve the length for
Returns
the length of the given line

◆ lineLengthWithoutNewline()

int edbee::TextBuffer::lineLengthWithoutNewline ( int  line)
virtual

Returns the length of the given line. Without counting a trailing newline character.

Parameters
linethe line to retrieve the length for
Returns
the length of the given line

◆ lineOffsetsAsString()

QString edbee::TextBuffer::lineOffsetsAsString ( )
virtual

◆ lineWithoutNewline()

QString edbee::TextBuffer::lineWithoutNewline ( int  line)
virtual

Returns the line without the newline character.

◆ offsetFromLine()

virtual int edbee::TextBuffer::offsetFromLine ( int  line)
pure virtual

Implemented in edbee::CharTextBuffer.

◆ offsetFromLineAndColumn()

int edbee::TextBuffer::offsetFromLineAndColumn ( int  line,
int  col 
)
virtual

This method returns the offset from the give line and column If the column exceed the number of column the caret is placed just before the newline.

◆ rawAppend() [1/2]

virtual void edbee::TextBuffer::rawAppend ( QChar  c)
pure virtual

this method should append the given character to the buffer

Implemented in edbee::CharTextBuffer.

◆ rawAppend() [2/2]

virtual void edbee::TextBuffer::rawAppend ( const QChar *  data,
int  dataLength 
)
pure virtual

This method should raw append the given character string.

Implemented in edbee::CharTextBuffer.

◆ rawAppendBegin()

virtual void edbee::TextBuffer::rawAppendBegin ( )
pure virtual

This method starts raw appending.

Implemented in edbee::CharTextBuffer.

◆ rawAppendEnd()

virtual void edbee::TextBuffer::rawAppendEnd ( )
pure virtual

the end raw append method should bring the document in a consistent state and emit the correct "replaceText" signals

WARNING the textAboutToBeReplaced signals are given but at that moment the text is already replaced And the newlines are already added to the newline list!

Implemented in edbee::CharTextBuffer.

◆ rawDataPointer()

virtual QChar* edbee::TextBuffer::rawDataPointer ( )
pure virtual

This method returns the raw data buffer. WARNING this method CAN be slow because when using a gapvector the gap is moved to the end to make a full buffer Modifying the content of the data will mess up the line-offset-vector and other dependent classes. For reading it's ok :-)

Implemented in edbee::CharTextBuffer.

◆ replaceText() [1/3]

virtual void edbee::TextBuffer::replaceText ( int  offset,
int  length,
const QChar *  buffer,
int  bufferLength 
)
pure virtual

this method should replace the given text And fire a 'text-replaced' signal

Implemented in edbee::CharTextBuffer.

◆ replaceText() [2/3]

void edbee::TextBuffer::replaceText ( int  offset,
int  length,
const QString &  text 
)
virtual

Replace the given text.

Replaces the given text.

Parameters
offsetthe offset to replace
lengththe of the text to replace
textthe new text to insert

◆ replaceText() [3/3]

void edbee::TextBuffer::replaceText ( const TextRange range,
const QString &  text 
)
virtual

replace the texts

Parameters
rangethe range to replace
textthe text to insert at the given location

◆ setText()

void edbee::TextBuffer::setText ( const QString &  text)

A convenient method for directly filling the textbuffer with the given content.

◆ text()

QString edbee::TextBuffer::text ( )

Returns the full text as a QString.

◆ textAboutToBeChanged

void edbee::TextBuffer::textAboutToBeChanged ( edbee::TextBufferChange  change)
signal

◆ textChanged

void edbee::TextBuffer::textChanged ( edbee::TextBufferChange  change)
signal

◆ textPart()

virtual QString edbee::TextBuffer::textPart ( int  offset,
int  length 
) const
pure virtual

return the given text.

Implemented in edbee::CharTextBuffer.


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