mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-15 11:39:27 +02:00
codetools: UseTabs
git-svn-id: trunk@40790 -
This commit is contained in:
parent
d6cee91c23
commit
501b3263a0
@ -84,7 +84,7 @@ function GetLineIndentWithTabs(const Source: string; Position: integer;
|
||||
function GetPosInLine(const Source: string; Position: integer): integer; // 0 based
|
||||
function GetBlockMinIndent(const Source: string;
|
||||
StartPos, EndPos: integer): integer;
|
||||
function GetIndentStr(Indent: integer): string;
|
||||
function GetIndentStr(Indent: integer; TabWidth: integer = 0): string;
|
||||
procedure IndentText(const Source: string; Indent, TabWidth: integer;
|
||||
out NewSource: string);
|
||||
function FindFirstNonSpaceCharInLine(const Source: string;
|
||||
@ -4083,11 +4083,25 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function GetIndentStr(Indent: integer): string;
|
||||
function GetIndentStr(Indent: integer; TabWidth: integer): string;
|
||||
var
|
||||
TabCnt: Integer;
|
||||
SpaceCnt: Integer;
|
||||
i: Integer;
|
||||
begin
|
||||
SetLength(Result,Indent);
|
||||
if Indent>0 then
|
||||
FillChar(Result[1],length(Result),' ');
|
||||
if TabWidth<=0 then begin
|
||||
SetLength(Result,Indent);
|
||||
if Indent>0 then
|
||||
FillChar(Result[1],length(Result),' ');
|
||||
end else begin
|
||||
TabCnt:=Indent div TabWidth;
|
||||
SpaceCnt:=Indent mod TabWidth;
|
||||
SetLength(Result,TabCnt+SpaceCnt);
|
||||
for i:=1 to TabCnt do
|
||||
Result[i]:=#9;
|
||||
for i:=TabCnt+1 to TabCnt+SpaceCnt do
|
||||
Result[i]:=' ';
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure IndentText(const Source: string; Indent, TabWidth: integer;
|
||||
|
@ -112,6 +112,9 @@ type
|
||||
TBeautifyCodeOptions = class(TPersistent)
|
||||
private
|
||||
CurLineLen: integer;
|
||||
FTabWidth: integer;
|
||||
FUseTabs: boolean;
|
||||
FUseTabWidth: integer;
|
||||
LastSplitPos: integer; // last position where splitting is allowed
|
||||
LastSrcLineStart: integer;// last line start, not added by splitting
|
||||
CurAtomType, LastAtomType: TAtomType;
|
||||
@ -125,13 +128,14 @@ type
|
||||
procedure ReadNextAtom;
|
||||
procedure ReadTilCommentEnd;
|
||||
function IsCommentType(aCommentType: char): boolean;
|
||||
procedure SetTabWidth(AValue: integer);
|
||||
procedure SetUseTabs(AValue: boolean);
|
||||
procedure StartComment(p: integer);
|
||||
function EndComment(CommentStart: char; p: integer): boolean;
|
||||
public
|
||||
LineLength: integer;
|
||||
LineEnd: string;
|
||||
Indent: integer;
|
||||
TabWidth: integer;
|
||||
Indent: integer; // see TabWidth, UseTabs and UseTabWidth
|
||||
KeyWordPolicy: TWordPolicy;
|
||||
IdentifierPolicy: TWordPolicy;
|
||||
WordExceptions: TWordPolicyExceptions;
|
||||
@ -175,6 +179,10 @@ type
|
||||
function BeautifyWord(const AWord: string; WordPolicy: TWordPolicy): string;
|
||||
function BeautifyKeyWord(const AWord: string): string;
|
||||
function BeautifyIdentifier(const AWord: string): string;
|
||||
property UseTabs: boolean read FUseTabs write SetUseTabs; // true=when indenting use tabs of TabWidth
|
||||
property UseTabWidth: integer read FUseTabWidth; // when UseTabs is true, UseTabWidth=TabWidth otherwise UseTabWidth=0
|
||||
property TabWidth: integer read FTabWidth write SetTabWidth;
|
||||
|
||||
procedure ConsistencyCheck;
|
||||
procedure WriteDebugReport;
|
||||
constructor Create;
|
||||
@ -1589,6 +1597,24 @@ begin
|
||||
Result:=(CommentLvl>0) and (CommentType=aCommentType);
|
||||
end;
|
||||
|
||||
procedure TBeautifyCodeOptions.SetTabWidth(AValue: integer);
|
||||
begin
|
||||
if FTabWidth=AValue then Exit;
|
||||
FTabWidth:=AValue;
|
||||
if UseTabs then
|
||||
FUseTabWidth:=FTabWidth;
|
||||
end;
|
||||
|
||||
procedure TBeautifyCodeOptions.SetUseTabs(AValue: boolean);
|
||||
begin
|
||||
if FUseTabs=AValue then Exit;
|
||||
FUseTabs:=AValue;
|
||||
if UseTabs then
|
||||
FUseTabWidth:=FTabWidth
|
||||
else
|
||||
FUseTabWidth:=0;
|
||||
end;
|
||||
|
||||
procedure TBeautifyCodeOptions.StartComment(p: integer);
|
||||
begin
|
||||
inc(CommentLvl);
|
||||
|
Loading…
Reference in New Issue
Block a user