implemented IDE code macro selection

git-svn-id: trunk@8102 -
This commit is contained in:
mattias 2005-11-08 15:50:42 +00:00
parent afe0734734
commit 4595d9066c
11 changed files with 371 additions and 193 deletions

View File

@ -652,9 +652,9 @@ begin
// find variable name
GetIdentStartEndAtPosition(Src,CleanCursorPos,
VarNameAtom.StartPos,VarNameAtom.EndPos);
//debugln('TCodeCompletionCodeTool.CheckLocalVarAssignmentSyntax A ',GetAtom(VarNameAtom),' "',copy(Src,CleanCursorPos,10),'"');
if VarNameAtom.StartPos=VarNameAtom.EndPos then exit;
MoveCursorToCleanPos(VarNameAtom.StartPos);
ReadNextAtom;
MoveCursorToAtomPos(VarNameAtom);
if AtomIsKeyWord then exit;
// find assignment operator
@ -2473,6 +2473,10 @@ var CleanCursorPos, Indent, insertPos: integer;
BuildSubTreeForBeginBlock(CursorNode);
CursorNode:=FindDeepestNodeAtPos(CleanCursorPos,true);
// read event name (optional)
while (CleanCursorPos<SrcLen)
and (Src[CleanCursorPos] in [':','=',' ',#9]) do
inc(CleanCursorPos);
GetIdentStartEndAtPosition(Src,CleanCursorPos,
UserEventAtom.StartPos,UserEventAtom.EndPos);
MoveCursorToAtomPos(UserEventAtom);
@ -2765,7 +2769,7 @@ begin
while (CleanCursorPos>1) and (Src[CleanCursorPos] in [#10,#13]) do
dec(CleanCursorPos);
// skip space (first try left)
while (CleanCursorPos>1) and (Src[CleanCursorPos-1] in [' ',#9,';']) do
while (CleanCursorPos>1) and (Src[CleanCursorPos] in [' ',#9,';']) do
dec(CleanCursorPos);
if (CleanCursorPos>0) and (CleanCursorPos<SrcLen)
and (Src[CleanCursorPos] in [#10,#13]) then begin

View File

@ -32,7 +32,7 @@ interface
uses
Classes, SysUtils, LCLProc, LResources, Forms, Controls, Graphics, Dialogs,
SynEdit, MacroIntf, SrcEditorIntf;
SynEdit, MacroIntf, LazIDEIntf, SrcEditorIntf;
type
TCodeMacroPromptDlg = class(TForm)
@ -75,6 +75,7 @@ begin
if copy(Pattern,1,length(CodeTemplateMakroMagic))=CodeTemplateMakroMagic
then begin
// macros enabled
LazarusIDE.SaveSourceEditorChangesToCodeCache(-1);
// remove first line (i.e. macro enabled flag)
Pattern:=TemplateValue;

View File

@ -1,46 +1,56 @@
object CodeMacroSelectDlg: TCodeMacroSelectDlg
ActiveControl = MacrosListBox
Caption = 'CodeMacroSelectDlg'
ClientHeight = 261
ClientWidth = 400
ClientHeight = 275
ClientWidth = 560
OnClose = FormClose
OnCreate = FormCreate
PixelsPerInch = 112
HorzScrollBar.Page = 399
VertScrollBar.Page = 260
PixelsPerInch = 75
HorzScrollBar.Page = 559
VertScrollBar.Page = 274
Left = 318
Height = 261
Height = 275
Top = 200
Width = 400
Width = 560
object MacrosGroupBox: TGroupBox
Anchors = [akTop, akLeft, akBottom]
Caption = 'MacrosGroupBox'
ClientHeight = 184
ClientHeight = 198
ClientWidth = 166
ParentColor = True
TabOrder = 0
Left = 10
Height = 201
Height = 215
Top = 10
Width = 170
object MacrosListBox: TListBox
Align = alClient
OnSelectionChange = MacrosListBoxSelectionChange
TabOrder = 0
TopIndex = -1
Height = 184
Height = 198
Width = 166
end
end
object DescriptionGroupBox: TGroupBox
Anchors = [akTop, akLeft, akRight, akBottom]
Caption = 'DescriptionGroupBox'
ClientHeight = 184
ClientWidth = 196
ParentColor = True
ClientHeight = 198
ClientWidth = 356
TabOrder = 1
Left = 190
Height = 201
Height = 215
Top = 10
Width = 200
Width = 360
object DescriptionLabel: TLabel
Align = alClient
AutoSize = False
Caption = 'DescriptionLabel'
Color = clNone
ParentColor = False
WordWrap = True
Height = 198
Width = 356
end
end
object OkButton: TButton
Anchors = [akTop, akRight]
@ -53,9 +63,9 @@ object CodeMacroSelectDlg: TCodeMacroSelectDlg
AnchorSideTop.Control = CancelButton
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = CancelButton
Left = 234
Left = 394
Height = 26
Top = 221
Top = 235
Width = 61
end
object CancelButton: TButton
@ -65,9 +75,9 @@ object CodeMacroSelectDlg: TCodeMacroSelectDlg
Caption = 'CancelButton'
ModalResult = 2
TabOrder = 3
Left = 305
Left = 465
Height = 26
Top = 221
Top = 235
Width = 85
end
end

View File

@ -2,25 +2,28 @@
LazarusResources.Add('TCodeMacroSelectDlg','FORMDATA',[
'TPF0'#19'TCodeMacroSelectDlg'#18'CodeMacroSelectDlg'#13'ActiveControl'#7#13
+'MacrosListBox'#7'Caption'#6#18'CodeMacroSelectDlg'#12'ClientHeight'#3#5#1#11
+'ClientWidth'#3#144#1#8'OnCreate'#7#10'FormCreate'#13'PixelsPerInch'#2'p'#18
+'HorzScrollBar.Page'#3#143#1#18'VertScrollBar.Page'#3#4#1#4'Left'#3'>'#1#6'H'
+'eight'#3#5#1#3'Top'#3#200#0#5'Width'#3#144#1#0#9'TGroupBox'#14'MacrosGroupB'
+'ox'#7'Anchors'#11#5'akTop'#6'akLeft'#8'akBottom'#0#7'Caption'#6#14'MacrosGr'
+'oupBox'#12'ClientHeight'#3#184#0#11'ClientWidth'#3#166#0#11'ParentColor'#9#8
+'TabOrder'#2#0#4'Left'#2#10#6'Height'#3#201#0#3'Top'#2#10#5'Width'#3#170#0#0
+#8'TListBox'#13'MacrosListBox'#5'Align'#7#8'alClient'#8'TabOrder'#2#0#8'TopI'
+'ndex'#2#255#6'Height'#3#184#0#5'Width'#3#166#0#0#0#0#9'TGroupBox'#19'Descri'
+'ptionGroupBox'#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#8'akBottom'#0#7
+'Caption'#6#19'DescriptionGroupBox'#12'ClientHeight'#3#184#0#11'ClientWidth'
+#3#196#0#11'ParentColor'#9#8'TabOrder'#2#1#4'Left'#3#190#0#6'Height'#3#201#0
+#3'Top'#2#10#5'Width'#3#200#0#0#0#7'TButton'#8'OkButton'#7'Anchors'#11#5'akT'
+'op'#7'akRight'#0#8'AutoSize'#9#19'BorderSpacing.Right'#2#10#25'BorderSpacin'
+'g.InnerBorder'#2#2#7'Caption'#6#8'OkButton'#11'ModalResult'#2#1#8'TabOrder'
+#2#2#21'AnchorSideTop.Control'#7#12'CancelButton'#18'AnchorSideTop.Side'#7#9
+'asrCenter'#23'AnchorSideRight.Control'#7#12'CancelButton'#4'Left'#3#234#0#6
+'Height'#2#26#3'Top'#3#221#0#5'Width'#2'='#0#0#7'TButton'#12'CancelButton'#7
+'Anchors'#11#7'akRight'#8'akBottom'#0#8'AutoSize'#9#25'BorderSpacing.InnerBo'
+'rder'#2#2#7'Caption'#6#12'CancelButton'#11'ModalResult'#2#2#8'TabOrder'#2#3
+#4'Left'#3'1'#1#6'Height'#2#26#3'Top'#3#221#0#5'Width'#2'U'#0#0#0
+'MacrosListBox'#7'Caption'#6#18'CodeMacroSelectDlg'#12'ClientHeight'#3#19#1
+#11'ClientWidth'#3'0'#2#7'OnClose'#7#9'FormClose'#8'OnCreate'#7#10'FormCreat'
+'e'#13'PixelsPerInch'#2'K'#18'HorzScrollBar.Page'#3'/'#2#18'VertScrollBar.Pa'
+'ge'#3#18#1#4'Left'#3'>'#1#6'Height'#3#19#1#3'Top'#3#200#0#5'Width'#3'0'#2#0
+#9'TGroupBox'#14'MacrosGroupBox'#7'Anchors'#11#5'akTop'#6'akLeft'#8'akBottom'
+#0#7'Caption'#6#14'MacrosGroupBox'#12'ClientHeight'#3#198#0#11'ClientWidth'#3
+#166#0#8'TabOrder'#2#0#4'Left'#2#10#6'Height'#3#215#0#3'Top'#2#10#5'Width'#3
+#170#0#0#8'TListBox'#13'MacrosListBox'#5'Align'#7#8'alClient'#17'OnSelection'
+'Change'#7#28'MacrosListBoxSelectionChange'#8'TabOrder'#2#0#8'TopIndex'#2#255
+#6'Height'#3#198#0#5'Width'#3#166#0#0#0#0#9'TGroupBox'#19'DescriptionGroupBo'
+'x'#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#8'akBottom'#0#7'Caption'#6#19
+'DescriptionGroupBox'#12'ClientHeight'#3#198#0#11'ClientWidth'#3'd'#1#8'TabO'
+'rder'#2#1#4'Left'#3#190#0#6'Height'#3#215#0#3'Top'#2#10#5'Width'#3'h'#1#0#6
+'TLabel'#16'DescriptionLabel'#5'Align'#7#8'alClient'#8'AutoSize'#8#7'Caption'
+#6#16'DescriptionLabel'#5'Color'#7#6'clNone'#11'ParentColor'#8#8'WordWrap'#9
+#6'Height'#3#198#0#5'Width'#3'd'#1#0#0#0#7'TButton'#8'OkButton'#7'Anchors'#11
+#5'akTop'#7'akRight'#0#8'AutoSize'#9#19'BorderSpacing.Right'#2#10#25'BorderS'
+'pacing.InnerBorder'#2#2#7'Caption'#6#8'OkButton'#11'ModalResult'#2#1#8'TabO'
+'rder'#2#2#21'AnchorSideTop.Control'#7#12'CancelButton'#18'AnchorSideTop.Sid'
+'e'#7#9'asrCenter'#23'AnchorSideRight.Control'#7#12'CancelButton'#4'Left'#3
+#138#1#6'Height'#2#26#3'Top'#3#235#0#5'Width'#2'='#0#0#7'TButton'#12'CancelB'
+'utton'#7'Anchors'#11#7'akRight'#8'akBottom'#0#8'AutoSize'#9#25'BorderSpacin'
+'g.InnerBorder'#2#2#7'Caption'#6#12'CancelButton'#11'ModalResult'#2#2#8'TabO'
+'rder'#2#3#4'Left'#3#209#1#6'Height'#2#26#3'Top'#3#235#0#5'Width'#2'U'#0#0#0
]);

View File

@ -31,39 +31,100 @@ interface
uses
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, StdCtrls,
Buttons, SrcEditorIntf;
Buttons, SrcEditorIntf, IDEWindowIntf,
InputHistory , LazarusIDEStrConsts;
type
{ TCodeMacroSelectDlg }
TCodeMacroSelectDlg = class(TForm)
DescriptionLabel: TLabel;
MacrosListBox: TListBox;
OkButton: TButton;
CancelButton: TButton;
MacrosGroupBox: TGroupBox;
DescriptionGroupBox: TGroupBox;
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure MacrosListBoxSelectionChange(Sender: TObject; User: boolean);
private
{ private declarations }
FSelected: TIDECodeMacro;
procedure FillMacrosListbox;
public
{ public declarations }
end;
property Selected: TIDECodeMacro read FSelected;
end;
var
CodeMacroSelectDlg: TCodeMacroSelectDlg;
function ShowCodeMacroSelectDialog: TIDECodeMacro;
implementation
function ShowCodeMacroSelectDialog: TIDECodeMacro;
var
CodeMacroSelectDlg: TCodeMacroSelectDlg;
begin
CodeMacroSelectDlg:=TCodeMacroSelectDlg.Create(nil);
if CodeMacroSelectDlg.ShowModal=mrOk then begin
Result:=CodeMacroSelectDlg.Selected;
end else begin
Result:=nil;
end;
CodeMacroSelectDlg.Free;
end;
{ TCodeMacroSelectDlg }
procedure TCodeMacroSelectDlg.FormCreate(Sender: TObject);
begin
Caption:='Select Code Macro';
MacrosGroupBox.Caption:='Macros';
DescriptionGroupBox.Caption:='Description';
OkButton.Caption:='Insert Macro';
CancelButton.Caption:='Cancel';
IDEDialogLayoutList.ApplyLayout(Self,550,250);
Caption:=lisCTSelectCodeMacro;
MacrosGroupBox.Caption:=lisEdtExtToolMacros;
DescriptionGroupBox.Caption:=lisToDoLDescription;
OkButton.Caption:=lisCTInsertMacro;
CancelButton.Caption:=dlgCancel;
FillMacrosListbox;
end;
procedure TCodeMacroSelectDlg.FormClose(Sender: TObject;
var CloseAction: TCloseAction);
begin
IDEDialogLayoutList.SaveLayout(Self);
end;
procedure TCodeMacroSelectDlg.MacrosListBoxSelectionChange(Sender: TObject;
User: boolean);
var
i: LongInt;
MacroName: string;
begin
i:=MacrosListBox.ItemIndex;
if (i>=0) then begin
MacroName:=MacrosListBox.Items[i];
FSelected:=IDECodeMacros.FindByName(MacroName);
end else begin
FSelected:=nil;
end;
if FSelected<>nil then begin
DescriptionLabel.Caption:=FSelected.LongDescription;
end else begin
DescriptionLabel.Caption:=lisCTPleaseSelectAMacro;
end;
end;
procedure TCodeMacroSelectDlg.FillMacrosListbox;
var
i: Integer;
begin
with MacrosListBox.Items do begin
BeginUpdate;
Clear;
for i:=0 to IDECodeMacros.Count-1 do
Add(IDECodeMacros[i].Name);
EndUpdate;
end;
end;
initialization

View File

@ -1,28 +1,28 @@
object CodeTemplateDialog: TCodeTemplateDialog
ActiveControl = FilenameEdit
Caption = 'CodeTemplateDialog'
ClientHeight = 432
ClientWidth = 596
ClientHeight = 450
ClientWidth = 600
OnClose = FormClose
OnCreate = FormCreate
PixelsPerInch = 112
HorzScrollBar.Page = 595
VertScrollBar.Page = 431
PixelsPerInch = 75
HorzScrollBar.Page = 599
VertScrollBar.Page = 449
Left = 290
Height = 432
Height = 450
Top = 163
Width = 596
Width = 600
object FilenameGroupBox: TGroupBox
Align = alTop
BorderSpacing.Around = 5
Caption = 'FilenameGroupBox'
ClientHeight = 42
ClientWidth = 582
ParentColor = True
ClientWidth = 586
TabOrder = 0
Left = 5
Height = 59
Top = 5
Width = 586
Width = 590
object FilenameEdit: TEdit
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Right = 5
@ -59,9 +59,9 @@ object CodeTemplateDialog: TCodeTemplateDialog
AnchorSideRight.Control = CancelButton
AnchorSideBottom.Control = CancelButton
AnchorSideBottom.Side = asrBottom
Left = 423
Left = 427
Height = 26
Top = 396
Top = 414
Width = 61
end
object CancelButton: TButton
@ -71,9 +71,9 @@ object CodeTemplateDialog: TCodeTemplateDialog
Caption = 'CancelButton'
ModalResult = 2
TabOrder = 2
Left = 498
Left = 502
Height = 26
Top = 396
Top = 414
Width = 85
end
object TemplateGroupBox: TGroupBox
@ -81,32 +81,34 @@ object CodeTemplateDialog: TCodeTemplateDialog
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Around = 5
Caption = 'TemplateGroupBox'
ClientHeight = 305
ClientWidth = 582
ParentColor = True
ClientHeight = 323
ClientWidth = 586
TabOrder = 3
AnchorSideBottom.Control = CancelButton
Left = 5
Height = 322
Height = 340
Top = 69
Width = 586
Width = 590
object TemplateListBox: TListBox
Anchors = [akTop, akLeft, akRight, akBottom]
OnSelectionChange = TemplateListBoxSelectionChange
TabOrder = 0
TopIndex = -1
AnchorSideBottom.Control = TemplateSplitter
Height = 150
Width = 408
Height = 190
Width = 412
end
object TemplateSynEdit: TSynEdit
Align = alBottom
Font.Height = -18
Font.Name = 'courier'
Height = 150
Height = 128
Name = 'TemplateSynEdit'
ParentColor = False
TabOrder = 1
Width = 582
Width = 586
BookMarkOptions.OnChange = nil
Gutter.OnChange = nil
Gutter.CodeFoldingWidth = 14
Highlighter = ASynPasSyn
Keystrokes = <
@ -433,22 +435,22 @@ object CodeTemplateDialog: TCodeTemplateDialog
Lines.Strings = (
'TemplateSynEdit'
)
SelectedColor.OnChange = nil
Cursor = crIBeam
Height = 150
Top = 155
Width = 582
Height = 128
Top = 195
Width = 586
end
object TemplateSplitter: TSplitter
Align = alBottom
Cursor = crVSplit
Height = 5
ParentColor = True
Width = 582
Width = 586
ResizeAnchor = akBottom
Cursor = crVSplit
Height = 5
Top = 150
Width = 582
Top = 190
Width = 586
end
object AddButton: TButton
Anchors = [akTop, akRight]
@ -456,7 +458,7 @@ object CodeTemplateDialog: TCodeTemplateDialog
Caption = 'AddButton'
OnClick = AddButtonClick
TabOrder = 2
Left = 457
Left = 461
Height = 30
Width = 115
end
@ -466,7 +468,7 @@ object CodeTemplateDialog: TCodeTemplateDialog
Caption = 'DeleteButton'
OnClick = DeleteButtonClick
TabOrder = 3
Left = 457
Left = 461
Height = 30
Top = 36
Width = 115
@ -477,7 +479,7 @@ object CodeTemplateDialog: TCodeTemplateDialog
Caption = 'EditButton'
OnClick = EditButtonClick
TabOrder = 4
Left = 457
Left = 461
Height = 30
Top = 71
Width = 115
@ -486,10 +488,21 @@ object CodeTemplateDialog: TCodeTemplateDialog
Anchors = [akTop, akRight]
Caption = 'UseMakrosCheckBox'
TabOrder = 5
Left = 426
Left = 433
Height = 24
Top = 106
Width = 146
Width = 143
end
object InsertMacroButton: TButton
Anchors = [akTop, akRight]
BorderSpacing.InnerBorder = 2
Caption = 'InsertMacroButton'
OnClick = InsertMacroButtonClick
TabOrder = 6
Left = 461
Height = 25
Top = 141
Width = 115
end
end
object ASynPasSyn: TSynPasSyn

View File

@ -2,99 +2,104 @@
LazarusResources.Add('TCodeTemplateDialog','FORMDATA',[
'TPF0'#19'TCodeTemplateDialog'#18'CodeTemplateDialog'#13'ActiveControl'#7#12
+'FilenameEdit'#7'Caption'#6#18'CodeTemplateDialog'#12'ClientHeight'#3#176#1
+#11'ClientWidth'#3'T'#2#8'OnCreate'#7#10'FormCreate'#13'PixelsPerInch'#2'p'
+#18'HorzScrollBar.Page'#3'S'#2#18'VertScrollBar.Page'#3#175#1#4'Left'#3'"'#1
+#6'Height'#3#176#1#3'Top'#3#163#0#5'Width'#3'T'#2#0#9'TGroupBox'#16'Filename'
+'GroupBox'#5'Align'#7#5'alTop'#20'BorderSpacing.Around'#2#5#7'Caption'#6#16
+'FilenameGroupBox'#12'ClientHeight'#2'*'#11'ClientWidth'#3'F'#2#11'ParentCol'
+'or'#9#8'TabOrder'#2#0#4'Left'#2#5#6'Height'#2';'#3'Top'#2#5#5'Width'#3'J'#2
+#0#5'TEdit'#12'FilenameEdit'#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#0#19
+'BorderSpacing.Right'#2#5#8'TabOrder'#2#0#4'Text'#6#12'FilenameEdit'#23'Anch'
+'orSideRight.Control'#7#14'FilenameButton'#4'Left'#2#9#6'Height'#2#23#3'Top'
+#2#4#5'Width'#3#19#2#0#0#7'TButton'#14'FilenameButton'#7'Anchors'#11#5'akTop'
+#6'akLeft'#8'akBottom'#0#25'BorderSpacing.InnerBorder'#2#2#7'Caption'#6#3'..'
+'.'#7'OnClick'#7#19'FilenameButtonClick'#8'TabOrder'#2#1#24'AnchorSideBottom'
+'.Control'#7#12'FilenameEdit'#21'AnchorSideBottom.Side'#7#9'asrBottom'#4'Lef'
+'t'#3'!'#2#6'Height'#2#23#3'Top'#2#4#5'Width'#2#30#0#0#0#7'TButton'#8'OkButt'
+'on'#7'Anchors'#11#7'akRight'#8'akBottom'#0#8'AutoSize'#9#19'BorderSpacing.R'
+'ight'#2#14#25'BorderSpacing.InnerBorder'#2#2#7'Caption'#6#8'OkButton'#7'OnC'
+'lick'#7#13'OkButtonClick'#8'TabOrder'#2#1#23'AnchorSideRight.Control'#7#12
+'CancelButton'#24'AnchorSideBottom.Control'#7#12'CancelButton'#21'AnchorSide'
+'Bottom.Side'#7#9'asrBottom'#4'Left'#3#167#1#6'Height'#2#26#3'Top'#3#140#1#5
+'Width'#2'='#0#0#7'TButton'#12'CancelButton'#7'Anchors'#11#7'akRight'#8'akBo'
+'ttom'#0#8'AutoSize'#9#25'BorderSpacing.InnerBorder'#2#2#7'Caption'#6#12'Can'
+'celButton'#11'ModalResult'#2#2#8'TabOrder'#2#2#4'Left'#3#242#1#6'Height'#2
+#26#3'Top'#3#140#1#5'Width'#2'U'#0#0#9'TGroupBox'#16'TemplateGroupBox'#5'Ali'
+'FilenameEdit'#7'Caption'#6#18'CodeTemplateDialog'#12'ClientHeight'#3#194#1
+#11'ClientWidth'#3'X'#2#7'OnClose'#7#9'FormClose'#8'OnCreate'#7#10'FormCreat'
+'e'#13'PixelsPerInch'#2'K'#18'HorzScrollBar.Page'#3'W'#2#18'VertScrollBar.Pa'
+'ge'#3#193#1#4'Left'#3'"'#1#6'Height'#3#194#1#3'Top'#3#163#0#5'Width'#3'X'#2
+#0#9'TGroupBox'#16'FilenameGroupBox'#5'Align'#7#5'alTop'#20'BorderSpacing.Ar'
+'ound'#2#5#7'Caption'#6#16'FilenameGroupBox'#12'ClientHeight'#2'*'#11'Client'
+'Width'#3'J'#2#8'TabOrder'#2#0#4'Left'#2#5#6'Height'#2';'#3'Top'#2#5#5'Width'
+#3'N'#2#0#5'TEdit'#12'FilenameEdit'#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRig'
+'ht'#0#19'BorderSpacing.Right'#2#5#8'TabOrder'#2#0#4'Text'#6#12'FilenameEdit'
+#23'AnchorSideRight.Control'#7#14'FilenameButton'#4'Left'#2#9#6'Height'#2#23
+#3'Top'#2#4#5'Width'#3#19#2#0#0#7'TButton'#14'FilenameButton'#7'Anchors'#11#5
+'akTop'#6'akLeft'#8'akBottom'#0#25'BorderSpacing.InnerBorder'#2#2#7'Caption'
+#6#3'...'#7'OnClick'#7#19'FilenameButtonClick'#8'TabOrder'#2#1#24'AnchorSide'
+'Bottom.Control'#7#12'FilenameEdit'#21'AnchorSideBottom.Side'#7#9'asrBottom'
+#4'Left'#3'!'#2#6'Height'#2#23#3'Top'#2#4#5'Width'#2#30#0#0#0#7'TButton'#8'O'
+'kButton'#7'Anchors'#11#7'akRight'#8'akBottom'#0#8'AutoSize'#9#19'BorderSpac'
+'ing.Right'#2#14#25'BorderSpacing.InnerBorder'#2#2#7'Caption'#6#8'OkButton'#7
+'OnClick'#7#13'OkButtonClick'#8'TabOrder'#2#1#23'AnchorSideRight.Control'#7
+#12'CancelButton'#24'AnchorSideBottom.Control'#7#12'CancelButton'#21'AnchorS'
+'ideBottom.Side'#7#9'asrBottom'#4'Left'#3#171#1#6'Height'#2#26#3'Top'#3#158#1
+#5'Width'#2'='#0#0#7'TButton'#12'CancelButton'#7'Anchors'#11#7'akRight'#8'ak'
+'Bottom'#0#8'AutoSize'#9#25'BorderSpacing.InnerBorder'#2#2#7'Caption'#6#12'C'
+'ancelButton'#11'ModalResult'#2#2#8'TabOrder'#2#2#4'Left'#3#246#1#6'Height'#2
+#26#3'Top'#3#158#1#5'Width'#2'U'#0#0#9'TGroupBox'#16'TemplateGroupBox'#5'Ali'
+'gn'#7#5'alTop'#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#8'akBottom'#0#20
+'BorderSpacing.Around'#2#5#7'Caption'#6#16'TemplateGroupBox'#12'ClientHeight'
+#3'1'#1#11'ClientWidth'#3'F'#2#11'ParentColor'#9#8'TabOrder'#2#3#24'AnchorSi'
+'deBottom.Control'#7#12'CancelButton'#4'Left'#2#5#6'Height'#3'B'#1#3'Top'#2
+'E'#5'Width'#3'J'#2#0#8'TListBox'#15'TemplateListBox'#7'Anchors'#11#5'akTop'
+#6'akLeft'#7'akRight'#8'akBottom'#0#17'OnSelectionChange'#7#30'TemplateListB'
+'oxSelectionChange'#8'TabOrder'#2#0#8'TopIndex'#2#255#24'AnchorSideBottom.Co'
+'ntrol'#7#16'TemplateSplitter'#6'Height'#3#150#0#5'Width'#3#152#1#0#0#8'TSyn'
+'Edit'#15'TemplateSynEdit'#5'Align'#7#8'alBottom'#11'Font.Height'#2#238#9'Fo'
+'nt.Name'#6#7'courier'#6'Height'#3#150#0#4'Name'#6#15'TemplateSynEdit'#8'Tab'
+'Order'#2#1#5'Width'#3'F'#2#23'Gutter.CodeFoldingWidth'#2#14#11'Highlighter'
+#7#10'ASynPasSyn'#10'Keystrokes'#14#1#7'Command'#2#3#8'ShortCut'#2'&'#0#1#7
+'Command'#2'g'#8'ShortCut'#3'& '#0#1#7'Command'#3#211#0#8'ShortCut'#3'&@'#0#1
+#7'Command'#2#4#8'ShortCut'#2'('#0#1#7'Command'#2'h'#8'ShortCut'#3'( '#0#1#7
+'Command'#3#212#0#8'ShortCut'#3'(@'#0#1#7'Command'#2#1#8'ShortCut'#2'%'#0#1#7
+'Command'#2'e'#8'ShortCut'#3'% '#0#1#7'Command'#2#5#8'ShortCut'#3'%@'#0#1#7
+'Command'#2'i'#8'ShortCut'#3'%`'#0#1#7'Command'#2#2#8'ShortCut'#2''''#0#1#7
+'Command'#2'f'#8'ShortCut'#3''' '#0#1#7'Command'#2#6#8'ShortCut'#3'''@'#0#1#7
+'Command'#2'j'#8'ShortCut'#3'''`'#0#1#7'Command'#2#10#8'ShortCut'#2'"'#0#1#7
+'Command'#2'n'#8'ShortCut'#3'" '#0#1#7'Command'#2#14#8'ShortCut'#3'"@'#0#1#7
+'Command'#2'r'#8'ShortCut'#3'"`'#0#1#7'Command'#2#9#8'ShortCut'#2'!'#0#1#7'C'
+'ommand'#2'm'#8'ShortCut'#3'! '#0#1#7'Command'#2#13#8'ShortCut'#3'!@'#0#1#7
+'Command'#2'q'#8'ShortCut'#3'!`'#0#1#7'Command'#2#7#8'ShortCut'#2'$'#0#1#7'C'
+'ommand'#2'k'#8'ShortCut'#3'$ '#0#1#7'Command'#2#15#8'ShortCut'#3'$@'#0#1#7
+'Command'#2's'#8'ShortCut'#3'$`'#0#1#7'Command'#2#8#8'ShortCut'#2'#'#0#1#7'C'
+'ommand'#2'l'#8'ShortCut'#3'# '#0#1#7'Command'#2#16#8'ShortCut'#3'#@'#0#1#7
+'Command'#2't'#8'ShortCut'#3'#`'#0#1#7'Command'#3#223#0#8'ShortCut'#2'-'#0#1
+#7'Command'#3#201#0#8'ShortCut'#3'-@'#0#1#7'Command'#3'\'#2#8'ShortCut'#3'- '
+#0#1#7'Command'#3#246#1#8'ShortCut'#2'.'#0#1#7'Command'#3'['#2#8'ShortCut'#3
+'. '#0#1#7'Command'#3#245#1#8'ShortCut'#2#8#0#1#7'Command'#3#245#1#8'ShortCu'
+'t'#3#8' '#0#1#7'Command'#3#248#1#8'ShortCut'#3#8'@'#0#1#7'Command'#3'Y'#2#8
+'ShortCut'#4#8#128#0#0#0#1#7'Command'#3'Z'#2#8'ShortCut'#4#8#160#0#0#0#1#7'C'
+'ommand'#3#253#1#8'ShortCut'#2#13#0#1#7'Command'#3#199#0#8'ShortCut'#3'A@'#0
+#1#7'Command'#3#201#0#8'ShortCut'#3'C@'#0#1#7'Command'#3'b'#2#8'ShortCut'#3
+'I`'#0#1#7'Command'#3#253#1#8'ShortCut'#3'M@'#0#1#7'Command'#3#254#1#8'Short'
+'Cut'#3'N@'#0#1#7'Command'#3#247#1#8'ShortCut'#3'T@'#0#1#7'Command'#3'c'#2#8
+'ShortCut'#3'U`'#0#1#7'Command'#3'\'#2#8'ShortCut'#3'V@'#0#1#7'Command'#3'['
+#2#8'ShortCut'#3'X@'#0#1#7'Command'#3#251#1#8'ShortCut'#3'Y@'#0#1#7'Command'
+#3#250#1#8'ShortCut'#3'Y`'#0#1#7'Command'#3'Y'#2#8'ShortCut'#3'Z@'#0#1#7'Com'
,'mand'#3'Z'#2#8'ShortCut'#3'Z`'#0#1#7'Command'#3'-'#1#8'ShortCut'#3'0@'#0#1#7
+'Command'#3'.'#1#8'ShortCut'#3'1@'#0#1#7'Command'#3'/'#1#8'ShortCut'#3'2@'#0
+#1#7'Command'#3'0'#1#8'ShortCut'#3'3@'#0#1#7'Command'#3'1'#1#8'ShortCut'#3'4'
+'@'#0#1#7'Command'#3'2'#1#8'ShortCut'#3'5@'#0#1#7'Command'#3'3'#1#8'ShortCut'
+#3'6@'#0#1#7'Command'#3'4'#1#8'ShortCut'#3'7@'#0#1#7'Command'#3'5'#1#8'Short'
+'Cut'#3'8@'#0#1#7'Command'#3'6'#1#8'ShortCut'#3'9@'#0#1#7'Command'#3'_'#1#8
+'ShortCut'#3'0`'#0#1#7'Command'#3'`'#1#8'ShortCut'#3'1`'#0#1#7'Command'#3'a'
+#1#8'ShortCut'#3'2`'#0#1#7'Command'#3'b'#1#8'ShortCut'#3'3`'#0#1#7'Command'#3
+'c'#1#8'ShortCut'#3'4`'#0#1#7'Command'#3'd'#1#8'ShortCut'#3'5`'#0#1#7'Comman'
+'d'#3'e'#1#8'ShortCut'#3'6`'#0#1#7'Command'#3'f'#1#8'ShortCut'#3'7`'#0#1#7'C'
+'ommand'#3'g'#1#8'ShortCut'#3'8`'#0#1#7'Command'#3'h'#1#8'ShortCut'#3'9`'#0#1
+#7'Command'#3#231#0#8'ShortCut'#3'N`'#0#1#7'Command'#3#232#0#8'ShortCut'#3'C'
+'`'#0#1#7'Command'#3#233#0#8'ShortCut'#3'L`'#0#1#7'Command'#3'd'#2#8'ShortCu'
+'t'#2#9#0#1#7'Command'#3'e'#2#8'ShortCut'#3#9' '#0#1#7'Command'#3#250#0#8'Sh'
+'ortCut'#3'B`'#0#0#13'Lines.Strings'#1#6#15'TemplateSynEdit'#0#6'Cursor'#7#7
+'crIBeam'#6'Height'#3#150#0#3'Top'#3#155#0#5'Width'#3'F'#2#0#0#9'TSplitter'
+#16'TemplateSplitter'#5'Align'#7#8'alBottom'#6'Cursor'#7#8'crVSplit'#6'Heigh'
+'t'#2#5#11'ParentColor'#9#5'Width'#3'F'#2#12'ResizeAnchor'#7#8'akBottom'#6'C'
+'ursor'#7#8'crVSplit'#6'Height'#2#5#3'Top'#3#150#0#5'Width'#3'F'#2#0#0#7'TBu'
+'tton'#9'AddButton'#7'Anchors'#11#5'akTop'#7'akRight'#0#25'BorderSpacing.Inn'
+'erBorder'#2#2#7'Caption'#6#9'AddButton'#7'OnClick'#7#14'AddButtonClick'#8'T'
+'abOrder'#2#2#4'Left'#3#201#1#6'Height'#2#30#5'Width'#2's'#0#0#7'TButton'#12
+'DeleteButton'#7'Anchors'#11#5'akTop'#7'akRight'#0#25'BorderSpacing.InnerBor'
+'der'#2#2#7'Caption'#6#12'DeleteButton'#7'OnClick'#7#17'DeleteButtonClick'#8
+'TabOrder'#2#3#4'Left'#3#201#1#6'Height'#2#30#3'Top'#2'$'#5'Width'#2's'#0#0#7
+#3'C'#1#11'ClientWidth'#3'J'#2#8'TabOrder'#2#3#24'AnchorSideBottom.Control'#7
+#12'CancelButton'#4'Left'#2#5#6'Height'#3'T'#1#3'Top'#2'E'#5'Width'#3'N'#2#0
+#8'TListBox'#15'TemplateListBox'#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'
+#8'akBottom'#0#17'OnSelectionChange'#7#30'TemplateListBoxSelectionChange'#8
+'TabOrder'#2#0#8'TopIndex'#2#255#24'AnchorSideBottom.Control'#7#16'TemplateS'
+'plitter'#6'Height'#3#190#0#5'Width'#3#156#1#0#0#8'TSynEdit'#15'TemplateSynE'
+'dit'#5'Align'#7#8'alBottom'#11'Font.Height'#2#238#9'Font.Name'#6#7'courier'
+#6'Height'#3#128#0#4'Name'#6#15'TemplateSynEdit'#11'ParentColor'#8#8'TabOrde'
+'r'#2#1#5'Width'#3'J'#2#24'BookMarkOptions.OnChange'#13#15'Gutter.OnChange'
+#13#23'Gutter.CodeFoldingWidth'#2#14#11'Highlighter'#7#10'ASynPasSyn'#10'Key'
+'strokes'#14#1#7'Command'#2#3#8'ShortCut'#2'&'#0#1#7'Command'#2'g'#8'ShortCu'
+'t'#3'& '#0#1#7'Command'#3#211#0#8'ShortCut'#3'&@'#0#1#7'Command'#2#4#8'Shor'
+'tCut'#2'('#0#1#7'Command'#2'h'#8'ShortCut'#3'( '#0#1#7'Command'#3#212#0#8'S'
+'hortCut'#3'(@'#0#1#7'Command'#2#1#8'ShortCut'#2'%'#0#1#7'Command'#2'e'#8'Sh'
+'ortCut'#3'% '#0#1#7'Command'#2#5#8'ShortCut'#3'%@'#0#1#7'Command'#2'i'#8'Sh'
+'ortCut'#3'%`'#0#1#7'Command'#2#2#8'ShortCut'#2''''#0#1#7'Command'#2'f'#8'Sh'
+'ortCut'#3''' '#0#1#7'Command'#2#6#8'ShortCut'#3'''@'#0#1#7'Command'#2'j'#8
+'ShortCut'#3'''`'#0#1#7'Command'#2#10#8'ShortCut'#2'"'#0#1#7'Command'#2'n'#8
+'ShortCut'#3'" '#0#1#7'Command'#2#14#8'ShortCut'#3'"@'#0#1#7'Command'#2'r'#8
+'ShortCut'#3'"`'#0#1#7'Command'#2#9#8'ShortCut'#2'!'#0#1#7'Command'#2'm'#8'S'
+'hortCut'#3'! '#0#1#7'Command'#2#13#8'ShortCut'#3'!@'#0#1#7'Command'#2'q'#8
+'ShortCut'#3'!`'#0#1#7'Command'#2#7#8'ShortCut'#2'$'#0#1#7'Command'#2'k'#8'S'
+'hortCut'#3'$ '#0#1#7'Command'#2#15#8'ShortCut'#3'$@'#0#1#7'Command'#2's'#8
+'ShortCut'#3'$`'#0#1#7'Command'#2#8#8'ShortCut'#2'#'#0#1#7'Command'#2'l'#8'S'
+'hortCut'#3'# '#0#1#7'Command'#2#16#8'ShortCut'#3'#@'#0#1#7'Command'#2't'#8
+'ShortCut'#3'#`'#0#1#7'Command'#3#223#0#8'ShortCut'#2'-'#0#1#7'Command'#3#201
+#0#8'ShortCut'#3'-@'#0#1#7'Command'#3'\'#2#8'ShortCut'#3'- '#0#1#7'Command'#3
+#246#1#8'ShortCut'#2'.'#0#1#7'Command'#3'['#2#8'ShortCut'#3'. '#0#1#7'Comman'
+'d'#3#245#1#8'ShortCut'#2#8#0#1#7'Command'#3#245#1#8'ShortCut'#3#8' '#0#1#7
+'Command'#3#248#1#8'ShortCut'#3#8'@'#0#1#7'Command'#3'Y'#2#8'ShortCut'#4#8
+#128#0#0#0#1#7'Command'#3'Z'#2#8'ShortCut'#4#8#160#0#0#0#1#7'Command'#3#253#1
+#8'ShortCut'#2#13#0#1#7'Command'#3#199#0#8'ShortCut'#3'A@'#0#1#7'Command'#3
+#201#0#8'ShortCut'#3'C@'#0#1#7'Command'#3'b'#2#8'ShortCut'#3'I`'#0#1#7'Comma'
+'nd'#3#253#1#8'ShortCut'#3'M@'#0#1#7'Command'#3#254#1#8'ShortCut'#3'N@'#0#1#7
+'Command'#3#247#1#8'ShortCut'#3'T@'#0#1#7'Command'#3'c'#2#8'ShortCut'#3'U`'#0
+#1#7'Command'#3'\'#2#8'ShortCut'#3'V@'#0#1#7'Command'#3'['#2#8'ShortCut'#3'X'
+'@'#0#1#7'Command'#3#251#1#8'ShortCut'#3'Y@'#0#1#7'Command'#3#250#1#8'ShortC'
,'ut'#3'Y`'#0#1#7'Command'#3'Y'#2#8'ShortCut'#3'Z@'#0#1#7'Command'#3'Z'#2#8'S'
+'hortCut'#3'Z`'#0#1#7'Command'#3'-'#1#8'ShortCut'#3'0@'#0#1#7'Command'#3'.'#1
+#8'ShortCut'#3'1@'#0#1#7'Command'#3'/'#1#8'ShortCut'#3'2@'#0#1#7'Command'#3
+'0'#1#8'ShortCut'#3'3@'#0#1#7'Command'#3'1'#1#8'ShortCut'#3'4@'#0#1#7'Comman'
+'d'#3'2'#1#8'ShortCut'#3'5@'#0#1#7'Command'#3'3'#1#8'ShortCut'#3'6@'#0#1#7'C'
+'ommand'#3'4'#1#8'ShortCut'#3'7@'#0#1#7'Command'#3'5'#1#8'ShortCut'#3'8@'#0#1
+#7'Command'#3'6'#1#8'ShortCut'#3'9@'#0#1#7'Command'#3'_'#1#8'ShortCut'#3'0`'
+#0#1#7'Command'#3'`'#1#8'ShortCut'#3'1`'#0#1#7'Command'#3'a'#1#8'ShortCut'#3
+'2`'#0#1#7'Command'#3'b'#1#8'ShortCut'#3'3`'#0#1#7'Command'#3'c'#1#8'ShortCu'
+'t'#3'4`'#0#1#7'Command'#3'd'#1#8'ShortCut'#3'5`'#0#1#7'Command'#3'e'#1#8'Sh'
+'ortCut'#3'6`'#0#1#7'Command'#3'f'#1#8'ShortCut'#3'7`'#0#1#7'Command'#3'g'#1
+#8'ShortCut'#3'8`'#0#1#7'Command'#3'h'#1#8'ShortCut'#3'9`'#0#1#7'Command'#3
+#231#0#8'ShortCut'#3'N`'#0#1#7'Command'#3#232#0#8'ShortCut'#3'C`'#0#1#7'Comm'
+'and'#3#233#0#8'ShortCut'#3'L`'#0#1#7'Command'#3'd'#2#8'ShortCut'#2#9#0#1#7
+'Command'#3'e'#2#8'ShortCut'#3#9' '#0#1#7'Command'#3#250#0#8'ShortCut'#3'B`'
+#0#0#13'Lines.Strings'#1#6#15'TemplateSynEdit'#0#22'SelectedColor.OnChange'
+#13#6'Cursor'#7#7'crIBeam'#6'Height'#3#128#0#3'Top'#3#195#0#5'Width'#3'J'#2#0
+#0#9'TSplitter'#16'TemplateSplitter'#5'Align'#7#8'alBottom'#6'Cursor'#7#8'cr'
+'VSplit'#6'Height'#2#5#5'Width'#3'J'#2#12'ResizeAnchor'#7#8'akBottom'#6'Curs'
+'or'#7#8'crVSplit'#6'Height'#2#5#3'Top'#3#190#0#5'Width'#3'J'#2#0#0#7'TButto'
+'n'#9'AddButton'#7'Anchors'#11#5'akTop'#7'akRight'#0#25'BorderSpacing.InnerB'
+'order'#2#2#7'Caption'#6#9'AddButton'#7'OnClick'#7#14'AddButtonClick'#8'TabO'
+'rder'#2#2#4'Left'#3#205#1#6'Height'#2#30#5'Width'#2's'#0#0#7'TButton'#12'De'
+'leteButton'#7'Anchors'#11#5'akTop'#7'akRight'#0#25'BorderSpacing.InnerBorde'
+'r'#2#2#7'Caption'#6#12'DeleteButton'#7'OnClick'#7#17'DeleteButtonClick'#8'T'
+'abOrder'#2#3#4'Left'#3#205#1#6'Height'#2#30#3'Top'#2'$'#5'Width'#2's'#0#0#7
+'TButton'#10'EditButton'#7'Anchors'#11#5'akTop'#7'akRight'#0#25'BorderSpacin'
+'g.InnerBorder'#2#2#7'Caption'#6#10'EditButton'#7'OnClick'#7#15'EditButtonCl'
+'ick'#8'TabOrder'#2#4#4'Left'#3#201#1#6'Height'#2#30#3'Top'#2'G'#5'Width'#2
+'ick'#8'TabOrder'#2#4#4'Left'#3#205#1#6'Height'#2#30#3'Top'#2'G'#5'Width'#2
+'s'#0#0#9'TCheckBox'#17'UseMakrosCheckBox'#7'Anchors'#11#5'akTop'#7'akRight'
+#0#7'Caption'#6#17'UseMakrosCheckBox'#8'TabOrder'#2#5#4'Left'#3#170#1#6'Heig'
+'ht'#2#24#3'Top'#2'j'#5'Width'#3#146#0#0#0#0#10'TSynPasSyn'#10'ASynPasSyn'#7
+'Enabled'#8#4'left'#3#24#1#3'top'#3#216#0#0#0#0
+#0#7'Caption'#6#17'UseMakrosCheckBox'#8'TabOrder'#2#5#4'Left'#3#177#1#6'Heig'
+'ht'#2#24#3'Top'#2'j'#5'Width'#3#143#0#0#0#7'TButton'#17'InsertMacroButton'#7
+'Anchors'#11#5'akTop'#7'akRight'#0#25'BorderSpacing.InnerBorder'#2#2#7'Capti'
+'on'#6#17'InsertMacroButton'#7'OnClick'#7#22'InsertMacroButtonClick'#8'TabOr'
+'der'#2#6#4'Left'#3#205#1#6'Height'#2#25#3'Top'#3#141#0#5'Width'#2's'#0#0#0
+#10'TSynPasSyn'#10'ASynPasSyn'#7'Enabled'#8#4'left'#3#24#1#3'top'#3#216#0#0#0
+#0
]);

View File

@ -34,7 +34,7 @@ uses
Classes, SysUtils, LCLProc, LResources, Forms, Controls, Graphics, Dialogs,
ClipBrd, StdCtrls, Buttons, ExtCtrls, Menus,
SynEdit, SynHighlighterPas, SynEditAutoComplete,
IDECommands, TextTools, SrcEditorIntf, MenuIntf,
IDECommands, TextTools, SrcEditorIntf, MenuIntf, IDEWindowIntf,
InputHistory, LazarusIDEStrConsts, EditorOptions, CodeMacroSelect;
type
@ -43,6 +43,7 @@ type
TCodeTemplateDialog = class(TForm)
AddButton: TButton;
InsertMacroButton: TButton;
UseMakrosCheckBox: TCheckBox;
EditButton: TButton;
DeleteButton: TButton;
@ -61,7 +62,9 @@ type
procedure DeleteButtonClick(Sender: TObject);
procedure EditButtonClick(Sender: TObject);
procedure FilenameButtonClick(Sender: TObject);
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure InsertMacroButtonClick(Sender: TObject);
procedure OkButtonClick(Sender: TObject);
procedure OnCopyMenuItem(Sender: TObject);
procedure OnCutMenuItem(Sender: TObject);
@ -72,6 +75,7 @@ type
SynAutoComplete: TSynEditAutoComplete;
LastTemplate: integer;
procedure BuildPopupMenu;
procedure DoInsertMacro;
public
procedure FillCodeTemplateListBox;
procedure ShowCurCodeTemplate;
@ -132,6 +136,10 @@ function CodeMakroLower(const Parameter: string; InteractiveValue: TPersistent;
function CodeMakroPaste(const Parameter: string; InteractiveValue: TPersistent;
SrcEdit: TSourceEditorInterface;
var Value, ErrorMsg: string): boolean;
function CodeMakroProcedureHead(const Parameter: string;
InteractiveValue: TPersistent;
SrcEdit: TSourceEditorInterface;
var Value, ErrorMsg: string): boolean;
const
CodeTemplatesMenuRootName = 'CodeTemplates';
@ -231,6 +239,14 @@ begin
Result:=true;
end;
function CodeMakroProcedureHead(const Parameter: string;
InteractiveValue: TPersistent; SrcEdit: TSourceEditorInterface; var Value,
ErrorMsg: string): boolean;
begin
Result:=true;
end;
procedure RegisterStandardCodeTemplatesMenuItems;
var
Path: string;
@ -256,6 +272,31 @@ begin
RegisterCodeMacro('Paste','paste clipboard',
'Paste text from clipboard',
@CodeMakroPaste,nil);
RegisterCodeMacro('ProcedureHead','insert procedure head',
'Insert header of current procedure'#13
+'Optional Parameters (comma separated):'#13
+'WithStart, // proc keyword e.g. ''function'', ''class procedure'''#13
+'WithoutClassKeyword,// without ''class'' proc keyword'#13
+'AddClassName, // extract/add ClassName.'#13
+'WithoutClassName, // skip classname'#13
+'WithoutName, // skip function name'#13
+'WithoutParamList, // skip param list'#13
+'WithVarModifiers, // extract ''var'', ''out'', ''const'''#13
+'WithParameterNames, // extract parameter names'#13
+'WithoutParamTypes, // skip colon, param types and default values'#13
+'WithDefaultValues, // extract default values'#13
+'WithResultType, // extract colon + result type'#13
+'WithOfObject, // extract ''of object'''#13
+'WithCallingSpecs, // extract cdecl; inline;'#13
+'WithProcModifiers, // extract forward; alias; external;'#13
+'WithComments, // extract comments and spaces'#13
+'InUpperCase, // turn to uppercase'#13
+'CommentsToSpace, // replace comments with a single space'#13
+' // (default is to skip unnecessary space,'#13
+' // e.g ''Do ;'' normally becomes ''Do;'''#13
+' // with this option you get ''Do ;'')'#13
+'WithoutBrackets, // skip start- and end-bracket of parameter list'#13,
@CodeMakroPaste,nil);
end;
{ TCodeTemplateEditForm }
@ -403,6 +444,8 @@ var
s: String;
ColorScheme: String;
begin
IDEDialogLayoutList.ApplyLayout(Self,600,450);
SynAutoComplete:=TSynEditAutoComplete.Create(Self);
LastTemplate:=-1;
@ -454,6 +497,11 @@ begin
BuildPopupMenu;
end;
procedure TCodeTemplateDialog.InsertMacroButtonClick(Sender: TObject);
begin
DoInsertMacro;
end;
procedure TCodeTemplateDialog.OkButtonClick(Sender: TObject);
var
Res: TModalResult;
@ -496,7 +544,7 @@ end;
procedure TCodeTemplateDialog.OnInsertMacroMenuItem(Sender: TObject);
begin
DoInsertMacro;
end;
procedure TCodeTemplateDialog.OnPasteMenuItem(Sender: TObject);
@ -575,6 +623,12 @@ begin
end;
end;
procedure TCodeTemplateDialog.FormClose(Sender: TObject;
var CloseAction: TCloseAction);
begin
IDEDialogLayoutList.SaveLayout(Self);
end;
procedure TCodeTemplateDialog.TemplateListBoxSelectionChange(Sender: TObject;
User: boolean);
begin
@ -598,17 +652,31 @@ begin
PopupMenu:=MainPopupMenu;
end;
procedure TCodeTemplateDialog.FillCodeTemplateListBox;
var a:integer;
procedure TCodeTemplateDialog.DoInsertMacro;
var
Macro: TIDECodeMacro;
begin
with TemplateListBox do begin
Items.BeginUpdate;
Items.Clear;
Macro:=ShowCodeMacroSelectDialog;
if Macro<>nil then begin
TemplateSynEdit.SelText:='$'+Macro.Name+'()';
end;
end;
procedure TCodeTemplateDialog.FillCodeTemplateListBox;
var
a: integer;
sl: TStringList;
begin
sl:=TStringList.Create;
try
for a:=0 to SynAutoComplete.Completions.Count-1 do begin
Items.Add(SynAutoComplete.Completions[a]
sl.Add(SynAutoComplete.Completions[a]
+' - "'+SynAutoComplete.CompletionComments[a]+'"');
end;
Items.EndUpdate;
sl.Sort;
TemplateListBox.Items.Assign(sl);
finally
sl.Free;
end;
end;
@ -632,9 +700,18 @@ var
begin
EnableMakros:=false;
LineCount:=0;
i:=TemplateListBox.ItemIndex;
// search template
if i>=0 then begin
s:=TemplateListBox.Items[i];
sp:=Pos(' ',s);
if sp>0 then
s:=copy(s,1,sp-1);
i:=SynAutoComplete.Completions.IndexOf(s);
end;
TemplateSynEdit.Lines.BeginUpdate;
TemplateSynEdit.Lines.Clear;
i:=TemplateListBox.ItemIndex;
//debugln('TCodeTemplateDialog.ShowCurCodeTemplate A i=',dbgs(i));
if i>=0 then begin
LastTemplate:=-1;

View File

@ -693,6 +693,7 @@ resourcestring
lisLazDoc = 'LazDoc';
lisOkBtn = 'Ok';
dlgCancel = 'Cancel';
lisCTPleaseSelectAMacro = 'please select a macro';
lisA2PCreateNewFile = 'Create new file';
dlgEnvLanguage = 'Language';
dlgAutoSave = 'Auto save';
@ -1847,6 +1848,7 @@ resourcestring
lisTodoListPrintList='Print todo items';
lisToDoListOptions='ToDo options...';
lisToDoLDescription = 'Description';
lisCTInsertMacro = 'Insert Macro';
lisToDoLFile = 'File';
lisToDoLLine = 'Line';
@ -2877,6 +2879,7 @@ resourcestring
lisLazDocExampleTag = 'Example';
lisLazDocBrowseExampleButton = 'Browse';
lisEnableMakros = 'Enable Makros';
lisCTSelectCodeMacro = 'Select Code Macro';
implementation
end.

View File

@ -201,8 +201,6 @@ type
ActiveUnitInfo: TUnitInfo;
NewSource: TCodeBuffer; NewX, NewY, NewTopLine: integer;
AddJumpPoint: boolean): TModalResult; virtual; abstract;
procedure DoJumpToCodeToolBossError; virtual; abstract;
procedure SaveSourceEditorChangesToCodeCache(PageIndex: integer); virtual; abstract;
procedure FindInFilesPerDialog(AProject: TProject); virtual; abstract;
procedure FindInFiles(AProject: TProject; const FindText: string); virtual; abstract;

View File

@ -126,6 +126,9 @@ type
TryWithoutNumber: boolean): string; virtual; abstract;
function SubstituteMakros(var s: string): boolean; virtual; abstract;
procedure DoJumpToCodeToolBossError; virtual; abstract;
procedure SaveSourceEditorChangesToCodeCache(PageIndex: integer); virtual; abstract;
public
property ActiveProject: TLazProject read GetActiveProject;