mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 12:16:18 +02:00
LazUtils: Move string manipulation functions from LazUtilities to LazStringUtils.
git-svn-id: trunk@58634 -
This commit is contained in:
parent
9b85717453
commit
41dc46374f
@ -35,7 +35,7 @@ interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, zstream, Laz2_XMLCfg, LazUTF8, LConvEncoding,
|
||||
LazFileUtils, LazUtilities;
|
||||
LazFileUtils, LazStringUtils, LazUtilities;
|
||||
|
||||
type
|
||||
TAPackageType = (
|
||||
|
@ -43,7 +43,7 @@ uses
|
||||
Classes, SysUtils, contnrs, TypInfo, types, Laz_AVL_Tree,
|
||||
// LazUtils
|
||||
LazFileUtils, LazFileCache, LazMethodList, LazDbgLog, AvgLvlTree,
|
||||
LazUtilities,
|
||||
LazStringUtils,
|
||||
// Codetools
|
||||
FileProcs, BasicCodeTools, CodeToolsStrConsts,
|
||||
EventCodeTool, CodeTree, CodeAtom, SourceChanger, DefineTemplates, CodeCache,
|
||||
|
@ -32,7 +32,7 @@ interface
|
||||
uses
|
||||
Classes, SysUtils, Laz_AVL_Tree,
|
||||
// LazUtils
|
||||
LazFileUtils, LazUtilities,
|
||||
LazFileUtils, LazStringUtils,
|
||||
// Codetools
|
||||
FileProcs, FindDeclarationTool, CodeBeautifier, CodeCache, StdCodeTools,
|
||||
DirectoryCacher, LinkScanner, CustomCodeTool, CodeTree, CodeToolsStructs;
|
||||
|
@ -59,8 +59,8 @@ uses
|
||||
CodeToolsStrConsts, ExprEval, DirectoryCacher, BasicCodeTools,
|
||||
CodeToolsStructs, KeywordFuncLists, LinkScanner, FileProcs,
|
||||
// LazUtils
|
||||
LazUtilities, LazUTF8, LazUTF8Classes, LazFileUtils, UTF8Process,
|
||||
LazFileCache, LazDbgLog, AvgLvlTree, Laz2_XMLCfg;
|
||||
LazStringUtils, LazFileUtils, LazFileCache,
|
||||
LazUTF8, LazUTF8Classes, UTF8Process, LazDbgLog, AvgLvlTree, Laz2_XMLCfg;
|
||||
|
||||
const
|
||||
ExternalMacroStart = ExprEval.ExternalMacroStart;
|
||||
|
@ -40,7 +40,8 @@ uses
|
||||
// CodeTools
|
||||
FileProcs,
|
||||
// LazUtils
|
||||
LazUTF8, LazFileCache, LazFileUtils, LazUtilities, AvgLvlTree, LazDbgLog;
|
||||
LazUTF8, LazFileCache, LazFileUtils, LazUtilities, LazStringUtils, LazDbgLog,
|
||||
AvgLvlTree;
|
||||
|
||||
// verbosity
|
||||
{ $DEFINE CTDEBUG}
|
||||
|
@ -16,9 +16,9 @@ interface
|
||||
uses
|
||||
Classes, SysUtils,
|
||||
// LCL
|
||||
LCLProc, LCLType, Forms, Controls, Graphics,
|
||||
LCLType, Forms, Controls, Graphics,
|
||||
// LazUtils
|
||||
FileUtil, Laz2_XMLCfg,
|
||||
FileUtil, Laz2_XMLCfg, LazStringUtils,
|
||||
// IdeIntf
|
||||
ProjectIntf, IDECommands;
|
||||
|
||||
|
@ -15,7 +15,7 @@ interface
|
||||
uses
|
||||
Classes, SysUtils, types, math,
|
||||
// LazUtils
|
||||
LazLoggerBase, LazClasses, LazFileUtils, LazUtilities, LazUTF8;
|
||||
LazLoggerBase, LazClasses, LazFileUtils, LazStringUtils, LazUTF8;
|
||||
|
||||
type
|
||||
|
||||
|
@ -37,8 +37,14 @@ type
|
||||
const
|
||||
EndOfLine: shortstring = LineEnding;
|
||||
|
||||
// Functions for line endings
|
||||
function LineEndingCount(const Txt: string; var LengthOfLastLine: integer): integer;
|
||||
function ChangeLineEndings(const s, NewLineEnding: string): string;
|
||||
function LineBreaksToSystemLineBreaks(const s: string): string;
|
||||
function LineBreaksToDelimiter(const s: string; Delimiter: char): string;
|
||||
function ConvertLineEndings(const s: string): string;
|
||||
|
||||
// Conversions
|
||||
function TabsToSpaces(const s: string; TabWidth: integer; UseUTF8: boolean): string;
|
||||
//function CommentLines(const s: string): string;
|
||||
function CommentText(const s: string; CommentType: TCommentType): string;
|
||||
@ -47,13 +53,14 @@ function CommentText(const s: string; CommentType: TCommentType): string;
|
||||
// const SpecialChars: string): string;
|
||||
function SimpleSyntaxToRegExpr(const Src: string): string;
|
||||
function BinaryStrToText(const s: string): string;
|
||||
function SpecialCharsToSpaces(const s: string; FixUTF8: boolean): string;
|
||||
function SpecialCharsToHex(const s: string): string;
|
||||
function BreakString(const s: string; MaxLineLength, Indent: integer): string;
|
||||
|
||||
// Conversions to and from a StringList
|
||||
function SplitString(const s: string; Delimiter: char): TStrings;
|
||||
procedure SplitString(const s: string; Delimiter: char; AddTo: TStrings;
|
||||
ClearList: boolean = true);
|
||||
function SpecialCharsToSpaces(const s: string; FixUTF8: boolean): string;
|
||||
function SpecialCharsToHex(const s: string): string;
|
||||
function LineBreaksToSystemLineBreaks(const s: string): string;
|
||||
function LineBreaksToDelimiter(const s: string; Delimiter: char): string;
|
||||
function StringListToText(List: TStrings; const Delimiter: string;
|
||||
IgnoreEmptyLines: boolean = false): string;
|
||||
function StringListPartToText(List: TStrings; FromIndex, ToIndex: integer;
|
||||
@ -63,6 +70,15 @@ function StringListToString(List: TStrings; FromIndex, ToIndex: integer;
|
||||
IgnoreEmptyLines: boolean = false): string;
|
||||
procedure StringToStringList(const s: string; List: TStrings);
|
||||
|
||||
// Text with delimiters
|
||||
function GetNextDelimitedItem(const List: string; Delimiter: char;
|
||||
var Position: integer): string;
|
||||
function HasDelimitedItem(const List: string; Delimiter: char; FindItem: string
|
||||
): boolean;
|
||||
function FindNextDelimitedItem(const List: string; Delimiter: char;
|
||||
var Position: integer; FindItem: string): string;
|
||||
function MergeWithDelimiter(const a, b: string; Delimiter: char): string;
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
@ -143,6 +159,59 @@ begin
|
||||
//if Src-1<>@s[length(s)] then RaiseGDBException('');
|
||||
end;
|
||||
|
||||
function LineBreaksToSystemLineBreaks(const s: string): string;
|
||||
begin
|
||||
Result:=ChangeLineEndings(s,LineEnding);
|
||||
end;
|
||||
|
||||
function LineBreaksToDelimiter(const s: string; Delimiter: char): string;
|
||||
var
|
||||
p: Integer;
|
||||
StartPos: LongInt;
|
||||
begin
|
||||
Result:=s;
|
||||
p:=1;
|
||||
while (p<=length(Result)) do begin
|
||||
if Result[p] in [#10,#13] then begin
|
||||
StartPos:=p;
|
||||
repeat
|
||||
inc(p);
|
||||
until (p>length(Result)) or (not (Result[p] in [#10,#13]));
|
||||
if p<=length(Result) then
|
||||
Result:=copy(Result,1,StartPos-1)+Delimiter+copy(Result,p,length(Result))
|
||||
else
|
||||
Result:=copy(Result,1,StartPos-1);
|
||||
end else begin
|
||||
inc(p);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
function ConvertLineEndings(const s: string): string;
|
||||
var
|
||||
i: Integer;
|
||||
EndingStart: LongInt;
|
||||
begin
|
||||
Result:=s;
|
||||
i:=1;
|
||||
while (i<=length(Result)) do begin
|
||||
if Result[i] in [#10,#13] then begin
|
||||
EndingStart:=i;
|
||||
inc(i);
|
||||
if (i<=length(Result)) and (Result[i] in [#10,#13])
|
||||
and (Result[i]<>Result[i-1]) then
|
||||
inc(i);
|
||||
if (length(LineEnding)<>i-EndingStart)
|
||||
or (LineEnding<>copy(Result,EndingStart,length(LineEnding))) then begin
|
||||
// line end differs => replace with current LineEnding
|
||||
Result:=copy(Result,1,EndingStart-1)+LineEnding+copy(Result,i,length(Result));
|
||||
i:=EndingStart+length(LineEnding);
|
||||
end;
|
||||
end else
|
||||
inc(i);
|
||||
end;
|
||||
end;
|
||||
|
||||
function TabsToSpaces(const s: string; TabWidth: integer; UseUTF8: boolean): string;
|
||||
// Convert all tabs to TabWidth number of spaces.
|
||||
|
||||
@ -602,37 +671,6 @@ begin
|
||||
RaiseGDBException('ERROR: BinaryStrToText: '+IntToStr(NewLen)+'<>'+IntToStr(NewPos-1));
|
||||
end;
|
||||
|
||||
function SplitString(const s: string; Delimiter: char): TStrings;
|
||||
begin
|
||||
Result:=TStringList.Create;
|
||||
SplitString(s,Delimiter,Result,false);
|
||||
end;
|
||||
|
||||
procedure SplitString(const s: string; Delimiter: char; AddTo: TStrings;
|
||||
ClearList: boolean);
|
||||
var
|
||||
SLen: Integer;
|
||||
StartPos: Integer;
|
||||
EndPos: Integer;
|
||||
begin
|
||||
if ClearList then
|
||||
AddTo.Clear;
|
||||
SLen:=length(s);
|
||||
StartPos:=1;
|
||||
EndPos:=1;
|
||||
repeat
|
||||
if (EndPos<=sLen) and (s[EndPos]<>Delimiter) then
|
||||
inc(EndPos)
|
||||
else begin
|
||||
if EndPos>StartPos then
|
||||
AddTo.Add(copy(s,StartPos,EndPos-StartPos));
|
||||
StartPos:=EndPos+1;
|
||||
if StartPos>sLen then exit;
|
||||
inc(EndPos);
|
||||
end;
|
||||
until false;
|
||||
end;
|
||||
|
||||
function SpecialCharsToSpaces(const s: string; FixUTF8: boolean): string;
|
||||
// Converts illegal characters to spaces. Trim leading and trailing spaces.
|
||||
var
|
||||
@ -676,32 +714,116 @@ begin
|
||||
+copy(Result,i+1,length(Result));
|
||||
end;
|
||||
|
||||
function LineBreaksToSystemLineBreaks(const s: string): string;
|
||||
function BreakString(const s: string; MaxLineLength, Indent: integer): string;
|
||||
var
|
||||
SrcLen: Integer;
|
||||
APos: Integer;
|
||||
Src: String;
|
||||
SplitPos: Integer;
|
||||
CurMaxLineLength: Integer;
|
||||
begin
|
||||
Result:=ChangeLineEndings(s,LineEnding);
|
||||
Result:='';
|
||||
Src:=s;
|
||||
CurMaxLineLength:=MaxLineLength;
|
||||
if Indent>MaxLineLength-2 then
|
||||
Indent:=MaxLineLength-2;
|
||||
if Indent<0 then
|
||||
MaxLineLength:=0;
|
||||
repeat
|
||||
SrcLen:=length(Src);
|
||||
if SrcLen<=CurMaxLineLength then begin
|
||||
Result:=Result+Src;
|
||||
break;
|
||||
end;
|
||||
// split line
|
||||
SplitPos:=0;
|
||||
// search new line chars
|
||||
APos:=1;
|
||||
while (APos<=CurMaxLineLength) do begin
|
||||
if Src[APos] in [#13,#10] then begin
|
||||
SplitPos:=APos;
|
||||
break;
|
||||
end;
|
||||
inc(APos);
|
||||
end;
|
||||
// search a space boundary
|
||||
if SplitPos=0 then begin
|
||||
APos:=CurMaxLineLength;
|
||||
while APos>1 do begin
|
||||
if (Src[APos-1] in [' ',#9])
|
||||
and (not (Src[APos] in [' ',#9])) then begin
|
||||
SplitPos:=APos;
|
||||
break;
|
||||
end;
|
||||
dec(APos);
|
||||
end;
|
||||
end;
|
||||
// search a word boundary
|
||||
if SplitPos=0 then begin
|
||||
APos:=CurMaxLineLength;
|
||||
while APos>1 do begin
|
||||
if (Src[APos] in ['A'..'Z','a'..'z'])
|
||||
and (not (Src[APos-1] in ['A'..'Z','a'..'z'])) then begin
|
||||
SplitPos:=APos;
|
||||
break;
|
||||
end;
|
||||
dec(APos);
|
||||
end;
|
||||
end;
|
||||
if SplitPos=0 then begin
|
||||
// no word boundary found -> split chars
|
||||
SplitPos:=CurMaxLineLength;
|
||||
end;
|
||||
// append part and newline
|
||||
if (SplitPos<=SrcLen) and (Src[SplitPos] in [#10,#13]) then begin
|
||||
// there is already a new line char at position
|
||||
inc(SplitPos);
|
||||
if (SplitPos<=SrcLen) and (Src[SplitPos] in [#10,#13])
|
||||
and (Src[SplitPos]<>Src[SplitPos-1]) then
|
||||
inc(SplitPos);
|
||||
Result:=Result+copy(Src,1,SplitPos-1);
|
||||
end else begin
|
||||
Result:=Result+copy(Src,1,SplitPos-1)+LineEnding;
|
||||
end;
|
||||
// append indent
|
||||
if Indent>0 then
|
||||
Result:=Result+StringOfChar(' ',Indent);
|
||||
// calculate new LineLength
|
||||
CurMaxLineLength:=MaxLineLength-Indent;
|
||||
// cut string
|
||||
Src:=copy(Src,SplitPos,length(Src)-SplitPos+1);
|
||||
until false;
|
||||
end;
|
||||
|
||||
function LineBreaksToDelimiter(const s: string; Delimiter: char): string;
|
||||
var
|
||||
p: Integer;
|
||||
StartPos: LongInt;
|
||||
function SplitString(const s: string; Delimiter: char): TStrings;
|
||||
begin
|
||||
Result:=s;
|
||||
p:=1;
|
||||
while (p<=length(Result)) do begin
|
||||
if Result[p] in [#10,#13] then begin
|
||||
StartPos:=p;
|
||||
repeat
|
||||
inc(p);
|
||||
until (p>length(Result)) or (not (Result[p] in [#10,#13]));
|
||||
if p<=length(Result) then
|
||||
Result:=copy(Result,1,StartPos-1)+Delimiter+copy(Result,p,length(Result))
|
||||
else
|
||||
Result:=copy(Result,1,StartPos-1);
|
||||
end else begin
|
||||
inc(p);
|
||||
Result:=TStringList.Create;
|
||||
SplitString(s,Delimiter,Result,false);
|
||||
end;
|
||||
|
||||
procedure SplitString(const s: string; Delimiter: char; AddTo: TStrings;
|
||||
ClearList: boolean);
|
||||
var
|
||||
SLen: Integer;
|
||||
StartPos: Integer;
|
||||
EndPos: Integer;
|
||||
begin
|
||||
if ClearList then
|
||||
AddTo.Clear;
|
||||
SLen:=length(s);
|
||||
StartPos:=1;
|
||||
EndPos:=1;
|
||||
repeat
|
||||
if (EndPos<=sLen) and (s[EndPos]<>Delimiter) then
|
||||
inc(EndPos)
|
||||
else begin
|
||||
if EndPos>StartPos then
|
||||
AddTo.Add(copy(s,StartPos,EndPos-StartPos));
|
||||
StartPos:=EndPos+1;
|
||||
if StartPos>sLen then exit;
|
||||
inc(EndPos);
|
||||
end;
|
||||
end;
|
||||
until false;
|
||||
end;
|
||||
|
||||
function StringListToText(List: TStrings; const Delimiter: string;
|
||||
@ -880,5 +1002,47 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function GetNextDelimitedItem(const List: string; Delimiter: char;
|
||||
var Position: integer): string;
|
||||
var
|
||||
StartPos: LongInt;
|
||||
begin
|
||||
StartPos:=Position;
|
||||
while (Position<=length(List)) and (List[Position]<>Delimiter) do
|
||||
inc(Position);
|
||||
Result:=copy(List,StartPos,Position-StartPos);
|
||||
if Position<=length(List) then inc(Position); // skip Delimiter
|
||||
end;
|
||||
|
||||
function HasDelimitedItem(const List: string; Delimiter: char; FindItem: string
|
||||
): boolean;
|
||||
var
|
||||
p: Integer;
|
||||
begin
|
||||
p:=1;
|
||||
Result:=FindNextDelimitedItem(List,Delimiter,p,FindItem)<>'';
|
||||
end;
|
||||
|
||||
function FindNextDelimitedItem(const List: string; Delimiter: char;
|
||||
var Position: integer; FindItem: string): string;
|
||||
begin
|
||||
while Position<=length(List) do begin
|
||||
Result:=GetNextDelimitedItem(List,Delimiter,Position);
|
||||
if Result=FindItem then exit;
|
||||
end;
|
||||
Result:='';
|
||||
end;
|
||||
|
||||
function MergeWithDelimiter(const a, b: string; Delimiter: char): string;
|
||||
begin
|
||||
if a<>'' then begin
|
||||
if b<>'' then
|
||||
Result:=a+Delimiter+b
|
||||
else
|
||||
Result:=a;
|
||||
end else
|
||||
Result:=b;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
@ -25,16 +25,6 @@ function CompareBoolean(b1, b2: boolean): integer;
|
||||
procedure MergeSortWithLen(List: PPointer; ListLength: PtrInt;
|
||||
const Compare: TListSortCompare);
|
||||
|
||||
function GetNextDelimitedItem(const List: string; Delimiter: char;
|
||||
var Position: integer): string;
|
||||
function HasDelimitedItem(const List: string; Delimiter: char; FindItem: string
|
||||
): boolean;
|
||||
function FindNextDelimitedItem(const List: string; Delimiter: char;
|
||||
var Position: integer; FindItem: string): string;
|
||||
function MergeWithDelimiter(const a, b: string; Delimiter: char): string;
|
||||
function BreakString(const s: string; MaxLineLength, Indent: integer): string;
|
||||
function ConvertLineEndings(const s: string): string;
|
||||
|
||||
var
|
||||
ConsoleVerbosity: integer = 0; // 0=normal, -1=quiet, 1=verbose, 2=very verbose
|
||||
|
||||
@ -141,153 +131,5 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function GetNextDelimitedItem(const List: string; Delimiter: char;
|
||||
var Position: integer): string;
|
||||
var
|
||||
StartPos: LongInt;
|
||||
begin
|
||||
StartPos:=Position;
|
||||
while (Position<=length(List)) and (List[Position]<>Delimiter) do
|
||||
inc(Position);
|
||||
Result:=copy(List,StartPos,Position-StartPos);
|
||||
if Position<=length(List) then inc(Position); // skip Delimiter
|
||||
end;
|
||||
|
||||
function HasDelimitedItem(const List: string; Delimiter: char; FindItem: string
|
||||
): boolean;
|
||||
var
|
||||
p: Integer;
|
||||
begin
|
||||
p:=1;
|
||||
Result:=FindNextDelimitedItem(List,Delimiter,p,FindItem)<>'';
|
||||
end;
|
||||
|
||||
function FindNextDelimitedItem(const List: string; Delimiter: char;
|
||||
var Position: integer; FindItem: string): string;
|
||||
begin
|
||||
while Position<=length(List) do begin
|
||||
Result:=GetNextDelimitedItem(List,Delimiter,Position);
|
||||
if Result=FindItem then exit;
|
||||
end;
|
||||
Result:='';
|
||||
end;
|
||||
|
||||
function MergeWithDelimiter(const a, b: string; Delimiter: char): string;
|
||||
begin
|
||||
if a<>'' then begin
|
||||
if b<>'' then
|
||||
Result:=a+Delimiter+b
|
||||
else
|
||||
Result:=a;
|
||||
end else
|
||||
Result:=b;
|
||||
end;
|
||||
|
||||
function BreakString(const s: string; MaxLineLength, Indent: integer): string;
|
||||
var
|
||||
SrcLen: Integer;
|
||||
APos: Integer;
|
||||
Src: String;
|
||||
SplitPos: Integer;
|
||||
CurMaxLineLength: Integer;
|
||||
begin
|
||||
Result:='';
|
||||
Src:=s;
|
||||
CurMaxLineLength:=MaxLineLength;
|
||||
if Indent>MaxLineLength-2 then
|
||||
Indent:=MaxLineLength-2;
|
||||
if Indent<0 then
|
||||
MaxLineLength:=0;
|
||||
repeat
|
||||
SrcLen:=length(Src);
|
||||
if SrcLen<=CurMaxLineLength then begin
|
||||
Result:=Result+Src;
|
||||
break;
|
||||
end;
|
||||
// split line
|
||||
SplitPos:=0;
|
||||
// search new line chars
|
||||
APos:=1;
|
||||
while (APos<=CurMaxLineLength) do begin
|
||||
if Src[APos] in [#13,#10] then begin
|
||||
SplitPos:=APos;
|
||||
break;
|
||||
end;
|
||||
inc(APos);
|
||||
end;
|
||||
// search a space boundary
|
||||
if SplitPos=0 then begin
|
||||
APos:=CurMaxLineLength;
|
||||
while APos>1 do begin
|
||||
if (Src[APos-1] in [' ',#9])
|
||||
and (not (Src[APos] in [' ',#9])) then begin
|
||||
SplitPos:=APos;
|
||||
break;
|
||||
end;
|
||||
dec(APos);
|
||||
end;
|
||||
end;
|
||||
// search a word boundary
|
||||
if SplitPos=0 then begin
|
||||
APos:=CurMaxLineLength;
|
||||
while APos>1 do begin
|
||||
if (Src[APos] in ['A'..'Z','a'..'z'])
|
||||
and (not (Src[APos-1] in ['A'..'Z','a'..'z'])) then begin
|
||||
SplitPos:=APos;
|
||||
break;
|
||||
end;
|
||||
dec(APos);
|
||||
end;
|
||||
end;
|
||||
if SplitPos=0 then begin
|
||||
// no word boundary found -> split chars
|
||||
SplitPos:=CurMaxLineLength;
|
||||
end;
|
||||
// append part and newline
|
||||
if (SplitPos<=SrcLen) and (Src[SplitPos] in [#10,#13]) then begin
|
||||
// there is already a new line char at position
|
||||
inc(SplitPos);
|
||||
if (SplitPos<=SrcLen) and (Src[SplitPos] in [#10,#13])
|
||||
and (Src[SplitPos]<>Src[SplitPos-1]) then
|
||||
inc(SplitPos);
|
||||
Result:=Result+copy(Src,1,SplitPos-1);
|
||||
end else begin
|
||||
Result:=Result+copy(Src,1,SplitPos-1)+LineEnding;
|
||||
end;
|
||||
// append indent
|
||||
if Indent>0 then
|
||||
Result:=Result+StringOfChar(' ',Indent);
|
||||
// calculate new LineLength
|
||||
CurMaxLineLength:=MaxLineLength-Indent;
|
||||
// cut string
|
||||
Src:=copy(Src,SplitPos,length(Src)-SplitPos+1);
|
||||
until false;
|
||||
end;
|
||||
|
||||
function ConvertLineEndings(const s: string): string;
|
||||
var
|
||||
i: Integer;
|
||||
EndingStart: LongInt;
|
||||
begin
|
||||
Result:=s;
|
||||
i:=1;
|
||||
while (i<=length(Result)) do begin
|
||||
if Result[i] in [#10,#13] then begin
|
||||
EndingStart:=i;
|
||||
inc(i);
|
||||
if (i<=length(Result)) and (Result[i] in [#10,#13])
|
||||
and (Result[i]<>Result[i-1]) then
|
||||
inc(i);
|
||||
if (length(LineEnding)<>i-EndingStart)
|
||||
or (LineEnding<>copy(Result,EndingStart,length(LineEnding))) then begin
|
||||
// line end differs => replace with current LineEnding
|
||||
Result:=copy(Result,1,EndingStart-1)+LineEnding+copy(Result,i,length(Result));
|
||||
i:=EndingStart+length(LineEnding);
|
||||
end;
|
||||
end else
|
||||
inc(i);
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
@ -43,7 +43,7 @@ uses
|
||||
FileProcs, CodeToolsCfgScript, LinkScanner,
|
||||
// LazUtils
|
||||
LConvEncoding, FileUtil, LazFileUtils, LazFileCache, LazUTF8, Laz2_XMLCfg,
|
||||
LazUtilities, LazMethodList,
|
||||
LazUtilities, LazStringUtils, LazMethodList,
|
||||
// IDEIntf
|
||||
BaseIDEIntf, IDEOptionsIntf, ProjectIntf, MacroIntf, IDEDialogs, IDEExternToolIntf,
|
||||
CompOptsIntf, LazIDEIntf, MacroDefIntf, IDEMsgIntf, PackageDependencyIntf,
|
||||
|
@ -32,7 +32,7 @@ uses
|
||||
// LCL
|
||||
Forms, Controls, Dialogs, ButtonPanel, StdCtrls, ComCtrls, Masks, LCLIntf,
|
||||
// LazUtils
|
||||
LazFileUtils, LazFileCache, LazUtilities, AvgLvlTree,
|
||||
LazFileUtils, LazFileCache, LazStringUtils, AvgLvlTree,
|
||||
// codetools
|
||||
FileProcs, CodeToolManager, DirectoryCacher,
|
||||
// IDEIntf
|
||||
|
@ -54,7 +54,7 @@ uses
|
||||
BasicCodeTools, DefineTemplates, CodeTree, CodeCache, CodeToolManager,
|
||||
PascalParserTool, LinkScanner, FileProcs, CodeIndex, StdCodeTools, SourceLog,
|
||||
// LazUtils
|
||||
LazFileUtils, LazUtilities, AvgLvlTree,
|
||||
LazFileUtils, LazStringUtils, AvgLvlTree,
|
||||
// IDEIntf
|
||||
IDEWindowIntf, SrcEditorIntf, IDEMsgIntf, IDEDialogs, LazConfigStorage,
|
||||
IDEHelpIntf, PackageIntf, IDECommands, LazIDEIntf, IDEExternToolIntf,
|
||||
|
@ -44,14 +44,12 @@ unit CodeToolsDefines;
|
||||
interface
|
||||
|
||||
uses
|
||||
//Classes, SysUtils, Math, LCLIntf, Forms, Controls, Buttons, StdCtrls,
|
||||
//ComCtrls, LCLType, ExtCtrls, Menus, LCLProc, Graphics, Dialogs, ButtonPanel,
|
||||
Classes, SysUtils, Math,
|
||||
// LCL
|
||||
LCLType, LCLIntf, Forms, Controls, Buttons, StdCtrls,
|
||||
ComCtrls, ExtCtrls, Menus, Graphics, Dialogs, ButtonPanel,
|
||||
// LazUtils
|
||||
LazFileUtils, LazLogger, LazUtilities,
|
||||
LazFileUtils, LazLogger, LazStringUtils,
|
||||
// SynEdit
|
||||
SynEdit,
|
||||
// Codetools
|
||||
|
@ -33,7 +33,7 @@ uses
|
||||
// FCL
|
||||
Classes, SysUtils,
|
||||
// LazUtils
|
||||
Laz2_DOM, Laz2_XMLRead, LazUtilities, LazTracer,
|
||||
Laz2_DOM, Laz2_XMLRead, LazStringUtils, LazTracer,
|
||||
// LCL
|
||||
LResources, StdCtrls, Buttons, ComCtrls, Controls, Dialogs,
|
||||
ExtCtrls, Forms, Graphics, LCLType, LCLProc,
|
||||
|
@ -32,7 +32,7 @@ uses
|
||||
// LCL
|
||||
Controls, Dialogs, Graphics, StdCtrls,
|
||||
// LazUtils
|
||||
LazFileUtils, LazUtilities,
|
||||
LazFileUtils, LazStringUtils,
|
||||
// CodeTools
|
||||
DefineTemplates,
|
||||
// IdeIntf
|
||||
|
@ -40,7 +40,7 @@ uses
|
||||
// CodeTools
|
||||
BasicCodeTools, FileProcs, CodeToolManager, CodeToolsConfig, CodeCache,
|
||||
// IDE
|
||||
IDECmdLine, LazConf;
|
||||
LazConf;
|
||||
|
||||
type
|
||||
// copy
|
||||
|
@ -32,14 +32,14 @@ uses
|
||||
Interfaces, // this includes the NoGUI widgetset
|
||||
// LazUtils
|
||||
Masks, LConvEncoding, FileUtil, LazFileUtils, LazLoggerBase, LazUtilities,
|
||||
LazUTF8, Laz2_XMLCfg, UITypes,
|
||||
LazUTF8, Laz2_XMLCfg, UITypes, LazStringUtils,
|
||||
// LCL
|
||||
LCLPlatformDef, Forms,
|
||||
// Codetools
|
||||
CodeCache, CodeToolManager, DefineTemplates, FileProcs,
|
||||
// IDEIntf
|
||||
BaseIDEIntf, MacroIntf, PackageIntf, LazMsgDialogs, ProjectIntf, IDEExternToolIntf,
|
||||
CompOptsIntf, IDEOptionsIntf, LazIDEIntf, PackageDependencyIntf,
|
||||
CompOptsIntf, IDEOptionsIntf, PackageDependencyIntf,
|
||||
// IDE
|
||||
IDEProcs, InitialSetupProc, ExtTools, CompilerOptions,
|
||||
ApplicationBundle, TransferMacros, EnvironmentOpts, IDETranslations,
|
||||
|
@ -40,7 +40,7 @@ uses
|
||||
// LCL
|
||||
LCLType, Graphics, Controls,
|
||||
// LazUtils
|
||||
LazFileUtils, LazUtilities,
|
||||
LazFileUtils, LazStringUtils,
|
||||
// SynEdit
|
||||
SynCompletion,
|
||||
// CodeTools
|
||||
|
@ -43,7 +43,7 @@ uses
|
||||
CodeToolManager, DefineTemplates, CTUnitGraph, CTUnitGroupGraph,
|
||||
FileProcs, CodeCache, AvgLvlTree,
|
||||
// LazUtils
|
||||
LazLoggerBase, LazFileUtils, LazFileCache, LazUtilities, LazUTF8, LvlGraphCtrl,
|
||||
LazLoggerBase, LazFileUtils, LazFileCache, LazStringUtils, LazUTF8, LvlGraphCtrl,
|
||||
// IDE interface
|
||||
LazIDEIntf, ProjectIntf, IDEWindowIntf, PackageIntf, SrcEditorIntf, IDEImagesIntf,
|
||||
IDEMsgIntf, IDEExternToolIntf, IDECommands, IDEDialogs,
|
||||
|
@ -24,11 +24,11 @@ uses
|
||||
// RTL + FCL
|
||||
Types, typinfo, Classes, SysUtils,
|
||||
// LCL
|
||||
LMessages, LResources, LCLIntf, InterfaceBase, LCLStrConsts, LCLType, LCLProc,
|
||||
LMessages, LResources, LCLIntf, InterfaceBase, LCLStrConsts, LCLType,
|
||||
Forms, Controls, Themes, GraphType, Graphics, Buttons, ButtonPanel, StdCtrls,
|
||||
ExtCtrls, LCLClasses, ClipBrd, Menus, LCLTaskDialog,
|
||||
// LazUtils
|
||||
UITypes, FileUtil, LazFileUtils;
|
||||
UITypes, FileUtil, LazFileUtils, LazStringUtils, LazLoggerBase;
|
||||
|
||||
type
|
||||
// Aliases for types in UITypes.
|
||||
|
@ -28,7 +28,7 @@ uses
|
||||
// LCL
|
||||
LCLProc, LCLType, Graphics, Controls, StdCtrls,
|
||||
// LazUtils
|
||||
LazUtf8Classes, TextStrings,
|
||||
LazUtf8Classes, TextStrings, LazStringUtils,
|
||||
// LCL Carbon
|
||||
CarbonEdits, CarbonListViews;
|
||||
|
||||
|
@ -39,7 +39,7 @@ uses
|
||||
{$EndIf}
|
||||
gdk2pixbuf, gtk2, gdk2, glib2, Pango,
|
||||
// LazUtils
|
||||
LazFileUtils, LazUTF8, DynHashArray, Maps, IntegerList, LazLoggerBase, LazUtilities,
|
||||
LazFileUtils, LazUTF8, DynHashArray, Maps, IntegerList, LazLoggerBase, LazStringUtils,
|
||||
// LCL
|
||||
Dialogs, Controls, Forms, LCLStrConsts,
|
||||
LMessages, LCLProc, LCLIntf, LCLType, GraphType, GraphMath,
|
||||
|
@ -38,7 +38,7 @@ uses
|
||||
// FPC
|
||||
Classes, SysUtils, Math, Types,
|
||||
// LazUtils
|
||||
LazUTF8, Maps, LazUtilities,
|
||||
LazUTF8, Maps, LazStringUtils,
|
||||
// LCL
|
||||
LCLPlatformDef, InterfaceBase, LCLProc, LCLType, LCLIntf,
|
||||
LMessages, LCLMessageGlue, LCLStrConsts,
|
||||
|
@ -37,7 +37,7 @@ uses
|
||||
// FPC
|
||||
Classes, SysUtils, Math, Types, maps,
|
||||
// LazUtils
|
||||
LazUtilities,
|
||||
LazStringUtils,
|
||||
// LCL
|
||||
InterfaceBase, LCLPlatformDef, LCLProc, LazUTF8, LCLType, LMessages, LCLMessageGlue, LCLStrConsts,
|
||||
Controls, ExtCtrls, Forms,
|
||||
|
@ -244,7 +244,6 @@ procedure DbgOut(const s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12: string); overload
|
||||
procedure CloseDebugOutput;
|
||||
{$ENDIF}
|
||||
|
||||
function ConvertLineEndings(const s: string): string; inline;
|
||||
function DbgS(const c: cardinal): string; overload; inline;
|
||||
function DbgS(const i: longint): string; overload; inline;
|
||||
function DbgS(const i: int64): string; overload; inline;
|
||||
@ -1838,11 +1837,6 @@ begin
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
function ConvertLineEndings(const s: string): string;
|
||||
begin
|
||||
Result:=LazUtilities.ConvertLineEndings(s);
|
||||
end;
|
||||
|
||||
function DbgS(const c: cardinal): string;
|
||||
begin
|
||||
Result:=LazLoggerBase.DbgS(c);
|
||||
|
@ -35,7 +35,7 @@ uses
|
||||
// LCL
|
||||
Forms, Controls, ComCtrls, StdCtrls, ExtCtrls, LCLType, ButtonPanel,
|
||||
// LazUtils
|
||||
LazUtilities,
|
||||
LazStringUtils,
|
||||
// LazControls
|
||||
ListViewFilterEdit,
|
||||
// IdeIntf
|
||||
|
@ -42,7 +42,7 @@ uses
|
||||
LCLType, LCLIntf, Forms, Controls, ComCtrls, StdCtrls, ExtCtrls,
|
||||
Menus, ButtonPanel,
|
||||
// LazUtils
|
||||
LazLoggerBase, LazUtilities, LazTracer,
|
||||
LazLoggerBase, LazTracer, LazStringUtils,
|
||||
// LazControls
|
||||
LvlGraphCtrl,
|
||||
// IdeIntf
|
||||
|
Loading…
Reference in New Issue
Block a user