ptEnd.x = 0;
ptEnd.y = curDiff.dend;
- if (bScroll)
+ if (bScroll && !m_bDetailView)
{
if (!IsDiffVisible(curDiff, CONTEXT_LINES_BELOW))
{
else
m_bCurrentLineIsDiff = false;
- UpdateLocationViewPosition(m_nTopSubLine, m_nTopSubLine + GetScreenLines());
+ CWnd* pWnd = GetFocus();
+ if (!m_bDetailView || (pWnd && pWnd->m_hWnd == this->m_hWnd))
+ UpdateLocationViewPosition(m_nTopSubLine, m_nTopSubLine + GetScreenLines());
}
/**
* @brief Select linedifference in the current line.
}
/**
+ * @brief Adjust the point to remain in the displayed diff
+ *
+ * @return Tells if the point has been changed
+ */
+bool CMergeEditView::EnsureInDiff(CPoint& pt)
+{
+ int diffLength = m_lineEnd - m_lineBegin + 1;
+ // first get the degenerate case out of the way
+ // no diff ?
+ if (diffLength == 0)
+ {
+ if (pt.y == m_lineBegin && pt.x == 0)
+ return false;
+ pt.y = m_lineBegin;
+ pt.x = 0;
+ return true;
+ }
+
+ // not above diff
+ if (pt.y < m_lineBegin)
+ {
+ pt.y = m_lineBegin;
+ pt.x = 0;
+ return true;
+ }
+ // diff is defined and not below diff
+ if (m_lineEnd > -1 && pt.y > m_lineEnd)
+ {
+ pt.y = m_lineEnd;
+ pt.x = GetLineLength(pt.y);
+ return true;
+ }
+ return false;
+}
+
+void CMergeEditView::EnsureVisible(CPoint pt)
+{
+ CPoint ptNew = pt;
+ if (m_bDetailView)
+ {
+ // ensure we remain in diff
+ if (EnsureInDiff(ptNew))
+ SetCursorPos(ptNew);
+ }
+ CCrystalTextView::EnsureVisible(ptNew);
+}
+
+void CMergeEditView::EnsureVisible(CPoint ptStart, CPoint ptEnd)
+{
+ CCrystalTextView::EnsureVisible(ptStart, ptEnd);
+}
+
+void CMergeEditView::SetSelection(const CPoint& ptStart, const CPoint& ptEnd, bool bUpdateView)
+{
+ CPoint ptStartNew = ptStart;
+ CPoint ptEndNew = ptEnd;
+ if (m_bDetailView)
+ {
+ // ensure we remain in diff
+ EnsureInDiff(ptStartNew);
+ EnsureInDiff(ptEndNew);
+ }
+ CCrystalTextView::SetSelection(ptStartNew, ptEndNew, bUpdateView);
+}
+
+void CMergeEditView::ScrollToSubLine(int nNewTopLine, bool bNoSmoothScroll /*= FALSE*/, bool bTrackScrollBar /*= TRUE*/)
+{
+ if (m_bDetailView)
+ {
+ // ensure we remain in diff
+ int sublineBegin = GetSubLineIndex(m_lineBegin);
+ int sublineEnd = GetSubLineIndex(m_lineEnd) + GetSubLines(m_lineEnd) - 1;
+ int diffLength = sublineEnd - sublineBegin + 1;
+ int displayLength = GetScreenLines();
+ if (diffLength <= displayLength)
+ nNewTopLine = sublineBegin;
+ else
+ {
+ if (nNewTopLine < sublineBegin)
+ nNewTopLine = sublineBegin;
+ if (nNewTopLine + displayLength - 1 > sublineEnd)
+ nNewTopLine = GetSubLineIndex(sublineEnd - displayLength + 1);
+ }
+
+ CPoint pt = GetCursorPos();
+ if (EnsureInDiff(pt))
+ SetCursorPos(pt);
+
+ CPoint ptSelStart, ptSelEnd;
+ GetSelection(ptSelStart, ptSelEnd);
+ if (EnsureInDiff(ptSelStart) || EnsureInDiff(ptSelEnd))
+ SetSelection(ptSelStart, ptSelEnd);
+ }
+ CCrystalTextView::ScrollToSubLine(nNewTopLine, bNoSmoothScroll, bTrackScrollBar);
+}
+
+/**
* @brief Called when user selects View/Zoom In from menu.
*/
void CMergeEditView::OnViewZoomIn()
bool IsDiffVisible(int nDiff);
void ZoomText(short amount);
virtual bool QueryEditable() override;
+ virtual void EnsureVisible(CPoint pt) override;
+ virtual void EnsureVisible(CPoint ptStart, CPoint ptEnd) override;
+ bool EnsureInDiff(CPoint& pt);
+ void SetSelection(const CPoint& ptStart, const CPoint& ptEnd, bool bUpdateView = true) override;
+ void ScrollToSubLine(int nNewTopLine, bool bNoSmoothScroll = false, bool bTrackScrollBar = true) override;
// Overrides
// ClassWizard generated virtual function overrides