/** * @file XTPSyntaxEditUndoManager.h * * @copyright * (c) 1998-2025 Codejock Software, All Rights Reserved. * * This source file is the property of Codejock Software and must not be * redistributed by any means without the explicit written permission of * Codejock Software. * * The use of this source code is governed by the terms and conditions specified * in the Toolkit Pro license agreement. Codejock Software grants you, as a * single software developer, the limited right to use this software on one * computer only. * * Contact Information: * support@codejock.com * http://www.codejock.com * */ /** @cond */ #if !defined(__XTPSYNTAXEDITUNDOMANAGER_H__) # define __XTPSYNTAXEDITUNDOMANAGER_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPSyntaxEditBufferManager; class CXTPSyntaxEditCtrl; /** * @brief * This class represents an abstract Edit Control command interface. * Its descendants must implement custom Execute and UnExecute * functionality depending on a command type. * * This class is used internally by the library only. * @see * CXTPSyntaxEditUndoRedoManager, CXTPSyntaxEditBatchCommand, * CXTPSyntaxEditBufferCommand */ class _XTP_EXT_CLASS CXTPSyntaxEditCommand : public CObject { /** @cond */ DECLARE_DYNAMIC(CXTPSyntaxEditCommand) /** @endcond */ public: /** * @brief * A default command destructor. * Destroys the command object, handles its cleanup and de-allocation. */ virtual ~CXTPSyntaxEditCommand(); /** * @brief * This is an interface function for operation execution. * @param lcFrom [out] Start text position affected by the action. * @param lcTo [out] End text position affected by the action. * @param pEditCtrl [in] Pointer to the edit control. * @return * A bitwise combination of the following edit actions: * XTP_EDIT_EDITACTION_MODIFYROW, XTP_EDIT_EDITACTION_DELETEROW, * XTP_EDIT_EDITACTION_INSERTROW * @see * UnExecute */ virtual int Execute(XTP_EDIT_LINECOL& lcFrom, XTP_EDIT_LINECOL& lcTo, CXTPSyntaxEditCtrl* pEditCtrl) = 0; /** * @brief * This is an interface function for operation undoing. * @param lcFrom [out] Start text position affected by the action. * @param lcTo [out] End text position affected by the action. * @param pEditCtrl [in] Pointer to the edit control. * @return * A bitwise combination of the following edit actions: * XTP_EDIT_EDITACTION_MODIFYROW, XTP_EDIT_EDITACTION_DELETEROW, * XTP_EDIT_EDITACTION_INSERTROW * @see * Execute */ virtual int UnExecute(XTP_EDIT_LINECOL& lcFrom, XTP_EDIT_LINECOL& lcTo, CXTPSyntaxEditCtrl* pEditCtrl) = 0; /** * @brief * Gets command text. * @details * Each command has a string describing contained changes. * (e.g. "Typing: something", "Delete", "Paste", etc.). * This string is referred to as command text. * * This function allows for a command to overwrite its * own command text retrieval. * @return * Command text. * @see * SetCommandText */ virtual LPCTSTR GetCommandText() const; /** * @brief * Sets command text. * @param szText [in] Command text to be set. * @details * Each command has a string describing contained changes. * (e.g. "Typing: something", "Delete", "Paste", etc.). * This string is referred to as command text. * * This function allows for a command to overwrite its * own command text. * @see * GetCommandText */ virtual void SetCommandText(LPCTSTR szText); /** * @brief * Gets the undo command data size (in bytes). * @return * The undo command data size (in bytes). */ virtual int GetDataSize() const; protected: /** * @brief * Protected constructor because this class could not be instantiated * itself, only by its descendants. */ CXTPSyntaxEditCommand(); /** * @brief * Sets the line and column position for the specified control using * internal fast methods. * @param pEditCtrl [in] Pointer to the edit control. * @param lcPos [in] Reference to the text position * to be set to the edit control. * @return */ static void AFX_CDECL SetPositionInternally(CXTPSyntaxEditCtrl* pEditCtrl, const XTP_EDIT_LINECOL& lcPos); CString m_strCommandText; /**< Text description of the command. */ }; AFX_INLINE void CXTPSyntaxEditCommand::SetCommandText(LPCTSTR szText) { m_strCommandText = szText; } AFX_INLINE LPCTSTR CXTPSyntaxEditCommand::GetCommandText() const { return m_strCommandText; } AFX_INLINE int CXTPSyntaxEditCommand::GetDataSize() const { return 0; } /** * @brief * This class represents a pack of commands in one. * It stores commands in the list, and implements standard command * execution interfaces on command (un)execution. * @see * CXTPSyntaxEditCommand */ class _XTP_EXT_CLASS CXTPSyntaxEditBatchCommand : public CXTPSyntaxEditCommand { /** @cond */ DECLARE_DYNAMIC(CXTPSyntaxEditBatchCommand) /** @endcond */ public: CXTPSyntaxEditBatchCommand(); /** * @brief * A default command destructor. * Destroys the command object with all sub-commands, * handles its cleanup and de-allocation. */ ~CXTPSyntaxEditBatchCommand(); /** * @brief * Executes the batch command by successively executing all stored commands. * @param lcFrom [out] Start text position affected by the command chain. * @param lcTo [out] End text position affected by the command chain. * @param pEditCtrl [in] Pointer to the edit control. * @return * A bitwise combination of the edit actions that occurred: * XTP_EDIT_EDITACTION_MODIFYROW, XTP_EDIT_EDITACTION_DELETEROW, * XTP_EDIT_EDITACTION_INSERTROW * @see * UnExecute */ virtual int Execute(XTP_EDIT_LINECOL& lcFrom, XTP_EDIT_LINECOL& lcTo, CXTPSyntaxEditCtrl* pEditCtrl); /** * @brief * Unexecutes the batch command by successively undoing all stored commands. * @param lcFrom [out] Start text position affected by the command chain. * @param lcTo [out] End text position affected by the command chain. * @param pEditCtrl [in] Pointer to the edit control. * @return * A bitwise combination of the edit actions that occurred: * XTP_EDIT_EDITACTION_MODIFYROW, XTP_EDIT_EDITACTION_DELETEROW, * XTP_EDIT_EDITACTION_INSERTROW * @see * Execute */ virtual int UnExecute(XTP_EDIT_LINECOL& lcFrom, XTP_EDIT_LINECOL& lcTo, CXTPSyntaxEditCtrl* pEditCtrl); /** * @brief * Adds a command to the batch command buffer. * @param pCommand [in] Pointer to the command to be added. * @return * The position of the newly added command inside the internal list. * * Example: * pBatchCmd->AddCommand(new CXTPSyntaxEditDeleteStringCommand(...)); */ POSITION AddCommand(CXTPSyntaxEditCommand* pCommand); /** * @brief * Gets the number of individual command items inside * the batch command buffer. * @return * The number of individual command items inside * the batch command buffer. */ int GetCommandsCount(); /** * @brief * Gets the undo command data size (in bytes). * @return * The undo command data size (in bytes). */ virtual int GetDataSize() const; protected: /** * @brief * Clears the batch command buffer and deletes all commands. */ void Clear(); CPtrList m_CommandList; /**< Commands buffer storage. */ }; /** * @brief * The base class for all edit commands related to CXTPSyntaxEditBufferManager. * It stores the handle of the buffer manager and provides implementation * of common buffer operations such as text insertion and deletion. * @see * CXTPSyntaxEditCommand, CXTPSyntaxEditInsertStringCommand, * CXTPSyntaxEditDeleteStringCommand */ class _XTP_EXT_CLASS CXTPSyntaxEditBufferCommand : public CXTPSyntaxEditCommand { /** @cond */ DECLARE_DYNAMIC(CXTPSyntaxEditBufferCommand) /** @endcond */ public: /** * @brief * A default command destructor. * Destroys the command object, handles its cleanup and de-allocation. */ virtual ~CXTPSyntaxEditBufferCommand(); protected: /** * @brief * Creates the buffer command object, initializes its members. * @param pMgr [in] Pointer to the associated buffer manager object. * @param szText [in] Text which was changed during the buffer operation. * It will be used for insert/remove text operations. * @param lcFrom [in] Start text position affected by the command. * @param lcTo [in] End text position affected by the command. */ CXTPSyntaxEditBufferCommand(CXTPSyntaxEditBufferManager* pMgr, LPCTSTR szText, const XTP_EDIT_LINECOL& lcFrom, const XTP_EDIT_LINECOL& lcTo); CXTPSyntaxEditBufferManager* m_pBufferMgr; /**< Pointer to the associated text buffer. */ /** * @brief * Keeps the buffer overwrite flag for the specified buffer manager * from class construction until destruction, and resets this flag to * FALSE during class lifetime. * * Example: * void DoSomething() * { * CXTPSyntaxEditBufferKeepOverwriteSettings bufOwr(m_pBufferMgr); * ... * } */ class CXTPSyntaxEditBufferKeepOverwriteSettings { public: /** * @brief * Creates the object and stores buffer overwrite settings. * @param pBufferMgr [in] Pointer to the associated buffer manager object. */ CXTPSyntaxEditBufferKeepOverwriteSettings(CXTPSyntaxEditBufferManager* pBufferMgr); /** * @brief * Destroys the object and restores buffer overwrite settings. */ virtual ~CXTPSyntaxEditBufferKeepOverwriteSettings(); private: CXTPSyntaxEditBufferManager* m_pBufMgr; /**< Associated buffer manager. */ BOOL m_bOldSettings; /**< Buffer overwrite settings. */ }; /** * @brief * Inserts the stored text at the stored positions and returns * the start and final affected text positions. * @param lcFrom [out] Start text position affected by the command. * @param lcTo [out] End text position affected by the command. * @param pEditCtrl [in] Pointer to the edit control. * @return * A bitwise combination of the edit actions that occurred: * XTP_EDIT_EDITACTION_MODIFYROW, XTP_EDIT_EDITACTION_DELETEROW, * XTP_EDIT_EDITACTION_INSERTROW * @see * DoDeleteText */ int DoInsertText(XTP_EDIT_LINECOL& lcFrom, XTP_EDIT_LINECOL& lcTo, CXTPSyntaxEditCtrl* pEditCtrl); /** * @brief * Deletes the text at the stored positions and returns * the start and final affected text positions. * @param lcFrom [out] Start text position affected by the command. * @param lcTo [out] End text position affected by the command. * @param pEditCtrl [in] Pointer to the edit control. * @return * A bitwise combination of the edit actions that occurred: * XTP_EDIT_EDITACTION_MODIFYROW, XTP_EDIT_EDITACTION_DELETEROW, * XTP_EDIT_EDITACTION_INSERTROW * @see * DoInsertText */ int DoDeleteText(XTP_EDIT_LINECOL& lcFrom, XTP_EDIT_LINECOL& lcTo, CXTPSyntaxEditCtrl* pEditCtrl); /** * @brief * Gets the undo command data size (in bytes). * @return * The undo command data size (in bytes). */ virtual int GetDataSize() const; protected: CString m_strText; /**< Changed text. */ XTP_EDIT_LINECOL m_lcFrom; /**< Start edit position. */ XTP_EDIT_LINECOL m_lcTo; /**< End edit position. */ }; /** * @brief * This class represents the insert string command. * Command execution will insert specified text in the buffer * and un-execution will delete this text from the buffer. * @see * CXTPSyntaxEditBufferCommand, CXTPSyntaxEditDeleteStringCommand */ class _XTP_EXT_CLASS CXTPSyntaxEditInsertStringCommand : public CXTPSyntaxEditBufferCommand { /** @cond */ DECLARE_DYNAMIC(CXTPSyntaxEditInsertStringCommand) /** @endcond */ public: /** * @brief * Creates the insert string command object, initializes its members. * @param pMgr [in] Pointer to the associated buffer manager object. * @param szText [in] Text which was changed during the buffer operation. * It will be used for insert/remove text operations. * @param lcFrom [in] Start text position affected by the command. * @param lcTo [in] End text position affected by the command. */ CXTPSyntaxEditInsertStringCommand(CXTPSyntaxEditBufferManager* pMgr, LPCTSTR szText, const XTP_EDIT_LINECOL& lcFrom, const XTP_EDIT_LINECOL& lcTo); /** * @brief * A default command destructor. * Destroys the command object, handles its cleanup and de-allocation. */ virtual ~CXTPSyntaxEditInsertStringCommand(); /** * @brief * Executes the insert string command. * @param lcFrom [out] Start text position affected by the command. * @param lcTo [out] End text position affected by the command. * @param pEditCtrl [in] Pointer to the edit control. * @return * A bitwise combination of the edit actions that occurred: * XTP_EDIT_EDITACTION_MODIFYROW, XTP_EDIT_EDITACTION_INSERTROW * @see * UnExecute */ virtual int Execute(XTP_EDIT_LINECOL& lcFrom, XTP_EDIT_LINECOL& lcTo, CXTPSyntaxEditCtrl* pEditCtrl); /** * @brief * Unexecutes the insert string command (i.e. deletes the string). * @param lcFrom [out] Start text position affected by the command. * @param lcTo [out] End text position affected by the command. * @param pEditCtrl [in] Pointer to the edit control. * @return * A bitwise combination of the edit actions that occurred: * XTP_EDIT_EDITACTION_MODIFYROW, XTP_EDIT_EDITACTION_DELETEROW * @see * Execute */ virtual int UnExecute(XTP_EDIT_LINECOL& lcFrom, XTP_EDIT_LINECOL& lcTo, CXTPSyntaxEditCtrl* pEditCtrl); }; /** * @brief * This class represents the delete string command. * Command execution will delete the text from the buffer between the specified * text positions and un-execution will insert this text into the buffer. * @see * CXTPSyntaxEditBufferCommand, CXTPSyntaxEditInsertStringCommand */ class _XTP_EXT_CLASS CXTPSyntaxEditDeleteStringCommand : public CXTPSyntaxEditBufferCommand { /** @cond */ DECLARE_DYNAMIC(CXTPSyntaxEditDeleteStringCommand) /** @endcond */ public: /** * @brief * Creates the delete string command object, initializes its members. * @param pMgr [in] Pointer to the associated buffer manager object. * @param szText [in] Text which was changed during the buffer operation. * It will be used for insert/remove text operations. * @param lcFrom [in] Start text position affected by the command. * @param lcTo [in] End text position affected by the command. */ CXTPSyntaxEditDeleteStringCommand(CXTPSyntaxEditBufferManager* pMgr, LPCTSTR szText, const XTP_EDIT_LINECOL& lcFrom, const XTP_EDIT_LINECOL& lcTo); /** * @brief * A default command destructor. * Destroys the command object, handles its cleanup and de-allocation. */ virtual ~CXTPSyntaxEditDeleteStringCommand(); /** * @brief * Executes the delete string command. * @param lcFrom [out] Start text position affected by the command. * @param lcTo [out] End text position affected by the command. * @param pEditCtrl [in] Pointer to the edit control. * @return * A bitwise combination of the edit actions that occurred: * XTP_EDIT_EDITACTION_MODIFYROW, XTP_EDIT_EDITACTION_DELETEROW * @see * UnExecute */ virtual int Execute(XTP_EDIT_LINECOL& lcFrom, XTP_EDIT_LINECOL& lcTo, CXTPSyntaxEditCtrl* pEditCtrl); /** * @brief * Unexecutes the delete string command (i.e. inserts the string). * @param lcFrom [out] Start text position affected by the command. * @param lcTo [out] End text position affected by the command. * @param pEditCtrl [in] Pointer to the edit control. * @return * A bitwise combination of the edit actions that occurred: * XTP_EDIT_EDITACTION_MODIFYROW, XTP_EDIT_EDITACTION_INSERTROW * @see * Execute */ virtual int UnExecute(XTP_EDIT_LINECOL& lcFrom, XTP_EDIT_LINECOL& lcTo, CXTPSyntaxEditCtrl* pEditCtrl); }; /** * @brief * This class represents the replace string command. * Command execution will replace the text from the buffer between the specified * text positions and un-execution will do the contrary replacement. * @see * CXTPSyntaxEditBufferCommand */ class _XTP_EXT_CLASS CXTPSyntaxEditReplaceStringCommand : public CXTPSyntaxEditBufferCommand { /** @cond */ DECLARE_DYNAMIC(CXTPSyntaxEditReplaceStringCommand) /** @endcond */ public: /** * @brief * Creates the replace string command object, initializes its members. * @param pMgr [in] Pointer to the associated buffer manager object. * @param szText [in] Text which was inserted during the buffer operation. * @param szReplacedText [in] Text which was changed during the buffer operation. * @param lcFrom [in] Start text position affected by the command. * @param lcTo [in] End text position affected by the command. */ CXTPSyntaxEditReplaceStringCommand(CXTPSyntaxEditBufferManager* pMgr, LPCTSTR szText, LPCTSTR szReplacedText, const XTP_EDIT_LINECOL& lcFrom, const XTP_EDIT_LINECOL& lcTo); /** * @brief * A default command destructor. * Destroys the command object, handles its cleanup and de-allocation. */ virtual ~CXTPSyntaxEditReplaceStringCommand(); /** * @brief * Executes the delete string command. * @param lcFrom [out] Start text position affected by the command. * @param lcTo [out] End text position affected by the command. * @param pEditCtrl [in] Pointer to the edit control. * @return * A bitwise combination of the edit actions that occurred: * XTP_EDIT_EDITACTION_MODIFYROW, XTP_EDIT_EDITACTION_DELETEROW * @see * UnExecute */ virtual int Execute(XTP_EDIT_LINECOL& lcFrom, XTP_EDIT_LINECOL& lcTo, CXTPSyntaxEditCtrl* pEditCtrl); /** * @brief * Unexecutes the delete string command (i.e. inserts the string). * @param lcFrom [out] Start text position affected by the command. * @param lcTo [out] End text position affected by the command. * @param pEditCtrl [in] Pointer to the edit control. * @return * A bitwise combination of the edit actions that occurred: * XTP_EDIT_EDITACTION_MODIFYROW, XTP_EDIT_EDITACTION_INSERTROW * @see * Execute */ virtual int UnExecute(XTP_EDIT_LINECOL& lcFrom, XTP_EDIT_LINECOL& lcTo, CXTPSyntaxEditCtrl* pEditCtrl); /** * @brief * Gets the undo command data size (in bytes). * @return * The undo command data size (in bytes). */ virtual int GetDataSize() const; protected: CString m_strReplacedText; /**< Buffer which holds the replaced text. */ /** * @brief * Performs the replace text operation. * @param szText [in] Text to replace to. * @param lcFrom [out] Start text position affected by the command. * @param lcTo [out] End text position affected by the command. * @param pEditCtrl [in] Pointer to the edit control. * @return * A bitwise combination of the edit actions that occurred: * XTP_EDIT_EDITACTION_MODIFYROW, XTP_EDIT_EDITACTION_INSERTROW */ int DoReplaceText(LPCTSTR szText, XTP_EDIT_LINECOL& lcFrom, XTP_EDIT_LINECOL& lcTo, CXTPSyntaxEditCtrl* pEditCtrl); }; /** * @brief * This class maintains the list of undo/redo commands. * It is managed by the CEditBufferManager class. * * This class allows for adding new commands in the buffer (see AddCommand), * undoing the last added operation (see DoUndo), and redoing operations * following the latest unexecuted operation (see DoRedo). * * This class also allows for checking if it is possible to perform undo/redo * operations (see CanUndo / CanRedo). * * This class also allows for marking the current position of the undo/redo * operation queue as saved, and returns the "modified" flag if the * queue position will be changed (see MarkSaved / IsModified). * * Another piece of the functionality is commands grouping. The following * methods are related to this: SetGroupInsertMode and ChainLastCommand. * ChainLastCommand forces the latest added undo command to be merged into * a group with the previous undo command. This method could be useful * for group operations like moving a selected text by mouse. In this * case, there would be 2 different commands added: remove selected text * from its original position and insert it into the new position. * By using ChainLastCommand, both of these operations would be merged into * a single ooperation, which will be further done/undone together. * SetGroupInsertMode forces the undo/redo manager to merge all added * operations into a single chain. For example, this could be useful when * the user is typing some text, which could be later done/undone as * a single word, instead of individually by each character. * * Also, one more piece of functionality is related to the command * description text management. Related functions allow setting the * new text description for the last undo command (SetLastCommandText). * As an example, it could be used after the ChainLastCommand method * for setting the new description for the merged command (e.g. 'Move' * instead of 'Delete'+'Insert'). * * Another two functions allow for the retrieval of string description lists * from the list of undo/redo commands (GetUndoTextList / GetRedoTextList). * * However, this class is used internally by the library only. * @see * CXTPSyntaxEditCommand */ class _XTP_EXT_CLASS CXTPSyntaxEditUndoRedoManager { public: /** * @brief * Creates the undo/redo manager object, initializes its members. */ CXTPSyntaxEditUndoRedoManager(); /** * @brief * Destroys the undo/redo manager object, * handles its cleanup and de-allocation. */ virtual ~CXTPSyntaxEditUndoRedoManager(); /** * @brief * Performs a single undo operation (unexecutes the latest command). * @param lcFrom [out] Start text position affected by the command. * @param lcTo [out] End text position affected by the command. * @param pEditCtrl [in] Pointer to the edit control. * @return * A bitwise combination of the edit actions that occurred: * XTP_EDIT_EDITACTION_MODIFYROW, XTP_EDIT_EDITACTION_DELETEROW, * XTP_EDIT_EDITACTION_INSERTROW * @see * DoRedo */ int DoUndo(XTP_EDIT_LINECOL& lcFrom, XTP_EDIT_LINECOL& lcTo, CXTPSyntaxEditCtrl* pEditCtrl); /** * @brief * Performs a single redo operation (executes the next command). * @param lcFrom [out] Start text position affected by the command. * @param lcTo [out] End text position affected by the command. * @param pEditCtrl [in] Pointer to the edit control. * @return * A bitwise combination of the edit actions that occurred: * XTP_EDIT_EDITACTION_MODIFYROW, XTP_EDIT_EDITACTION_DELETEROW, * XTP_EDIT_EDITACTION_INSERTROW * @see * DoUndo */ int DoRedo(XTP_EDIT_LINECOL& lcFrom, XTP_EDIT_LINECOL& lcTo, CXTPSyntaxEditCtrl* pEditCtrl); /** * @brief * Adds a command to the undo buffer. * Deletes all redo commands if they exist. * @param pCommand [in] Pointer to the undo command to be added. */ void AddCommand(CXTPSyntaxEditCommand* pCommand); /** * @brief * Clears the undo manager buffer and deletes all commands. */ void Clear(); /** * @brief * Determines if it is possible to perform the undo action. * @return * TRUE if it is possible to perform the undo action, otherwise FALSE. * @see * CanRedo */ BOOL CanUndo() const; /** * @brief * Determines if it is possible to perform the redo action. * @return * TRUE if it is possible to perform the redo action, otherwise FALSE. * @see * CanUndo */ BOOL CanRedo() const; /** * @brief * Marks the current command buffer position as last saved. * @details * This method is used for the further calculating of the modified flag. * @see * IsModified */ void MarkSaved(); /** * @brief * Determines if the document was modified by any command from * the buffer since the document was last saved/loaded. * @return * TRUE if the document was modified by any command from the buffer * since the document was last saved/loaded, otherwise FALSE. * @see * MarkSaved */ BOOL IsModified() const; /** * @brief * Enables/disables group insert mode. * @param bInsertInGroup [in] TRUE to enable group insert mode, * FALSE to disable group insert mode. * @details * Group insert mode is required when a user is typing certain text in * normal INS mode. When an undo/redo command occurs, a group of text * will be undone/redone in a single shot. This setting is cleared when * in overwrite mode or while the user presses SPACE, TAB, ENTER, etc. * @see * ChainLastCommand */ void SetGroupInsertMode(BOOL bInsertInGroup = TRUE); /** * @brief * Merges the latest undo command into a batch command with * the previous undo command. * @see * SetGroupInsertMode */ void ChainLastCommand(); /** * @brief * Sets the text for the last undo command in the stack. * @param szText [in] Text to be set. * @see * GetUndoTextList, GetRedoTextList */ void SetLastCommandText(LPCTSTR szText); /** * @brief * Sets the text for the last undo command in the stack. * @param nTextId [in] Resource text identifier of the text string to be set. * @see * GetUndoTextList, GetRedoTextList */ void SetLastCommandText(UINT nTextId); /** * @brief * Gets the list of text for undo operations. * @return * A reference to the list of text for undo operations. * @see * GetRedoTextList, SetLastCommandText */ const CStringList& GetUndoTextList(); /** * @brief * Gets the list of text for redo operations. * @return * A reference to the list of text for redo operations. * @see * GetUndoTextList, SetLastCommandText */ const CStringList& GetRedoTextList(); /** * @brief * Gets the undo buffer data size (in bytes). * @return * The undo buffer data size (in bytes). */ virtual int GetDataSize() const; /** * @brief * Checks the undo buffer data size and removes old stored commands * to clear memory if the data size limit has been reached. * @param nNewCommandData Size (in bytes) of the undo command to be added. * @param nDataSizeLimit Data size limit of the undo buffer. */ virtual void LimitDataSize(int nNewCommandData, int nDataSizeLimit); private: /** * @brief * Removes the command queue tail after the current element. */ void RemoveTail(); protected: CPtrList m_CommandList; /**< Commands buffer. */ POSITION m_posFirstUndo; /**< Actual command position in the buffer. */ POSITION m_posSavedMark; /**< Last saved command position in the buffer. */ BOOL m_bGroupInsertMode; /**< TRUE if group insert mode is on, FALSE otherwise. */ int m_nDataSizeLimit; /**< Memory limit for undo data. */ private: CStringList m_lstUndoText; /**< Temporary storage for undo text strings. */ CStringList m_lstRedoText; /**< Temporary storage for redo text strings. */ }; # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" /** @cond */ #endif // !defined(__XTPSYNTAXEDITUNDOMANAGER_H__) /** @endcond */