Don't create the tooltips as topmost, and don't position them as topmost either but...
[TortoiseGit.git] / src / TortoiseGitBlame / TortoiseGitBlameData.h
blobcc4ac494bbf79c05c86d30ff8666df41f8d37be0
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2013, 2015 - 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 "gitlogcache.h"
26 class CTortoiseGitBlameData
28 // Implementation
29 public:
30 CTortoiseGitBlameData();
31 virtual ~CTortoiseGitBlameData();
33 public:
34 int GetEncode(unsigned char * buffer, int size, int *bomoffset);
35 int GetEncode(int *bomoffset);
36 void ParseBlameOutput(BYTE_VECTOR &data, CGitHashMap & HashToRev, DWORD dateFormat, bool bRelativeTimes);
37 // updates sourcecode lines to the given encoding, encode==0 detects the encoding, returns the used encoding
38 int UpdateEncoding(int encode = 0);
40 BOOL IsValidLine(int line)
42 return line >= 0 && line < (int)m_Hash.size();
44 int FindNextLine(CGitHash& commithash, int line, bool bUpOrDown=false);
45 // find first line with the given hash starting with given "line"
46 int FindFirstLine(CGitHash& commithash, int line)
48 int numberOfLines = (int)GetNumberOfLines();
49 for (int i = (line >= 0 ? line : 0); i < numberOfLines; ++i)
51 if (m_Hash[i] == commithash)
52 return i;
54 return -1;
56 // find first line of the current block with the given hash starting with given "line"
57 int FindFirstLineInBlock(CGitHash& commithash, int line)
59 while (line >= 0)
61 if (m_Hash[line] != commithash)
62 return line++;
63 --line;
65 return line;
67 enum SearchDirection{ SearchNext = 0, SearchPrevious = 1 };
68 int FindFirstLineWrapAround(SearchDirection direction, const CString& what, int line, bool bCaseSensitive);
70 int GetNumberOfLines() const
72 return (int)m_Hash.size();
75 CGitHash& GetHash(int line)
77 return m_Hash[line];
80 void GetHashes(std::set<CGitHash>& hashes)
82 hashes.clear();
83 for (auto it = m_Hash.begin(); it != m_Hash.end(); ++it)
85 hashes.insert(*it);
89 const CString& GetDate(int line) const
91 return m_Dates[line];
94 const CString& GetAuthor(int line) const
96 return m_Authors[line];
99 const CString& GetFilename(int line) const
101 return m_Filenames[line];
104 int GetOriginalLineNumber(int line) const
106 return m_OriginalLineNumbers[line];
109 const CStringA& GetUtf8Line(int line) const
111 return m_Utf8Lines[line];
114 bool ContainsOnlyFilename(const CString &filename) const;
116 GitRevLoglist* GetRev(int line, CGitHashMap & hashToRev)
118 return GetRevForHash(hashToRev, GetHash(line));
121 private:
122 static GitRevLoglist* GetRevForHash(CGitHashMap& HashToRev, CGitHash& hash, CString* err = nullptr);
123 static CString UnquoteFilename(CStringA& s);
125 std::vector<CGitHash> m_Hash;
126 std::vector<CString> m_Dates;
127 std::vector<CString> m_Authors;
128 std::vector<CString> m_Filenames;
129 std::vector<int> m_OriginalLineNumbers;
130 std::vector<BYTE_VECTOR> m_RawLines;
132 int m_encode;
133 std::vector<CStringA> m_Utf8Lines;