Revision: 5721
http://winmerge.svn.sourceforge.net/winmerge/?rev=5721&view=rev
Author: kimmov
Date: 2008-08-02 17:59:01 +0000 (Sat, 02 Aug 2008)
Log Message:
-----------
Move SUndoRecord struct code to own files.
Modified Paths:
--------------
trunk/Src/Merge.vcproj
trunk/Src/editlib/ccrystaltextbuffer.cpp
trunk/Src/editlib/ccrystaltextbuffer.h
Added Paths:
-----------
trunk/Src/editlib/UndoRecord.cpp
trunk/Src/editlib/UndoRecord.h
Modified: trunk/Src/Merge.vcproj
===================================================================
--- trunk/Src/Merge.vcproj 2008-08-02 15:42:20 UTC (rev 5720)
+++ trunk/Src/Merge.vcproj 2008-08-02 17:59:01 UTC (rev 5721)
@@ -8409,6 +8409,46 @@
</FileConfiguration>
</File>
<File
+ RelativePath="editlib\UndoRecord.h">
+ </File>
+ <File
+ RelativePath="editlib\UndoRecord.cpp">
+ <FileConfiguration
+ Name="UnicodeRelease|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="UnicodeDebug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""
+ BrowseInformation="1"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""
+ BrowseInformation="1"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""/>
+ </FileConfiguration>
+ </File>
+ <File
RelativePath="editlib\wispelld.h">
</File>
<File
Added: trunk/Src/editlib/UndoRecord.cpp
===================================================================
--- trunk/Src/editlib/UndoRecord.cpp (rev 0)
+++ trunk/Src/editlib/UndoRecord.cpp 2008-08-02 17:59:01 UTC (rev 5721)
@@ -0,0 +1,41 @@
+/**
+ * @file UndoRecord.cpp
+ *
+ * @brief Implementation of UndoRecord struct.
+ */
+// ID line follows -- this is updated by SVN
+// $Id$
+
+#include "stdafx.h"
+#include "UndoRecord.h"
+
+void SUndoRecord::
+SetText (LPCTSTR pszText, int nLength)
+{
+ FreeText();
+ if (nLength)
+ {
+ if (nLength > 1)
+ {
+ m_pszText = (TextBuffer *)malloc(sizeof(TextBuffer) + nLength * sizeof(TCHAR));
+ m_pszText->size = nLength;
+ memcpy(m_pszText->data, pszText, nLength * sizeof(TCHAR));
+ m_pszText->data[nLength] = _T('?'); // debug sentinel
+ }
+ else
+ {
+ m_szText[0] = pszText[0];
+ }
+ }
+}
+
+void SUndoRecord::
+FreeText ()
+{
+ // See the m_szText/m_pszText definition
+ // Check if m_pszText is a pointer by removing bits having
+ // possible char value
+ if (((INT_PTR)m_pszText >> 16) != 0)
+ free(m_pszText);
+ m_pszText = NULL;
+}
Property changes on: trunk/Src/editlib/UndoRecord.cpp
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/Src/editlib/UndoRecord.h
===================================================================
--- trunk/Src/editlib/UndoRecord.h (rev 0)
+++ trunk/Src/editlib/UndoRecord.h 2008-08-02 17:59:01 UTC (rev 5721)
@@ -0,0 +1,98 @@
+/**
+ * @file UndoRecord.h
+ *
+ * @brief Declaration for SUndoRecord structure.
+ *
+ */
+// ID line follows -- this is updated by SVN
+// $Id$
+
+#ifndef _EDITOR_UNDO_RECORD_H_
+#define _EDITOR_UNDO_RECORD_H_
+
+struct SUndoRecord
+{
+ DWORD m_dwFlags;
+ CPoint m_ptStartPos, m_ptEndPos; // Block of text participating
+ int m_nAction; // For information only: action type
+ CDWordArray *m_paSavedRevisonNumbers;
+
+private:
+ // TCHAR *m_pcText;
+ // Since in most cases we have 1 character here,
+ // we should invent a better way. Note: 2 * sizeof(WORD) <= sizeof(TCHAR*)
+ //
+ // Here we will use the following trick: on Win32 platforms high-order word
+ // of any pointer will be != 0. So we can store 1 character strings without
+ // allocating memory.
+ //
+ struct TextBuffer
+ {
+ int size;
+ TCHAR data[1];
+ };
+
+ union
+ {
+ TextBuffer *m_pszText; // For cases when we have > 1 character strings
+ TCHAR m_szText[2]; // For single-character strings
+ };
+
+ public:
+ SUndoRecord () // default constructor
+ {
+ memset (this, 0, sizeof (SUndoRecord));
+ }
+
+ SUndoRecord (const SUndoRecord & src) // copy constructor
+ {
+ memset (this, 0, sizeof (SUndoRecord));
+ (*this)=src;
+ }
+
+ SUndoRecord & operator=(const SUndoRecord & src) // copy assignment
+ {
+ m_dwFlags = src.m_dwFlags;
+ m_ptStartPos = src.m_ptStartPos;
+ m_ptEndPos = src.m_ptEndPos;
+ m_nAction = src.m_nAction;
+ SetText(src.GetText(), src.GetTextLength());
+ INT_PTR size = src.m_paSavedRevisonNumbers->GetSize();
+ if (!m_paSavedRevisonNumbers)
+ m_paSavedRevisonNumbers = new CDWordArray();
+ m_paSavedRevisonNumbers->SetSize(size);
+ INT_PTR i;
+ for (i = 0; i < size; i++)
+ (*m_paSavedRevisonNumbers)[i] = (*src.m_paSavedRevisonNumbers)[i];
+ return *this;
+ }
+
+ ~SUndoRecord () // destructor
+ {
+ FreeText();
+ if (m_paSavedRevisonNumbers)
+ delete m_paSavedRevisonNumbers;
+ }
+
+ void SetText (LPCTSTR pszText, int cchText);
+ void FreeText ();
+
+ LPCTSTR GetText () const
+ {
+ // See the m_szText/m_pszText definition
+ // Check if m_pszText is a pointer by removing bits having
+ // possible char value
+ if (((INT_PTR)m_pszText >> 16) != 0)
+ return m_pszText->data;
+ return m_szText;
+ }
+
+ int GetTextLength () const
+ {
+ if (((INT_PTR)m_pszText >> 16) != 0)
+ return m_pszText->size;
+ return 1;
+ }
+};
+
+#endif // _EDITOR_UNDO_RECORD_H_
Property changes on: trunk/Src/editlib/UndoRecord.h
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Modified: trunk/Src/editlib/ccrystaltextbuffer.cpp
===================================================================
--- trunk/Src/editlib/ccrystaltextbuffer.cpp 2008-08-02 15:42:20 UTC (rev 5720)
+++ trunk/Src/editlib/ccrystaltextbuffer.cpp 2008-08-02 17:59:01 UTC (rev 5721)
@@ -67,6 +67,7 @@
#include <malloc.h>
#include "editcmd.h"
#include "LineInfo.h"
+#include "UndoRecord.h"
#include "ccrystaltextbuffer.h"
#include "ccrystaltextview.h"
#include "filesup.h"
@@ -98,41 +99,7 @@
int CCrystalTextBuffer::m_nDefaultEncoding = -1;
-/////////////////////////////////////////////////////////////////////////////
-// CCrystalTextBuffer::SUndoRecord
-void CCrystalTextBuffer::SUndoRecord::
-SetText (LPCTSTR pszText, int nLength)
-{
- FreeText();
- if (nLength)
- {
- if (nLength > 1)
- {
- m_pszText = (TextBuffer *)malloc(sizeof(TextBuffer) + nLength * sizeof(TCHAR));
- m_pszText->size = nLength;
- memcpy(m_pszText->data, pszText, nLength * sizeof(TCHAR));
- m_pszText->data[nLength] = _T('?'); // debug sentinel
- }
- else
- {
- m_szText[0] = pszText[0];
- }
- }
-}
-
-void CCrystalTextBuffer::SUndoRecord::
-FreeText ()
-{
- // See the m_szText/m_pszText definition
- // Check if m_pszText is a pointer by removing bits having
- // possible char value
- if (((INT_PTR)m_pszText >> 16) != 0)
- free(m_pszText);
- m_pszText = NULL;
-}
-
-
/////////////////////////////////////////////////////////////////////////////
// CCrystalTextBuffer::CUpdateContext
Modified: trunk/Src/editlib/ccrystaltextbuffer.h
===================================================================
--- trunk/Src/editlib/ccrystaltextbuffer.h 2008-08-02 15:42:20 UTC (rev 5720)
+++ trunk/Src/editlib/ccrystaltextbuffer.h 2008-08-02 17:59:01 UTC (rev 5721)
@@ -39,6 +39,7 @@
#include <vector>
#include "LineInfo.h"
+#include "UndoRecord.h"
#include "ccrystaltextview.h"
#ifndef __AFXTEMPL_H__
@@ -129,98 +130,12 @@
int FindLineWithFlag (DWORD dwFlag);
protected :
-#pragma pack(push, 1)
- // Nested class declarations
enum
{
UNDO_INSERT = 0x0001,
UNDO_BEGINGROUP = 0x0100
};
- // [JRT] Support For Descriptions On Undo/Redo Actions
- struct SUndoRecord
- {
- DWORD m_dwFlags;
-
- CPoint m_ptStartPos, m_ptEndPos; // Block of text participating
- int m_nAction; // For information only: action type
- CDWordArray *m_paSavedRevisonNumbers;
-
-private :
- // TCHAR *m_pcText;
- // Since in most cases we have 1 character here,
- // we should invent a better way. Note: 2 * sizeof(WORD) <= sizeof(TCHAR*)
- //
- // Here we will use the following trick: on Win32 platforms high-order word
- // of any pointer will be != 0. So we can store 1 character strings without
- // allocating memory.
- //
- struct TextBuffer
- {
- int size;
- TCHAR data[1];
- };
- union
- {
- TextBuffer *m_pszText; // For cases when we have > 1 character strings
- TCHAR m_szText[2]; // For single-character strings
- };
-
-public :
- SUndoRecord () // default constructor
- {
- memset (this, 0, sizeof (SUndoRecord));
- }
- SUndoRecord (const SUndoRecord & src) // copy constructor
- {
- memset (this, 0, sizeof (SUndoRecord));
- (*this)=src;
- }
- SUndoRecord & operator=(const SUndoRecord & src) // copy assignment
- {
- m_dwFlags = src.m_dwFlags;
- m_ptStartPos = src.m_ptStartPos;
- m_ptEndPos = src.m_ptEndPos;
- m_nAction = src.m_nAction;
- SetText(src.GetText(), src.GetTextLength());
- INT_PTR size = src.m_paSavedRevisonNumbers->GetSize();
- if (!m_paSavedRevisonNumbers)
- m_paSavedRevisonNumbers = new CDWordArray();
- m_paSavedRevisonNumbers->SetSize(size);
- INT_PTR i;
- for (i = 0; i < size; i++)
- (*m_paSavedRevisonNumbers)[i] = (*src.m_paSavedRevisonNumbers)[i];
- return *this;
- }
- ~SUndoRecord () // destructor
- {
- FreeText();
- if (m_paSavedRevisonNumbers)
- delete m_paSavedRevisonNumbers;
- }
-
- void SetText (LPCTSTR pszText, int cchText);
- void FreeText ();
-
- LPCTSTR GetText () const
- {
- // See the m_szText/m_pszText definition
- // Check if m_pszText is a pointer by removing bits having
- // possible char value
- if (((INT_PTR)m_pszText >> 16) != 0)
- return m_pszText->data;
- return m_szText;
- }
- int GetTextLength () const
- {
- if (((INT_PTR)m_pszText >> 16) != 0)
- return m_pszText->size;
- return 1;
- }
- };
-
-#pragma pack(pop)
-
class EDITPADC_CLASS CInsertContext : public CUpdateContext
{
public :
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|