Home » Developing U++ » U++ Developers corner » TheIDE Find/Replace  
	
		
		
			| Re: TheIDE Find/Replace [message #25043 is a reply to message #25042] | 
			Tue, 09 February 2010 09:01    | 
		 
		
			
				
				
				  | 
					
						  
						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  , 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  
		
		
		
 |  
	| 
		
	 | 
 
 
 |  
  
 
Goto Forum:
 
 Current Time: Tue Nov 04 12:59:00 CET 2025 
 Total time taken to generate the page: 0.00743 seconds 
 |