Add lock for tgitcache and fix ignore entry miss
[TortoiseGit.git] / src / TortoiseMerge / Undo.h
blobe44c8765a0699d86d10117a490579562550b0c3e
1 // TortoiseMerge - a Diff/Patch program
3 // Copyright (C) 2006-2007 - TortoiseSVN
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #pragma once
20 #include "ViewData.h"
21 #include <map>
22 #include <list>
24 class CBaseView;
26 /**
27 * \ingroup TortoiseMerge
28 * this struct holds all the information of a single change in TortoiseMerge.
30 typedef struct viewstate
32 std::map<int, CString> difflines;
33 std::map<int, DWORD> linestates;
34 std::map<int, DWORD> linelines;
35 std::list<int> addedlines;
37 std::map<int, viewdata> removedlines;
39 void AddLineFormView(CBaseView *pView, int nLine, bool bAddEmptyLine);
40 } viewstate;
42 /**
43 * \ingroup TortoiseMerge
44 * Holds all the information of previous changes made to a view content.
45 * Of course, can undo those changes.
47 class CUndo
49 public:
50 static CUndo& GetInstance();
52 bool Undo(CBaseView * pLeft, CBaseView * pRight, CBaseView * pBottom);
53 void AddState(const viewstate& leftstate, const viewstate& rightstate, const viewstate& bottomstate, POINT pt);
54 bool CanUndo() {return (m_viewstates.size() > 0);}
56 bool IsGrouping() { return m_groups.size() % 2 == 1; }
57 void BeginGrouping() { ASSERT(!IsGrouping()); m_groups.push_back(m_caretpoints.size()); }
58 void EndGrouping(){ ASSERT(IsGrouping()); m_groups.push_back(m_caretpoints.size()); }
59 void Clear();
60 void MarkAsOriginalState() { m_originalstate = m_viewstates.size(); }
61 protected:
62 void Undo(const viewstate& state, CBaseView * pView);
63 void UndoOne(CBaseView * pLeft, CBaseView * pRight, CBaseView * pBottom);
64 std::list<viewstate> m_viewstates;
65 std::list<POINT> m_caretpoints;
66 std::list< std::list<int>::size_type > m_groups;
67 unsigned int m_originalstate;
68 private:
69 CUndo();
70 ~CUndo();