IceCold
IceCold

Reputation: 21154

How does TMemo handle the enter (CRLF) issue on Mac?

This is related to a previous question: TMemo cannot handle Unix text (LF as line ending) correctly.

On Delphi XE, TMemo can only handle Windows formatted text (CRLF as enter). For example this text:

test1+ LF+ test2

is treated/shown as a single line of text: test1test2
instead of:
test1
test2

I realize this is a bigger problem so I am curious how/if they fix this problem in Delphi XE2 (which I think has Mac support). There is a property similar to TMemo.Lines.TextLineBreakStyle (Lazarus)?

(I only own a Delphi XE license.)

Upvotes: 1

Views: 554

Answers (1)

Deltics
Deltics

Reputation: 23036

As David says, Mac applications in Delphi are only supported using the new FireMonkey framework, as opposed to the VCL controls in previous versions of Delphi. You can still use VCL in XE2 (and later), but only for developing Windows applications. FireMonkey can be used for developing both Mac and Windows applications.

FireMonkey has a memo control, just as the VCL does, and this also has a Text property, so this line of code would be perfectly valid in both a VCL and a FireMonkey (FMX) application:

Memo1.Text := 'Line 1'#10'Line 2'#10'Line 3'#13#10'Final Line';

Where Memo1 is a VCL or FMX Memo control.

However, the VCL control (as of XE4 at least) still does not properly support the #10 (LF) line breaks, but the FMX control does, on both Windows and Mac so although the code above can be used in both VCL and FMX applications, the results will be different.

In VCL (Windows) you will get the following content in the memo:

Line 1Line 2Line 3
Line

Where as with FireMonkey on Windows and/or Mac you will get:

Line 1
Line 2
Line 3
Final Line

So the answer is that FMX behaves differently than the VCL and respects both #10 and #13#10 line break sequences, irrespective of platform where-as the VCL memo behaviour remains unchanged and is only supported on Windows.

Upvotes: 3

Related Questions