Page 1 of 1
Search and replace that crosses item boundaries?
Posted: Wed Dec 19, 2007 1:04 pm
by martindholmes
Hi there,
Earlier this year, DavidRM and Michael Pro developed and bugfixed some code for effective search and replace which is more unicode-friendly than SearchText, and which can span item boundaries. This was the discussion where the code was posted and worked out:
http://www.trichview.com/forums/viewtop ... ch+replace
I also noticed you've recently released a new version with better Unicode support:
http://www.trichview.com/forums/viewtop ... ght=search
I'm wondering if this new version includes searching across item boundaries? If not, do you plan to implement that?
Best regards,
Martin
Posted: Wed Dec 19, 2007 6:18 pm
by Sergey Tkachenko
No, the new RichView.SearchTextW is an Unicode version of RichView.SearchText, it does not introduce any new features and cannot search across item boundaries
Posted: Wed Dec 19, 2007 7:42 pm
by martindholmes
Are you planning to add that functionality?
Cheers,
Martin
Posted: Sat Dec 22, 2007 3:59 pm
by Sergey Tkachenko
Yes, but after the next major update
Posted: Wed Jan 23, 2008 6:20 am
by Michael Pro
I'm still experiencing some problems with this procedure - it's incorrectly analizes table items.
I'll workaround with this trouble for a few days - if there gonna be any improvments, I'll tell you about bugfixes.
To avoid bugs with tables, I've made a dummy IF-statement
I think, that in few days I gonna fix this problem at all.
Actually, problem is in DavidRM function in next branch
Code: Select all
else
begin
if styleNo = -60 then // my dummy fix
continue; // my dummy fix
item:=rvData.GetItem(ii);
storeSub:=nil;
subRVData:=TCustomRVFormattedData(item.GetSubRVData(storeSub,rvdFirst));
if subRVData<>nil then
begin
Result:=DoSearchTextUnicodeInItem(item,storeSub,subRVData,searchText);
if Result then
Exit;
end;
end;
In case of table cells we need to make recursive move inside the table cells.
Posted: Wed Jan 23, 2008 7:08 am
by toolwiz
Does the above code work ok for normal ASCII text, not Unicode?
Will it let me do a search from the current cursor position to the end of the file?
What happens when you locate a string that spans item boundaries, and you replace it? Does it create a new separate item?
Do you just use InsertText to do the replacement?
Posted: Wed Jan 23, 2008 10:28 am
by Michael Pro
Well, the author of contributed function is DavidRM - I've only fixed one very nasty bug. If you've got some questions - I could help you, but as tester, not the author - some moments in source text aren't clear to me too.
toolwiz wrote:Does the above code work ok for normal ASCII text, not Unicode?
In spite of "complete-source-using-without-source-analyze" I've tested this function a numerous times - it excellently works in my ASCII-project.
You could simply create test project and run it on your native settings.
toolwiz wrote:Will it let me do a search from the current cursor position to the end of the file?
Yes, the last parameter
would help you set all options.
toolwiz wrote:What happens when you locate a string that spans item boundaries, and you replace it? Does it create a new separate item?
Do you just use InsertText to do the replacement?
Yes, I'm using InsertText function. It creates one common item with common style.
Posted: Wed Jan 23, 2008 9:13 pm
by toolwiz
Very helpful, thank you!
-David
Posted: Tue Feb 19, 2008 1:23 am
by toolwiz
Michael Pro, Would you mind pasting the ENTIRE FUNCTION here?
I've got pieces from three different messages that I tried to merge, and the compiler is saying there are variables that aren't being used that are part of fixes people have posted. I'm sure others are are will run into similar problems.
(Is there a section where full text of code like this are located? Or just individual message?)
Thanks
-David