mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 07:19:22 +02:00
memo: Changes the LFM writer to store the lines without wordwrap so that this information is not lost, see bug #30659
git-svn-id: trunk@53052 -
This commit is contained in:
parent
b7265a7a7e
commit
9ead143427
@ -26,7 +26,7 @@ uses
|
|||||||
// rtl+ftl
|
// rtl+ftl
|
||||||
Classes, SysUtils,
|
Classes, SysUtils,
|
||||||
// LCL
|
// LCL
|
||||||
LCLProc, LCLType, Graphics, Controls, StdCtrls, LazUtf8Classes,
|
LCLProc, LCLType, Graphics, Controls, StdCtrls, LazUtf8Classes, textstrings,
|
||||||
// LCL Carbon
|
// LCL Carbon
|
||||||
CarbonEdits, CarbonListViews;
|
CarbonEdits, CarbonListViews;
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ type
|
|||||||
|
|
||||||
{ TCarbonMemoStrings }
|
{ TCarbonMemoStrings }
|
||||||
|
|
||||||
TCarbonMemoStrings = class(TStrings)
|
TCarbonMemoStrings = class(TCustomMemoStrings)
|
||||||
private
|
private
|
||||||
FOwner: TCarbonMemo; // Carbon memo control owning strings
|
FOwner: TCarbonMemo; // Carbon memo control owning strings
|
||||||
protected
|
protected
|
||||||
|
@ -27,7 +27,7 @@ uses
|
|||||||
MacOSAll, CocoaAll, Classes, sysutils,
|
MacOSAll, CocoaAll, Classes, sysutils,
|
||||||
// LCL
|
// LCL
|
||||||
Controls, StdCtrls, Graphics, LCLType, LMessages, LCLProc, LCLMessageGlue,
|
Controls, StdCtrls, Graphics, LCLType, LMessages, LCLProc, LCLMessageGlue,
|
||||||
LazUtf8Classes,
|
LazUtf8Classes, textstrings,
|
||||||
// Widgetset
|
// Widgetset
|
||||||
WSStdCtrls, WSLCLClasses, WSControls, WSProc,
|
WSStdCtrls, WSLCLClasses, WSControls, WSProc,
|
||||||
// LCL Cocoa
|
// LCL Cocoa
|
||||||
@ -134,7 +134,7 @@ type
|
|||||||
|
|
||||||
{ TCocoaMemoStrings }
|
{ TCocoaMemoStrings }
|
||||||
|
|
||||||
TCocoaMemoStrings = class(TStrings)
|
TCocoaMemoStrings = class(TCustomMemoStrings)
|
||||||
private
|
private
|
||||||
FTextView: NSTextView;
|
FTextView: NSTextView;
|
||||||
public
|
public
|
||||||
|
@ -113,6 +113,11 @@ end;"/>
|
|||||||
<ValueDescriptions Count="2"/>
|
<ValueDescriptions Count="2"/>
|
||||||
</Item2>
|
</Item2>
|
||||||
</BuildMacros>
|
</BuildMacros>
|
||||||
|
<Linking>
|
||||||
|
<Debugging>
|
||||||
|
<DebugInfoType Value="dsDwarf2"/>
|
||||||
|
</Debugging>
|
||||||
|
</Linking>
|
||||||
<Other>
|
<Other>
|
||||||
<CompilerMessages>
|
<CompilerMessages>
|
||||||
<IgnoredMessages idx5044="True"/>
|
<IgnoredMessages idx5044="True"/>
|
||||||
|
@ -13,6 +13,11 @@
|
|||||||
</SearchPaths>
|
</SearchPaths>
|
||||||
<Conditionals Value="if SrcOS<>'win' then
|
<Conditionals Value="if SrcOS<>'win' then
|
||||||
UnitPath := 'nonwin32';"/>
|
UnitPath := 'nonwin32';"/>
|
||||||
|
<Linking>
|
||||||
|
<Debugging>
|
||||||
|
<DebugInfoType Value="dsDwarf2"/>
|
||||||
|
</Debugging>
|
||||||
|
</Linking>
|
||||||
<Other>
|
<Other>
|
||||||
<Verbosity>
|
<Verbosity>
|
||||||
<ShowNotes Value="False"/>
|
<ShowNotes Value="False"/>
|
||||||
|
@ -16,6 +16,10 @@
|
|||||||
|
|
||||||
TTextStrings is a TStrings descendent that is optimized for handling the
|
TTextStrings is a TStrings descendent that is optimized for handling the
|
||||||
complete text as whole (instead of as line by line as in TStringList).
|
complete text as whole (instead of as line by line as in TStringList).
|
||||||
|
|
||||||
|
TCustomMemoStrings is a TStrings descendent which works around the behavior
|
||||||
|
of TMemo.Lines, which contains the text with wordwrap line endings, in order
|
||||||
|
to store the text in the LFM without those wordwrap line endings. See bug 30659
|
||||||
}
|
}
|
||||||
unit TextStrings;
|
unit TextStrings;
|
||||||
|
|
||||||
@ -37,7 +41,14 @@ type
|
|||||||
end;
|
end;
|
||||||
PTextLineRange = ^TTextLineRange;
|
PTextLineRange = ^TTextLineRange;
|
||||||
|
|
||||||
TTextStrings = class(TStrings)
|
TCustomMemoStrings = class(TStrings)
|
||||||
|
protected
|
||||||
|
procedure DoReadData(Reader: TReader); virtual;
|
||||||
|
procedure DoWriteData(Writer: TWriter); virtual;
|
||||||
|
procedure DefineProperties(Filer: TFiler); override;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TTextStrings = class(TCustomMemoStrings)
|
||||||
private
|
private
|
||||||
FOnChange: TNotifyEvent;
|
FOnChange: TNotifyEvent;
|
||||||
FOnChanging: TNotifyEvent;
|
FOnChanging: TNotifyEvent;
|
||||||
@ -90,6 +101,48 @@ type
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
{ TCustomMemoStrings }
|
||||||
|
|
||||||
|
procedure TCustomMemoStrings.DoReadData(Reader: TReader);
|
||||||
|
begin
|
||||||
|
Reader.ReadListBegin;
|
||||||
|
BeginUpdate;
|
||||||
|
try
|
||||||
|
Clear;
|
||||||
|
while not Reader.EndOfList do
|
||||||
|
Add(Reader.ReadString);
|
||||||
|
finally
|
||||||
|
EndUpdate;
|
||||||
|
end;
|
||||||
|
Reader.ReadListEnd;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCustomMemoStrings.DoWriteData(Writer: TWriter);
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
lStringsNoWordWrap: TStringList;
|
||||||
|
begin
|
||||||
|
lStringsNoWordWrap := TStringList.Create;
|
||||||
|
try
|
||||||
|
lStringsNoWordWrap.Text := Text;
|
||||||
|
|
||||||
|
Writer.WriteListBegin;
|
||||||
|
for i := 0 to lStringsNoWordWrap.Count - 1 do
|
||||||
|
Writer.WriteString(lStringsNoWordWrap.Strings[i]);
|
||||||
|
Writer.WriteListEnd;
|
||||||
|
finally
|
||||||
|
lStringsNoWordWrap.Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCustomMemoStrings.DefineProperties(Filer: TFiler);
|
||||||
|
var
|
||||||
|
HasData: Boolean;
|
||||||
|
begin
|
||||||
|
HasData := Count > 0;
|
||||||
|
Filer.DefineProperty('Strings', @DoReadData, @DoWriteData, HasData);
|
||||||
|
end;
|
||||||
|
|
||||||
{ TTextStrings }
|
{ TTextStrings }
|
||||||
|
|
||||||
function TTextStrings.GetTextStr: string;
|
function TTextStrings.GetTextStr: string;
|
||||||
|
Loading…
Reference in New Issue
Block a user