mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-30 11:30:28 +02:00
synedit: removed indenter
git-svn-id: trunk@15429 -
This commit is contained in:
parent
f1f758e093
commit
aa685453e3
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -997,6 +997,7 @@ components/synedit/languages/synmacrorecorder.po svneol=native#text/plain
|
|||||||
components/synedit/languages/synmacrorecorder.ru.po svneol=native#text/plain
|
components/synedit/languages/synmacrorecorder.ru.po svneol=native#text/plain
|
||||||
components/synedit/languages/synmacrorecorder.ua.po svneol=native#text/plain
|
components/synedit/languages/synmacrorecorder.ua.po svneol=native#text/plain
|
||||||
components/synedit/languages/synmacrorecorder.zh-cn.po svneol=native#text/utf8
|
components/synedit/languages/synmacrorecorder.zh-cn.po svneol=native#text/utf8
|
||||||
|
components/synedit/synbeautifierpas.pas svneol=native#text/plain
|
||||||
components/synedit/syncompletion.pas svneol=native#text/pascal
|
components/synedit/syncompletion.pas svneol=native#text/pascal
|
||||||
components/synedit/synedit.inc svneol=native#text/pascal
|
components/synedit/synedit.inc svneol=native#text/pascal
|
||||||
components/synedit/synedit.pp svneol=native#text/pascal
|
components/synedit/synedit.pp svneol=native#text/pascal
|
||||||
|
40
components/synedit/synbeautifierpas.pas
Normal file
40
components/synedit/synbeautifierpas.pas
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
{-------------------------------------------------------------------------------
|
||||||
|
The contents of this file are subject to the Mozilla Public License
|
||||||
|
Version 1.1 (the "License"); you may not use this file except in compliance
|
||||||
|
with the License. You may obtain a copy of the License at
|
||||||
|
http://www.mozilla.org/MPL/
|
||||||
|
Software distributed under the License is distributed on an "AS IS" basis,
|
||||||
|
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
|
||||||
|
the specific language governing rights and limitations under the License.
|
||||||
|
-------------------------------------------------------------------------------}
|
||||||
|
unit SynBeautifierPas;
|
||||||
|
|
||||||
|
{$I synedit.inc}
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
Classes, SysUtils, LCLProc, SynEdit;
|
||||||
|
|
||||||
|
type
|
||||||
|
|
||||||
|
{ TSynBeautifierPas }
|
||||||
|
|
||||||
|
TSynBeautifierPas = class(TSynCustomBeautifier)
|
||||||
|
public
|
||||||
|
function GetIndentForLineBreak(Editor: TCustomSynEdit;
|
||||||
|
InsertPos: TPoint; var NextText: string): integer; override;
|
||||||
|
end;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
{ TSynBeautifierPas }
|
||||||
|
|
||||||
|
function TSynBeautifierPas.GetIndentForLineBreak(Editor: TCustomSynEdit;
|
||||||
|
InsertPos: TPoint; var NextText: string): integer;
|
||||||
|
begin
|
||||||
|
Result:=inherited GetIndentForLineBreak(Editor, InsertPos, NextText);
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
||||||
|
|
@ -318,26 +318,6 @@ type
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
{$IFDEF SYN_LAZARUS}
|
{$IFDEF SYN_LAZARUS}
|
||||||
// aIndex parameters of Line notifications are 0-based.
|
|
||||||
TSynCustomLineIndenter = class(TComponent)
|
|
||||||
private
|
|
||||||
FEditor: TCustomSynEdit;
|
|
||||||
procedure SetEditor(const AValue: TCustomSynEdit);
|
|
||||||
public
|
|
||||||
destructor Destroy; override;
|
|
||||||
// plugin notifications
|
|
||||||
procedure LinesInserted(aIndex: integer; aCount: integer);
|
|
||||||
procedure LinesDeleted(aIndex: integer; aCount: integer);
|
|
||||||
procedure LinesPutted(aIndex: integer; aCount: integer);
|
|
||||||
// pretty clear, heh?
|
|
||||||
procedure Reset;
|
|
||||||
// indentation
|
|
||||||
function GetLineIndentProposal(aIndex: integer;
|
|
||||||
IgnoreCurrentLineText: boolean): integer;
|
|
||||||
public
|
|
||||||
property Editor: TCustomSynEdit read FEditor write SetEditor;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ TSynCustomBeautifier }
|
{ TSynCustomBeautifier }
|
||||||
|
|
||||||
TSynCustomBeautifier = class(TComponent)
|
TSynCustomBeautifier = class(TComponent)
|
||||||
@ -383,7 +363,6 @@ type
|
|||||||
fBracketHighlightPos: TPoint;
|
fBracketHighlightPos: TPoint;
|
||||||
fBracketHighlightAntiPos: TPoint;
|
fBracketHighlightAntiPos: TPoint;
|
||||||
fCtrlMouseActive: boolean;
|
fCtrlMouseActive: boolean;
|
||||||
fLineIndenter: TSynCustomLineIndenter;
|
|
||||||
FCFDividerDrawLevel: Integer;
|
FCFDividerDrawLevel: Integer;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
fLastCaretX: integer; // physical position (screen) //mh 2000-10-19
|
fLastCaretX: integer; // physical position (screen) //mh 2000-10-19
|
||||||
@ -501,7 +480,6 @@ type
|
|||||||
function AdjustPhysPosToCharacterStart(Line: integer; PhysPos: integer): integer;
|
function AdjustPhysPosToCharacterStart(Line: integer; PhysPos: integer): integer;
|
||||||
function GetLogicalCaretXY: TPoint;
|
function GetLogicalCaretXY: TPoint;
|
||||||
procedure SetCFDividerDrawLevel(const AValue: Integer);
|
procedure SetCFDividerDrawLevel(const AValue: Integer);
|
||||||
procedure SetLineIndenter(const AValue: TSynCustomLineIndenter);
|
|
||||||
procedure SetLogicalCaretXY(const NewLogCaretXY: TPoint);
|
procedure SetLogicalCaretXY(const NewLogCaretXY: TPoint);
|
||||||
procedure SetBeautifier(NewBeautifier: TSynCustomBeautifier);
|
procedure SetBeautifier(NewBeautifier: TSynCustomBeautifier);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
@ -844,8 +822,6 @@ type
|
|||||||
property Beautifier: TSynCustomBeautifier read fBeautifier write SetBeautifier;
|
property Beautifier: TSynCustomBeautifier read fBeautifier write SetBeautifier;
|
||||||
property CtrlMouseActive: boolean read fCtrlMouseActive;
|
property CtrlMouseActive: boolean read fCtrlMouseActive;
|
||||||
property LogicalCaretXY: TPoint read GetLogicalCaretXY write SetLogicalCaretXY;
|
property LogicalCaretXY: TPoint read GetLogicalCaretXY write SetLogicalCaretXY;
|
||||||
property LineIndenter: TSynCustomLineIndenter read fLineIndenter
|
|
||||||
write SetLineIndenter;
|
|
||||||
property SelStart: Integer read GetSelStart write SetSelStart;
|
property SelStart: Integer read GetSelStart write SetSelStart;
|
||||||
property SelEnd: Integer read GetSelEnd write SetSelEnd;
|
property SelEnd: Integer read GetSelEnd write SetSelEnd;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
@ -1570,7 +1546,7 @@ var
|
|||||||
begin
|
begin
|
||||||
{$IFDEF SYN_LAZARUS}
|
{$IFDEF SYN_LAZARUS}
|
||||||
if HandleAllocated then LCLIntf.DestroyCaret(Handle);
|
if HandleAllocated then LCLIntf.DestroyCaret(Handle);
|
||||||
LineIndenter:=nil;
|
Beautifier:=nil;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
Highlighter := nil;
|
Highlighter := nil;
|
||||||
// free listeners while other fields are still valid
|
// free listeners while other fields are still valid
|
||||||
@ -1728,21 +1704,6 @@ begin
|
|||||||
FCFDividerDrawLevel := AValue;
|
FCFDividerDrawLevel := AValue;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomSynEdit.SetLineIndenter(const AValue: TSynCustomLineIndenter);
|
|
||||||
var
|
|
||||||
OldLineIndenter: TSynCustomLineIndenter;
|
|
||||||
begin
|
|
||||||
if Assigned(fLineIndenter) then begin
|
|
||||||
OldLineIndenter:=fLineIndenter;
|
|
||||||
fLineIndenter:=nil;
|
|
||||||
OldLineIndenter.Editor:=nil;
|
|
||||||
end;
|
|
||||||
fLineIndenter:=AValue;
|
|
||||||
if Assigned(fLineIndenter) then begin
|
|
||||||
fLineIndenter.Editor:=Self;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TCustomSynEdit.SetLogicalCaretXY(const NewLogCaretXY: TPoint);
|
procedure TCustomSynEdit.SetLogicalCaretXY(const NewLogCaretXY: TPoint);
|
||||||
begin
|
begin
|
||||||
CaretXY:=LogicalToPhysicalPos(NewLogCaretXY);
|
CaretXY:=LogicalToPhysicalPos(NewLogCaretXY);
|
||||||
@ -10823,9 +10784,13 @@ var
|
|||||||
s: string;
|
s: string;
|
||||||
FirstNonBlank: Integer;
|
FirstNonBlank: Integer;
|
||||||
begin
|
begin
|
||||||
if fLineIndenter<>nil then
|
if fBeautifier<>nil then begin
|
||||||
Result:=fLineIndenter.GetLineIndentProposal(Line-1,IgnoreCurrentLineText)
|
if IgnoreCurrentLineText then
|
||||||
else begin
|
s:=''
|
||||||
|
else
|
||||||
|
s:=LineText;
|
||||||
|
Result:=fBeautifier.GetIndentForLineBreak(Self,Point(1,Line),s);
|
||||||
|
end else begin
|
||||||
// default: use last non empty line indent, ignore always current line
|
// default: use last non empty line indent, ignore always current line
|
||||||
y:=Line-1;
|
y:=Line-1;
|
||||||
if y>Lines.Count then y:=Lines.Count;
|
if y>Lines.Count then y:=Lines.Count;
|
||||||
@ -11417,51 +11382,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
{$IFDEF SYN_LAZARUS}
|
{$IFDEF SYN_LAZARUS}
|
||||||
{ TSynCustomLineIndenter }
|
|
||||||
|
|
||||||
procedure TSynCustomLineIndenter.SetEditor(const AValue: TCustomSynEdit);
|
|
||||||
begin
|
|
||||||
if FEditor=AValue then exit;
|
|
||||||
FEditor:=AValue;
|
|
||||||
if fEditor<>nil then fEditor.LineIndenter:=Self;
|
|
||||||
end;
|
|
||||||
|
|
||||||
destructor TSynCustomLineIndenter.Destroy;
|
|
||||||
begin
|
|
||||||
Editor:=nil;
|
|
||||||
inherited Destroy;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TSynCustomLineIndenter.LinesInserted(aIndex: integer;
|
|
||||||
aCount: integer);
|
|
||||||
begin
|
|
||||||
// for descendants to override
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TSynCustomLineIndenter.LinesDeleted(aIndex: integer; aCount: integer);
|
|
||||||
begin
|
|
||||||
// for descendants to override
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TSynCustomLineIndenter.LinesPutted(aIndex: integer; aCount: integer);
|
|
||||||
begin
|
|
||||||
// for descendants to override
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TSynCustomLineIndenter.Reset;
|
|
||||||
begin
|
|
||||||
// for descendants to override
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TSynCustomLineIndenter.GetLineIndentProposal(aIndex: integer;
|
|
||||||
IgnoreCurrentLineText: boolean): integer;
|
|
||||||
begin
|
|
||||||
// for descendants to override
|
|
||||||
RaiseGDBException('TSynEditLineIndentPlugin.GetLineIndentProposal '+ClassName);
|
|
||||||
Result:=0;
|
|
||||||
end;
|
|
||||||
{$ENDIF}
|
|
||||||
|
|
||||||
{ TSynCustomBeautifier }
|
{ TSynCustomBeautifier }
|
||||||
|
|
||||||
function TSynCustomBeautifier.LeftSpaces(Editor: TCustomSynEdit;
|
function TSynCustomBeautifier.LeftSpaces(Editor: TCustomSynEdit;
|
||||||
@ -11507,6 +11427,7 @@ begin
|
|||||||
dec(LastTextY);
|
dec(LastTextY);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
{$IFNDEF SYN_LAZARUS}
|
{$IFNDEF SYN_LAZARUS}
|
||||||
|
Loading…
Reference in New Issue
Block a user