View Issue Details

IDProjectCategoryView StatusLast Update
0017000LazarusLCLpublic2011-12-01 11:26
ReporterChris Rorden Assigned ToPaul Ishenin  
Status closedResolutionfixed 
Product Version0.9.29 (SVN) 
Fixed in Version0.9.31 (SVN) 
Summary0017000: TMemo does not handle line breaks well.
DescriptionThe TMemo has problems with non-native EOLN symbols. The EOLN is different for different OSes: Macintosh computers use CR ($0D), UNIX computers use LF ($0A) and DOS/Windows computers use CR/LF pairs ($0D0A). The problems can be seen by running
on either Lazarus for Windows. Things work well on Lazarus for Linux and Lazarus for OSX.

On Windows (0.9.29 svn 23531), only Windows EOLN symbols are recognized: otherwise the text is loaded as a single line (wrapping if that is the TMemo's property).

TagsNo tags attached.
Fixed in Revision29915
Attached Files


2010-07-21 18:02 (3,327 bytes)

Dmitry Boyarintsev

2010-07-21 19:42

developer   ~0039565

Last edited: 2010-07-21 19:44

It's widgetset specific, to be sure you must take care of line-endings processing on your own.

Bart Broersma

2010-07-22 14:43

developer   ~0039597

AdjustLinebreaks(Memo1.Text) may help?

Chris Rorden

2010-07-23 05:01

reporter   ~0039604

For both ease-of-use and compatibility with Delphi, I think Lazarus should convert the line breaks to the native format. For example, if you load a text-file with Unix line endings with Delphi, it appears normally (using Windows line breaks).

Bart made an elegant suggestion. It should be noted that the obvious code does not work:
 procedure LoadMemoFails(F: string;var lMemo: TMemo);
Once the text is loaded to the Memo, AdjustLinebreaks does not work correctly. The code which does work is
procedure LoadMemo(F: string;var lMemo: TMemo);
    lLines: TStrings;
    lLines := TStringList.Create;
    //next - remove trailing line feed to match Delphi
  if length(lLines.Text) > length(LineEnding) then
      lMemo.Text:= copy(lLines.Text, 1, length(lLines.Text) - length(LineEnding))

I really think this should be incorporated into Lazarus whenever Memo1.Lines.LoadFromFile is called. Otherwise each programmer will have to discover and patch this difference with Delphi.

Dmitry Boyarintsev

2010-07-23 07:47

developer   ~0039607

You're right, Delphi adjusts line breaks.

Paul Ishenin

2011-03-19 18:00

manager   ~0046687

Please test and close if ok.

Issue History

Date Modified Username Field Change
2010-07-21 18:02 Chris Rorden New Issue
2010-07-21 18:02 Chris Rorden File Added:
2010-07-21 18:02 Chris Rorden Widgetset => Win32/Win64
2010-07-21 19:42 Dmitry Boyarintsev LazTarget => 1.0
2010-07-21 19:42 Dmitry Boyarintsev Note Added: 0039565
2010-07-21 19:42 Dmitry Boyarintsev Status new => acknowledged
2010-07-21 19:44 Dmitry Boyarintsev Note Edited: 0039565
2010-07-22 14:43 Bart Broersma Note Added: 0039597
2010-07-23 05:01 Chris Rorden Note Added: 0039604
2010-07-23 07:47 Dmitry Boyarintsev Note Added: 0039607
2011-03-19 18:00 Paul Ishenin Fixed in Revision => 29915
2011-03-19 18:00 Paul Ishenin Status acknowledged => resolved
2011-03-19 18:00 Paul Ishenin Fixed in Version => 0.9.31 (SVN)
2011-03-19 18:00 Paul Ishenin Resolution open => fixed
2011-03-19 18:00 Paul Ishenin Assigned To => Paul Ishenin
2011-03-19 18:00 Paul Ishenin Note Added: 0046687
2011-12-01 11:26 Marc Weustink Status resolved => closed