Fixed issue #2507: Support keyboard shortcuts in yes/no prompts
[TortoiseGit.git] / src / Utils / MiscUI / LineColors.h
blobad6a2072c5f98628748cd20c18ebbc394c67d5ac
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2010 - 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 <map>
23 struct linecolors_t
25 COLORREF text;
26 COLORREF background;
27 COLORREF shot;
30 class LineColors : public std::map<int, linecolors_t>
32 public:
33 void AddShotColor(int pos, COLORREF b)
35 // make sure position exists
36 SplitBlock(pos);
37 // set value
38 (*this)[pos].shot = b;
41 void SetColor(int pos, COLORREF f, COLORREF b)
43 linecolors_t c;
44 c.text = f;
45 c.background = b;
46 c.shot = b;
47 (*this)[pos] = c;
50 void SetColor(int pos, const linecolors_t &c)
52 linecolors_t cNew = c;
53 cNew.shot = c.background;
54 (*this)[pos] = cNew;
57 void SplitBlock(int pos) /// insert colormark with same value as previous position defines
59 std::map<int, linecolors_t>::const_iterator it = this->upper_bound(pos);
60 if (it != this->begin())
62 if ((it == this->end()) || (it->first != pos))
64 SetColor(pos, (--it)->second);
67 else if (it != this->end())
69 SetColor(pos, it->second);