mirror of https://gitlab.com/basile.b/dexed.git
fix #270 - code formatting as an action, assignable to a shortcut
This commit is contained in:
parent
559745039f
commit
93958edd28
|
@ -63,7 +63,7 @@ type
|
||||||
|
|
||||||
{ TCEDfmtWidget }
|
{ TCEDfmtWidget }
|
||||||
|
|
||||||
TCEDfmtWidget = class(TCEWidget, ICEDocumentObserver)
|
TCEDfmtWidget = class(TCEWidget, ICEDocumentObserver, ICECodeFormatting)
|
||||||
btnApply: TSpeedButton;
|
btnApply: TSpeedButton;
|
||||||
btnCancel: TSpeedButton;
|
btnCancel: TSpeedButton;
|
||||||
pnlFooter: TPanel;
|
pnlFooter: TPanel;
|
||||||
|
@ -85,6 +85,8 @@ type
|
||||||
public
|
public
|
||||||
constructor create(aOwner: TComponent); override;
|
constructor create(aOwner: TComponent); override;
|
||||||
destructor destroy; override;
|
destructor destroy; override;
|
||||||
|
function singleServiceName: string;
|
||||||
|
procedure formatCurrent();
|
||||||
end;
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
@ -129,6 +131,8 @@ begin
|
||||||
|
|
||||||
dfmtOptionEditor.TIObject := fDmtWrapper;
|
dfmtOptionEditor.TIObject := fDmtWrapper;
|
||||||
dfmtOptionEditor.DefaultItemHeight:=scaleY(24,96);
|
dfmtOptionEditor.DefaultItemHeight:=scaleY(24,96);
|
||||||
|
|
||||||
|
EntitiesConnector.addSingleService(self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TCEDfmtWidget.destroy;
|
destructor TCEDfmtWidget.destroy;
|
||||||
|
@ -282,6 +286,16 @@ begin
|
||||||
str.Add('--template_constraint_style=' + cts[fConstraints]);
|
str.Add('--template_constraint_style=' + cts[fConstraints]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TCEDfmtWidget.singleServiceName: string;
|
||||||
|
begin
|
||||||
|
exit('ICECodeFormatting');
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCEDfmtWidget.formatCurrent();
|
||||||
|
begin
|
||||||
|
doApply(self);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCEDfmtWidget.doApply(sender: TObject);
|
procedure TCEDfmtWidget.doApply(sender: TObject);
|
||||||
var
|
var
|
||||||
inp: string;
|
inp: string;
|
||||||
|
|
|
@ -379,6 +379,16 @@ type
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
(**
|
||||||
|
* Single service for DFMT
|
||||||
|
*)
|
||||||
|
ICECodeFormatting = interface(ICESingleService)
|
||||||
|
// formats the focused editor
|
||||||
|
procedure formatCurrent();
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
TDCDCompletionKind = (
|
TDCDCompletionKind = (
|
||||||
dckClass,
|
dckClass,
|
||||||
dckInterface,
|
dckInterface,
|
||||||
|
@ -440,6 +450,7 @@ type
|
||||||
function getOptionsEditor: ICEOptionsEditor; inline;
|
function getOptionsEditor: ICEOptionsEditor; inline;
|
||||||
function getCompilerSelector: ICECompilerSelector; inline;
|
function getCompilerSelector: ICECompilerSelector; inline;
|
||||||
function getMainMenu: ICEMainMenu; inline;
|
function getMainMenu: ICEMainMenu; inline;
|
||||||
|
function getCodeFormatting: ICECodeFormatting; inline;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
@ -594,6 +605,11 @@ function getMainMenu: ICEMainMenu;
|
||||||
begin
|
begin
|
||||||
exit(EntitiesConnector.getSingleService('ICEMainMenu') as ICEMainMenu);
|
exit(EntitiesConnector.getSingleService('ICEMainMenu') as ICEMainMenu);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function getCodeFormatting: ICECodeFormatting; inline;
|
||||||
|
begin
|
||||||
|
exit(EntitiesConnector.getSingleService('ICECodeFormatting') as ICECodeFormatting);
|
||||||
|
end;
|
||||||
{$ENDREGION}
|
{$ENDREGION}
|
||||||
|
|
||||||
function usingCompilerInfo(value: DCompiler): string;
|
function usingCompilerInfo(value: DCompiler): string;
|
||||||
|
|
|
@ -1599,6 +1599,9 @@ object CEMainForm: TCEMainForm
|
||||||
object MenuItem21: TMenuItem
|
object MenuItem21: TMenuItem
|
||||||
Caption = '-'
|
Caption = '-'
|
||||||
end
|
end
|
||||||
|
object MenuItem31: TMenuItem
|
||||||
|
Action = actEdFormat
|
||||||
|
end
|
||||||
object MenuItem54: TMenuItem
|
object MenuItem54: TMenuItem
|
||||||
Action = actEdIndent
|
Action = actEdIndent
|
||||||
end
|
end
|
||||||
|
@ -2367,6 +2370,11 @@ object CEMainForm: TCEMainForm
|
||||||
OnExecute = actFileCloseAllExecute
|
OnExecute = actFileCloseAllExecute
|
||||||
OnUpdate = updateDocumentBasedAction
|
OnUpdate = updateDocumentBasedAction
|
||||||
end
|
end
|
||||||
|
object actEdFormat: TAction
|
||||||
|
Category = 'Edit'
|
||||||
|
Caption = 'Apply code formatting'
|
||||||
|
OnExecute = actEdFormatExecute
|
||||||
|
end
|
||||||
end
|
end
|
||||||
object ApplicationProperties1: TApplicationProperties
|
object ApplicationProperties1: TApplicationProperties
|
||||||
OnActivate = ApplicationProperties1Activate
|
OnActivate = ApplicationProperties1Activate
|
||||||
|
|
|
@ -105,6 +105,7 @@ type
|
||||||
actFileCloseAllOthers: TAction;
|
actFileCloseAllOthers: TAction;
|
||||||
actFileCloseAll: TAction;
|
actFileCloseAll: TAction;
|
||||||
actFileNewClip: TAction;
|
actFileNewClip: TAction;
|
||||||
|
actEdFormat: TAction;
|
||||||
actLayoutReset: TAction;
|
actLayoutReset: TAction;
|
||||||
actProjDscan: TAction;
|
actProjDscan: TAction;
|
||||||
actProjGroupCompileCustomSync: TAction;
|
actProjGroupCompileCustomSync: TAction;
|
||||||
|
@ -158,6 +159,7 @@ type
|
||||||
MenuItem107: TMenuItem;
|
MenuItem107: TMenuItem;
|
||||||
MenuItem108: TMenuItem;
|
MenuItem108: TMenuItem;
|
||||||
MenuItem109: TMenuItem;
|
MenuItem109: TMenuItem;
|
||||||
|
MenuItem31: TMenuItem;
|
||||||
MenuItem77: TMenuItem;
|
MenuItem77: TMenuItem;
|
||||||
mnuOpts: TMenuItem;
|
mnuOpts: TMenuItem;
|
||||||
mnuItemMruGroup: TMenuItem;
|
mnuItemMruGroup: TMenuItem;
|
||||||
|
@ -260,6 +262,7 @@ type
|
||||||
MenuItem7: TMenuItem;
|
MenuItem7: TMenuItem;
|
||||||
MenuItem8: TMenuItem;
|
MenuItem8: TMenuItem;
|
||||||
MenuItem9: TMenuItem;
|
MenuItem9: TMenuItem;
|
||||||
|
procedure actEdFormatExecute(Sender: TObject);
|
||||||
procedure actFileCloseAllExecute(Sender: TObject);
|
procedure actFileCloseAllExecute(Sender: TObject);
|
||||||
procedure actFileCloseAllOthersExecute(Sender: TObject);
|
procedure actFileCloseAllOthersExecute(Sender: TObject);
|
||||||
procedure actFileCompileExecute(Sender: TObject);
|
procedure actFileCompileExecute(Sender: TObject);
|
||||||
|
@ -3135,6 +3138,13 @@ begin
|
||||||
fMultidoc.closeDocument(i);
|
fMultidoc.closeDocument(i);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCEMainForm.actEdFormatExecute(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if fDoc.isNil then
|
||||||
|
exit;
|
||||||
|
getCodeFormatting.formatCurrent();
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCEMainForm.actFileDscannerExecute(Sender: TObject);
|
procedure TCEMainForm.actFileDscannerExecute(Sender: TObject);
|
||||||
var
|
var
|
||||||
lst: TStringList;
|
lst: TStringList;
|
||||||
|
|
Loading…
Reference in New Issue