mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-06-13 22:04:36 -06:00
ide: Find in files panes refactored
git-svn-id: svn://ultimatepp.org/upp/trunk@14014 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
ad673a6a9f
commit
ab88a4bbbd
4 changed files with 60 additions and 49 deletions
|
|
@ -164,9 +164,9 @@ void Ide::FindError()
|
|||
FindLineError(console.GetLine(console.GetCursor()));
|
||||
}
|
||||
|
||||
bool Ide::Next(int tab, ArrayCtrl& a, int d)
|
||||
bool Ide::Next(ArrayCtrl& a, int d)
|
||||
{
|
||||
if(btabs.GetCursor() == tab) {
|
||||
if(a.IsVisible()) {
|
||||
int c = a.GetCursor();
|
||||
for(;;) {
|
||||
c += d;
|
||||
|
|
@ -191,7 +191,7 @@ bool Ide::Next(int tab, ArrayCtrl& a, int d)
|
|||
|
||||
void Ide::FindNextError()
|
||||
{
|
||||
if(Next(BERRORS, error, 1) || Next(BFINDINFILES1 + ffoundi, ffound[ffoundi], 1))
|
||||
if(Next(error, 1) || Next(FFound(), 1))
|
||||
return;
|
||||
int ln = console.GetLine(console.GetCursor());
|
||||
int l = ln;
|
||||
|
|
@ -202,7 +202,7 @@ void Ide::FindNextError()
|
|||
}
|
||||
|
||||
void Ide::FindPrevError() {
|
||||
if(Next(BERRORS, error, -1) || Next(BFINDINFILES1 + ffoundi, ffound[ffoundi], -1))
|
||||
if(Next(error, -1) || Next(FFound(), -1))
|
||||
return;
|
||||
int ln = console.GetLine(console.GetCursor());
|
||||
int l = ln;
|
||||
|
|
@ -598,28 +598,8 @@ void Ide::ConsoleRunEnd()
|
|||
|
||||
void Ide::ShowFound()
|
||||
{
|
||||
if(ffound[ffoundi].IsCursor())
|
||||
GoToError(ffound[ffoundi]);
|
||||
}
|
||||
|
||||
void Ide::CopyFound(bool all)
|
||||
{
|
||||
String txt;
|
||||
for(int i = 0; i < ffound[ffoundi].GetCount(); i++) {
|
||||
if(all)
|
||||
txt << ffound[ffoundi].Get(i, 0) << " (" << ffound[ffoundi].Get(i, 1) << "): ";
|
||||
String h = ffound[ffoundi].Get(i, 2);
|
||||
if(*h == '\1')
|
||||
h = Split(~h + 1, '\1', false).Top();
|
||||
txt << h << "\r\n";
|
||||
}
|
||||
WriteClipboardText(txt);
|
||||
}
|
||||
|
||||
void Ide::FFoundMenu(Bar& bar)
|
||||
{
|
||||
bar.Add("Copy text", THISBACK1(CopyFound, false));
|
||||
bar.Add("Copy all", THISBACK1(CopyFound, true));
|
||||
if(FFound().IsCursor())
|
||||
GoToError(FFound());
|
||||
}
|
||||
|
||||
void Ide::CopyError(bool all)
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ void Ide::AddFoundFile(const String& fn, int ln, const String& line, int pos, in
|
|||
f.kind = 0;
|
||||
f.message = "\1" + EditorSyntax::GetSyntaxForFilename(fn) + "\1" +
|
||||
AsString(pos) + "\1" + AsString(count) + "\1" + line;
|
||||
ffound[ffoundi].Add(fn, ln, f.message, RawToValue(f));
|
||||
FFound().Add(fn, ln, f.message, RawToValue(f));
|
||||
}
|
||||
|
||||
bool Ide::SearchInFile(const String& fn, const String& pattern, bool wholeword, bool ignorecase,
|
||||
|
|
@ -159,7 +159,7 @@ bool Ide::SearchInFile(const String& fn, const String& pattern, bool wholeword,
|
|||
}
|
||||
|
||||
if(sync)
|
||||
ffound[ffoundi].Sync();
|
||||
FFound().Sync();
|
||||
|
||||
in.Close();
|
||||
int ffs = ~ff.style;
|
||||
|
|
@ -184,8 +184,8 @@ bool Ide::SearchInFile(const String& fn, const String& pattern, bool wholeword,
|
|||
editor.SelectAll();
|
||||
editor.BlockReplace();
|
||||
SaveFile();
|
||||
ffound[ffoundi].Add(fn, Null, AsString(infile) + " replacements made");
|
||||
ffound[ffoundi].Sync();
|
||||
FFound().Add(fn, Null, AsString(infile) + " replacements made");
|
||||
FFound().Sync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -228,10 +228,9 @@ void Ide::FindInFiles(bool replace) {
|
|||
if(c == IDOK) {
|
||||
SaveFile();
|
||||
|
||||
ffoundi = ~ff.output;
|
||||
ffoundi_next = (ffoundi + 1) % 3;
|
||||
SetFFound(~ff.output);
|
||||
|
||||
ffound[ffoundi].HeaderTab(2).SetText("Source line");
|
||||
FFound().HeaderTab(2).SetText("Source line");
|
||||
Renumber();
|
||||
ff.find.AddHistory();
|
||||
ff.files.AddHistory();
|
||||
|
|
@ -278,8 +277,7 @@ void Ide::FindInFiles(bool replace) {
|
|||
else
|
||||
pattern = ~ff.find;
|
||||
pi.SetTotal(files.GetCount());
|
||||
ShowFindInFiles();
|
||||
ffound[ffoundi].Clear();
|
||||
FFound().Clear();
|
||||
pi.SetPos(0);
|
||||
int n = 0;
|
||||
for(int i = 0; i < files.GetCount(); i++) {
|
||||
|
|
@ -296,33 +294,33 @@ void Ide::FindInFiles(bool replace) {
|
|||
f.linepos = 0;
|
||||
f.kind = 0;
|
||||
f.message = files[i];
|
||||
ffound[ffoundi].Add(f.file, 1, f.message, RawToValue(f));
|
||||
ffound[ffoundi].Sync();
|
||||
FFound().Add(f.file, 1, f.message, RawToValue(f));
|
||||
FFound().Sync();
|
||||
n++;
|
||||
}
|
||||
}
|
||||
if(!IsNull(pattern))
|
||||
ffound[ffoundi].Add(Null, Null, AsString(n) + " occurrence(s) have been found.");
|
||||
FFound().Add(Null, Null, AsString(n) + " occurrence(s) have been found.");
|
||||
else
|
||||
ffound[ffoundi].Add(Null, Null, AsString(n) + " matching file(s) have been found.");
|
||||
ffound[ffoundi].HeaderTab(2).SetText(Format("Source line (%d)", ffound[ffoundi].GetCount()));
|
||||
FFound().Add(Null, Null, AsString(n) + " matching file(s) have been found.");
|
||||
FFound().HeaderTab(2).SetText(Format("Source line (%d)", FFound().GetCount()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Ide::FindFileAll(const Vector<Tuple<int64, int>>& f)
|
||||
{
|
||||
ShowFindInFiles();
|
||||
ffoundi = ffoundi_next;
|
||||
ffound[ffoundi].Clear();
|
||||
SetFFound(ffoundi_next);
|
||||
FFound().Clear();
|
||||
for(auto pos : f) {
|
||||
editor.CachePos(pos.a);
|
||||
int linei = editor.GetLinePos64(pos.a);
|
||||
WString ln = editor.GetWLine(linei);
|
||||
AddFoundFile(editfile, linei + 1, ln.ToString(), lenAsUtf8(~ln, (int)pos.a), lenAsUtf8(~ln + pos.a, pos.b));
|
||||
}
|
||||
ffound[ffoundi].HeaderTab(2).SetText(Format("Source line (%d)", ffound[ffoundi].GetCount()));
|
||||
ffound[ffoundi].Add(Null, Null, AsString(f.GetCount()) + " occurrence(s) have been found.");
|
||||
FFound().HeaderTab(2).SetText(Format("Source line (%d)", FFound().GetCount()));
|
||||
FFound().Add(Null, Null, AsString(f.GetCount()) + " occurrence(s) have been found.");
|
||||
}
|
||||
|
||||
void Ide::FindString(bool back)
|
||||
|
|
@ -457,3 +455,36 @@ bool FindInFilesDlg::Key(dword key, int count)
|
|||
}
|
||||
return TopWindow::Key(key, count);
|
||||
}
|
||||
|
||||
void Ide::SetFFound(int ii)
|
||||
{
|
||||
ii = clamp(ii, 0, 2);
|
||||
SetBottom(BFINDINFILES1 + ii);
|
||||
ffoundi_next = (ii + 1) % 3;
|
||||
}
|
||||
|
||||
ArrayCtrl& Ide::FFound()
|
||||
{
|
||||
int i = btabs.GetCursor() - BFINDINFILES1;
|
||||
return i >= 0 && i < 3 ? ffound[i] : ffound[0];
|
||||
}
|
||||
|
||||
void Ide::CopyFound(bool all)
|
||||
{
|
||||
String txt;
|
||||
for(int i = 0; i < FFound().GetCount(); i++) {
|
||||
if(all)
|
||||
txt << FFound().Get(i, 0) << " (" << FFound().Get(i, 1) << "): ";
|
||||
String h = FFound().Get(i, 2);
|
||||
if(*h == '\1')
|
||||
h = Split(~h + 1, '\1', false).Top();
|
||||
txt << h << "\r\n";
|
||||
}
|
||||
WriteClipboardText(txt);
|
||||
}
|
||||
|
||||
void Ide::FFoundMenu(Bar& bar)
|
||||
{
|
||||
bar.Add("Copy text", THISBACK1(CopyFound, false));
|
||||
bar.Add("Copy all", THISBACK1(CopyFound, true));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -447,7 +447,6 @@ public:
|
|||
Console console;
|
||||
|
||||
ArrayCtrl ffound[3];
|
||||
int ffoundi = 0; // current target for find in files
|
||||
int ffoundi_next = 0;
|
||||
|
||||
ArrayCtrl error;
|
||||
|
|
@ -709,7 +708,6 @@ public:
|
|||
void ToggleBottom(int i);
|
||||
void ShowBottom(int i);
|
||||
void ShowConsole() { ShowBottom(1); }
|
||||
void ShowFindInFiles() { ShowBottom(BFINDINFILES1 + ffoundi); }
|
||||
void ToggleConsole() { ToggleBottom(1); }
|
||||
void SwapBottom();
|
||||
bool IsBottomShown() const;
|
||||
|
|
@ -833,7 +831,7 @@ public:
|
|||
void EditFindNext() { editor.FindNext(); }
|
||||
void EditFindPrevious() { editor.FindPrev(); }
|
||||
void EditPaste() { editor.Paste(); }
|
||||
bool Next(int tab, ArrayCtrl& ctrl, int d);
|
||||
bool Next(ArrayCtrl& ctrl, int d);
|
||||
void FindNextError();
|
||||
void FindPrevError();
|
||||
|
||||
|
|
@ -1027,6 +1025,8 @@ public:
|
|||
void CopyError(bool all);
|
||||
void ErrorMenu(Bar& bar);
|
||||
void ShowError();
|
||||
void SetFFound(int ii);
|
||||
ArrayCtrl& FFound();
|
||||
void ShowFound();
|
||||
void CopyFound(bool all);
|
||||
void FFoundMenu(Bar& bar);
|
||||
|
|
|
|||
|
|
@ -656,7 +656,7 @@ void Ide::BuildMenu(Bar& menu)
|
|||
|
||||
bool ff = BottomIsFindInFiles();
|
||||
String hh = ff ? "position" : "error line";
|
||||
bool ffb = ff ? ffound[ffoundi].GetCount() : error.GetCount();
|
||||
bool ffb = ff ? FFound().GetCount() : error.GetCount();
|
||||
menu.Add(ffb, AK_FINDNEXTERROR, THISBACK(FindNextError))
|
||||
.Help("Find next " + hh + "according to console pane");
|
||||
menu.Add(ffb, AK_FINDPREVERROR, THISBACK(FindPrevError))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue