mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-09 10:47:58 +02:00
started IDE code macro selector
git-svn-id: trunk@8100 -
This commit is contained in:
parent
cce0d7d024
commit
eee77db4e6
3
.gitattributes
vendored
3
.gitattributes
vendored
@ -839,6 +839,9 @@ ide/codeexplorer.pas svneol=native#text/pascal
|
||||
ide/codemacroprompt.lfm svneol=native#text/plain
|
||||
ide/codemacroprompt.lrs svneol=native#text/plain
|
||||
ide/codemacroprompt.pas svneol=native#text/plain
|
||||
ide/codemacroselect.lfm svneol=native#text/plain
|
||||
ide/codemacroselect.lrs svneol=native#text/plain
|
||||
ide/codemacroselect.pas svneol=native#text/plain
|
||||
ide/codetemplatesdlg.lfm svneol=native#text/plain
|
||||
ide/codetemplatesdlg.lrs svneol=native#text/plain
|
||||
ide/codetemplatesdlg.pas svneol=native#text/pascal
|
||||
|
73
ide/codemacroselect.lfm
Normal file
73
ide/codemacroselect.lfm
Normal file
@ -0,0 +1,73 @@
|
||||
object CodeMacroSelectDlg: TCodeMacroSelectDlg
|
||||
ActiveControl = MacrosListBox
|
||||
Caption = 'CodeMacroSelectDlg'
|
||||
ClientHeight = 261
|
||||
ClientWidth = 400
|
||||
OnCreate = FormCreate
|
||||
PixelsPerInch = 112
|
||||
HorzScrollBar.Page = 399
|
||||
VertScrollBar.Page = 260
|
||||
Left = 318
|
||||
Height = 261
|
||||
Top = 200
|
||||
Width = 400
|
||||
object MacrosGroupBox: TGroupBox
|
||||
Anchors = [akTop, akLeft, akBottom]
|
||||
Caption = 'MacrosGroupBox'
|
||||
ClientHeight = 184
|
||||
ClientWidth = 166
|
||||
ParentColor = True
|
||||
TabOrder = 0
|
||||
Left = 10
|
||||
Height = 201
|
||||
Top = 10
|
||||
Width = 170
|
||||
object MacrosListBox: TListBox
|
||||
Align = alClient
|
||||
TabOrder = 0
|
||||
TopIndex = -1
|
||||
Height = 184
|
||||
Width = 166
|
||||
end
|
||||
end
|
||||
object DescriptionGroupBox: TGroupBox
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
Caption = 'DescriptionGroupBox'
|
||||
ClientHeight = 184
|
||||
ClientWidth = 196
|
||||
ParentColor = True
|
||||
TabOrder = 1
|
||||
Left = 190
|
||||
Height = 201
|
||||
Top = 10
|
||||
Width = 200
|
||||
end
|
||||
object OkButton: TButton
|
||||
Anchors = [akTop, akRight]
|
||||
AutoSize = True
|
||||
BorderSpacing.Right = 10
|
||||
BorderSpacing.InnerBorder = 2
|
||||
Caption = 'OkButton'
|
||||
ModalResult = 1
|
||||
TabOrder = 2
|
||||
AnchorSideTop.Control = CancelButton
|
||||
AnchorSideTop.Side = asrCenter
|
||||
AnchorSideRight.Control = CancelButton
|
||||
Left = 234
|
||||
Height = 26
|
||||
Top = 221
|
||||
Width = 61
|
||||
end
|
||||
object CancelButton: TButton
|
||||
Anchors = [akRight, akBottom]
|
||||
AutoSize = True
|
||||
BorderSpacing.InnerBorder = 2
|
||||
Caption = 'CancelButton'
|
||||
ModalResult = 2
|
||||
TabOrder = 3
|
||||
Left = 305
|
||||
Height = 26
|
||||
Top = 221
|
||||
Width = 85
|
||||
end
|
||||
end
|
26
ide/codemacroselect.lrs
Normal file
26
ide/codemacroselect.lrs
Normal file
@ -0,0 +1,26 @@
|
||||
{ This is an automatically generated lazarus resource file }
|
||||
|
||||
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
|
||||
]);
|
73
ide/codemacroselect.pas
Normal file
73
ide/codemacroselect.pas
Normal file
@ -0,0 +1,73 @@
|
||||
{
|
||||
***************************************************************************
|
||||
* *
|
||||
* This source is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This code is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* General Public License for more details. *
|
||||
* *
|
||||
* A copy of the GNU General Public License is available on the World *
|
||||
* Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also *
|
||||
* obtain it by writing to the Free Software Foundation, *
|
||||
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
Author: Mattias Gaertner
|
||||
|
||||
Abstract:
|
||||
Dialog to select a macro.
|
||||
}
|
||||
unit CodeMacroSelect;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, StdCtrls,
|
||||
Buttons, SrcEditorIntf;
|
||||
|
||||
type
|
||||
|
||||
{ TCodeMacroSelectDlg }
|
||||
|
||||
TCodeMacroSelectDlg = class(TForm)
|
||||
MacrosListBox: TListBox;
|
||||
OkButton: TButton;
|
||||
CancelButton: TButton;
|
||||
MacrosGroupBox: TGroupBox;
|
||||
DescriptionGroupBox: TGroupBox;
|
||||
procedure FormCreate(Sender: TObject);
|
||||
private
|
||||
{ private declarations }
|
||||
public
|
||||
{ public declarations }
|
||||
end;
|
||||
|
||||
var
|
||||
CodeMacroSelectDlg: TCodeMacroSelectDlg;
|
||||
|
||||
implementation
|
||||
|
||||
{ TCodeMacroSelectDlg }
|
||||
|
||||
procedure TCodeMacroSelectDlg.FormCreate(Sender: TObject);
|
||||
begin
|
||||
Caption:='Select Code Macro';
|
||||
MacrosGroupBox.Caption:='Macros';
|
||||
DescriptionGroupBox.Caption:='Description';
|
||||
OkButton.Caption:='Insert Macro';
|
||||
CancelButton.Caption:='Cancel';
|
||||
end;
|
||||
|
||||
initialization
|
||||
{$I codemacroselect.lrs}
|
||||
|
||||
end.
|
||||
|
@ -494,7 +494,7 @@ object CodeTemplateDialog: TCodeTemplateDialog
|
||||
end
|
||||
object ASynPasSyn: TSynPasSyn
|
||||
Enabled = False
|
||||
left = 277
|
||||
left = 280
|
||||
top = 216
|
||||
end
|
||||
end
|
||||
|
@ -96,5 +96,5 @@ LazarusResources.Add('TCodeTemplateDialog','FORMDATA',[
|
||||
+'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#21#1#3'top'#3#216#0#0#0#0
|
||||
+'Enabled'#8#4'left'#3#24#1#3'top'#3#216#0#0#0#0
|
||||
]);
|
||||
|
@ -32,10 +32,10 @@ interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, LCLProc, LResources, Forms, Controls, Graphics, Dialogs,
|
||||
ClipBrd, StdCtrls, Buttons, ExtCtrls,
|
||||
ClipBrd, StdCtrls, Buttons, ExtCtrls, Menus,
|
||||
SynEdit, SynHighlighterPas, SynEditAutoComplete,
|
||||
IDECommands, TextTools, SrcEditorIntf, MacroIntf,
|
||||
InputHistory, LazarusIDEStrConsts, EditorOptions;
|
||||
IDECommands, TextTools, SrcEditorIntf, MenuIntf,
|
||||
InputHistory, LazarusIDEStrConsts, EditorOptions, CodeMacroSelect;
|
||||
|
||||
type
|
||||
|
||||
@ -56,16 +56,22 @@ type
|
||||
FilenameButton: TButton;
|
||||
FilenameEdit: TEdit;
|
||||
FilenameGroupBox: TGroupBox;
|
||||
MainPopupMenu: TPopupMenu;
|
||||
procedure AddButtonClick(Sender: TObject);
|
||||
procedure DeleteButtonClick(Sender: TObject);
|
||||
procedure EditButtonClick(Sender: TObject);
|
||||
procedure FilenameButtonClick(Sender: TObject);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure OkButtonClick(Sender: TObject);
|
||||
procedure OnCopyMenuItem(Sender: TObject);
|
||||
procedure OnCutMenuItem(Sender: TObject);
|
||||
procedure OnInsertMacroMenuItem(Sender: TObject);
|
||||
procedure OnPasteMenuItem(Sender: TObject);
|
||||
procedure TemplateListBoxSelectionChange(Sender: TObject; User: boolean);
|
||||
private
|
||||
SynAutoComplete: TSynEditAutoComplete;
|
||||
LastTemplate: integer;
|
||||
procedure BuildPopupMenu;
|
||||
public
|
||||
procedure FillCodeTemplateListBox;
|
||||
procedure ShowCurCodeTemplate;
|
||||
@ -127,6 +133,17 @@ function CodeMakroPaste(const Parameter: string; InteractiveValue: TPersistent;
|
||||
SrcEdit: TSourceEditorInterface;
|
||||
var Value, ErrorMsg: string): boolean;
|
||||
|
||||
const
|
||||
CodeTemplatesMenuRootName = 'CodeTemplates';
|
||||
|
||||
var
|
||||
CodeTemplateCopyIDEMenuCommand: TIDEMenuCommand;
|
||||
CodeTemplateCutIDEMenuCommand: TIDEMenuCommand;
|
||||
CodeTemplatePasteIDEMenuCommand: TIDEMenuCommand;
|
||||
CodeTemplateInsertMacroIDEMenuCommand: TIDEMenuCommand;
|
||||
|
||||
procedure RegisterStandardCodeTemplatesMenuItems;
|
||||
|
||||
implementation
|
||||
|
||||
function ShowCodeTemplateDialog: TModalResult;
|
||||
@ -214,6 +231,19 @@ begin
|
||||
Result:=true;
|
||||
end;
|
||||
|
||||
procedure RegisterStandardCodeTemplatesMenuItems;
|
||||
var
|
||||
Path: string;
|
||||
begin
|
||||
CodeTemplatesMenuRoot := RegisterIDEMenuRoot(CodeTemplatesMenuRootName);
|
||||
Path := CodeTemplatesMenuRoot.Name;
|
||||
CodeTemplateCutIDEMenuCommand := RegisterIDEMenuCommand(Path,'Cut','Cut');
|
||||
CodeTemplateCopyIDEMenuCommand := RegisterIDEMenuCommand(Path,'Copy','Copy');
|
||||
CodeTemplatePasteIDEMenuCommand := RegisterIDEMenuCommand(Path,'Paste','Paste');
|
||||
CodeTemplateInsertMacroIDEMenuCommand := RegisterIDEMenuCommand(Path,
|
||||
'InsertMacro','Insert Macro');
|
||||
end;
|
||||
|
||||
procedure CreateStandardCodeMacros;
|
||||
begin
|
||||
IDECodeMacros:=TLazCodeMacros.Create;
|
||||
@ -420,6 +450,8 @@ begin
|
||||
ItemIndex:=0;
|
||||
ShowCurCodeTemplate;
|
||||
end;
|
||||
|
||||
BuildPopupMenu;
|
||||
end;
|
||||
|
||||
procedure TCodeTemplateDialog.OkButtonClick(Sender: TObject);
|
||||
@ -452,6 +484,26 @@ begin
|
||||
ModalResult:=mrOk;
|
||||
end;
|
||||
|
||||
procedure TCodeTemplateDialog.OnCopyMenuItem(Sender: TObject);
|
||||
begin
|
||||
TemplateSynEdit.CopyToClipboard;
|
||||
end;
|
||||
|
||||
procedure TCodeTemplateDialog.OnCutMenuItem(Sender: TObject);
|
||||
begin
|
||||
TemplateSynEdit.CutToClipboard;
|
||||
end;
|
||||
|
||||
procedure TCodeTemplateDialog.OnInsertMacroMenuItem(Sender: TObject);
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
procedure TCodeTemplateDialog.OnPasteMenuItem(Sender: TObject);
|
||||
begin
|
||||
TemplateSynEdit.PasteFromClipboard;
|
||||
end;
|
||||
|
||||
procedure TCodeTemplateDialog.AddButtonClick(Sender: TObject);
|
||||
var
|
||||
Token: String;
|
||||
@ -530,6 +582,22 @@ begin
|
||||
ShowCurCodeTemplate;
|
||||
end;
|
||||
|
||||
procedure TCodeTemplateDialog.BuildPopupMenu;
|
||||
begin
|
||||
CodeTemplateCopyIDEMenuCommand.OnClick:=@OnCopyMenuItem;
|
||||
CodeTemplateCutIDEMenuCommand.OnClick:=@OnCutMenuItem;
|
||||
CodeTemplatePasteIDEMenuCommand.OnClick:=@OnPasteMenuItem;
|
||||
CodeTemplateInsertMacroIDEMenuCommand.OnClick:=@OnInsertMacroMenuItem;
|
||||
|
||||
// assign the root TMenuItem to the registered menu root.
|
||||
MainPopupMenu:=TPopupMenu.Create(Self);
|
||||
// This will automatically create all registered items
|
||||
CodeTemplatesMenuRoot.MenuItem := MainPopupMenu.Items;
|
||||
//MainPopupMenu.Items.WriteDebugReport('TMessagesView.Create ');
|
||||
|
||||
PopupMenu:=MainPopupMenu;
|
||||
end;
|
||||
|
||||
procedure TCodeTemplateDialog.FillCodeTemplateListBox;
|
||||
var a:integer;
|
||||
begin
|
||||
|
@ -1751,6 +1751,7 @@ begin
|
||||
RegisterStandardSourceEditorMenuItems;
|
||||
RegisterStandardMessagesViewMenuItems;
|
||||
RegisterStandardCodeExplorerMenuItems;
|
||||
RegisterStandardCodeTemplatesMenuItems;
|
||||
end;
|
||||
|
||||
procedure TMainIDE.SetupStandardProjectTypes;
|
||||
|
@ -380,6 +380,8 @@ var
|
||||
// CodeExplorer window popupmenu
|
||||
CodeExplorerMenuRoot: TIDEMenuSection;
|
||||
|
||||
// Messages window popupmenu
|
||||
CodeTemplatesMenuRoot: TIDEMenuSection;
|
||||
|
||||
function RegisterIDEMenuRoot(const Name: string; MenuItem: TMenuItem = nil
|
||||
): TIDEMenuSection;
|
||||
|
Loading…
Reference in New Issue
Block a user