[Lazarus] Version 1.4
Bob B.
parkingspace26 at yahoo.com
Tue Apr 14 21:26:13 CEST 2015
In the upcoming 1.4 release of Lazarus, please include lzRichEdit (http://wiki.lazarus.freepascal.org/lzRichEdit) in one of the two lists under Package->Install/Uninstall Packages...
Laz currently does not come with a RichEdit component as Delphi does to create and display files in Rich Text Format (RTF). Unlike RichMemo, with lzRichEdit you don't have to wrestle with svn, just download the zip file from http://sourceforge.net/projects/lazarusfiles/files/lzRichEdit.zip/download and extract it into a directory off of lazarus/components, finally Package->Open Package File .lpk, Compile and Uses->Install. It'll be in the Common Controls tab of the pallete.
Another need for a substitute for Delphi's RichEdit (like lzRichEdit) is that the FindText method (not property) doesn't exist in TMemo. It's needed by the FindDialog component to use the WholeWord and CaseSensitive options. Below I've shown an example of using FindDialog's OnFind event to do this with the lzRichEdit component.
I'd also like to see the FindText method added to TMemo to avoid overhead when the RTF format isn't needed.
Bob B.
procedure TForm1.FindDialog1Find(Sender: TObject);
var
s: string;
FoundAt: LongInt;
StartPos, ToEnd: Integer;
mySearchTypes : TSearchTypes;
myFindOptions : TFindOptions;
begin
mySearchTypes := [];
with RichEdit1 do
begin
if frMatchCase in FindDialog1.Options then
mySearchTypes := mySearchTypes + [stMatchCase];
if frWholeWord in FindDialog1.Options then
mySearchTypes := mySearchTypes + [stWholeWord];
{ Begin the search after the current selection, if there is one. }
{ Otherwise, begin at the start of the text. }
if SelLength <> 0 then
StartPos := SelStart + SelLength
else
StartPos := 0;
{ ToEnd is the length from StartPos through the end of the
text in the rich edit control. }
ToEnd := Length(Text) - StartPos;
s:=FindDialog1.FindText; // to avoid confusion with richedit1's findtext METHOD
FoundAt :=
richedit1.FindText(s, StartPos, ToEnd, mySearchTypes,not (frdown in finddialog1.Options));
if FoundAt <> -1 then
begin
SetFocus;
SelStart := FoundAt;
SelLength := Length(FindDialog1.FindText);
end
else showmessage(s+'not found!');
end;
end;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20150414/7020f3c2/attachment-0002.html>
More information about the Lazarus
mailing list