Revision: 5738
http://winmerge.svn.sourceforge.net/winmerge/?rev=5738&view=rev
Author: kimmov
Date: 2008-08-05 20:30:02 +0000 (Tue, 05 Aug 2008)
Log Message:
-----------
PATCH: [ 2039263 ] Refactor editor linebuf code to class
Modified Paths:
--------------
trunk/Src/GhostTextBuffer.cpp
trunk/Src/editlib/LineInfo.cpp
trunk/Src/editlib/LineInfo.h
trunk/Src/editlib/ccrystaltextbuffer.cpp
trunk/Src/editlib/ccrystaltextbuffer.h
Modified: trunk/Src/GhostTextBuffer.cpp
===================================================================
--- trunk/Src/GhostTextBuffer.cpp 2008-08-05 19:15:34 UTC (rev 5737)
+++ trunk/Src/GhostTextBuffer.cpp 2008-08-05 20:30:02 UTC (rev 5738)
@@ -136,7 +136,7 @@
for (int i = nLine ; i < nLine + nCount; i++)
{
ASSERT (GetLineFlags(i) & LF_GHOST);
- delete[] m_aLines[i].m_pcLine;
+ m_aLines[i].Clear();
}
m_aLines.RemoveAt (nLine, nCount);
@@ -210,7 +210,7 @@
int soffset = (i == nStartLine ? nStartChar : 0);
int eoffset = (i == nEndLine ? nEndChar : GetLineLength(i));
int chars = eoffset - soffset;
- LPCTSTR szLine = m_aLines[i].m_pcLine + soffset;
+ LPCTSTR szLine = m_aLines[i].GetLine(soffset);
CopyMemory(pszBuf, szLine, chars * sizeof(TCHAR));
pszBuf += chars;
@@ -234,7 +234,7 @@
int soffset = (i == nStartLine ? nStartChar : 0);
int eoffset = (i == nEndLine ? nEndChar : GetFullLineLength(i));
int chars = eoffset - soffset;
- LPCTSTR szLine = m_aLines[i].m_pcLine + soffset;
+ LPCTSTR szLine = m_aLines[i].GetLine(soffset);
CopyMemory(pszBuf, szLine, chars * sizeof(TCHAR));
pszBuf += chars;
@@ -340,9 +340,9 @@
int bLastLineGhost = ((GetLineFlags(apparent_ptEndPos.y) & LF_GHOST) != 0);
if ((apparent_ptStartPos.y < m_aLines.GetSize ()) &&
- (apparent_ptStartPos.x <= m_aLines[apparent_ptStartPos.y].m_nLength) &&
+ (apparent_ptStartPos.x <= m_aLines[apparent_ptStartPos.y].Length()) &&
(apparent_ptEndPos.y < m_aLines.GetSize ()) &&
- (apparent_ptEndPos.x <= m_aLines[apparent_ptEndPos.y].m_nLength))
+ (apparent_ptEndPos.x <= m_aLines[apparent_ptEndPos.y].Length()))
{
GetTextWithoutEmptys (apparent_ptStartPos.y, apparent_ptStartPos.x, apparent_ptEndPos.y, apparent_ptEndPos.x, text);
if (text.GetLength() == ur.GetTextLength() && memcmp(text, ur.GetText(), text.GetLength() * sizeof(TCHAR)) == 0)
@@ -884,7 +884,7 @@
for(ct = 0; ct < nlines; ct++)
{
if (GetLineFlags(ct) & LF_GHOST)
- delete[] m_aLines[ct].m_pcLine;
+ m_aLines[ct].FreeBuffer();
}
// Compact non-ghost lines
// (we copy the buffer address, so the buffer don't move and we don't free it)
@@ -1203,34 +1203,32 @@
if (bLastRealLine)
{
bLastRealLine = 0;
- if (m_aLines[i].m_nEolChars != 0)
+ if (m_aLines[i].HasEol())
{
// if the last real line has an EOL, remove it
- m_aLines[i].m_pcLine[m_aLines[i].m_nLength] = '\0';
- m_aLines[i].m_nEolChars = 0;
- if (pSource!=NULL)
+ m_aLines[i].RemoveEol();
+ if (pSource != NULL)
UpdateViews (pSource, NULL, UPDATE_HORZRANGE | UPDATE_SINGLELINE, i);
}
}
else
{
- if (m_aLines[i].m_nEolChars == 0)
+ if (!m_aLines[i].HasEol())
{
// if a real line (not the last) has no EOL, add one
AppendLine (i, GetDefaultEol(), (int) _tcslen(GetDefaultEol()));
- if (pSource!=NULL)
+ if (pSource != NULL)
UpdateViews (pSource, NULL, UPDATE_HORZRANGE | UPDATE_SINGLELINE, i);
}
}
}
else
{
- if (m_aLines[i].m_nEolChars != 0)
+ if (m_aLines[i].HasEol())
{
// if a ghost line has an EOL, remove it
- m_aLines[i].m_pcLine[m_aLines[i].m_nLength] = '\0';
- m_aLines[i].m_nEolChars = 0;
- if (pSource!=NULL)
+ m_aLines[i].RemoveEol();
+ if (pSource != NULL)
UpdateViews (pSource, NULL, UPDATE_HORZRANGE | UPDATE_SINGLELINE, i);
}
}
Modified: trunk/Src/editlib/LineInfo.cpp
===================================================================
--- trunk/Src/editlib/LineInfo.cpp 2008-08-05 19:15:34 UTC (rev 5737)
+++ trunk/Src/editlib/LineInfo.cpp 2008-08-05 20:30:02 UTC (rev 5738)
@@ -16,21 +16,74 @@
#endif
/**
+ @brief Constructor.
+ */
+LineInfo::LineInfo()
+: m_pcLine(NULL)
+, m_nLength(0)
+, m_nMax(0)
+, m_nEolChars(0)
+, m_dwFlags(0)
+, m_dwRevisionNumber(0)
+{
+};
+
+/**
+ * @brief Clear item.
+ * Frees buffer, sets members to initial values.
+ */
+void LineInfo::Clear()
+{
+ if (m_pcLine != NULL)
+ {
+ delete[] m_pcLine;
+ m_pcLine = NULL;
+ m_nLength = 0;
+ m_nMax = 0;
+ m_nEolChars = 0;
+ m_dwFlags = 0;
+ m_dwRevisionNumber = 0;
+ }
+}
+
+/**
+ * @brief Free reserved memory.
+ * Frees reserved memory, but does not clear flags.
+ */
+void LineInfo::FreeBuffer()
+{
+ if (m_pcLine != NULL)
+ {
+ delete[] m_pcLine;
+ m_pcLine = NULL;
+ m_nLength = 0;
+ m_nMax = 0;
+ m_nEolChars = 0;
+ }
+}
+
+/**
* @brief Create a line.
* @param [in] pszLine Line data.
* @param [in] nLength Line length.
*/
void LineInfo::Create(LPCTSTR pszLine, int nLength)
{
+ if (nLength == 0)
+ {
+ CreateEmpty();
+ return;
+ }
+
m_nLength = nLength;
m_nMax = ALIGN_BUF_SIZE (m_nLength + 1);
ASSERT (m_nMax >= m_nLength + 1);
+ if (m_pcLine != NULL)
+ delete[] m_pcLine;
m_pcLine = new TCHAR[m_nMax];
- if (m_nLength > 0)
- {
- DWORD dwLen = sizeof (TCHAR) * m_nLength;
- CopyMemory (m_pcLine, pszLine, dwLen);
- }
+ ZeroMemory(m_pcLine, m_nMax * sizeof(TCHAR));
+ const DWORD dwLen = sizeof (TCHAR) * m_nLength;
+ CopyMemory (m_pcLine, pszLine, dwLen);
m_pcLine[m_nLength] = '\0';
int nEols = 0;
@@ -50,8 +103,10 @@
m_nLength = 0;
m_nEolChars = 0;
m_nMax = ALIGN_BUF_SIZE (m_nLength + 1);
+ if (m_pcLine != NULL)
+ delete [] m_pcLine;
m_pcLine = new TCHAR[m_nMax];
- m_pcLine[0] = '\0';
+ ZeroMemory(m_pcLine, m_nMax * sizeof(TCHAR));
}
/**
@@ -89,3 +144,121 @@
m_nLength -= m_nEolChars;
ASSERT (m_nLength + m_nEolChars <= m_nMax);
}
+
+/**
+ * @brief Has the line EOL?
+ * @return TRUE if the line has EOL bytes.
+ */
+BOOL LineInfo::HasEol() const
+{
+ if (m_nEolChars)
+ return TRUE;
+ else
+ return FALSE;
+}
+
+/**
+ * @brief Get line's EOL bytes.
+ * @return EOL bytes, or NULL if no EOL bytes.
+ */
+LPCTSTR LineInfo::GetEol() const
+{
+ if (HasEol())
+ return &m_pcLine[Length()];
+ else
+ return NULL;
+}
+
+/**
+ * @brief Change line's EOL.
+ * @param [in] lpEOL New EOL bytes.
+ * @return TRUE if succeeded, FALSE if failed (nothing to change).
+ */
+BOOL LineInfo::ChangeEol(LPCTSTR lpEOL)
+{
+ const int nNewEolChars = (int) _tcslen(lpEOL);
+
+ // Check if we really are changing EOL.
+ if (nNewEolChars == m_nEolChars)
+ if (_tcscmp(m_pcLine + Length(), lpEOL) == 0)
+ return FALSE;
+
+ int nBufNeeded = m_nLength + nNewEolChars+1;
+ if (nBufNeeded > m_nMax)
+ {
+ m_nMax = ALIGN_BUF_SIZE (nBufNeeded);
+ ASSERT (m_nMax >= nBufNeeded);
+ TCHAR *pcNewBuf = new TCHAR[m_nMax];
+ if (FullLength() > 0)
+ memcpy (pcNewBuf, m_pcLine, sizeof (TCHAR) * (FullLength() + 1));
+ delete[] m_pcLine;
+ m_pcLine = pcNewBuf;
+ }
+
+ // copy also the 0 to zero-terminate the line
+ memcpy (m_pcLine + m_nLength, lpEOL, sizeof (TCHAR) * (nNewEolChars + 1));
+ m_nEolChars = nNewEolChars;
+ return TRUE;
+}
+
+/**
+ * @brief Delete part of the line.
+ * @param [in] nStartChar Start position for removal.
+ * @param [in] nEndChar End position for removal.
+ */
+void LineInfo::Delete(int nStartChar, int nEndChar)
+{
+ if (nEndChar < Length() || m_nEolChars)
+ {
+ // preserve characters after deleted range by shifting up
+ memcpy (m_pcLine + nStartChar, m_pcLine + nEndChar,
+ sizeof (TCHAR) * (FullLength() - nEndChar));
+ }
+ m_nLength -= (nEndChar - nStartChar);
+ m_pcLine[FullLength()] = '\0';
+}
+
+/**
+ * @brief Delete line contents from given index to the end.
+ * @param [in] Index of first character to remove.
+ */
+void LineInfo::DeleteEnd(int nStartChar)
+{
+ m_nLength = nStartChar;
+ m_pcLine[nStartChar] = 0;
+ m_nEolChars = 0;
+}
+
+/**
+ * @brief Copy contents from another LineInfo item.
+ * @param [in] li Item to copy.
+ */
+void LineInfo::CopyFrom(const LineInfo &li)
+{
+ if (m_pcLine != NULL)
+ delete [] m_pcLine;
+ m_pcLine = new TCHAR[li.m_nMax];
+ memcpy(m_pcLine, li.m_pcLine, li.m_nMax * sizeof(TCHAR));
+}
+
+/**
+ * @brief Remove EOL from line.
+ */
+void LineInfo::RemoveEol()
+{
+ if (HasEol())
+ {
+ m_pcLine[m_nLength] = '\0';
+ m_nEolChars = 0;
+ }
+}
+
+/**
+ * @brief Get line contents.
+ * @param [in] index Index of first character to get.
+ * @note Make a copy from returned string, as it can get reallocated.
+ */
+LPCTSTR LineInfo::GetLine(int index) const
+{
+ return &m_pcLine[index];
+}
Modified: trunk/Src/editlib/LineInfo.h
===================================================================
--- trunk/Src/editlib/LineInfo.h 2008-08-05 19:15:34 UTC (rev 5737)
+++ trunk/Src/editlib/LineInfo.h 2008-08-05 20:30:02 UTC (rev 5738)
@@ -20,34 +20,47 @@
*/
class LineInfo
{
-public: // All public as this used to be a struct.
- TCHAR *m_pcLine; /**< Line data. */
- int m_nLength; /**< Line length (without EOL bytes). */
- int m_nMax; /**< Allocated space for line data. */
- int m_nEolChars; /**< # of EOL bytes. */
+public:
DWORD m_dwFlags; /**< Line flags. */
DWORD m_dwRevisionNumber; /**< Edit revision (for edit tracking). */
- int FullLength() const { return m_nLength+m_nEolChars; }
- int Length() const { return m_nLength; }
+ LineInfo();
+ void Clear();
+ void FreeBuffer();
void Create(LPCTSTR pszLine, int nLength);
void CreateEmpty();
void Append(LPCTSTR pszChars, int nLength);
+ void Delete(int nStartChar, int nEndChar);
+ void DeleteEnd(int nStartChar);
+ void CopyFrom(const LineInfo &li);
+ BOOL HasEol() const;
+ LPCTSTR GetEol() const;
+ BOOL ChangeEol(LPCTSTR lpEOL);
+ void RemoveEol();
+ LPCTSTR GetLine(int index = 0) const;
- LineInfo ()
- {
- memset (this, 0, sizeof (LineInfo));
- };
+ /** @brief Return full line length (including EOL bytes). */
+ int FullLength() const { return m_nLength + m_nEolChars; }
+ /** @brief Return line length. */
+ int Length() const { return m_nLength; }
+ /** @brief Is the char an EOL char? */
static bool IsEol(TCHAR ch)
{
return ch=='\r' || ch=='\n';
};
+ /** @brief Are the characters DOS EOL bytes? */
static bool IsDosEol(LPCTSTR sz)
{
return sz[0]=='\r' && sz[1]=='\n';
};
+
+private:
+ TCHAR *m_pcLine; /**< Line data. */
+ int m_nMax; /**< Allocated space for line data. */
+ int m_nLength; /**< Line length (without EOL bytes). */
+ int m_nEolChars; /**< # of EOL bytes. */
};
#endif // _EDITOR_LINEINFO_H_
Modified: trunk/Src/editlib/ccrystaltextbuffer.cpp
===================================================================
--- trunk/Src/editlib/ccrystaltextbuffer.cpp 2008-08-05 19:15:34 UTC (rev 5737)
+++ trunk/Src/editlib/ccrystaltextbuffer.cpp 2008-08-05 20:30:02 UTC (rev 5738)
@@ -206,8 +206,7 @@
// duplicate the text data for lines after the first one
for (int ic = 1; ic < nCount; ic++)
{
- m_aLines[nPosition+ic].m_pcLine = new TCHAR[li.m_nMax];
- memcpy(m_aLines[nPosition+ic].m_pcLine, li.m_pcLine, li.m_nMax * sizeof(TCHAR));
+ m_aLines[nPosition+ic].CopyFrom(li);
}
#ifdef _DEBUG
@@ -285,11 +284,10 @@
FreeAll ()
{
// Free text
- int nCount = (int) m_aLines.GetSize ();
+ const int nCount = (int) m_aLines.GetSize ();
for (int I = 0; I < nCount; I++)
{
- if (m_aLines[I].m_nMax > 0)
- delete[] m_aLines[I].m_pcLine;
+ m_aLines[I].Clear();
}
m_aLines.RemoveAll ();
@@ -659,7 +657,7 @@
for (i = 0 ; i < m_aLines.GetSize () ; i++)
{
// the last real line has no EOL
- if (m_aLines[i].m_nEolChars == 0)
+ if (!m_aLines[i].HasEol())
continue;
bChanged |= ChangeLineEol(i, lpEOLtoApply);
}
@@ -686,7 +684,7 @@
ASSERT (m_bInit); // Text buffer not yet initialized.
// You must call InitNew() or LoadFromFile() first!
- return m_aLines[nLine].m_nLength;
+ return m_aLines[nLine].Length();
}
// number of characters in line (including any trailing eol characters)
@@ -696,7 +694,7 @@
ASSERT (m_bInit); // Text buffer not yet initialized.
// You must call InitNew() or LoadFromFile() first!
- return m_aLines[nLine].m_nLength + m_aLines[nLine].m_nEolChars;
+ return m_aLines[nLine].FullLength();
}
// get pointer to any trailing eol characters (pointer to empty string if none)
@@ -704,8 +702,8 @@
GetLineEol (int nLine) const
{
ASSERT (m_bInit); // Text buffer not yet initialized.
- if (m_aLines[nLine].m_nEolChars)
- return &m_aLines[nLine].m_pcLine[m_aLines[nLine].Length()];
+ if (m_aLines[nLine].HasEol())
+ return m_aLines[nLine].GetEol();
else
return _T("");
}
@@ -714,38 +712,16 @@
ChangeLineEol (int nLine, LPCTSTR lpEOL)
{
LineInfo & li = m_aLines[nLine];
- int nNewEolChars = (int) _tcslen(lpEOL);
- if (nNewEolChars == li.m_nEolChars)
- if (_tcscmp(li.m_pcLine + li.Length(), lpEOL) == 0)
- return FALSE;
-
- int nBufNeeded = li.m_nLength + nNewEolChars+1;
- if (nBufNeeded > li.m_nMax)
- {
- li.m_nMax = ALIGN_BUF_SIZE (nBufNeeded);
- ASSERT (li.m_nMax >= nBufNeeded);
- TCHAR *pcNewBuf = new TCHAR[li.m_nMax];
- if (li.FullLength() > 0)
- memcpy (pcNewBuf, li.m_pcLine, sizeof (TCHAR) * (li.FullLength()+1));
- delete[] li.m_pcLine;
- li.m_pcLine = pcNewBuf;
- }
-
- // copy also the 0 to zero-terminate the line
- memcpy (li.m_pcLine + li.m_nLength, lpEOL, sizeof (TCHAR) * (nNewEolChars+1));
- li.m_nEolChars = nNewEolChars;
-
- // modified
- return TRUE;
+ return li.ChangeEol(lpEOL);
}
-LPTSTR CCrystalTextBuffer::
+LPCTSTR CCrystalTextBuffer::
GetLineChars (int nLine) const
{
ASSERT (m_bInit); // Text buffer not yet initialized.
// You must call InitNew() or LoadFromFile() first!
- return m_aLines[nLine].m_pcLine;
+ return m_aLines[nLine].GetLine();
}
DWORD CCrystalTextBuffer::
@@ -895,9 +871,9 @@
// You must call InitNew() or LoadFromFile() first!
ASSERT (nStartLine >= 0 && nStartLine < m_aLines.GetSize ());
- ASSERT (nStartChar >= 0 && nStartChar <= m_aLines[nStartLine].m_nLength);
+ ASSERT (nStartChar >= 0 && nStartChar <= m_aLines[nStartLine].Length());
ASSERT (nEndLine >= 0 && nEndLine < m_aLines.GetSize ());
- ASSERT (nEndChar >= 0 && nEndChar <= m_aLines[nEndLine].m_nLength);
+ ASSERT (nEndChar >= 0 && nEndChar <= m_aLines[nEndLine].Length());
ASSERT (nStartLine < nEndLine || nStartLine == nEndLine && nStartChar <= nEndChar);
// some edit functions (copy...) should do nothing when there is no selection.
// assert to be sure to catch these 'do nothing' cases.
@@ -911,7 +887,7 @@
int nBufSize = 0;
for (int L = nStartLine; L <= nEndLine; L++)
{
- nBufSize += m_aLines[L].m_nLength;
+ nBufSize += m_aLines[L].Length();
nBufSize += nCRLFLength;
}
@@ -919,20 +895,20 @@
if (nStartLine < nEndLine)
{
- int nCount = m_aLines[nStartLine].m_nLength - nStartChar;
+ int nCount = m_aLines[nStartLine].Length() - nStartChar;
if (nCount > 0)
{
- memcpy (pszBuf, m_aLines[nStartLine].m_pcLine + nStartChar, sizeof (TCHAR) * nCount);
+ memcpy (pszBuf, m_aLines[nStartLine].GetLine(nStartChar), sizeof (TCHAR) * nCount);
pszBuf += nCount;
}
memcpy (pszBuf, pszCRLF, sizeof (TCHAR) * nCRLFLength);
pszBuf += nCRLFLength;
for (int I = nStartLine + 1; I < nEndLine; I++)
{
- nCount = m_aLines[I].m_nLength;
+ nCount = m_aLines[I].Length();
if (nCount > 0)
{
- memcpy (pszBuf, m_aLines[I].m_pcLine, sizeof (TCHAR) * nCount);
+ memcpy (pszBuf, m_aLines[I].GetLine(), sizeof (TCHAR) * nCount);
pszBuf += nCount;
}
memcpy (pszBuf, pszCRLF, sizeof (TCHAR) * nCRLFLength);
@@ -940,14 +916,14 @@
}
if (nEndChar > 0)
{
- memcpy (pszBuf, m_aLines[nEndLine].m_pcLine, sizeof (TCHAR) * nEndChar);
+ memcpy (pszBuf, m_aLines[nEndLine].GetLine(), sizeof (TCHAR) * nEndChar);
pszBuf += nEndChar;
}
}
else
{
int nCount = nEndChar - nStartChar;
- memcpy (pszBuf, m_aLines[nStartLine].m_pcLine + nStartChar, sizeof (TCHAR) * nCount);
+ memcpy (pszBuf, m_aLines[nStartLine].GetLine(nStartChar), sizeof (TCHAR) * nCount);
pszBuf += nCount;
}
text.ReleaseBuffer (pszBuf - text);
@@ -1021,9 +997,9 @@
// You must call InitNew() or LoadFromFile() first!
ASSERT (nStartLine >= 0 && nStartLine < m_aLines.GetSize ());
- ASSERT (nStartChar >= 0 && nStartChar <= m_aLines[nStartLine].m_nLength);
+ ASSERT (nStartChar >= 0 && nStartChar <= m_aLines[nStartLine].Length());
ASSERT (nEndLine >= 0 && nEndLine < m_aLines.GetSize ());
- ASSERT (nEndChar >= 0 && nEndChar <= m_aLines[nEndLine].m_nLength);
+ ASSERT (nEndChar >= 0 && nEndChar <= m_aLines[nEndLine].Length());
ASSERT (nStartLine < nEndLine || nStartLine == nEndLine && nStartChar <= nEndChar);
// some edit functions (delete...) should do nothing when there is no selection.
// assert to be sure to catch these 'do nothing' cases.
@@ -1040,14 +1016,7 @@
{
// delete part of one line
LineInfo & li = m_aLines[nStartLine];
- if (nEndChar < li.Length() || li.m_nEolChars)
- {
- // preserve characters after deleted range by shifting up
- memcpy (li.m_pcLine + nStartChar, li.m_pcLine + nEndChar,
- sizeof (TCHAR) * (li.FullLength() - nEndChar));
- }
- li.m_nLength -= (nEndChar - nStartChar);
- li.m_pcLine[li.FullLength()] = '\0';
+ li.Delete(nStartChar, nEndChar);
if (pSource!=NULL)
UpdateViews (pSource, &context, UPDATE_SINGLELINE | UPDATE_HORZRANGE, nStartLine);
@@ -1056,17 +1025,15 @@
{
// delete multiple lines
int nRestCount = m_aLines[nEndLine].FullLength() - nEndChar;
- CString sTail(m_aLines[nEndLine].m_pcLine + nEndChar, nRestCount);
+ CString sTail(m_aLines[nEndLine].GetLine(nEndChar), nRestCount);
int nDelCount = nEndLine - nStartLine;
for (int L = nStartLine + 1; L <= nEndLine; L++)
- delete[] m_aLines[L].m_pcLine;
+ m_aLines[L].Clear();
m_aLines.RemoveAt (nStartLine + 1, nDelCount);
// nEndLine is no more valid
- m_aLines[nStartLine].m_nLength = nStartChar;
- m_aLines[nStartLine].m_pcLine[nStartChar] = 0;
- m_aLines[nStartLine].m_nEolChars = 0;
+ m_aLines[nStartLine].DeleteEnd(nStartChar);
if (nRestCount > 0)
{
AppendLine (nStartLine, sTail, sTail.GetLength());
@@ -1099,9 +1066,9 @@
// Must not take off more than exist
ASSERT(offset >= 0);
- li.m_nLength = offset;
- li.m_nEolChars = 0;
- return CString(li.m_pcLine + offset, bytes);
+ CString ret(li.GetLine(offset), bytes);
+ li.DeleteEnd(offset);
+ return ret;
}
@@ -1129,7 +1096,7 @@
// You must call InitNew() or LoadFromFile() first!
ASSERT (nLine >= 0 && nLine < m_aLines.GetSize ());
- ASSERT (nPos >= 0 && nPos <= m_aLines[nLine].m_nLength);
+ ASSERT (nPos >= 0 && nPos <= m_aLines[nLine].Length());
if (m_bReadOnly)
return FALSE;
@@ -1398,9 +1365,9 @@
CString text;
if ((apparent_ptStartPos.y < m_aLines.GetSize ()) &&
- (apparent_ptStartPos.x <= m_aLines[apparent_ptStartPos.y].m_nLength) &&
+ (apparent_ptStartPos.x <= m_aLines[apparent_ptStartPos.y].Length()) &&
(apparent_ptEndPos.y < m_aLines.GetSize ()) &&
- (apparent_ptEndPos.x <= m_aLines[apparent_ptEndPos.y].m_nLength))
+ (apparent_ptEndPos.x <= m_aLines[apparent_ptEndPos.y].Length()))
{
GetTextWithoutEmptys (apparent_ptStartPos.y, apparent_ptStartPos.x, apparent_ptEndPos.y, apparent_ptEndPos.x, text);
if (_tcscmp(text, ur.GetText()) == 0)
@@ -1911,7 +1878,7 @@
void CCrystalTextBuffer::DeleteLine(int line, int nCount /*=1*/)
{
for (int ic = 0; ic < nCount; ic++)
- delete[] m_aLines[line+ic].m_pcLine;
+ m_aLines[line + ic].Clear();
m_aLines.RemoveAt(line, nCount);
}
Modified: trunk/Src/editlib/ccrystaltextbuffer.h
===================================================================
--- trunk/Src/editlib/ccrystaltextbuffer.h 2008-08-05 19:15:34 UTC (rev 5737)
+++ trunk/Src/editlib/ccrystaltextbuffer.h 2008-08-05 20:30:02 UTC (rev 5738)
@@ -221,7 +221,7 @@
int GetFullLineLength (int nLine) const; // including EOLs
LPCTSTR GetLineEol (int nLine) const;
BOOL ChangeLineEol (int nLine, LPCTSTR lpEOL);
- LPTSTR GetLineChars (int nLine) const;
+ LPCTSTR GetLineChars (int nLine) const;
DWORD GetLineFlags (int nLine) const;
DWORD GetLineRevisionNumber (int nLine) const;
int GetLineWithFlag (DWORD dwFlag);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|