lazutils: deprecated ConvertLineEndings in favor of LineBreaksToSystemLineBreaks

git-svn-id: trunk@59144 -
This commit is contained in:
mattias 2018-09-23 10:33:52 +00:00
parent f14e40c50d
commit 1f64e2b29d
11 changed files with 28 additions and 56 deletions

View File

@ -609,8 +609,8 @@ var
begin begin
NewName:=IDECodeMacros.CreateUniqueName(Name); NewName:=IDECodeMacros.CreateUniqueName(Name);
Result:=TIDECodeMacro.Create(NewName); Result:=TIDECodeMacro.Create(NewName);
Result.ShortDescription:=ConvertLineEndings(ShortDescription); Result.ShortDescription:=LineBreaksToSystemLineBreaks(ShortDescription);
Result.LongDescription:=ConvertLineEndings(LongDescription); Result.LongDescription:=LineBreaksToSystemLineBreaks(LongDescription);
Result.OnGetValueProc:=OnGetValueProc; Result.OnGetValueProc:=OnGetValueProc;
Result.OnGetValueMethod:=OnGetValueMethod; Result.OnGetValueMethod:=OnGetValueMethod;
IDECodeMacros.Add(Result); IDECodeMacros.Add(Result);
@ -624,8 +624,8 @@ var
begin begin
NewName:=IDECodeMacros.CreateUniqueName(Name); NewName:=IDECodeMacros.CreateUniqueName(Name);
Result:=TIDECodeMacro.Create(NewName); Result:=TIDECodeMacro.Create(NewName);
Result.ShortDescription:=ConvertLineEndings(ShortDescription); Result.ShortDescription:=LineBreaksToSystemLineBreaks(ShortDescription);
Result.LongDescription:=ConvertLineEndings(LongDescription); Result.LongDescription:=LineBreaksToSystemLineBreaks(LongDescription);
Result.OnGetValueExProc:=OnGetValueProc; Result.OnGetValueExProc:=OnGetValueProc;
Result.OnGetValueExMethod:=OnGetValueMethod; Result.OnGetValueExMethod:=OnGetValueMethod;
IDECodeMacros.Add(Result); IDECodeMacros.Add(Result);

View File

@ -1552,7 +1552,7 @@ begin
ADst.ReleaseData; ADst.ReleaseData;
// get intersection // get intersection
IntersectRect(R, Rect(0, 0, Description.Width, Description.Height), ARect); IntersectRect(R{%H-}, Rect(0, 0, Description.Width, Description.Height), ARect);
ADst.Description.Width := R.Right - R.Left; ADst.Description.Width := R.Right - R.Left;
ADst.Description.Height := R.Bottom - R.Top; ADst.Description.Height := R.Bottom - R.Top;
if (ADst.Description.Width <= 0) if (ADst.Description.Width <= 0)

View File

@ -727,9 +727,9 @@ begin
end; end;
if FDebugNestAtBOL and (s <> '') then if FDebugNestAtBOL and (s <> '') then
FileHandle.WriteLnToFile(FDebugIndent + ConvertLineEndings(s)) FileHandle.WriteLnToFile(FDebugIndent + LineBreaksToSystemLineBreaks(s))
else else
FileHandle.WriteLnToFile(ConvertLineEndings(s)); FileHandle.WriteLnToFile(LineBreaksToSystemLineBreaks(s));
FDebugNestAtBOL := True; FDebugNestAtBOL := True;
end; end;

View File

@ -42,7 +42,7 @@ function LineEndingCount(const Txt: string; var LengthOfLastLine: integer): inte
function ChangeLineEndings(const s, NewLineEnding: string): string; function ChangeLineEndings(const s, NewLineEnding: string): string;
function LineBreaksToSystemLineBreaks(const s: string): string; function LineBreaksToSystemLineBreaks(const s: string): string;
function LineBreaksToDelimiter(const s: string; Delimiter: char): string; function LineBreaksToDelimiter(const s: string; Delimiter: char): string;
function ConvertLineEndings(const s: string): string; inline; // duplicate of LineBreaksToSystemLineBreaks function ConvertLineEndings(const s: string): string; inline; deprecated 'use LineBreaksToSystemLineBreaks instead';
// Conversions // Conversions
function TabsToSpaces(const s: string; TabWidth: integer; UseUTF8: boolean): string; function TabsToSpaces(const s: string; TabWidth: integer; UseUTF8: boolean): string;

View File

@ -2244,17 +2244,6 @@
<short></short> <short></short>
</element> </element>
<!-- function Visibility: default -->
<element name="ConvertLineEndings">
<short></short>
<descr>
</descr>
<errors>
</errors>
<seealso>
</seealso>
</element>
<!-- function result Visibility: default --> <!-- function result Visibility: default -->
<element name="ConvertLineEndings.Result"> <element name="ConvertLineEndings.Result">
<short></short> <short></short>

View File

@ -1411,23 +1411,6 @@
<element name="DebugLnExit.s16"/> <element name="DebugLnExit.s16"/>
<element name="DebugLnExit.s17"/> <element name="DebugLnExit.s17"/>
<element name="DebugLnExit.s18"/> <element name="DebugLnExit.s18"/>
<!-- function Visibility: default -->
<element name="ConvertLineEndings">
<short>Converts all line endings in a string into platform LineEnding.
</short>
<descr>
</descr>
<errors>
</errors>
<seealso>
</seealso>
</element>
<element name="ConvertLineEndings.Result">
<short/>
</element>
<element name="ConvertLineEndings.s">
<short/>
</element>
<!-- procedure Visibility: default --> <!-- procedure Visibility: default -->
<element name="DbgOut"> <element name="DbgOut">
<short/> <short/>

View File

@ -1582,7 +1582,7 @@ begin
SrcPath := sp(aXMLConfig.GetValue(p+'SrcPath/Value', '')); SrcPath := sp(aXMLConfig.GetValue(p+'SrcPath/Value', ''));
{ Conditionals } { Conditionals }
FConditionals:=ConvertLineEndings(UTF8Trim( FConditionals:=LineBreaksToSystemLineBreaks(UTF8Trim(
aXMLConfig.GetValue(Path+'Conditionals/Value',DefaultConditionals),[])); aXMLConfig.GetValue(Path+'Conditionals/Value',DefaultConditionals),[]));
TIDEBuildMacros(fBuildMacros).LoadFromXMLConfig(aXMLConfig, TIDEBuildMacros(fBuildMacros).LoadFromXMLConfig(aXMLConfig,
Path+'BuildMacros/',PathDelimChange); Path+'BuildMacros/',PathDelimChange);
@ -4520,10 +4520,10 @@ procedure TIDEBuildMacro.LoadFromXMLConfig(AXMLConfig: TXMLConfig;
begin begin
FIdentifier:=AXMLConfig.GetValue(Path+'Identifier/Value',''); FIdentifier:=AXMLConfig.GetValue(Path+'Identifier/Value','');
if not IsValidIdent(FIdentifier) then FIdentifier:=''; if not IsValidIdent(FIdentifier) then FIdentifier:='';
FDescription:=ConvertLineEndings(AXMLConfig.GetValue(Path+'Description/Value','')); FDescription:=LineBreaksToSystemLineBreaks(AXMLConfig.GetValue(Path+'Description/Value',''));
LoadStringList(AXMLConfig,FValues,Path+'Values/'); LoadStringList(AXMLConfig,FValues,Path+'Values/');
LoadStringList(AXMLConfig,FValueDescriptions,Path+'ValueDescriptions/'); LoadStringList(AXMLConfig,FValueDescriptions,Path+'ValueDescriptions/');
FDefaultValue:=ConvertLineEndings(AXMLConfig.GetValue(Path+'Default/Value','')); FDefaultValue:=LineBreaksToSystemLineBreaks(AXMLConfig.GetValue(Path+'Default/Value',''));
while ValueDescriptions.Count>Values.Count do while ValueDescriptions.Count>Values.Count do
ValueDescriptions.Delete(ValueDescriptions.Count-1); ValueDescriptions.Delete(ValueDescriptions.Count-1);

View File

@ -852,11 +852,11 @@ begin
begin begin
FOldValues:=Element.FPDocFile.GetValuesFromNode(Element.ElementNode); FOldValues:=Element.FPDocFile.GetValuesFromNode(Element.ElementNode);
FOldVisualValues[fpdiShort]:=ReplaceLineEndings(FOldValues[fpdiShort],''); FOldVisualValues[fpdiShort]:=ReplaceLineEndings(FOldValues[fpdiShort],'');
FOldVisualValues[fpdiElementLink]:=ConvertLineEndings(FOldValues[fpdiElementLink]); FOldVisualValues[fpdiElementLink]:=LineBreaksToSystemLineBreaks(FOldValues[fpdiElementLink]);
FOldVisualValues[fpdiDescription]:=ConvertLineEndings(FOldValues[fpdiDescription]); FOldVisualValues[fpdiDescription]:=LineBreaksToSystemLineBreaks(FOldValues[fpdiDescription]);
FOldVisualValues[fpdiErrors]:=ConvertLineEndings(FOldValues[fpdiErrors]); FOldVisualValues[fpdiErrors]:=LineBreaksToSystemLineBreaks(FOldValues[fpdiErrors]);
FOldVisualValues[fpdiSeeAlso]:=ConvertLineEndings(FOldValues[fpdiSeeAlso]); FOldVisualValues[fpdiSeeAlso]:=LineBreaksToSystemLineBreaks(FOldValues[fpdiSeeAlso]);
FOldVisualValues[fpdiExample]:=ConvertLineEndings(FOldValues[fpdiExample]); FOldVisualValues[fpdiExample]:=LineBreaksToSystemLineBreaks(FOldValues[fpdiExample]);
//DebugLn(['TFPDocEditor.LoadGUIValues Short="',dbgstr(FOldValues[fpdiShort]),'"']); //DebugLn(['TFPDocEditor.LoadGUIValues Short="',dbgstr(FOldValues[fpdiShort]),'"']);
end end
else else

View File

@ -130,7 +130,7 @@ var
begin begin
Btns := GetPromptUserButtons(Buttons, CancelValue, DefaultIndex, ButtonCount, Btns := GetPromptUserButtons(Buttons, CancelValue, DefaultIndex, ButtonCount,
False, mbYes); False, mbYes);
Result := DialogResults[PromptUser(ConvertLineEndings(aMsg), Result := DialogResults[PromptUser(LineBreaksToSystemLineBreaks(aMsg),
DialogIds[DlgType], Btns, ButtonCount, DefaultIndex, CancelValue)]; DialogIds[DlgType], Btns, ButtonCount, DefaultIndex, CancelValue)];
ReallocMem(Btns, 0); ReallocMem(Btns, 0);
end; end;
@ -145,7 +145,7 @@ var
begin begin
Btns := GetPromptUserButtons(Buttons, CancelValue, DefaultIndex, ButtonCount, Btns := GetPromptUserButtons(Buttons, CancelValue, DefaultIndex, ButtonCount,
False, mbYes); False, mbYes);
Result := DialogResults[PromptUser(aCaption, ConvertLineEndings(aMsg), Result := DialogResults[PromptUser(aCaption, LineBreaksToSystemLineBreaks(aMsg),
DialogIds[DlgType], Btns, ButtonCount, DefaultIndex, CancelValue)]; DialogIds[DlgType], Btns, ButtonCount, DefaultIndex, CancelValue)];
ReallocMem(Btns, 0); ReallocMem(Btns, 0);
end; end;
@ -160,7 +160,7 @@ var
begin begin
Btns := GetPromptUserButtons(Buttons, CancelValue, DefaultIndex, ButtonCount, Btns := GetPromptUserButtons(Buttons, CancelValue, DefaultIndex, ButtonCount,
True, DefaultButton); True, DefaultButton);
Result := DialogResults[PromptUser(aCaption, ConvertLineEndings(aMsg), Result := DialogResults[PromptUser(aCaption, LineBreaksToSystemLineBreaks(aMsg),
DialogIds[DlgType], Btns, ButtonCount, DefaultIndex, CancelValue)]; DialogIds[DlgType], Btns, ButtonCount, DefaultIndex, CancelValue)];
ReallocMem(Btns, 0); ReallocMem(Btns, 0);
end; end;
@ -189,7 +189,7 @@ var
begin begin
Btns := GetPromptUserButtons(Buttons, CancelValue, DefaultIndex, ButtonCount, Btns := GetPromptUserButtons(Buttons, CancelValue, DefaultIndex, ButtonCount,
False, mbYes); False, mbYes);
Result := DialogResults[PromptUserAtXY(ConvertLineEndings(aMsg), Result := DialogResults[PromptUserAtXY(LineBreaksToSystemLineBreaks(aMsg),
DialogIds[DlgType], Btns, ButtonCount, DefaultIndex, CancelValue, X, Y)]; DialogIds[DlgType], Btns, ButtonCount, DefaultIndex, CancelValue, X, Y)];
ReallocMem(Btns, 0); ReallocMem(Btns, 0);
end; end;
@ -205,17 +205,17 @@ end;
procedure ShowMessage(const aMsg: string); procedure ShowMessage(const aMsg: string);
begin begin
NotifyUser(ConvertLineEndings(aMsg), idDialogBase); NotifyUser(LineBreaksToSystemLineBreaks(aMsg), idDialogBase);
end; end;
procedure ShowMessageFmt(const aMsg: string; Params: array of const); procedure ShowMessageFmt(const aMsg: string; Params: array of const);
begin begin
NotifyUser(ConvertLineEndings(Format(aMsg, Params)), idDialogBase); NotifyUser(LineBreaksToSystemLineBreaks(Format(aMsg, Params)), idDialogBase);
end; end;
procedure ShowMessagePos(const aMsg: string; X, Y: Integer); procedure ShowMessagePos(const aMsg: string; X, Y: Integer);
begin begin
NotifyUserAtXY(ConvertLineEndings(aMsg), idDialogBase, X, Y); NotifyUserAtXY(LineBreaksToSystemLineBreaks(aMsg), idDialogBase, X, Y);
end; end;
//----------------------------------------------------------------------------// //----------------------------------------------------------------------------//
@ -335,7 +335,7 @@ end;
function InputQuery(const ACaption, APrompt : String; MaskInput : Boolean; function InputQuery(const ACaption, APrompt : String; MaskInput : Boolean;
var Value : String) : Boolean; var Value : String) : Boolean;
begin begin
Result := LCLIntf.RequestInput(ACaption, ConvertLineEndings(APrompt), Result := LCLIntf.RequestInput(ACaption, LineBreaksToSystemLineBreaks(APrompt),
MaskInput, Value); MaskInput, Value);
end; end;

View File

@ -138,7 +138,7 @@ begin
BorderStyle := bsDialog; BorderStyle := bsDialog;
Position := poScreenCenter; Position := poScreenCenter;
SetInitialBounds(0,0,200,100); SetInitialBounds(0,0,200,100);
MSG := ConvertLineEndings(AMSG); MSG := LineBreaksToSystemLineBreaks(AMSG);
Buttons := nil; Buttons := nil;
FBitmap := nil; FBitmap := nil;
case DialogType of case DialogType of
@ -827,7 +827,7 @@ begin
PopupMode := pmAuto; PopupMode := pmAuto;
BorderStyle := bsDialog; BorderStyle := bsDialog;
Position := poDesigned; Position := poDesigned;
MessageTxt := ConvertLineEndings(aMsg); MessageTxt := LineBreaksToSystemLineBreaks(aMsg);
HelpContext := HelpCtx; HelpContext := HelpCtx;
KeyPreview := True; KeyPreview := True;
@ -1058,7 +1058,7 @@ begin
end; end;
if DialogButtons.DefaultButton = nil then if DialogButtons.DefaultButton = nil then
DialogButtons.DefaultButton := DialogButtons.FindButton([mrYes, mrOk, mrYesToAll, mrAll, mrRetry, mrCancel, mrNo, mrNoToAll, mrAbort, mrIgnore]); DialogButtons.DefaultButton := DialogButtons.FindButton([mrYes, mrOk, mrYesToAll, mrAll, mrRetry, mrCancel, mrNo, mrNoToAll, mrAbort, mrIgnore]);
Result := WidgetSet.AskUser(aCaption, ConvertLineEndings(aMsg), Result := WidgetSet.AskUser(aCaption, LineBreaksToSystemLineBreaks(aMsg),
DialogIds[DlgType], DialogButtons, HelpCtx); DialogIds[DlgType], DialogButtons, HelpCtx);
finally finally
DialogButtons.Free; DialogButtons.Free;

View File

@ -464,7 +464,7 @@ begin
try try
// don't need to copy Objects, VCL does not support them neither // don't need to copy Objects, VCL does not support them neither
// preserve the last line ending // preserve the last line ending
Text:=ConvertLineEndings(TheStrings.Text); Text:=LineBreaksToSystemLineBreaks(TheStrings.Text);
finally finally
EndUpdate; EndUpdate;
end; end;