SECEdit Class

class SECEdit: public MvcTransactionModel, public CObject

The SECEdit class represents the data model which is manipulated by the controller class (SECEditController) and observed by the viewport class (SECEditViewport, a parent class of both SECEditCtrl and SECEditView). Because this class derives from MvcTransactionModel, it is capable of undo and redo operations.

Actually, the text itself is not stored in the SECEdit model, but is stored in SECEditBuffer, which implements the ISECEditBuffer interface.

SECEditCtrl objects contain a SECEdit model, whereas SECEditView objects simply reference a SECEdit model through a pointer (since multiple views may refer to the same model).

Defined in: SECEdit.h

See Also

SECEditController SECEditBlockBuffer SECEditViewport SECEditCtrl SECEditView

Class Members

Creation/Initialization

EDIT_API SECEdit()

Default Constructor.

EDIT_API virtual BOOL Init()

Initializes the SECEdit model.

EDIT_API virtual BOOL Init(LPCTSTR lpszLanguage)

Initializes the SECEdit model.

EDIT_API virtual ~SECEdit()

Default Destructor

Syntax Coloring and Language

EDIT_API virtual BOOL Configure()

Invokes the language configuration dialog for the current language.

EDIT_API virtual ISECEditLangConfig* GetLangPtr() const

Get the language pointer for this model

EDIT_API virtual void SetLangPtr(ISECEditLangConfig* pILangConfig)

Explicitly set the language for this model

EDIT_API CString GetLangId() const

Returns a string with the language this model is using

EDIT_API virtual BOOL SetLanguage(LPCTSTR lpszLanguage)

Set the language by name for this model

EDIT_API BOOL GetSyntaxColoring() const

Indicates if syntax coloring is enabled for this model

EDIT_API void SetSyntaxColoring(BOOL bEnabled)

Sets the status of syntax coloring for this model

EDIT_API virtual SECEditFontInfo* GetFontInfo()

Retrieves the font info manager object.

EDIT_API virtual void SetFontInfo(SECEditFontInfo* pFontInfo)

Sets the font info manager object.

EDIT_API virtual SECEditLineColor* GetLineColor(int nLine)

Retrieves the color of the text on the given line.

EDIT_API virtual SECEditLineColor* SetLineColor(int nLine, int nStartCol = 0)

Sets the line color for the given line.

EDIT_API virtual SECEditFontInfo* GetNewFontInfo()

Creates the font info manager object.

EDIT_API virtual int ColorToken(int nLine, LPCTSTR lpszLine, LPCTSTR lpszToken, int nTokenLength, int nLength, unsigned short& nWhiteLength, SECEditLineColor* pLineColor)

Sets the syntax coloring for the token given

EDIT_API virtual int ColorKeyword(int nLine, LPCTSTR lpszLine, LPCTSTR lpszToken, int nTokenLength, int nLength, unsigned short& nWhiteLength, SECEditLineColor* pLineColor)

Sets the syntax coloring for the keyword given

EDIT_API virtual int ColorTokenKw(int nLine, LPCTSTR lpszLine, LPCTSTR lpszToken, int nTokenLength, int nLength, unsigned short& nWhiteLength, SECEditLineColor* pLineColor)

Sets the syntax coloring for the token keyword given

EDIT_API virtual int ColorOperatorKw(int nLine, LPCTSTR lpszLine, LPCTSTR lpszToken, int nTokenLength, int nLength, unsigned short& nWhiteLength, SECEditLineColor* pLineColor)

Sets the syntax coloring for the operator given

EDIT_API virtual SECEditKeywordInfo* IsTokenKw(int nLine, LPCTSTR lpszLine, LPCTSTR lpszToken, int nTokenLength, int nLength, SECEditKeywordType keytype/* = secKT_All */) const

Determines of the token passed begins a token keyword

EDIT_API virtual int ColorTokenKwML(int nLine, LPCTSTR lpszLine, LPCTSTR lpszToken, int nLength, SECEditLineColor* pLineColor, SECEditKeywordInfo* pInfo)

Sets the syntax coloring for the multiline token keyword passed

EDIT_API virtual int ColorTokenKwSL(int nLine, LPCTSTR lpszLine, LPCTSTR lpszToken, int nLength, SECEditLineColor* pLineColor, SECEditKeywordInfo* pInfo)

Sets the syntax coloring for the single line token keyword passed

EDIT_API virtual void FillWhiteLength(SECEditLineColor* pLineColor, unsigned short& nWhiteLength)

Sets the syntax coloring for the block of non colored text prior to a colored block

EDIT_API virtual SECEditLineCol FindTokenKwEnd(SECEditLineCol lcStart, SECEditKeywordInfo* pInfo) const

Finds the end of the token keyword passed

EDIT_API void ResetKeywordColoringCache()

Clears the syntax coloring cache and causes visible lines to be recolored

EDIT_API LPCTSTR EndKeyword(LPCTSTR lpszText, int nLength) const

Parses for the end of a keyword.

EDIT_API virtual int IsKeyword(LPCTSTR lpszKeyword, int nKeywordLength, unsigned short& nOffset) const

Compares given string to the list of keywords.

EDIT_API virtual BOOL FindSLComment(int nLine, int& nStartCol, int& nEndCol) const

Searches for the given single line keyword (e.g., comments, quotes, and operators).

EDIT_API virtual BOOL IsLineColInSLComment(const SECEditLineCol& lc, int* pStartCol = NULL, int* pEndCol = NULL) const

Tests whether the given text position is located in a single line comment.

EDIT_API BOOL ColorMLComments(const SECEditLineColPair& lcpBlock)

Colors all Multiline keywords in lcpBlock.

Text Document

EDIT_API virtual ISECEditBuffer* GetNewEditBuffer()

Creates the edit buffer containing the text for the model.

EDIT_API BOOL IsModified() const

Tests the model for the modified state.

EDIT_API virtual void SetModified(BOOL bModified = TRUE)

Sets the modified state of the model.

EDIT_API BOOL GetOverStrike() const

Tests the overstrike state.

EDIT_API void SetOverStrike(BOOL bOverStrike)

Sets or clears the overstrike state.

EDIT_API virtual BOOL GetReadOnly() const

Tests the read-only state.

EDIT_API void SetReadOnly(BOOL bReadOnly = TRUE)

Sets the read-only state.

EDIT_API unsigned char GetDefaultCharset() const

Returns the default character set in use by this model

EDIT_API SECEditLineCol GetDocEnd() const

Returns a SECEditLineCol just after the last character in the document

EDIT_API CString GetLineBreakChar() const

Retrieves the linebreak character if one exists.

EDIT_API virtual TCHAR GetWhitespaceChar(BOOL bTabChar = FALSE) const

Retrieves a visible character that represents white space.

BOOL m_bForceLineLengthValid

Set to TRUE for transient operations in which line length validation should not be performed

EDIT_API virtual void Serialize(CArchive& ar)

Serializes the Text and the Language name of this SECEdit

EDIT_API virtual void SerializeText(CArchive& ar)

Serializes the text only of this SECEdit

EDIT_API virtual void SerializeLang(CArchive& ar)

Serializes the Language Name only of this SECEdit

EDIT_API void GetEditText(CString& strEditText) const

Places a copy of all of the text of this SECEdit into the CString reference parameter

EDIT_API void SetEditText(LPCTSTR lpszText, int nLength = -1)

Sets the text of this SECEdit to the given text and clears the undo buffers

EDIT_API virtual BOOL ReadFile(LPCTSTR lpszPathName)

Reads in text from a file.

EDIT_API virtual void ReadFileFail()

CWang005 Error Handler for ReadFile

EDIT_API virtual BOOL SaveFile(LPCTSTR lpszPathName)

Saves the current text to a file.

EDIT_API BOOL AppendFileData(LPSTR lpszText, UINT nBytes, int& nLine, int& nCol)

Helper method for loading data from a file.

EDIT_API int GetTabStops(SECEditFontInfo* pFontInfo) const

Retrieves the width of an expanded tab stop in logical units.

EDIT_API virtual BOOL Insert(int nLine, int nCol, LPCTSTR lpszText, int nLength = -1)

Inserts text into the the text buffer at the specified position.

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

Inserts text into the the text buffer at the specified position.

EDIT_API virtual int ConvertColumn(int nCol, BOOL bConversionType, LPCTSTR lpszLine, int *pScreenCol = NULL) const

Converts the given column offset on a line to an actual offset.

EDIT_API virtual int ConvertColumn(int nCol, BOOL bConversionType, int nLine, int *pScreenCol = NULL) const

Converts the given column offset on a line to an actual offset.

EDIT_API virtual CString PadSpaces(int nSpaces, SECEditLineCol lcSpace = SECEditLineCol(0, 0), BOOL bUseDefault = TRUE) const

Return a string that would fill the requestd amount of whitespace

EDIT_API virtual int GetTabSpaces(SECEditLineCol lc) const

Return the number of spaces a tab stop at this location would require

EDIT_API virtual BOOL ClearTextBlock(int nStartLine, int nStartCol, int nEndLine, int nEndCol)

Clears the block of text specified by the given positions.

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

Retrieves the block of text between by two positions.

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

Retrieves the block of text between by two positions.

EDIT_API virtual void UpdateModifiedFlag()

Sets the modified flag.

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) const

Locates text in the text buffer.

LPCTSTR FindNextChar(LPCTSTR lpszText, TCHAR chFind, int nLength = -1) const

Find a character in a string.

LPCTSTR FindNextString(LPCTSTR lpszText, LPCTSTR lpszFind, int nLength = -1, BOOL bMatchCase = TRUE) const

Find a string in a string.

EDIT_API SECEditCharType GetCharType(unsigned int nChar, BOOL bReturnWhitespace = FALSE) const

Return the type of the given character

EDIT_API void FreeUndoBuffers()

Clears the undo state of the transaction model.

EDIT_API virtual void InitFontInfo()

Initializes the font info for the model.

EDIT_API virtual BOOL InsertTab(int nLine, int nCol)

Inserts a tab or spaces to the text data.

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

Converts an index position into line and column.

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

Converts a line and column position into a virtual text index.

EDIT_API virtual BOOL EnforceLineLengths(BOOL bEnforce = TRUE, int nStartLine = 0, int nEndLine = -1)

Validates the lengths and optionally breaks any lines that are too long in the given range

EDIT_API virtual sfl::MvcCommand* ProcessInsert(SECEditLineColPair& lcpInsertBlock)

Creates a command objects for insert commands.

EDIT_API BOOL EnforceMaxLineLength(SECEditLineColPair& lcpBlock, SECEditCompositeCommand* pCmd, int nFirstLineInsert = -1)

Scans lines in the given block to enforce the max length rule

EDIT_API void UpdateCmds(SECEditCommand* pCmd)

Updates the state of the model to accomodate the effect of the given command

sfl::MvcCommand* m_pCurrentCommand

Points to the current command.

sfl::MvcController* m_pDragSelf

Indicates a self-source copy to the controller.

Undo/Redo

EDIT_API virtual sfl::MvcCommand* Undo()

Performs an undo operation on the last command.

EDIT_API virtual sfl::MvcCommand* Redo()

Performs a redo on a command that has been undone.

EDIT_API BOOL GetUndoGroup() const

Test the command grouping state.

EDIT_API virtual void SetUndoGroup(BOOL bGroupCommands)

Groups commands as they are executed so they can be undone as a singleton.

EDIT_API sfl::MvcCommand* RemoveTopUndoCmd()

Removes the top command from the undo stack.

EDIT_API virtual void MergeUndoCommand(SECEditCommand* pCmd, BOOL bNewCmdFirst)

Merges the given command with the top command on the undo stack.

EDIT_API virtual BOOL Log(sfl::MvcCommand* pCmd)

Logs the given command.

Line

EDIT_API virtual int GetLine(int nLine, CString& strLine, LPCTSTR& lpszLine) const

Retrieves the text on a given line.

EDIT_API int GetLineLength(int nLine) const

Retrieves the length of a given line.

EDIT_API virtual int GetLineVisibleLength(int nLine) const

Retrieves the number of visible characters on a given line.

EDIT_API virtual BOOL IsLineColValid(int nLine, int nCol, BOOL bVirtualSpace = FALSE) const

Tests the validity of a given line and column pair.

EDIT_API virtual int DoesSplitMBCS(int nLine, int nCol, BOOL bVirtualSpace = FALSE) const

Tests whether a byte splits a multibyte character.

EDIT_API int GetLineCount() const

Retrieves the number of lines in the text.

EDIT_API int GetLastLine() const

Gets the zero-based line number of the last text line.

EDIT_API CString GetLineEnd() const

Returns the character that signals the end of a line.

EDIT_API virtual int GetMaxWidth() const

Retrieves the maximum possible width of a line.

EDIT_API virtual BOOL IsLineWhiteSpace(int nLine) const

Tests the line for the presence of exclusively white space.

EDIT_API int FirstNonWhiteChar(int nLine) const

Retrieves the index of the first non-whitespace character.

Line ItemData

EDIT_API virtual BOOL GetItemDataFlag(int nLine, unsigned int nFlag) const

Retrieves an indexed bit flag for a given line.

EDIT_API void SetItemDataFlag(int nLine, unsigned int nFlag, BOOL bAdd)

Sets or clears an indexed bit flag for a given line.

EDIT_API virtual void ToggleItemDataFlag(int nLine, unsigned int nFlag)

Toggles the state of a bit flag for a given line.

EDIT_API virtual void DeleteAllItemDataFlag(unsigned int nFlag)

Clears all lines of a given bit flag.

EDIT_API virtual int GetNextFlag(int nLine, unsigned int nFlag, BOOL bForward) const

Retrieves the next line number that has a given bit flag set.

EDIT_API virtual int CountItemDataFlag(unsigned int nFlag) const

Counts the number of lines with a given flag set.

EDIT_API virtual SEC_DWORD GetItemData(int nLine) const

Retrieves user data associated with the given line.

EDIT_API virtual SEC_DWORD SetItemData(int nLine, SEC_DWORD dwItemData)

Sets user data associated with the given line.

EDIT_API virtual SECEditItemData* GetItemDataPtr(int nLine)

Retrieves the item data structure associated with a line.

EDIT_API virtual void DeleteItemDataPtr(int nLine)

Deletes the item data associated with a line.

EDIT_API virtual void InsertItemDataLines(int nNewLine, int nNumLines, BOOL bMoveDown)

Helper function to manage the item data array.

EDIT_API virtual void RemoveItemDataLines(int nStartLine, int nEndLine)

Deletes the item data objects from the specified lines.

EDIT_API virtual void OnDeleteLineData(SECEditItemData* pData, int nLine)

Called when any line data is deleted

Objective Edit 1.x compatibility methods

EDIT_API void ClearEdit()

Initializes the SECEdit model object.

EDIT_API void InitEdit()

Initializes the SECEdit model object.

EDIT_API BOOL GetModified() const

Tests the model for the modified state.

EDIT_API BOOL WriteFile(LPCTSTR lpszFileName)

Saves the current text to a file.

EDIT_API void SetFileMappingKey(LPCTSTR lpszKey = NULL)

Sets the keyword coloring key.

EDIT_API virtual void OnUpdate(sfl::ISubject* pSubject, sfl::IMessage* pMsg)

Handle notifications of change for this SECEdit

Protected Data Members

BOOL m_bUnicodeFile

Ansi/Unicode file flag

BOOL m_bSyntaxColoringEnabled

Flag indicating if Syntax Coloring is enabled for this model

BOOL m_bItemDataFlags

Flag indicating if ItemDataFlags are set in UpdateCmds - do not set for large insert

ISECEditBuffer* m_pEditBuffer

Points to the buffer containing the text.

SECEditMLCommentArray m_MLCommentArray

Maintains multiline comment starting and ending positions.

CTypedPtrArray<CPtrArray, SECEditLineColor*> m_LineColorArray

RArray of syntax coloring information for each line

CTypedPtrArray<CPtrArray, SECEditItemData*> m_ItemDataArray

Array of SECEditItemData objects associated with each line.

CTypedPtrMap<CMapPtrToPtr, SECEditItemData*, void*> m_ItemDataMap

Map of SECEditItemData objects associated with each line.

BOOL m_bModified

Stores the modified state of this text

BOOL m_bReadOnly

Flag indicating if this text is read only

BOOL m_bOverStrike

Flag indicating of overstrike mode is enabled

BOOL m_bGroupCommands

Flag indicating if command grouping is enabled

int m_nMaxWidth

MAximum amount of characters permitted on a line

int m_nInvalidIndex

Tracks the lines that have been scanned for multiline keyword types

SECEditCompositeCommand* m_pGroupCommand

Pointer to the current group command

sfl::MvcCommand* m_pSaveCommand

Pointer the the command on the undo stack when this text was saved

SECEditFontInfo* m_pFontInfo

Pointer to the font information for this text

ISECEditLangConfig* m_pLanguage

Pointer to the language this model observes

BOOL m_bInsertDeleteDownUp

CWang002: An Indicator for Insert and Delete In case Insert, true if the entire start line will be moved down In case Delete, true if the start line will be completely replaced