TRichMemo does not save to nor load from a file on Linux with GTK2
Original Reporter info from Mantis: HeinrichWolf
-
Reporter name: Heinrich Wolf
Original Reporter info from Mantis: HeinrichWolf
- Reporter name: Heinrich Wolf
Description:
Hello,
I would like to create an RTF file on hard disk without user input. To do this, I installed RichMemo from „svn co https://lazarus-ccr.svn.sourceforge.net/svnroot/lazarus-ccr/components/richmemo/“. On Linux I had to apply the patch from http://bugs.freepascal.org/view.php?id=17319 to be able to install it. Consecutively I append formatted text pieces to a hidden RichMemo and then write it's content to a FileStream. On Windows that works, but on Linux I always get an empty file, although I see the correct content in the RichMemo.
1st problem (solved):
If I set visible := false, then the RichMemo does not accept text. Instead I keep visible := True and cover the RichMemo with a Panel.
2nd problem (Linux only, solved):
RichMemo.SelStart := RichMemo.GetTextLen;
RichMemo.SelText := s;
only works on Windows, but not on Linux. Instead I use
RichMemo.Text := RichMemo.Text + s;
But then I lose all formatting so far. So I collect all formatting in a TList and apply them not before all concatenations are done.
3rd problem (solved):
I pass UTF8 encoded text pieces.
RichMemo.GetTextLen
returns numbers, which are not suitable for setting the range of formatting. Instead I maintain my own length:
Inc(RichLen, UTF8Length(s));
4th problem, not solved, please help!
This code to save the text in a file only works on Windows. In Linux I always get an empty file.
Stream := TFileStream.Create(SaveDialog.FileName, fmCreate);
RichMemo.SaveRichText(Stream);
Stream.Free;
I already posted these questions in http://www.lazarusforum.de/viewtopic.php?f=18&t=5110 . Someone answered that the code for SaveRichText in GTK2 does not yet exist.
I created an RTF file with the samples/testsimple projekt on Windows and tried to load this file with the samples/testsimple projekt on Linux. But then I get an empty window. Maybe the code for LoadRichText in GTK2 also does not yet exist.
kind regards
Heiner
Mantis conversion info:
- Mantis ID: 19624
- Monitored by: » HeinrichWolf (Heinrich Wolf)