mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-09-01 15:52:41 -06:00
ide: Display/apply patch tool in Assist
git-svn-id: svn://ultimatepp.org/upp/trunk@13482 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
026d4ca1e6
commit
51904d3621
15 changed files with 605 additions and 218 deletions
|
|
@ -2,6 +2,98 @@
|
|||
|
||||
namespace Upp {
|
||||
|
||||
DirDiffDlg::DirDiffDlg()
|
||||
{
|
||||
int div = HorzLayoutZoom(4);
|
||||
int cy = dir1.GetStdSize().cy;
|
||||
int bcx = GetTextSize(t_("Compare"), StdFont()).cx * 12 / 10 + 2 * div;
|
||||
|
||||
hidden.SetLabel(t_("Hidden"));
|
||||
|
||||
added.SetColor(Green()).SetLabel(t_("New"));
|
||||
modified.SetLabel(t_("Modified"));
|
||||
removed.SetColor(Red()).SetLabel(t_("Removed"));
|
||||
|
||||
compare.SetLabel(t_("Compare"));
|
||||
int bcy = compare.GetStdSize().cy;
|
||||
|
||||
files_pane.Add(dir1.TopPos(0, cy).HSizePos());
|
||||
files_pane.Add(dir2.TopPos(cy + div, cy).HSizePos());
|
||||
files_pane.Add(hidden.TopPos(2 * cy + 2 * div, bcy).LeftPos(0, bcx));
|
||||
|
||||
files_pane.Add( added.TopPos(3 * cy + 3 * div, bcy).LeftPosZ(2, 60));
|
||||
files_pane.Add(modified.TopPos(3 * cy + 3 * div, bcy).LeftPosZ(52, 70));
|
||||
files_pane.Add( removed.TopPos(3 * cy + 3 * div, bcy).LeftPosZ(128, 80));
|
||||
|
||||
removed = 1;
|
||||
added = 1;
|
||||
modified = 1;
|
||||
find.NullText(t_("Find (Ctrl+F)"));
|
||||
clearFind.SetLabel("X");
|
||||
clearFind.RightPosZ(1, 16).VSizePosZ(1, 1);
|
||||
find.AddChild(&clearFind);
|
||||
|
||||
files_pane.Add(info.SetAlign(ALIGN_RIGHT).TopPos(3 * cy + 3 * div, bcy).RightPos(1, Zx(70)));
|
||||
files_pane.Add(compare.TopPos(2 * cy + 2 * div, bcy).RightPos(0, bcx));
|
||||
files_pane.Add(files.VSizePos(3 * cy + bcy + 4 * div, Zy(24)).HSizePos());
|
||||
files_pane.Add(find.BottomPosZ(4, 19).HSizePosZ());
|
||||
|
||||
Add(files_diff.SizePos());
|
||||
files_diff.Set(files_pane, diff);
|
||||
files_diff.SetPos(2000);
|
||||
files_diff.SetMinPixels(0, Zx(256));
|
||||
|
||||
Sizeable().Zoomable();
|
||||
|
||||
seldir1.Attach(dir1);
|
||||
seldir2.Attach(dir2);
|
||||
|
||||
seldir1.Title("First directory to compare");
|
||||
seldir2.Title("Second directory to compare");
|
||||
|
||||
compare <<= THISBACK(Compare);
|
||||
dir1 <<= THISBACK(ClearFiles);
|
||||
dir2 <<= THISBACK(ClearFiles);
|
||||
|
||||
modified << [=] { ShowResult(); };
|
||||
removed << [=] { ShowResult(); };
|
||||
added << [=] { ShowResult(); };
|
||||
find << [=] { ShowResult(); };
|
||||
clearFind << [=] { find.Clear(); ShowResult();};
|
||||
|
||||
files.WhenSel = THISBACK(File);
|
||||
|
||||
diff.InsertFrameLeft(left);
|
||||
diff.InsertFrameRight(right);
|
||||
|
||||
bcx = GetTextSize(t_("Copy"), StdFont()).cx + HorzLayoutZoom(40);
|
||||
|
||||
left.Height(EditField::GetStdHeight());
|
||||
lfile.SetReadOnly();
|
||||
left.Add(lfile.VSizePos().HSizePos(0, bcx));
|
||||
left.Add(copyright.VSizePos().RightPos(0, bcx));
|
||||
copyright.SetImage(DiffImg::CopyRight());
|
||||
copyright.SetLabel("Copy");
|
||||
copyright <<= THISBACK1(Copy, false);
|
||||
|
||||
right.Height(EditField::GetStdHeight());
|
||||
rfile.SetReadOnly();
|
||||
right.Add(rfile.VSizePos().HSizePos(bcx, 0));
|
||||
right.Add(copyleft.VSizePos().LeftPos(0, bcx));
|
||||
copyleft.SetImage(DiffImg::CopyLeft());
|
||||
copyleft.SetLabel("Copy");
|
||||
copyleft <<= THISBACK1(Copy, true);
|
||||
|
||||
copyleft.Disable();
|
||||
copyright.Disable();
|
||||
|
||||
Icon(DiffImg::DirDiff());
|
||||
|
||||
WhenIcon = [](const char *path) -> Image { return NativePathIcon(path); };
|
||||
|
||||
Title("Compare directories");
|
||||
};
|
||||
|
||||
void DirDiffDlg::GatherFilesDeep(Index<String>& files, const String& base, const String& path)
|
||||
{
|
||||
FindFile ff(AppendFileName(AppendFileName(base, path), "*.*"));
|
||||
|
|
@ -18,7 +110,7 @@ void DirDiffDlg::GatherFilesDeep(Index<String>& files, const String& base, const
|
|||
}
|
||||
}
|
||||
|
||||
bool FileEqual(const String& f1, const String& f2, int& n)
|
||||
bool DirDiffDlg::FileEqual(const String& f1, const String& f2, int& n)
|
||||
{
|
||||
FileIn in1(f1);
|
||||
FileIn in2(f2);
|
||||
|
|
@ -33,7 +125,7 @@ bool FileEqual(const String& f1, const String& f2, int& n)
|
|||
}
|
||||
else
|
||||
{
|
||||
n = (in1 ? 1 : 2);
|
||||
n = (in1 ? DELETED_FILE : NEW_FILE);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
@ -60,7 +152,7 @@ void DirDiffDlg::Compare()
|
|||
break;
|
||||
String p1 = AppendFileName(~dir1, f[i]);
|
||||
String p2 = AppendFileName(~dir2, f[i]);
|
||||
int n = 0;
|
||||
int n = NORMAL_FILE;
|
||||
if(!FileEqual(p1, p2, n))
|
||||
list.Add(MakeTuple(f[i], p1, p2, n));
|
||||
}
|
||||
|
|
@ -68,18 +160,42 @@ void DirDiffDlg::Compare()
|
|||
ShowResult();
|
||||
}
|
||||
|
||||
FileList::File DirDiffDlg::MakeFile(int i)
|
||||
{
|
||||
static Color cs[] = { SColorText(), SRed(), SGreen(), SRed(), SLtBlue() };
|
||||
FileList::File m;
|
||||
m.isdir = false;
|
||||
m.unixexe = false;
|
||||
m.hidden = false;
|
||||
Image icn = WhenIcon(FileExists(list[i].b) ? list[i].b : list[i].c);
|
||||
int k = list[i].d;
|
||||
if(IsNull(icn))
|
||||
icn = CtrlImg::File();
|
||||
m.icon = decode(k, FAILED_FILE, MakeImage(icn, [] (const Image& m) { return GetOver(m, DiffImg::Failed()); }),
|
||||
PATCHED_FILE, MakeImage(icn, [] (const Image& m) { return GetOver(m, DiffImg::Patched()); }),
|
||||
icn);
|
||||
m.name = list[i].a;
|
||||
m.font = decode(k, FAILED_FILE, StdFont().Strikeout().Italic(),
|
||||
PATCHED_FILE, StdFont().Italic(), StdFont());
|
||||
m.ink = cs[k];
|
||||
m.length = 0;
|
||||
m.time = Null;
|
||||
m.extink = m.ink;
|
||||
m.data = i;
|
||||
return m;
|
||||
}
|
||||
|
||||
void DirDiffDlg::ShowResult()
|
||||
{
|
||||
static Color cs[] = { SColorText(), Red(), Green() };
|
||||
files.Clear();
|
||||
String sFind = ToLower((String)~find);
|
||||
for(int i = 0; i < list.GetCount(); i++)
|
||||
{
|
||||
int n = list[i].d;
|
||||
if(n == 0 && modified || n == 1 && removed || n == 2 && added)
|
||||
if(ToLower(list[i].a).Find(sFind) >= 0)
|
||||
files.Add(list[i].a, NativePathIcon(FileExists(list[i].b) ? list[i].b : list[i].c),
|
||||
StdFont(), cs[list[i].d]);
|
||||
if((n == NORMAL_FILE && modified || n == DELETED_FILE && removed
|
||||
|| n == NEW_FILE && added || n == FAILED_FILE || n == PATCHED_FILE)
|
||||
&& ToLower(list[i].a).Find(sFind) >= 0)
|
||||
files.Add(MakeFile(i));
|
||||
}
|
||||
info = AsString(files.GetCount()) + " files";
|
||||
clearFind.Show(!IsNull(find));
|
||||
|
|
@ -129,88 +245,4 @@ bool Upp::DirDiffDlg::HotKey(dword key)
|
|||
return false;
|
||||
}
|
||||
|
||||
DirDiffDlg::DirDiffDlg()
|
||||
{
|
||||
int div = HorzLayoutZoom(4);
|
||||
int cy = dir1.GetStdSize().cy;
|
||||
int bcx = GetTextSize(t_("Compare"), StdFont()).cx * 12 / 10 + 2 * div;
|
||||
|
||||
hidden.SetLabel(t_("Hidden"));
|
||||
|
||||
added.SetColor(Green()).SetLabel(t_("New"));
|
||||
modified.SetLabel(t_("Modified"));
|
||||
removed.SetColor(Red()).SetLabel(t_("Removed"));
|
||||
|
||||
compare.SetLabel(t_("Compare"));
|
||||
int bcy = compare.GetStdSize().cy;
|
||||
|
||||
files_pane.Add(dir1.TopPos(0, cy).HSizePos());
|
||||
files_pane.Add(dir2.TopPos(cy + div, cy).HSizePos());
|
||||
files_pane.Add(hidden.TopPos(2 * cy + 2 * div, bcy).LeftPos(0, bcx));
|
||||
|
||||
files_pane.Add( added.TopPos(3 * cy + 3 * div, bcy).LeftPosZ(2, 60));
|
||||
files_pane.Add(modified.TopPos(3 * cy + 3 * div, bcy).LeftPosZ(52, 70));
|
||||
files_pane.Add( removed.TopPos(3 * cy + 3 * div, bcy).LeftPosZ(128, 80));
|
||||
|
||||
removed = 1;
|
||||
added = 1;
|
||||
modified = 1;
|
||||
find.NullText(t_("Find (Ctrl+F)"));
|
||||
clearFind.SetLabel("X");
|
||||
clearFind.RightPosZ(1, 16).VSizePosZ(1, 1);
|
||||
find.AddChild(&clearFind);
|
||||
|
||||
files_pane.Add(info.SetAlign(ALIGN_RIGHT).TopPos(3 * cy + 3 * div, bcy).RightPos(1, Zx(70)));
|
||||
files_pane.Add(compare.TopPos(2 * cy + 2 * div, bcy).RightPos(0, bcx));
|
||||
files_pane.Add(files.VSizePos(3 * cy + bcy + 4 * div, Zy(24)).HSizePos());
|
||||
files_pane.Add(find.BottomPosZ(4, 19).HSizePosZ());
|
||||
|
||||
Add(files_diff.SizePos());
|
||||
files_diff.Set(files_pane, diff);
|
||||
files_diff.SetPos(2000);
|
||||
|
||||
Sizeable().Zoomable();
|
||||
|
||||
seldir1.Attach(dir1);
|
||||
seldir2.Attach(dir2);
|
||||
|
||||
compare <<= THISBACK(Compare);
|
||||
dir1 <<= THISBACK(ClearFiles);
|
||||
dir2 <<= THISBACK(ClearFiles);
|
||||
|
||||
modified << [=] { ShowResult(); };
|
||||
removed << [=] { ShowResult(); };
|
||||
added << [=] { ShowResult(); };
|
||||
find << [=] { ShowResult(); };
|
||||
clearFind << [=] { find.Clear(); ShowResult();};
|
||||
|
||||
files.WhenSel = THISBACK(File);
|
||||
|
||||
diff.InsertFrameLeft(left);
|
||||
diff.InsertFrameRight(right);
|
||||
|
||||
bcx = GetTextSize(t_("Copy"), StdFont()).cx + HorzLayoutZoom(40);
|
||||
|
||||
left.Height(EditField::GetStdHeight());
|
||||
lfile.SetReadOnly();
|
||||
left.Add(lfile.VSizePos().HSizePos(0, bcx));
|
||||
left.Add(copyright.VSizePos().RightPos(0, bcx));
|
||||
copyright.SetImage(DiffImg::CopyRight());
|
||||
copyright.SetLabel("Copy");
|
||||
copyright <<= THISBACK1(Copy, false);
|
||||
|
||||
right.Height(EditField::GetStdHeight());
|
||||
rfile.SetReadOnly();
|
||||
right.Add(rfile.VSizePos().HSizePos(bcx, 0));
|
||||
right.Add(copyleft.VSizePos().LeftPos(0, bcx));
|
||||
copyleft.SetImage(DiffImg::CopyLeft());
|
||||
copyleft.SetLabel("Copy");
|
||||
copyleft <<= THISBACK1(Copy, true);
|
||||
|
||||
copyleft.Disable();
|
||||
copyright.Disable();
|
||||
|
||||
Icon(DiffImg::DirDiff());
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue