Search and replace that crosses item boundaries?

General TRichView support forum. Please post your questions here
Post Reply
martindholmes
Posts: 131
Joined: Mon Aug 29, 2005 12:03 pm

Search and replace that crosses item boundaries?

Post 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
Sergey Tkachenko
Site Admin
Posts: 17566
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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
martindholmes
Posts: 131
Joined: Mon Aug 29, 2005 12:03 pm

Post by martindholmes »

Are you planning to add that functionality?

Cheers,
Martin
Sergey Tkachenko
Site Admin
Posts: 17566
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Yes, but after the next major update
Michael Pro
Posts: 42
Joined: Wed Feb 28, 2007 4:14 am

Post 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

Code: Select all

if styleNo = -60 then
  continue;
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.
toolwiz
Posts: 150
Joined: Wed Nov 30, 2005 3:27 am

Post 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?
Michael Pro
Posts: 42
Joined: Wed Feb 28, 2007 4:14 am

Post 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

Code: Select all

flags: TSTUFlags
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.
toolwiz
Posts: 150
Joined: Wed Nov 30, 2005 3:27 am

Post by toolwiz »

Very helpful, thank you!

-David
toolwiz
Posts: 150
Joined: Wed Nov 30, 2005 3:27 am

Post 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
Post Reply