From 155667dad3d38ed5eb641a097cfddbc4d40d3ead Mon Sep 17 00:00:00 2001 From: cxl Date: Tue, 13 Jan 2015 10:58:00 +0000 Subject: [PATCH] ide: 'grep' speed improved git-svn-id: svn://ultimatepp.org/upp/trunk@8034 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/CodeEditor/FindReplace.cpp | 24 +++++++++++++++-------- uppsrc/Core/Core.upp | 2 +- uppsrc/CtrlLib/TextEdit.h | 1 + uppsrc/CtrlLib/src.tpp/TextCtrl$en-us.tpp | 4 ++++ 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/uppsrc/CodeEditor/FindReplace.cpp b/uppsrc/CodeEditor/FindReplace.cpp index 854682738..7bdeb072d 100644 --- a/uppsrc/CodeEditor/FindReplace.cpp +++ b/uppsrc/CodeEditor/FindReplace.cpp @@ -519,7 +519,11 @@ int CodeEditor::BlockReplace() int count = 0; foundpos = l; Index 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); diff --git a/uppsrc/Core/Core.upp b/uppsrc/Core/Core.upp index 32bc65a6f..b5c6633c4 100644 --- a/uppsrc/Core/Core.upp +++ b/uppsrc/Core/Core.upp @@ -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, diff --git a/uppsrc/CtrlLib/TextEdit.h b/uppsrc/CtrlLib/TextEdit.h index a4d9693d0..0a4a3a9dd 100644 --- a/uppsrc/CtrlLib/TextEdit.h +++ b/uppsrc/CtrlLib/TextEdit.h @@ -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); diff --git a/uppsrc/CtrlLib/src.tpp/TextCtrl$en-us.tpp b/uppsrc/CtrlLib/src.tpp/TextCtrl$en-us.tpp index 2547652a5..4c7c655c1 100644 --- a/uppsrc/CtrlLib/src.tpp/TextCtrl$en-us.tpp +++ b/uppsrc/CtrlLib/src.tpp/TextCtrl$en-us.tpp @@ -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