Replace word with text from another DBRichViewEdit

General TRichView support forum. Please post your questions here
Post Reply
agent86
Posts: 59
Joined: Mon Jun 28, 2010 2:18 am
Location: San Francisco Bay Area, USA
Contact:

Replace word with text from another DBRichViewEdit

Post by agent86 »

I have written my own AutoText/AutoCorrect because I need to enter and retrieve paragraphs of formatted text. I use the following to append the text to another DBRichView.

Code: Select all

procedure TReportWriterMainForm.AddReplacementText ;
var Stream: TMemoryStream;
begin
   Stream := TMemoryStream.Create;
   ReplacementTextDBRichViewEdit.SaveRVFToStream(Stream, False);
   Stream.Position := 0;
   rve.AppendRVFFromStream(Stream, -1 );
   Stream.Free;
   rve.Format;
end;
The problem of course is that the target word in the sentence needs to be replaced with the text. I have studied the AutoCorrect function but don't see how to overwrite the "word" that is to be replaced.

How do I find the previous word in a sentence related to my current cursor position? Of course it could be the first word in the sentence or in the middle of a sentence that needs to be replaced. It won't always be the last word.

I have done all the programming to look up the replacement text. The only problem I have left is finding the word before my cursor and replacing the word with my replacment text which is "stored" in a DBRichView.
Sergey Tkachenko
Site Admin
Posts: 17566
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Look in RichViewActions.pas, RVA_Addict3AutoCorrect (this function makes autocorrection using Addict3/4.
This functions selects the word to the left of the caret position (using SetSelectionBounds), and inserts a new text that replaces the selection,
Post Reply