ON_UPDATE_COMMAND_UI(ID_PREVDIFFRO, OnUpdatePrevdiffRO)
ON_WM_LBUTTONDBLCLK()
ON_WM_LBUTTONUP()
+ ON_WM_RBUTTONDOWN()
ON_COMMAND(ID_ALL_LEFT, OnAllLeft)
ON_UPDATE_COMMAND_UI(ID_ALL_LEFT, OnUpdateAllLeft)
ON_COMMAND(ID_ALL_RIGHT, OnAllRight)
pd->ForEachView (0, [&](auto& pView) { if (pView->m_bDetailView) pView->OnDisplayDiff(nDiff); });
}
+void CMergeEditView::DeselectDiffIfCursorNotInCurrentDiff()
+{
+ CMergeDoc *pd = GetDocument();
+ // If we have a selected diff, deselect it
+ int nCurrentDiff = pd->GetCurrentDiff();
+ if (nCurrentDiff != -1)
+ {
+ CPoint pos = GetCursorPos();
+ if (!IsLineInCurrentDiff(pos.y))
+ {
+ pd->SetCurrentDiff(-1);
+ Invalidate();
+ pd->UpdateAllViews(this);
+ }
+ }
+}
+
/**
* @brief Called when user selects "Current Difference".
* Goes to active diff. If no active diff, selects diff under cursor
*/
void CMergeEditView::OnLButtonUp(UINT nFlags, CPoint point)
{
- CMergeDoc *pd = GetDocument();
CCrystalEditViewEx::OnLButtonUp(nFlags, point);
+ DeselectDiffIfCursorNotInCurrentDiff();
+}
- // If we have a selected diff, deselect it
- int nCurrentDiff = pd->GetCurrentDiff();
- if (nCurrentDiff != -1)
- {
- CPoint pos = GetCursorPos();
- if (!IsLineInCurrentDiff(pos.y))
- {
- pd->SetCurrentDiff(-1);
- Invalidate();
- pd->UpdateAllViews(this);
- }
- }
+/**
+ * @brief Called when mouse right button is pressed.
+ *
+ * If right button is pressed outside diffs, current diff
+ * is deselected.
+ */
+void CMergeEditView::OnRButtonDown(UINT nFlags, CPoint point)
+{
+ CCrystalEditViewEx::OnRButtonDown(nFlags, point);
+ DeselectDiffIfCursorNotInCurrentDiff();
}
void CMergeEditView::OnX2Y(int srcPane, int dstPane)
bool IsLineInCurrentDiff(int nLine) const;
void SelectNone();
void SelectDiff(int nDiff, bool bScroll = true, bool bSelectText = true);
+ void DeselectDiffIfCursorNotInCurrentDiff();
virtual CCrystalTextBuffer *LocateTextBuffer ();
const CCrystalTextBuffer *LocateTextBuffer () const { return const_cast<CMergeEditView *>(this)->LocateTextBuffer(); };
void GetFullySelectedDiffs(int & firstDiff, int & lastDiff, int & firstWordDiff, int & lastWordDiff, const CPoint *pptStart = nullptr, const CPoint *ppEnd = nullptr);
afx_msg void OnUpdatePrevdiffRO(CCmdUI* pCmdUI);
afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
+ afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
afx_msg void OnAllLeft();
afx_msg void OnUpdateAllLeft(CCmdUI* pCmdUI);
afx_msg void OnAllRight();