mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-08-31 07:12:39 -06:00
ide: Incremental searching
git-svn-id: svn://ultimatepp.org/upp/trunk@7474 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
1e5f80877e
commit
264964556b
4 changed files with 38 additions and 9 deletions
|
|
@ -232,7 +232,8 @@ void CodeEditor::SelectionChanged()
|
|||
Refresh();
|
||||
}
|
||||
if(!foundsel) {
|
||||
CloseFindReplace();
|
||||
if(!persistent_find_replace && !findreplace.incremental)
|
||||
CloseFindReplace();
|
||||
found = false;
|
||||
notfoundfw = notfoundbk = false;
|
||||
findreplace.amend.Disable();
|
||||
|
|
|
|||
|
|
@ -282,6 +282,7 @@ protected:
|
|||
void FindWildcard();
|
||||
void ReplaceWildcard();
|
||||
void InsertWildcard(int c);
|
||||
void IncrementalFind();
|
||||
void CheckSyntaxRefresh(int pos, const WString& text);
|
||||
|
||||
void SetFound(int fi, int type, const WString& text);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
LAYOUT(IDEFindReplaceLayout, 528, 52)
|
||||
LAYOUT(IDEFindReplaceLayout, 616, 52)
|
||||
ITEM(Label, dv___0, SetLabel(t_("&Find")).LeftPosZ(8, 46).TopPosZ(4, 19))
|
||||
ITEM(WithDropChoice<EditString>, find, LeftPosZ(56, 144).TopPosZ(4, 19))
|
||||
ITEM(Label, dv___2, SetLabel(t_("&Replace")).LeftPosZ(8, 60).TopPosZ(28, 21))
|
||||
|
|
@ -8,6 +8,7 @@ LAYOUT(IDEFindReplaceLayout, 528, 52)
|
|||
ITEM(Option, wildcards, SetLabel(t_("Wild&cards")).LeftPosZ(252, 72).TopPosZ(4, 19))
|
||||
ITEM(Option, wholeword, SetLabel(t_("&Whole word")).LeftPosZ(328, 88).TopPosZ(4, 19))
|
||||
ITEM(Option, ignorecase, SetLabel(t_("&Ignore case")).LeftPosZ(420, 80).TopPosZ(4, 19))
|
||||
ITEM(Option, incremental, SetLabel(t_("&Incremental")).LeftPosZ(504, 80).TopPosZ(4, 19))
|
||||
ITEM(Button, close, RightPosZ(4, 20).TopPosZ(4, 19))
|
||||
ITEM(Button, amend, LeftPosZ(204, 20).TopPosZ(28, 19))
|
||||
ITEM(Option, samecase, SetLabel(t_("Mimic case")).LeftPosZ(252, 108).TopPosZ(28, 19))
|
||||
|
|
|
|||
|
|
@ -14,19 +14,22 @@ void CodeEditor::InitFindReplace()
|
|||
findreplace.prev <<= THISBACK(DoFindBack);
|
||||
findreplace.replacing = false;
|
||||
found = notfoundfw = notfoundbk = foundsel = false;
|
||||
persistent_find_replace = false;
|
||||
persistent_find_replace = false;
|
||||
findreplace.find <<= findreplace.wholeword <<= findreplace.wildcards
|
||||
<<= findreplace.ignorecase <<= THISBACK(IncrementalFind);
|
||||
}
|
||||
|
||||
FindReplaceDlg::FindReplaceDlg()
|
||||
{
|
||||
ignorecase <<= THISBACK(Sync);
|
||||
samecase <<= true;
|
||||
Sync();
|
||||
close.Cancel();
|
||||
prev.SetImage(CtrlImg::SmallUp());
|
||||
prev.Tip("Find prev");
|
||||
amend.SetImage(CodeEditorImg::Replace());
|
||||
amend.Tip("Replace");
|
||||
incremental <<= true;
|
||||
Sync();
|
||||
}
|
||||
|
||||
void FindReplaceDlg::Sync()
|
||||
|
|
@ -268,21 +271,29 @@ void CodeEditor::FindReplaceAddHistory()
|
|||
|
||||
bool CodeEditor::Find(bool back, bool blockreplace, bool replace)
|
||||
{
|
||||
DLOG("============FIND");
|
||||
DDUMP(findreplace.IsOpen());
|
||||
FindReplaceAddHistory();
|
||||
findreplace.find.Error(false);
|
||||
DDUMP(findreplace.IsOpen());
|
||||
if(Find(back, (WString)~findreplace.find, findreplace.wholeword,
|
||||
findreplace.ignorecase, findreplace.wildcards, blockreplace)) {
|
||||
DDUMP(findreplace.IsOpen());
|
||||
if(!blockreplace) {
|
||||
DDUMP(findreplace.IsOpen());
|
||||
if(!findreplace.IsOpen())
|
||||
OpenNormalFindReplace(replace);
|
||||
findreplace.amend.Enable();
|
||||
SetFocus();
|
||||
if(!findreplace.incremental)
|
||||
SetFocus();
|
||||
}
|
||||
DLOG("----------------");
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
findreplace.find.Error();
|
||||
SetFocus();
|
||||
if(!findreplace.incremental)
|
||||
SetFocus();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -457,12 +468,13 @@ void CodeEditor::OpenNormalFindReplace(bool replace)
|
|||
findreplace.close <<= THISBACK(CloseFindReplace);
|
||||
if(!findreplace.IsOpen())
|
||||
AddFrame(findreplace);
|
||||
DLOG("OpenNormal " << findreplace.IsOpen());
|
||||
}
|
||||
|
||||
void CodeEditor::FindReplace(bool pick_selection, bool pick_text, bool replace)
|
||||
{
|
||||
if(findreplace.IsOpen())
|
||||
findreplace.Close();
|
||||
CloseFindReplace();
|
||||
|
||||
replacei = 0;
|
||||
WString find_text;
|
||||
|
|
@ -511,7 +523,7 @@ void CodeEditor::FindReplace(bool pick_selection, bool pick_text, bool replace)
|
|||
if(find_pos >= 0)
|
||||
SetCursor(find_pos);
|
||||
OpenNormalFindReplace(replace);
|
||||
findreplace.find.SetWantFocus();
|
||||
findreplace.find.SetFocus();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -622,10 +634,24 @@ void CodeEditor::ReplaceWildcard()
|
|||
|
||||
void CodeEditor::CloseFindReplace()
|
||||
{
|
||||
if(!persistent_find_replace && findreplace.IsOpen())
|
||||
DLOG("============= CLOSE FIND REPLACE");
|
||||
if(findreplace.IsOpen())
|
||||
RemoveFrame(findreplace);
|
||||
}
|
||||
|
||||
void CodeEditor::IncrementalFind()
|
||||
{
|
||||
DLOG("Incremental find");
|
||||
if(!findreplace.incremental)
|
||||
return;
|
||||
DLOG("Incremental find 2");
|
||||
int l, h;
|
||||
GetSelection(l, h);
|
||||
ClearSelection();
|
||||
SetCursor(min(l, h));
|
||||
Find();
|
||||
}
|
||||
|
||||
void CodeEditor::DoFind()
|
||||
{
|
||||
Find();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue