Keep the font size of 8 for the explorer property page
[TortoiseGit.git] / src / TortoiseGitBlame / TortoiseGitBlameData.h
blobcf4d9b4b12e99e2d3f9eaeedd7dcfc709015db79
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2013, 2015-2018 - TortoiseGit
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 // CTortoiseGitBlameData.h : interface of the CTortoiseGitBlameData class
22 #pragma once
24 #include "GitHash.h"
25 #include "gitlogcache.h"
26 #include <unordered_set>
28 class CTortoiseGitBlameData
30 // Implementation
31 public:
32 CTortoiseGitBlameData();
33 virtual ~CTortoiseGitBlameData();
35 public:
36 int GetEncode(unsigned char * buffer, int size, int *bomoffset);
37 int GetEncode(int *bomoffset);
38 void ParseBlameOutput(BYTE_VECTOR &data, CGitHashMap & HashToRev, DWORD dateFormat, bool bRelativeTimes);
39 // updates sourcecode lines to the given encoding, encode==0 detects the encoding, returns the used encoding
40 int UpdateEncoding(int encode = 0);
42 BOOL IsValidLine(int line)
44 return line >= 0 && line < (int)m_Hash.size();
46 int FindNextLine(CGitHash& commithash, int line, bool bUpOrDown=false);
47 // find first line with the given hash starting with given "line"
48 int FindFirstLine(CGitHash& commithash, int line)
50 int numberOfLines = (int)GetNumberOfLines();
51 for (int i = (line >= 0 ? line : 0); i < numberOfLines; ++i)
53 if (m_Hash[i] == commithash)
54 return i;
56 return -1;
58 // find first line of the current block with the given hash starting with given "line"
59 int FindFirstLineInBlock(CGitHash& commithash, int line)
61 while (line >= 0)
63 if (m_Hash[line] != commithash)
64 return line++;
65 --line;
67 return line;
69 enum SearchDirection{ SearchNext = 0, SearchPrevious = 1 };
70 int FindFirstLineWrapAround(SearchDirection direction, const CString& what, int line, bool bCaseSensitive, std::function<void()> wraparound);
72 size_t GetNumberOfLines() const
74 return m_Hash.size();
77 CGitHash& GetHash(size_t line)
79 return m_Hash[line];
82 void GetHashes(std::unordered_set<CGitHash>& hashes)
84 hashes.clear();
85 for (const auto& hash : m_Hash)
87 hashes.insert(hash);
91 const CString& GetDate(size_t line) const
93 return m_Dates[line];
96 const CString& GetAuthor(size_t line) const
98 return m_Authors[line];
101 const CString& GetFilename(size_t line) const
103 return m_Filenames[line];
106 int GetOriginalLineNumber(size_t line) const
108 return m_OriginalLineNumbers[line];
111 const CStringA& GetUtf8Line(size_t line) const
113 return m_Utf8Lines[line];
116 bool ContainsOnlyFilename(const CString &filename) const;
118 GitRevLoglist* GetRev(int line, CGitHashMap& hashToRev)
120 return GetRevForHash(hashToRev, GetHash(line));
123 private:
124 static GitRevLoglist* GetRevForHash(CGitHashMap& HashToRev, const CGitHash& hash, CString* err = nullptr);
125 static CString UnquoteFilename(CStringA& s);
127 std::vector<CGitHash> m_Hash;
128 std::vector<CString> m_Dates;
129 std::vector<CString> m_Authors;
130 std::vector<CString> m_Filenames;
131 std::vector<int> m_OriginalLineNumbers;
132 std::vector<BYTE_VECTOR> m_RawLines;
134 int m_encode;
135 std::vector<CStringA> m_Utf8Lines;