mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-08 04:35:57 +02:00
SynEdit, Beautifier: Renamed OnDesiredIndentNeeded / Added to SourcEditor
git-svn-id: trunk@20490 -
This commit is contained in:
parent
8edea32cee
commit
cfcc5f9b04
@ -51,7 +51,7 @@ type
|
|||||||
|
|
||||||
TSynCustomBeautifier = class(TComponent)
|
TSynCustomBeautifier = class(TComponent)
|
||||||
private
|
private
|
||||||
FOnDesiredIndentNeeded: TSynBeautifierGetIndentEvent;
|
FOnGetDesiredIndent: TSynBeautifierGetIndentEvent;
|
||||||
public
|
public
|
||||||
function CanUnindent(const Editor: TSynEditBase; const Lines: TSynEditStrings;
|
function CanUnindent(const Editor: TSynEditBase; const Lines: TSynEditStrings;
|
||||||
const ACaret: TSynEditCaret): Boolean; virtual; abstract;
|
const ACaret: TSynEditCaret): Boolean; virtual; abstract;
|
||||||
@ -66,8 +66,8 @@ type
|
|||||||
function GetDesiredIndentForLine(Editor: TSynEditBase; const Lines: TSynEditStrings;
|
function GetDesiredIndentForLine(Editor: TSynEditBase; const Lines: TSynEditStrings;
|
||||||
const ACaret: TSynEditCaret;
|
const ACaret: TSynEditCaret;
|
||||||
out DesiredIndent: String): Integer; virtual; abstract;
|
out DesiredIndent: String): Integer; virtual; abstract;
|
||||||
property OnDesiredIndentNeeded: TSynBeautifierGetIndentEvent
|
property OnGetDesiredIndent: TSynBeautifierGetIndentEvent
|
||||||
read FOnDesiredIndentNeeded write FOnDesiredIndentNeeded;
|
read FOnGetDesiredIndent write FOnGetDesiredIndent;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TSynBeautifierIndentType = (sbitSpace, sbitCopySpaceTab, sbitPositionCaret);
|
TSynBeautifierIndentType = (sbitSpace, sbitCopySpaceTab, sbitPositionCaret);
|
||||||
@ -192,8 +192,8 @@ begin
|
|||||||
until (BackCounter = 0) or (Temp <> '');
|
until (BackCounter = 0) or (Temp <> '');
|
||||||
|
|
||||||
FoundLine := BackCounter + 1;
|
FoundLine := BackCounter + 1;
|
||||||
if assigned(FOnDesiredIndentNeeded) then
|
if assigned(FOnGetDesiredIndent) then
|
||||||
FOnDesiredIndentNeeded(Editor, ACaret.LineBytePos, ACaret.LinePos, Result, FoundLine);
|
FOnGetDesiredIndent(Editor, ACaret.LineBytePos, ACaret.LinePos, Result, FoundLine);
|
||||||
|
|
||||||
if Result < 0 then exit;
|
if Result < 0 then exit;
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ uses
|
|||||||
// synedit
|
// synedit
|
||||||
SynEditStrConst, SynEditTypes, SynEdit, SynRegExpr, SynEditHighlighter,
|
SynEditStrConst, SynEditTypes, SynEdit, SynRegExpr, SynEditHighlighter,
|
||||||
SynEditAutoComplete, SynEditKeyCmds, SynCompletion, SynEditMiscClasses,
|
SynEditAutoComplete, SynEditKeyCmds, SynCompletion, SynEditMiscClasses,
|
||||||
SynEditMarkupHighAll, SynGutterLineNumber, SynEditMarks,
|
SynEditMarkupHighAll, SynGutterLineNumber, SynEditMarks, SynBeautifier,
|
||||||
// IDE interface
|
// IDE interface
|
||||||
MacroIntf, ProjectIntf, SrcEditorIntf, MenuIntf, LazIDEIntf, PackageIntf,
|
MacroIntf, ProjectIntf, SrcEditorIntf, MenuIntf, LazIDEIntf, PackageIntf,
|
||||||
IDEDialogs, IDEHelpIntf, IDEWindowIntf, IDEImagesIntf,
|
IDEDialogs, IDEHelpIntf, IDEWindowIntf, IDEImagesIntf,
|
||||||
@ -117,6 +117,7 @@ type
|
|||||||
FCodeTemplates: TSynEditAutoComplete;
|
FCodeTemplates: TSynEditAutoComplete;
|
||||||
FHasExecutionMarks: Boolean;
|
FHasExecutionMarks: Boolean;
|
||||||
FMarksRequested: Boolean;
|
FMarksRequested: Boolean;
|
||||||
|
FOnGetDesiredIndent: TSynBeautifierGetIndentEvent;
|
||||||
FPageName: string;
|
FPageName: string;
|
||||||
|
|
||||||
FCodeBuffer: TCodeBuffer;
|
FCodeBuffer: TCodeBuffer;
|
||||||
@ -159,6 +160,8 @@ type
|
|||||||
procedure EditorMouseWheel(Sender: TObject; Shift: TShiftState;
|
procedure EditorMouseWheel(Sender: TObject; Shift: TShiftState;
|
||||||
WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
|
WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
|
||||||
procedure EditorKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
procedure EditorKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
||||||
|
procedure EditorGetIndent(Sender: TObject; LogCaret: TPoint; Line: Integer;
|
||||||
|
var Indent, BasedLine: Integer);
|
||||||
procedure EditorStatusChanged(Sender: TObject; Changes: TSynStatusChanges);
|
procedure EditorStatusChanged(Sender: TObject; Changes: TSynStatusChanges);
|
||||||
procedure SetCodeBuffer(NewCodeBuffer: TCodeBuffer);
|
procedure SetCodeBuffer(NewCodeBuffer: TCodeBuffer);
|
||||||
function GetSource: TStrings;
|
function GetSource: TStrings;
|
||||||
@ -383,6 +386,8 @@ type
|
|||||||
property OnMouseLink: TSynMouseLinkEvent read FOnMouseLink write FOnMouseLink;
|
property OnMouseLink: TSynMouseLinkEvent read FOnMouseLink write FOnMouseLink;
|
||||||
property OnMouseWheel: TMouseWheelEvent read FOnMouseWheel write FOnMouseWheel;
|
property OnMouseWheel: TMouseWheelEvent read FOnMouseWheel write FOnMouseWheel;
|
||||||
property OnKeyDown: TKeyEvent read FOnKeyDown write FOnKeyDown;
|
property OnKeyDown: TKeyEvent read FOnKeyDown write FOnKeyDown;
|
||||||
|
property OnGetDesiredIndent: TSynBeautifierGetIndentEvent
|
||||||
|
read FOnGetDesiredIndent write FOnGetDesiredIndent;
|
||||||
property Owner: TComponent read FAOwner;
|
property Owner: TComponent read FAOwner;
|
||||||
property PageName: string read FPageName write SetPageName;
|
property PageName: string read FPageName write SetPageName;
|
||||||
property PopupMenu: TPopupMenu read FPopUpMenu write SetPopUpMenu;
|
property PopupMenu: TPopupMenu read FPopUpMenu write SetPopUpMenu;
|
||||||
@ -533,6 +538,7 @@ type
|
|||||||
FActiveEditKeyBGColor: TColor;
|
FActiveEditKeyBGColor: TColor;
|
||||||
FActiveEditSymbolFGColor: TColor;
|
FActiveEditSymbolFGColor: TColor;
|
||||||
FActiveEditSymbolBGColor: TColor;
|
FActiveEditSymbolBGColor: TColor;
|
||||||
|
FOnGetDesiredIndent: TSynBeautifierGetIndentEvent;
|
||||||
|
|
||||||
// PopupMenu
|
// PopupMenu
|
||||||
procedure BuildPopupMenu;
|
procedure BuildPopupMenu;
|
||||||
@ -596,6 +602,8 @@ type
|
|||||||
Shift: TShiftstate; X,Y: Integer);
|
Shift: TShiftstate; X,Y: Integer);
|
||||||
procedure EditorMouseLink(
|
procedure EditorMouseLink(
|
||||||
Sender: TObject; X,Y: Integer; var AllowMouseLink: Boolean);
|
Sender: TObject; X,Y: Integer; var AllowMouseLink: Boolean);
|
||||||
|
procedure EditorGetIndent(Sender: TObject; LogCaret: TPoint; Line: Integer;
|
||||||
|
var Indent, BasedLine: Integer);
|
||||||
procedure EditorKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
procedure EditorKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
||||||
procedure EditorMouseWheel(Sender: TObject; Shift: TShiftState;
|
procedure EditorMouseWheel(Sender: TObject; Shift: TShiftState;
|
||||||
WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
|
WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
|
||||||
@ -781,6 +789,8 @@ type
|
|||||||
read FOnCloseClicked write FOnCloseClicked;
|
read FOnCloseClicked write FOnCloseClicked;
|
||||||
property OnClickLink: TMouseEvent read FOnClickLink write FOnClickLink;
|
property OnClickLink: TMouseEvent read FOnClickLink write FOnClickLink;
|
||||||
property OnMouseLink: TSynMouseLinkEvent read FOnMouseLink write FOnMouseLink;
|
property OnMouseLink: TSynMouseLinkEvent read FOnMouseLink write FOnMouseLink;
|
||||||
|
property OnGetDesiredIndent: TSynBeautifierGetIndentEvent
|
||||||
|
read FOnGetDesiredIndent write FOnGetDesiredIndent;
|
||||||
property OnDeleteLastJumpPoint: TNotifyEvent
|
property OnDeleteLastJumpPoint: TNotifyEvent
|
||||||
read FOnDeleteLastJumpPoint write FOnDeleteLastJumpPoint;
|
read FOnDeleteLastJumpPoint write FOnDeleteLastJumpPoint;
|
||||||
property OnEditorVisibleChanged: TNotifyEvent
|
property OnEditorVisibleChanged: TNotifyEvent
|
||||||
@ -2527,6 +2537,7 @@ Begin
|
|||||||
OnClickLink := @EditorClickLink;
|
OnClickLink := @EditorClickLink;
|
||||||
OnMouseLink := @EditorMouseLink;
|
OnMouseLink := @EditorMouseLink;
|
||||||
OnKeyDown := @EditorKeyDown;
|
OnKeyDown := @EditorKeyDown;
|
||||||
|
Beautifier.OnGetDesiredIndent := @EditorGetIndent;
|
||||||
// IMPORTANT: when you change above, don't forget updating UnbindEditor
|
// IMPORTANT: when you change above, don't forget updating UnbindEditor
|
||||||
|
|
||||||
end;
|
end;
|
||||||
@ -2993,6 +3004,13 @@ begin
|
|||||||
OnKeyDown(Sender, Key, Shift);
|
OnKeyDown(Sender, Key, Shift);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TSourceEditor.EditorGetIndent(Sender: TObject; LogCaret: TPoint;
|
||||||
|
Line: Integer; var Indent, BasedLine: Integer);
|
||||||
|
begin
|
||||||
|
if Assigned(OnGetDesiredIndent) then
|
||||||
|
OnGetDesiredIndent(Sender, LogCaret, Line, Indent, BasedLine);
|
||||||
|
end;
|
||||||
|
|
||||||
Function TSourceEditor.GetCaretPosFromCursorPos(const CursorPos: TPoint): TPoint;
|
Function TSourceEditor.GetCaretPosFromCursorPos(const CursorPos: TPoint): TPoint;
|
||||||
var
|
var
|
||||||
NewTopLine: Integer;
|
NewTopLine: Integer;
|
||||||
@ -4793,6 +4811,7 @@ begin
|
|||||||
Result.OnClickLink := @EditorClickLink;
|
Result.OnClickLink := @EditorClickLink;
|
||||||
Result.OnMouseLink := @EditorMouseLink;
|
Result.OnMouseLink := @EditorMouseLink;
|
||||||
Result.OnKeyDown := @EditorKeyDown;
|
Result.OnKeyDown := @EditorKeyDown;
|
||||||
|
Result.OnGetDesiredIndent := @EditorGetIndent;
|
||||||
|
|
||||||
Result.EditorComponent.EndUpdate;
|
Result.EditorComponent.EndUpdate;
|
||||||
{$IFDEF IDE_DEBUG}
|
{$IFDEF IDE_DEBUG}
|
||||||
@ -6672,6 +6691,13 @@ begin
|
|||||||
OnMouseLink(Sender, X, Y, AllowMouseLink);
|
OnMouseLink(Sender, X, Y, AllowMouseLink);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TSourceNotebook.EditorGetIndent(Sender: TObject; LogCaret: TPoint; Line: Integer;
|
||||||
|
var Indent, BasedLine: Integer);
|
||||||
|
begin
|
||||||
|
if Assigned(OnGetDesiredIndent) then
|
||||||
|
OnGetDesiredIndent(Sender, LogCaret, Line, Indent, BasedLine);
|
||||||
|
end;
|
||||||
|
|
||||||
Procedure TSourceNotebook.HintTimer(sender: TObject);
|
Procedure TSourceNotebook.HintTimer(sender: TObject);
|
||||||
var
|
var
|
||||||
MousePos: TPoint;
|
MousePos: TPoint;
|
||||||
|
Loading…
Reference in New Issue
Block a user