SECEditBlockBuffer Class

class SECEditBlockBuffer: public ISECEditBuffer, public CTypedPtrArray<CObArray, SECEditBufferArray*>

The SECEditBlockBuffer class implements the ISECEditBuffer interface, through which the SECEdit model interacts with the actual text data. This allows greater flexibility for providing different implementations for managing the actual text data without having to make changes to the model itself.
The current implementation is that the entire text buffer is maintained in a single blcok. Soon this implementation will change such that it will utilize an array of SECEditBufferArray objects, each containing a portion of the text data.

Defined in: SECEditBlockBuffer.h

See Also

ISECEditBuffer SECEdit SECEditBufferArray

Class Members

Creation / initialization

EDIT_API SECEditBlockBuffer()

Constructor.

Array methods

EDIT_API virtual SECEditBufferArray*& ElementAt(int nIndex)

Retrieves the specified element.

EDIT_API virtual SECEditBufferArray*& operator[](int nIndex)

Retrieves the element at the given index.

EDIT_API virtual SECEditBufferArray* operator[](int nIndex) const

Retrieves the element at the given index.

EDIT_API virtual SECEditBufferArray* GetAt(int nIndex) const

Retrieves the element at the given index.

ISECEditBuffer implemtation

EDIT_API virtual BOOL Insert(SECEditLineColPair& lcpInsertBlock, LPCTSTR lpszText, int nLength = -1)

Insert Text into the buffer

EDIT_API virtual BOOL ClearTextBlock(const SECEditLineColPair& lcpDeleteBlock)

Delete the text within the specified block.

EDIT_API virtual int GetLineCount()

Gets the count of lines in this text buffer.

EDIT_API virtual int GetLineLength(int nLine)

Gets the length of the given line, including line end characters.

EDIT_API virtual int GetLineVisibleLength(int nLine)

Gets the visible length of this line.

EDIT_API virtual void SetLineEnd(TCHAR chLineEnd)

Sets the line end character.

EDIT_API virtual TCHAR GetLineEnd()

Gets the line end character.

EDIT_API virtual TCHAR GetLineBreakChar()

Gets the line break character.

EDIT_API virtual void SetLineBreakChar(TCHAR chLineBreak)

Sets the line break character.

EDIT_API virtual int GetTextBlock(LPCTSTR& lpszBlock, int nStartLine, int nStartCol = 0, int nEndLine = -1, int nEndCol = -1)

Retrieves a block of text from the text buffer.

EDIT_API virtual BOOL GetTextBlock(CString& strBlock, int nStartLine, int nStartCol = 0, int nEndLine = -1, int nEndCol = -1)

Retrieves a block of text from the text buffer.

EDIT_API virtual BOOL Init()

Initializes the text buffer.

EDIT_API virtual int FindText(int nLine, int nCol, int& nResultLine, int& nResultCol, LPCTSTR lpszText, BOOL bDown, BOOL bWrapAround, BOOL bMatchCase, BOOL bMatchWholeWord, BOOL bRegularExpression, int nStopLine = -1, int nStopCol = -1)

Finds the given text in the text buffer.

EDIT_API virtual int LineIndex(int nLine, int nCol = 0)

Converts a line and column position into an index.

EDIT_API virtual BOOL LineColFromChar(int nIndex, int& nLine, int& nCol)

Converts an index position into line and column.

EDIT_API virtual void Write(CFile* pFile, BOOL bSaveAsUnicodeText = FALSE)

Writes the buffer to a file.

Implementation

EDIT_API int CountLineEndsInBuffer(LPCTSTR lpszText, int nLength, int* pLastLineLength = NULL)

Counts the number of line ends in the current buffer.

EDIT_API virtual int GetBufferNo(int nOffset, BOOL bKeepBeforeLineEnd = FALSE)

Returns the buffer index for a given offset.

EDIT_API LPTSTR GetData(int nOffset)

Retrieves the line data for the line at the given virtual offset.

EDIT_API int GetLastLine()

Retrieves virtual offset of the last line in the buffer.

EDIT_API int GetLineCol(int nOffset, int* pCol = NULL)

Returns the column index for a given offset.

EDIT_API int IsLineColValid(int nLine, int nCol)

Checks the validity of the given line and column indices.

EDIT_API virtual void NotifyBufferArrayChanged(int nBuffer)

Signals the virtual offsets for element(s) in the buffer array have changed.

EDIT_API virtual BOOL WholeWord(int nOffset, int nLength)

Checks the text at the given offset and length for a whole word.

EDIT_API virtual void WriteToFile(CFile* pFile, int nOffset, int nBytes, BOOL bSaveAsUnicodeText)

Helper method for writing a segment of the buffer to a file.

CArray<_LineInfo, _LineInfo> m_LineStartArray

Array of the virtual offsets for the start of each line.

int m_nTopInvalidLine

Line number of the topmost known buffer line not yet validated.

int m_nTopInvalidBuffer

Array buffer index of the most topmost known buffer not yet validated.

int m_nMaxBufferSize

The maximum size in bytes of each element in the buffer array.

int m_nLineCount

The current line count.

TCHAR m_chLineEnd

Character used to delineate the line ends in the text buffer.

TCHAR m_chLineBreak

The line break character for the text buffer.

int m_nMaxLineLength

The maximum length a line can attain.