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