Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ TheIDE » U++ TheIDE: Other Features Wishlist and/or Bugs » My TheIDE complaints
Re: Replace All [message #29551 is a reply to message #27509] Thu, 28 October 2010 08:34 Go to previous message
oan1971 is currently offline  oan1971
Messages: 7
Registered: April 2010
Promising Member
I do not know the old find / replace dialog, but I am too missing the "Replace All" feature.

After looking at the U++ sources it does not seem too hard to create it:

Adding a new member function to uppsrc/CodeEditor/FindReplace.cpp:

void CodeEditor::ReplaceAll()
{
    NextUndo();
    if(!findreplace.replacing)
        return;
    int l, h;
    if(GetSelection(l, h))
        return;
    CachePos(l);
    SetSelection(0, 0);
    const WString find = ~findreplace.find;
    const bool wholeword = findreplace.wholeword;
    const bool ignorecase = findreplace.ignorecase;
    const bool wildcards = findreplace.wildcards;
    for(;;) {
        if(!Find(false, find, wholeword, ignorecase, wildcards, true))
            break;
        int hh, ll;
        GetSelection(ll, hh);
        int d = Paste(GetReplaceText(~findreplace.replace, wildcards)) - (hh - ll);
        if (hh <= l)
            l = l + d;
        else if (ll < l)
            l = min(l, hh + d);
    }
    SetSelection(l, l);
    Refresh();
}


Adding a new "Replace All" button to the find / replace dialog in uppsrc/CodeEditor/CodeEditor.lay:

LAYOUT(IDEFindReplaceLayout, 408, 118)
	ITEM(Label, dv___0, SetLabel(t_("Find:")).LeftPosZ(8, 46).TopPosZ(4, 19))
	ITEM(WithDropChoice<EditString>, find, HSizePosZ(54, 8).TopPosZ(4, 19))
	ITEM(Label, replace_lbl, SetLabel(t_("Replace:")).LeftPosZ(8, 46).TopPosZ(28, 19))
	ITEM(WithDropChoice<EditString>, replace, HSizePosZ(54, 8).TopPosZ(28, 19))
	ITEM(Option, wholeword, SetLabel(t_("&Whole word")).LeftPosZ(8, 76).BottomPosZ(40, 18))
	ITEM(Option, ignorecase, SetLabel(t_("&Ignore case")).LeftPosZ(100, 76).BottomPosZ(40, 18))
	ITEM(Option, wildcards, SetLabel(t_("Wild&cards")).LeftPosZ(192, 68).BottomPosZ(40, 18))
	ITEM(Button, amend, SetLabel(t_("R&eplace")).LeftPosZ(8, 68).BottomPosZ(6, 24))
	ITEM(Button, amendall, SetLabel(t_("Replace &All")).LeftPosZ(80, 68).BottomPosZ(6, 24))
	ITEM(Button, findback, SetLabel(t_("Find Previous")).RightPosZ(160, 80).BottomPosZ(6, 24))
	ITEM(Button, ok, SetLabel(t_("Find Next")).RightPosZ(80, 76).BottomPosZ(6, 24))
	ITEM(Button, cancel, SetLabel(t_("Cancel")).RightPosZ(8, 64).BottomPosZ(6, 24))
END_LAYOUT



Setting up the new button in uppsrc/CodeEditor/FindReplace.cpp:

Adding
amendall.Show(replacing);
to FindReplaceDlg::Setup just after
amend.Show(replacing);
and
findreplace.amendall.Hide();
to CodeEditor::FindReplace after
findreplace.amend.Hide();


Setting up the new function in uppsrc/CodeEditor/CodeEditor.h:

Adding
void   ReplaceAll();
to class CodeEditor just after
void   Replace();


Wiring the new button in uppsrc/CodeEditor/CodeEditor.cpp:

Adding
findreplace.amendall <<= THISBACK(ReplaceAll);
to CodeEditor::CodeEditor just after
findreplace.amendall <<= THISBACK(ReplaceAll);


The attached zip contains the changed files from uppsrc/CodeEditor (from release 2791).

I am not sure I got the CachePos call right. But it seems to work quite well for me.

Oliver


910eb20c14e026a87ffb2b0d38b9ddb7
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Compiling and linking problems
Next Topic: TheIDE hangs on "Show svn history of file"
Goto Forum:
  


Current Time: Tue May 14 16:28:38 CEST 2024

Total time taken to generate the page: 0.02507 seconds