OSDN Git Service

Status List Show diff color according to file status
authorFrank Li <lznuaa@gmail.com>
Mon, 29 Dec 2008 14:53:38 +0000 (22:53 +0800)
committerFrank Li <lznuaa@gmail.com>
Mon, 29 Dec 2008 14:53:38 +0000 (22:53 +0800)
src/Git/GitStatusListCtrl.cpp
src/Git/TGitPath.h

index 6b72253..8601958 100644 (file)
@@ -4275,10 +4275,11 @@ void CGitStatusListCtrl::OnNMCustomdraw(NMHDR *pNMHDR, LRESULT *pResult)
 \r
                        COLORREF crText = GetSysColor(COLOR_WINDOWTEXT);\r
 \r
-                       if (m_arListArray.size() > (DWORD_PTR)pLVCD->nmcd.dwItemSpec)\r
+                       if (m_arStatusArray.size() > (DWORD_PTR)pLVCD->nmcd.dwItemSpec)\r
                        {\r
-#if 0\r
-                               FileEntry * entry = GetListEntry((int)pLVCD->nmcd.dwItemSpec);\r
+\r
+                               //FileEntry * entry = GetListEntry((int)pLVCD->nmcd.dwItemSpec);\r
+                               CTGitPath *entry=(CTGitPath *)GetItemData((int)pLVCD->nmcd.dwItemSpec);\r
                                if (entry == NULL)\r
                                        return;\r
 \r
@@ -4290,51 +4291,29 @@ void CGitStatusListCtrl::OnNMCustomdraw(NMHDR *pNMHDR, LRESULT *pResult)
                                // brown  : missing, deleted, replaced\r
                                // green  : merged (or potential merges)\r
                                // red    : conflicts or sure conflicts\r
-                               switch (entry->status)\r
+                               if(entry->m_Action & CTGitPath::LOGACTIONS_CONFLICT)\r
                                {\r
-                               case git_wc_status_added:\r
-//                                     if (entry->remotestatus > git_wc_status_unversioned)\r
-                                               // locally added file, but file already exists in repository!\r
-//                                             crText = m_Colors.GetColor(CColors::Conflict);\r
-//                                     else\r
-                                               crText = m_Colors.GetColor(CColors::Added);\r
-                                       break;\r
-                               case git_wc_status_missing:\r
-                               case git_wc_status_deleted:\r
-                               case git_wc_status_replaced:\r
-                                       crText = m_Colors.GetColor(CColors::Deleted);\r
-                                       break;\r
-                               case git_wc_status_modified:\r
-//                                     if (entry->remotestatus == git_wc_status_modified)\r
-                                               // indicate a merge (both local and remote changes will require a merge)\r
-//                                             crText = m_Colors.GetColor(CColors::Merged);\r
-//                                     else if (entry->remotestatus == git_wc_status_deleted)\r
-//                                             // locally modified, but already deleted in the repository\r
-//                                             crText = m_Colors.GetColor(CColors::Conflict);\r
-//                                     else\r
-                                               crText = m_Colors.GetColor(CColors::Modified);\r
-                                       break;\r
-                               case git_wc_status_merged:\r
-                                       crText = m_Colors.GetColor(CColors::Merged);\r
-                                       break;\r
-                               case git_wc_status_conflicted:\r
-                               case git_wc_status_obstructed:\r
                                        crText = m_Colors.GetColor(CColors::Conflict);\r
-                                       break;\r
-                               case git_wc_status_none:\r
-                               case git_wc_status_unversioned:\r
-                               case git_wc_status_ignored:\r
-                               case git_wc_status_incomplete:\r
-                               case git_wc_status_normal:\r
-                               case git_wc_status_external:\r
-                               default:\r
+\r
+                               }else if(entry->m_Action & CTGitPath::LOGACTIONS_MODIFIED)\r
+                               {\r
+                                       crText = m_Colors.GetColor(CColors::Modified);\r
+\r
+                               }else if(entry->m_Action & CTGitPath::LOGACTIONS_ADDED)\r
+                               {\r
+                                       crText = m_Colors.GetColor(CColors::Added);\r
+                               }\r
+                               else if(entry->m_Action & CTGitPath::LOGACTIONS_DELETED)\r
+                               {\r
+                                       crText = m_Colors.GetColor(CColors::DeletedNode);\r
+                               }\r
+                               else if(entry->m_Action & CTGitPath::LOGACTIONS_REPLACED)\r
+                               {\r
+                                       crText = m_Colors.GetColor(CColors::RenamedNode);\r
+                               }else\r
+                               {\r
                                        crText = GetSysColor(COLOR_WINDOWTEXT);\r
-                                       break;\r
                                }\r
-\r
-                               if (entry->isConflicted)\r
-                                       crText = m_Colors.GetColor(CColors::Conflict);\r
-#endif\r
                                // Store the color back in the NMLVCUSTOMDRAW struct.\r
                                pLVCD->clrText = crText;\r
                        }\r
index 132835a..130e5ee 100644 (file)
@@ -15,6 +15,7 @@ public:
                LOGACTIONS_DELETED      = 0x00000008,\r
                LOGACTIONS_UNVER        = 0x80000000,\r
                LOGACTIONS_IGNORE       = 0x40000000,\r
+               LOGACTIONS_CONFLICT = 0x20000000,\r
        };\r
 \r
        CString m_StatAdd;\r