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 » Developing U++ » U++ Developers corner » TheIDE Find/Replace
TheIDE Find/Replace [message #25036] Mon, 08 February 2010 23:31 Go to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
OK, so per popular request, I have "separated" Find dialog (actually, it is still the same dialog, with some parts hidden). Same for Find in Files.

Please check whether the current version is less confusing!

Mirek
Re: TheIDE Find/Replace [message #25037 is a reply to message #25036] Mon, 08 February 2010 23:33 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
P.S.: You have to delete .cfg of theide to get default keys or redefine them; however it is Ctrl+F for Find, Ctrl+H for Replace and with Shift for "in files" (all taken from Visual Studio).
Re: TheIDE Find/Replace [message #25042 is a reply to message #25037] Tue, 09 February 2010 08:52 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Failed post...

Great job Mirek. This is what we needed.


Best regards
IƱaki

[Updated on: Tue, 09 February 2010 09:28]

Report message to a moderator

Re: TheIDE Find/Replace [message #25043 is a reply to message #25042] Tue, 09 February 2010 09:01 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
koldo wrote on Tue, 09 February 2010 07:52

Hello Mirek

Thank you for your improvements in the editor.

Now Ctrl-F has two behaviors:
- If no text is selected, it finds text
- If text is selected, it does a "Replace in Selection"

Is it a way to configure Ctrl-F for acting always as find text ?

Just to ask something additional Smile, it would be useful if Ctrl-F (and Ctrl-Shift-F) would search for the selected text.



long time ago I was tired of pressing Ctrl_I to have inserted selected text into FindInFiles... so my version looks like this:

void Ide::FindInFiles() {
	StringStream ss;
	editor.SerializeFind(ss);
	ss.Open(ss.GetResult());
	SerializeFf(ss);
	String findsel = editor.IsSelection()? editor.GetSelection() : editor.GetWord();//aris002
	if (!findsel.IsEmpty()){
		ff.find<<= findsel;
		ff.find.AddHistory();
	}
	
	if(String(ff.folder).IsEmpty())
		ff.folder <<= GetUppDir();
	ff.style <<= STYLE_NO_REPLACE;
	ff.itext = editor.GetI(); //aris002 should not use this at at all? or find 1more way?
	int c = ff.Execute();
	ss.Create();
	SerializeFf(ss);
	ss.Open(ss.GetResult());
	editor.SerializeFind(ss);
	if(c == IDOK && !String(ff.find).IsEmpty()) {
		Renumber();
		ff.find.AddHistory();
		ff.files.AddHistory();
		ff.folder.AddHistory();
		ff.replace.AddHistory();

		Progress pi("Found %d files to search.");
		Vector<String> files;
		SearchForFiles(files, NormalizePath((String)ff.folder, GetUppDir()), ~ff.files, pi);
		if(!pi.Canceled()) {
			String pattern;
			if(ff.wildcards) {
				String q = ~ff.find;
				for(const char *s = q; *s; s++)
					if(*s == '\\') {
						s++;
						if(*s == '\0') break;
						q.Cat(*s);
					}
					else
					switch(*s) {
					case '*': pattern.Cat(WILDANY); break;
					case '?': pattern.Cat(WILDONE); break;
					case '%': pattern.Cat(WILDSPACE); break;
					case '#': pattern.Cat(WILDNUMBER); break;
					case '$': pattern.Cat(WILDID); break;
					default:  pattern.Cat(*s);
					}
			}
			else
				pattern = ~ff.find;
			pi.SetTotal(files.GetCount());
			ShowConsole();
			console.Clear();
			pi.SetPos(0);
			int n = 0;
			for(int i = 0; i < files.GetCount(); i++) {
				pi.SetText(files[i]);
				if(pi.StepCanceled()) break;
				if(!SearchInFile(files[i], pattern, ff.wholeword, ff.ignorecase, n))
					break;
			}
			console << Format("%d occurrence(s) have been found.\n", n);
		}
	}
	SetErrorEditor();
}


it selects a word where the caret is. Should work if I haven't missed anything else
Re: TheIDE Find/Replace [message #25048 is a reply to message #25042] Tue, 09 February 2010 10:40 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
I have made some more fixes to the thing.

I hope it should work as desired now.
Re: TheIDE Find/Replace [message #25054 is a reply to message #25048] Tue, 09 February 2010 11:45 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
Clever! It just took a while (couldn't figure that out from the FindInFiles.cpp) that I need to change the ide environment editor settings to get the automatic selection into Find/Replace dialogs... Smile
Re: TheIDE Find/Replace [message #25058 is a reply to message #25043] Tue, 09 February 2010 12:58 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
fudadmin wrote on Tue, 09 February 2010 03:01

koldo wrote on Tue, 09 February 2010 07:52

Hello Mirek

Thank you for your improvements in the editor.

Now Ctrl-F has two behaviors:
- If no text is selected, it finds text
- If text is selected, it does a "Replace in Selection"

Is it a way to configure Ctrl-F for acting always as find text ?

Just to ask something additional Smile, it would be useful if Ctrl-F (and Ctrl-Shift-F) would search for the selected text.



long time ago I was tired of pressing Ctrl_I to have inserted selected text into FindInFiles... so my version looks like this:

void Ide::FindInFiles() {
	StringStream ss;
	editor.SerializeFind(ss);
	ss.Open(ss.GetResult());
	SerializeFf(ss);
	String findsel = editor.IsSelection()? editor.GetSelection() : editor.GetWord();//aris002
	if (!findsel.IsEmpty()){
		ff.find<<= findsel;
		ff.find.AddHistory();
	}
	
	if(String(ff.folder).IsEmpty())
		ff.folder <<= GetUppDir();
	ff.style <<= STYLE_NO_REPLACE;
	ff.itext = editor.GetI(); //aris002 should not use this at at all? or find 1more way?
	int c = ff.Execute();
	ss.Create();
	SerializeFf(ss);
	ss.Open(ss.GetResult());
	editor.SerializeFind(ss);
	if(c == IDOK && !String(ff.find).IsEmpty()) {
		Renumber();
		ff.find.AddHistory();
		ff.files.AddHistory();
		ff.folder.AddHistory();
		ff.replace.AddHistory();

		Progress pi("Found %d files to search.");
		Vector<String> files;
		SearchForFiles(files, NormalizePath((String)ff.folder, GetUppDir()), ~ff.files, pi);
		if(!pi.Canceled()) {
			String pattern;
			if(ff.wildcards) {
				String q = ~ff.find;
				for(const char *s = q; *s; s++)
					if(*s == '\\') {
						s++;
						if(*s == '\0') break;
						q.Cat(*s);
					}
					else
					switch(*s) {
					case '*': pattern.Cat(WILDANY); break;
					case '?': pattern.Cat(WILDONE); break;
					case '%': pattern.Cat(WILDSPACE); break;
					case '#': pattern.Cat(WILDNUMBER); break;
					case '$': pattern.Cat(WILDID); break;
					default:  pattern.Cat(*s);
					}
			}
			else
				pattern = ~ff.find;
			pi.SetTotal(files.GetCount());
			ShowConsole();
			console.Clear();
			pi.SetPos(0);
			int n = 0;
			for(int i = 0; i < files.GetCount(); i++) {
				pi.SetText(files[i]);
				if(pi.StepCanceled()) break;
				if(!SearchInFile(files[i], pattern, ff.wholeword, ff.ignorecase, n))
					break;
			}
			console << Format("%d occurrence(s) have been found.\n", n);
		}
	}
	SetErrorEditor();
}


it selects a word where the caret is. Should work if I haven't missed anything else



Actually, this functionality was added to theide two years ago (if I remember well). I am not sure if it is based on your code/proposal, but interestingly, it indeed is Ctrl+I Smile But there is also a small icon in the field (and you can insert to Replace field as well).

Mirek
Re: TheIDE Find/Replace [message #25066 is a reply to message #25058] Tue, 09 February 2010 15:26 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
Ctrl_I was yours. (I can't remember when it appeared) But at that time I couldn't get the word from current caret position (or maybe was too blind to find and enable it in ide settings) so I added my own version. It was more than 2 years ago...
The lesson for me "allways check all possible menus!" Smile
On the other hand, in forums there are plenty of questions , e.g , like "How to comment a selected block?"

Shouldn't be all goodies set true by default? Smile

Re: TheIDE Find/Replace [message #25067 is a reply to message #25066] Tue, 09 February 2010 15:48 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
fudadmin wrote on Tue, 09 February 2010 09:26

Ctrl_I was yours. (I can't remember when it appeared) But at that time I couldn't get the word from current caret position (or maybe was too blind to find and enable it in ide settings) so I added my own version. It was more than 2 years ago...
The lesson for me "allways check all possible menus!" Smile
On the other hand, in forums there are plenty of questions , e.g , like "How to comment a selected block?"

Shouldn't be all goodies set true by default? Smile




Well, a) I have learned to be conservative, prefer to make pre-existing mode default (I have made big exception with Find and Replace though) b) Personally, I find "Comment selected block" extremely annoying Wink

Mirek
Previous Topic: RapidSVN vs Ultimate SVN fuctionality
Next Topic: CodeEditor current caret position mark on gutter
Goto Forum:
  


Current Time: Fri Mar 29 10:41:44 CET 2024

Total time taken to generate the page: 0.01113 seconds