ide: 'grep' speed improved

git-svn-id: svn://ultimatepp.org/upp/trunk@8034 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2015-01-13 10:58:00 +00:00
parent 0c36000275
commit 155667dad3
4 changed files with 22 additions and 9 deletions

View file

@ -519,7 +519,11 @@ int CodeEditor::BlockReplace()
int count = 0;
foundpos = l;
Index<int> ln;
Progress pi("Searching...");
while(FindFrom(foundpos, false, true) && foundpos + foundsize <= h) {
pi.Set(foundpos - l, h - l);
if(pi.Canceled())
return count;
CachePos(foundpos);
if(~findreplace.mode == 0) {
Remove(foundpos, foundsize);
@ -535,23 +539,27 @@ int CodeEditor::BlockReplace()
}
}
if(~findreplace.mode != 0) {
pi.SetText("Removing lines");
ClearSelection();
int ll = GetLine(l);
int lh = GetLine(h);
if(GetPos(lh) == h)
lh--;
bool mm = ~findreplace.mode == 1;
for(int i = lh; i >= ll; i--) {
if((ln.Find(i) >= 0) != mm) {
int pos = GetPos(i);
int l = GetLineLength(i);
CachePos(pos);
Remove(pos, min(l + 1, GetLength() - pos));
String replace;
pi.SetTotal(lh - ll + 1);
for(int i = ll; i <= lh; i++) {
pi.Set(i, lh - ll + 1);
if(pi.Canceled())
return 0;
if((ln.Find(i) >= 0) == mm) {
replace << GetUtf8Line(i) << "\n";
count++;
}
}
SetSelection(GetPos(ll), lh - count + 1 < GetLineCount() ? GetPos(lh - count + 1)
: GetLength());
int pos = GetPos(ll);
Remove(pos, GetPos(GetLine(h)) - pos);
SetSelection(pos, pos + Insert(pos, replace));
}
else
SetSelection(l, h);

View file

@ -35,7 +35,7 @@ file
Core.h options PCH,
config.h,
Defs.h,
Cpu.cpp optimize_speed options NOPCH,
Cpu.cpp optimize_speed,
Mt.h,
Core.upp,
Mt.cpp,

View file

@ -168,6 +168,7 @@ public:
bool IsUndo() const { return undo.GetCount(); }
bool IsRedo() const { return redo.GetCount(); }
void ClearUndo() { undo.Clear(); redo.Clear(); }
void ClearRedo() { redo.Clear(); }
bool IsUndoOp() const { return undo_op; }
UndoData PickUndoData();
void SetPickUndoData(UndoData rval_ data);

View file

@ -361,6 +361,10 @@ in between is the same as calling it once.&]
[s2;%% Clears all undo and redo records.&]
[s3;%% &]
[s4; &]
[s5;:TextCtrl`:`:ClearRedo`(`): [@(0.0.255) void]_[* ClearRedo]()&]
[s2;%% Clears redo records.&]
[s3; &]
[s4; &]
[s5;:TextCtrl`:`:PickUndoData`(`): [_^TextCtrl`:`:UndoData^ UndoData]_[* PickUndoData]()&]
[s2;%% Picks undo and redo record. This is useful when single widget
is used to edit various text, this allows to change undo/redo