ide: New FillDiff features

git-svn-id: svn://ultimatepp.org/upp/trunk@6948 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2014-02-24 19:06:00 +00:00
parent a2a391f4e3
commit 3024f7af94
16 changed files with 389 additions and 160 deletions

View file

@ -22,6 +22,7 @@ TextCompareCtrl::TextCompareCtrl()
gutter_bg = Color(151, 190, 239);
gutter_fg = SGreen;
cursor = anchor = Null;
gutter_capture = false;
}
void TextCompareCtrl::DoSelection(int y, bool shift)
@ -43,24 +44,29 @@ void TextCompareCtrl::DoSelection(int y, bool shift)
void TextCompareCtrl::LeftDown(Point pt, dword keyflags)
{
Size sz = GetSize();
if(pt.x > sz.cx - gutter_width || HasCapture()) {
if(pt.x > sz.cx - gutter_width || HasCapture() && gutter_capture) {
if(!HasCapture())
SetCapture();
int line = (pt.y * lines.GetCount()) / sz.cy;
int page_lines = sz.cy / letter.cy;
scroll.SetY(line - page_lines / 2);
gutter_capture = true;
}
else {
DoSelection(pt.y, keyflags & K_SHIFT);
SetCapture();
gutter_capture = false;
}
SetWantFocus();
}
void TextCompareCtrl::MouseMove(Point pt, dword)
void TextCompareCtrl::MouseMove(Point pt, dword flags)
{
if(HasCapture())
DoSelection(pt.y, true);
if(gutter_capture)
LeftDown(pt, flags);
else
DoSelection(pt.y, true);
}
void TextCompareCtrl::LeftUp(Point pt, dword keyflags)
@ -92,7 +98,7 @@ void TextCompareCtrl::Copy()
void TextCompareCtrl::RightDown(Point p, dword keyflags)
{
MenuBar b;
b.Add(cursor != anchor, t_("Copy"), CtrlImg::copy(), THISBACK(Copy)).Key(K_CTRL_C);
b.Add(!IsNull(cursor), t_("Copy"), CtrlImg::copy(), THISBACK(Copy)).Key(K_CTRL_C);
b.Execute();
}
@ -210,7 +216,10 @@ void TextCompareCtrl::Paint(Draw& draw)
int y = i * letter.cy - offset.cy;
Color ink = l.color;
Color paper = SColorPaper();
if(!IsNull(l.number) && l.number >= sell && l.number <= selh) {
if(IsNull(l.number))
paper = SGray();
else
if(l.number >= sell && l.number <= selh) {
ink = SColorHighlightText;
paper = SColorHighlight;
}
@ -243,6 +252,11 @@ void TextCompareCtrl::SetFont(Font f, Font nf)
Layout();
}
void TextCompareCtrl::SetFont(Font f)
{
SetFont(f, GetNumberFont());
}
void TextCompareCtrl::Layout()
{
scroll.Set(scroll, (scroll.GetReducedViewSize() - Size(number_width + gutter_width, 0)) / letter, Size(maxwidth, lines.GetCount()));