From 5863ebf4ab83d0658a86fcbb9fbb90c8cef4e2d1 Mon Sep 17 00:00:00 2001 From: Takashi Sawanaka Date: Sun, 20 Aug 2017 20:17:41 +0900 Subject: [PATCH] ccrystaltextiview.cpp: remove duplicate code --- Externals/crystaledit/editlib/ccrystaltextview.cpp | 52 +++++----------------- 1 file changed, 12 insertions(+), 40 deletions(-) diff --git a/Externals/crystaledit/editlib/ccrystaltextview.cpp b/Externals/crystaledit/editlib/ccrystaltextview.cpp index e2a29b5bb..6ffaee469 100644 --- a/Externals/crystaledit/editlib/ccrystaltextview.cpp +++ b/Externals/crystaledit/editlib/ccrystaltextview.cpp @@ -1703,22 +1703,7 @@ DrawSingleLine (CDC * pdc, const CRect & rc, int nLineIndex) int nLength = GetViewableLineLength (nLineIndex); LPCTSTR pszChars = GetLineChars (nLineIndex); - // Parse the line - DWORD dwCookie = GetParseCookie (nLineIndex - 1); - std::vector blocks((nLength+1) * 3); // be aware of nLength == 0 - int nBlocks = 0; - - // insert at least one textblock of normal color at the beginning - blocks[0].m_nCharPos = 0; - blocks[0].m_nColorIndex = COLORINDEX_NORMALTEXT; - blocks[0].m_nBgColorIndex = COLORINDEX_BKGND; - nBlocks++; - - (*m_ParseCookies)[nLineIndex] = ParseLine (dwCookie, nLineIndex, blocks.data(), nBlocks); - ASSERT ((*m_ParseCookies)[nLineIndex] != - 1); - blocks.resize(nBlocks); - - std::vector mergedBlocks = MergeTextBlocks(blocks, GetAdditionalTextBlocks(nLineIndex)); + std::vector blocks = GetTextBlocks(nLineIndex); int nActualItem = 0; int nActualOffset = 0; @@ -1743,7 +1728,7 @@ DrawSingleLine (CDC * pdc, const CRect & rc, int nLineIndex) // draw start of line to first break DrawScreenLine( pdc, origin, rc, - mergedBlocks, + blocks, crText, crBkgnd, bDrawWhitespace, pszChars, 0, anBreaks[0], nActualOffset, CPoint( 0, nLineIndex ) ); @@ -1754,7 +1739,7 @@ DrawSingleLine (CDC * pdc, const CRect & rc, int nLineIndex) ASSERT( anBreaks[i] >= 0 && anBreaks[i] < nLength ); DrawScreenLine( pdc, origin, rc, - mergedBlocks, + blocks, crText, crBkgnd, bDrawWhitespace, pszChars, anBreaks[i], anBreaks[i + 1] - anBreaks[i], nActualOffset, CPoint( anBreaks[i], nLineIndex ) ); @@ -1763,7 +1748,7 @@ DrawSingleLine (CDC * pdc, const CRect & rc, int nLineIndex) // draw from last break till end of line DrawScreenLine( pdc, origin, rc, - mergedBlocks, + blocks, crText, crBkgnd, bDrawWhitespace, pszChars, anBreaks[i], nLength - anBreaks[i], nActualOffset, CPoint( anBreaks[i], nLineIndex ) ); @@ -1771,7 +1756,7 @@ DrawSingleLine (CDC * pdc, const CRect & rc, int nLineIndex) else DrawScreenLine( pdc, origin, rc, - mergedBlocks, + blocks, crText, crBkgnd, bDrawWhitespace, pszChars, 0, nLength, nActualOffset, CPoint(0, nLineIndex)); @@ -1984,20 +1969,7 @@ GetHTMLLine (int nLineIndex, LPCTSTR pszTag) COLORREF crBkgnd, crText; GetLineColors (nLineIndex, crBkgnd, crText, bDrawWhitespace); - // Parse the line - DWORD dwCookie = GetParseCookie (nLineIndex - 1); - std::vector blocks((nLength+1) * 3); // be aware of nLength == 0 - int nBlocks = 0; - // insert at least one textblock of normal color at the beginning - blocks[0].m_nCharPos = 0; - blocks[0].m_nColorIndex = COLORINDEX_NORMALTEXT; - blocks[0].m_nBgColorIndex = COLORINDEX_BKGND; - nBlocks++; - (*m_ParseCookies)[nLineIndex] = ParseLine (dwCookie, nLineIndex, blocks.data(), nBlocks); - ASSERT ((*m_ParseCookies)[nLineIndex] != - 1); - blocks.resize(nBlocks); - - std::vector mergedBlocks = MergeTextBlocks(blocks, GetAdditionalTextBlocks(nLineIndex)); + std::vector blocks = GetTextBlocks(nLineIndex); CString strHTML; CString strExpanded; @@ -2012,25 +1984,25 @@ GetHTMLLine (int nLineIndex, LPCTSTR pszTag) strHTML += GetHTMLAttribute (COLORINDEX_NORMALTEXT, COLORINDEX_BKGND, crText, crBkgnd); strHTML += _T(">"); - for (i = 0; i < mergedBlocks.size() - 1; i++) + for (i = 0; i < blocks.size() - 1; i++) { - ExpandChars (pszChars, mergedBlocks[i].m_nCharPos, mergedBlocks[i + 1].m_nCharPos - mergedBlocks[i].m_nCharPos, strExpanded, 0); + ExpandChars (pszChars, blocks[i].m_nCharPos, blocks[i + 1].m_nCharPos - blocks[i].m_nCharPos, strExpanded, 0); if (!strExpanded.IsEmpty()) { strHTML += _T(""); strHTML += EscapeHTML (strExpanded, bLastCharSpace, nNonbreakChars, nScreenChars); strHTML += _T(""); } } - if (nBlocks > 0) + if (blocks.size() > 0) { - ExpandChars (pszChars, mergedBlocks[i].m_nCharPos, nLength - mergedBlocks[i].m_nCharPos, strExpanded, 0); + ExpandChars (pszChars, blocks[i].m_nCharPos, nLength - blocks[i].m_nCharPos, strExpanded, 0); if (!strExpanded.IsEmpty()) { strHTML += _T(""); strHTML += EscapeHTML (strExpanded, bLastCharSpace, nNonbreakChars, nScreenChars); strHTML += _T(""); -- 2.11.0