OSDN Git Service

PATCH: [ 913792 ] Cache color options for MergeView
authorKimmo Varis <kimmov@gmail.com>
Thu, 11 Mar 2004 13:29:21 +0000 (13:29 +0000)
committerKimmo Varis <kimmov@gmail.com>
Thu, 11 Mar 2004 13:29:21 +0000 (13:29 +0000)
Src/MergeDoc.cpp
Src/MergeEditView.cpp
Src/MergeEditView.h
Src/readme.txt

index 49e4e12..0423edb 100644 (file)
@@ -2670,6 +2670,10 @@ void CMergeDoc::RefreshOptions()
        options.bEolSensitive = mf->m_options.GetInt(OPT_CMP_EOL_SENSITIVE);
 
        m_diffWrapper.SetOptions(&options);
+
+       // Refresh view options
+       m_pLeftView->RefreshOptions();
+       m_pRightView->RefreshOptions();
 }
 
 /**
index 743b6cf..ad1b29c 100644 (file)
@@ -65,6 +65,17 @@ CMergeEditView::CMergeEditView()
        SetParser(&m_xParser);
        m_bAutomaticRescan = FALSE;
        fTimerWaitingForIdle = 0;
+
+       m_bSyntaxHighlight = mf->m_options.GetInt(OPT_SYNTAX_HIGHLIGHT);
+       m_cachedColors.clrDiff = mf->m_options.GetInt(OPT_CLR_DIFF);
+       m_cachedColors.clrSelDiff = mf->m_options.GetInt(OPT_CLR_SELECTED_DIFF);
+       m_cachedColors.clrDiffDeleted = mf->m_options.GetInt(OPT_CLR_DIFF_DELETED);
+       m_cachedColors.clrSelDiffDeleted = mf->m_options.GetInt(OPT_CLR_SELECTED_DIFF_DELETED);
+       m_cachedColors.clrDiffText = mf->m_options.GetInt(OPT_CLR_DIFF_TEXT);
+       m_cachedColors.clrSelDiffText = mf->m_options.GetInt(OPT_CLR_SELECTED_DIFF_TEXT);
+       m_cachedColors.clrTrivial = mf->m_options.GetInt(OPT_CLR_TRIVIAL_DIFF);
+       m_cachedColors.clrTrivialDeleted = mf->m_options.GetInt(OPT_CLR_TRIVIAL_DIFF_DELETED);
+
 }
 
 CMergeEditView::~CMergeEditView()
@@ -293,7 +304,7 @@ void CMergeEditView::GetLineColors(int nLineIndex, COLORREF & crBkgnd,
        // Line inside diff
        if (dwLineFlags & LF_WINMERGE_FLAGS)
        {
-               crText = mf->m_options.GetInt(OPT_CLR_DIFF_TEXT);
+               crText = m_cachedColors.clrDiffText;
                bDrawWhitespace = TRUE;
                BOOL lineInCurrentDiff = IsLineInCurrentDiff(nLineIndex);
 
@@ -301,13 +312,13 @@ void CMergeEditView::GetLineColors(int nLineIndex, COLORREF & crBkgnd,
                {
                        if (lineInCurrentDiff)
                        {
-                               crBkgnd = mf->m_options.GetInt(OPT_CLR_SELECTED_DIFF);
-                               crText = mf->m_options.GetInt(OPT_CLR_SELECTED_DIFF_TEXT);
+                               crBkgnd = m_cachedColors.clrSelDiff;
+                               crText = m_cachedColors.clrSelDiffText;
                        }
                        else
                        {
-                               crBkgnd = mf->m_options.GetInt(OPT_CLR_DIFF);
-                               crText = mf->m_options.GetInt(OPT_CLR_DIFF_TEXT);
+                               crBkgnd = m_cachedColors.clrDiff;
+                               crText = m_cachedColors.clrDiffText;
                        }
                        return;
                }
@@ -316,25 +327,24 @@ void CMergeEditView::GetLineColors(int nLineIndex, COLORREF & crBkgnd,
                        // trivial diff can not be selected
                        if (dwLineFlags & LF_GHOST)
                                // ghost lines in trivial diff has their own color
-                               crBkgnd = mf->m_options.GetInt(OPT_CLR_TRIVIAL_DIFF_DELETED);
+                               crBkgnd = m_cachedColors.clrTrivialDeleted;
                        else
-                               crBkgnd = mf->m_options.GetInt(OPT_CLR_TRIVIAL_DIFF);
+                               crBkgnd = m_cachedColors.clrTrivial;
                        return;
                }
                else if (dwLineFlags & LF_GHOST)
                {
                        if (lineInCurrentDiff)
-                               crBkgnd = mf->m_options.GetInt(OPT_CLR_SELECTED_DIFF_DELETED);
+                               crBkgnd = m_cachedColors.clrSelDiffDeleted;
                        else
-                               crBkgnd = mf->m_options.GetInt(OPT_CLR_DIFF_DELETED);
+                               crBkgnd = m_cachedColors.clrDiffDeleted;
                        return;
                }
-
        }
        else
        {
                // Line not inside diff,
-               if (!mf->m_options.GetInt(OPT_SYNTAX_HIGHLIGHT))
+               if (!m_bSyntaxHighlight)
                {
                        // If no syntax hilighting, get windows default colors
                        crBkgnd = GetSysColor (COLOR_WINDOW);
@@ -1842,3 +1852,20 @@ void CMergeEditView::OnUpdateWMGoto(CCmdUI* pCmdUI)
 {
        pCmdUI->Enable(TRUE);
 }
+
+/**
+ * @brief Reload cached options.
+ */
+void CMergeEditView::RefreshOptions()
+{ 
+       m_bSyntaxHighlight = mf->m_options.GetInt(OPT_SYNTAX_HIGHLIGHT);
+       m_cachedColors.clrDiff = mf->m_options.GetInt(OPT_CLR_DIFF);
+       m_cachedColors.clrSelDiff = mf->m_options.GetInt(OPT_CLR_SELECTED_DIFF);
+       m_cachedColors.clrDiffDeleted = mf->m_options.GetInt(OPT_CLR_DIFF_DELETED);
+       m_cachedColors.clrSelDiffDeleted = mf->m_options.GetInt(OPT_CLR_SELECTED_DIFF_DELETED);
+       m_cachedColors.clrDiffText = mf->m_options.GetInt(OPT_CLR_DIFF_TEXT);
+       m_cachedColors.clrSelDiffText = mf->m_options.GetInt(OPT_CLR_SELECTED_DIFF_TEXT);
+       m_cachedColors.clrTrivial = mf->m_options.GetInt(OPT_CLR_TRIVIAL_DIFF);
+       m_cachedColors.clrTrivialDeleted = mf->m_options.GetInt(OPT_CLR_TRIVIAL_DIFF_DELETED);
+}
+
index 2ab45d3..57a3d0a 100644 (file)
 #if !defined(AFX_MERGEEDITVIEW_H__0CE31CFD_4BEE_4378_ADB4_B7C9F50A9F53__INCLUDED_)
 #define AFX_MERGEEDITVIEW_H__0CE31CFD_4BEE_4378_ADB4_B7C9F50A9F53__INCLUDED_
 
+/** 
+ * @brief Color settings.
+ */
+struct COLORSETTINGS
+{
+       COLORREF        clrDiff;                        // The difference color
+       COLORREF        clrSelDiff;                     // The selected difference color
+       COLORREF        clrDiffDeleted;         // The difference deleted color
+       COLORREF        clrSelDiffDeleted;      // The selected difference deleted color
+       COLORREF        clrDiffText;            // The difference text color
+       COLORREF        clrSelDiffText;         // The selected difference text color
+       COLORREF        clrTrivial;                     // The blank line change
+       COLORREF        clrTrivialDeleted;      // The missing blank line
+       COLORREF        clrFileLeftNewer;       // The left file newer color (dir view)
+       COLORREF        clrFileRightNewer;      // The right file newer color (dir view)
+};
 
 /** 
  * @brief Non-diff lines shown above diff when scrolling to it
@@ -100,7 +116,7 @@ public:
        IMergeEditStatus * m_piMergeEditStatus; // interface to status bar
 
 protected:
-       // Controls if rescan is done after edit events
+       /** Controls if rescan is done after edit events */
        BOOL m_bAutomaticRescan;
 
 private:
@@ -109,9 +125,12 @@ private:
        to wait for theApp::OnIdle before processing it 
        */
        BOOL fTimerWaitingForIdle;
+       COLORSETTINGS m_cachedColors; /**< Cached color settings */
+       BOOL m_bSyntaxHighlight; /**< Cached setting for syntax highlight */
 
 // Operations
 public:
+       void RefreshOptions();
        BOOL EnableRescan(BOOL bEnable);
        BOOL IsReadOnly(BOOL bLeft);
        void ShowDiff(BOOL bScroll, BOOL bSelectText);
index 7f16287..e5be8c8 100644 (file)
@@ -1,3 +1,7 @@
+2004-03-11 Kimmo
+ PATCH: [ 913792 ] Cache color options for MergeView
+  Src: MergeDoc.cpp MergeEditView.cpp MergeEditView.h
+
 2004-03-10 Kimmo
  Fix for OptionsMgr bugs when loading string options from registry
   UNICODE strings were not handled correctly, incorrect buffer lengths