MCPcopy Create free account
hub / github.com/WinMerge/winmerge / InternalDeleteGhostLine

Method InternalDeleteGhostLine

Src/GhostTextBuffer.cpp:73–111  ·  view source on GitHub ↗

InternalDeleteGhostLine accepts only apparent line numbers */ * @brief Delete a group of ghost lines. * @param [in] pSource View from which to delete the lines. * @param [in] nLine Line index where to delete the first ghost line. * @param [in] nCount the number of ghost lines to delete * @return true if the deletion succeeded, false otherwise. * @note @p nLine must be an apparent line number

Source from the content-addressed store, hash-verified

71 * @note @p nLine must be an apparent line number (ghost lines added).
72 */
73bool CGhostTextBuffer::InternalDeleteGhostLine (CCrystalTextView * pSource,
74 int nLine, int nCount)
75{
76 ASSERT (m_bInit); // Text buffer not yet initialized.
77 // You must call InitNew() or LoadFromFile() first!
78 ASSERT (nCount >= 0);
79 ASSERT (nLine >= 0 && (nLine + nCount) <= static_cast<intptr_t>(m_aLines.size ()));
80
81 if (nCount == 0)
82 return true;
83
84 for (int i = nLine ; i < nLine + nCount; i++)
85 {
86 ASSERT ( (GetLineFlags(i) & LF_GHOST) != 0 );
87 m_aLines[i].Clear();
88 }
89
90 vector<LineInfo>::iterator iterBegin = m_aLines.begin() + nLine;
91 vector<LineInfo>::iterator iterEnd = iterBegin + nCount;
92 m_aLines.erase(iterBegin, iterEnd);
93
94 if (pSource != nullptr)
95 {
96 CDeleteContext context;
97 context.m_ptStart.y = nLine;
98 context.m_ptStart.x = 0;
99 context.m_ptEnd.y = nLine + nCount;
100 context.m_ptEnd.x = 0;
101
102 if (nLine == GetLineCount())
103 nLine--;
104 // The last parameter is optimization
105 // - don't recompute lines preceding the removed line.
106 UpdateViews (pSource, &context, UPDATE_HORZRANGE | UPDATE_VERTRANGE,
107 nLine);
108 }
109
110 return true;
111}
112
113/**
114 * @brief Get text of specified lines (ghost lines will not contribute to text).

Callers

nothing calls this directly

Calls 4

sizeMethod · 0.45
ClearMethod · 0.45
beginMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected