IDE: Improve EditorMacroListViever.

This commit is contained in:
Juha 2022-03-05 13:31:11 +02:00
parent a1dca01b66
commit 06352700aa
5 changed files with 408 additions and 292 deletions

View File

@ -19,8 +19,7 @@ resourcestring
EMSNotActive = 'Scripting not active. Selftest failed.';
EMSNotActiveVerbose = 'EditorMacroScript failed its self-test and is not active. Some macros may not work.';
EMSActive = 'Scripting active.';
EMSPending = 'Scripting not active. Selftest will run next time the IDE is '
+'started.';
EMSPending = 'Scripting not active. Selftest will run next time the IDE is started.';
implementation

View File

@ -1,41 +1,41 @@
object MacroListView: TMacroListView
Left = 390
Height = 387
Height = 487
Top = 249
Width = 424
Width = 455
Caption = 'MacroListView'
ClientHeight = 387
ClientWidth = 424
Constraints.MinHeight = 365
Constraints.MinWidth = 300
ClientHeight = 487
ClientWidth = 455
Constraints.MinHeight = 450
Constraints.MinWidth = 360
OnActivate = FormActivate
OnDeactivate = FormActivate
LCLVersion = '2.1.0.0'
LCLVersion = '2.3.0.0'
object Panel1: TPanel
AnchorSideRight.Control = pnlButtons
AnchorSideBottom.Control = gbAddMacro
Left = 6
Height = 313
Height = 346
Top = 6
Width = 295
Align = alLeft
Width = 333
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 6
BorderSpacing.Top = 6
BorderSpacing.Right = 6
BevelOuter = bvNone
ClientHeight = 313
ClientWidth = 295
ClientHeight = 346
ClientWidth = 333
TabOrder = 0
object lbMacroView: TListView
Left = 0
Height = 266
Height = 299
Top = 22
Width = 295
Width = 333
Align = alClient
AutoWidthLastColumn = True
Columns = <
item
Width = 291
Width = 311
end>
PopupMenu = PopupMenu1
RowSelect = True
@ -49,7 +49,7 @@ object MacroListView: TMacroListView
Left = 0
Height = 22
Top = 0
Width = 295
Width = 333
AutoSize = True
BorderSpacing.InnerBorder = 1
EdgeBorders = []
@ -69,7 +69,7 @@ object MacroListView: TMacroListView
end
object tbProject: TToolButton
Tag = 1
Left = 78
Left = 89
Top = 0
Caption = 'tbProject'
Grouped = True
@ -78,7 +78,7 @@ object MacroListView: TMacroListView
end
object tbIDE: TToolButton
Tag = 1
Left = 142
Left = 161
Top = 0
Caption = 'tbIDE'
Grouped = True
@ -86,14 +86,14 @@ object MacroListView: TMacroListView
Style = tbsCheck
end
object ToolButton3: TToolButton
Left = 70
Left = 81
Height = 22
Top = 0
Caption = 'ToolButton3'
Style = tbsSeparator
end
object ToolButton4: TToolButton
Left = 134
Left = 153
Height = 22
Top = 0
Caption = 'ToolButton4'
@ -103,8 +103,8 @@ object MacroListView: TMacroListView
object ToolBar2: TToolBar
Left = 0
Height = 22
Top = 291
Width = 295
Top = 324
Width = 333
Align = alBottom
AutoSize = True
BorderSpacing.Top = 3
@ -116,20 +116,19 @@ object MacroListView: TMacroListView
Left = 1
Height = 22
Top = 0
Width = 52
Width = 60
Align = alLeft
Caption = 'lbMoveTo'
Layout = tlCenter
ParentColor = False
end
object tbMoveProject: TToolButton
Left = 53
Left = 61
Top = 0
Caption = 'tbMoveProject'
OnClick = tbMoveProjectClick
end
object tbMoveIDE: TToolButton
Left = 139
Left = 160
Top = 0
Caption = 'tbMoveIDE'
OnClick = tbMoveIDEClick
@ -138,9 +137,9 @@ object MacroListView: TMacroListView
end
object ButtonPanel1: TButtonPanel
Left = 6
Height = 34
Top = 347
Width = 412
Height = 42
Top = 439
Width = 443
OKButton.Name = 'OKButton'
OKButton.DefaultCaption = True
HelpButton.Name = 'HelpButton'
@ -154,187 +153,31 @@ object MacroListView: TMacroListView
ShowButtons = [pbClose, pbHelp]
end
object pnlButtons: TPanel
Left = 307
Height = 319
Top = 0
Width = 117
Align = alRight
AnchorSideTop.Control = Panel1
AnchorSideRight.Side = asrBottom
Left = 345
Height = 307
Top = 22
Width = 110
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Top = 16
BevelOuter = bvNone
ClientHeight = 319
ClientWidth = 117
ClientHeight = 307
ClientWidth = 110
Constraints.MinHeight = 250
TabOrder = 1
object btnSelect: TButton
AnchorSideLeft.Control = pnlButtons
AnchorSideTop.Control = pnlButtons
AnchorSideRight.Control = pnlButtons
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Side = asrBottom
Left = 6
Height = 25
Top = 6
Width = 105
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Left = 6
BorderSpacing.Top = 6
BorderSpacing.Right = 6
Caption = 'btnSelect'
OnClick = btnSelectClick
TabOrder = 0
end
object btnRename: TButton
AnchorSideLeft.Control = pnlButtons
AnchorSideTop.Control = btnSelect
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = pnlButtons
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Side = asrBottom
Left = 6
Height = 25
Top = 37
Width = 105
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Left = 6
BorderSpacing.Top = 6
BorderSpacing.Right = 6
Caption = 'btnRename'
OnClick = btnRenameClick
TabOrder = 1
end
object btnPlay: TButton
AnchorSideLeft.Control = pnlButtons
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = pnlButtons
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = PanelRepeat
Left = 6
Height = 25
Top = 178
Width = 105
Anchors = [akLeft, akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 6
BorderSpacing.Right = 6
BorderSpacing.Bottom = 3
Caption = 'btnPlay'
OnClick = btnPlayClick
TabOrder = 5
end
object btnRecord: TButton
AnchorSideLeft.Control = pnlButtons
AnchorSideTop.Control = btnRename
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = pnlButtons
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = btnRecordStop
Left = 6
Height = 25
Top = 263
Width = 105
Anchors = [akLeft, akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 6
BorderSpacing.Right = 6
BorderSpacing.Bottom = 6
Caption = 'btnRecord'
OnClick = btnRecordClick
TabOrder = 6
end
object btnRecordStop: TButton
AnchorSideLeft.Control = pnlButtons
AnchorSideTop.Control = btnRename
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = pnlButtons
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = pnlButtons
AnchorSideBottom.Side = asrBottom
Left = 6
Height = 25
Top = 294
Width = 105
Anchors = [akLeft, akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 6
BorderSpacing.Right = 6
Caption = 'btnRecordStop'
OnClick = btnRecordStopClick
TabOrder = 7
end
object btnDelete: TButton
AnchorSideLeft.Control = pnlButtons
AnchorSideTop.Control = btnEdit
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = pnlButtons
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Side = asrBottom
Left = 6
Height = 25
Top = 130
Width = 105
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Left = 6
BorderSpacing.Top = 6
BorderSpacing.Right = 6
Caption = 'btnDelete'
OnClick = btnDeleteClick
TabOrder = 4
end
object btnSetKeys: TButton
AnchorSideLeft.Control = pnlButtons
AnchorSideTop.Control = btnRename
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = pnlButtons
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Side = asrBottom
Left = 6
Height = 25
Top = 68
Width = 105
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Left = 6
BorderSpacing.Top = 6
BorderSpacing.Right = 6
Caption = 'btnSetKeys'
OnClick = btnSetKeysClick
TabOrder = 2
end
object btnEdit: TButton
AnchorSideLeft.Control = pnlButtons
AnchorSideTop.Control = btnSetKeys
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = pnlButtons
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Side = asrBottom
Left = 6
Height = 25
Top = 99
Width = 105
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Left = 6
BorderSpacing.Top = 6
BorderSpacing.Right = 6
Caption = 'btnEdit'
OnClick = btnEditClick
TabOrder = 3
end
object PanelRepeat: TPanel
AnchorSideLeft.Control = pnlButtons
AnchorSideTop.Control = btnPlay
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = pnlButtons
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = btnRecord
Left = 6
Height = 54
Top = 206
Width = 105
Anchors = [akLeft, akRight, akBottom]
Height = 61
Top = 243
Width = 98
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Left = 6
BorderSpacing.Top = 3
@ -342,9 +185,9 @@ object MacroListView: TMacroListView
BorderSpacing.Bottom = 3
BevelOuter = bvNone
BorderStyle = bsSingle
ClientHeight = 50
ClientWidth = 101
TabOrder = 8
ClientHeight = 59
ClientWidth = 96
TabOrder = 0
object edRepeat: TSpinEdit
AnchorSideLeft.Control = PanelRepeat
AnchorSideTop.Control = chkRepeat
@ -352,9 +195,9 @@ object MacroListView: TMacroListView
AnchorSideRight.Control = PanelRepeat
AnchorSideRight.Side = asrBottom
Left = 3
Height = 23
Top = 24
Width = 95
Height = 29
Top = 27
Width = 90
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 3
BorderSpacing.Top = 3
@ -370,11 +213,10 @@ object MacroListView: TMacroListView
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = PanelRepeat
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = edRepeat
Left = 3
Height = 19
Top = 2
Width = 95
Height = 21
Top = 3
Width = 90
Anchors = [akLeft, akRight]
BorderSpacing.Left = 3
BorderSpacing.Right = 3
@ -383,53 +225,234 @@ object MacroListView: TMacroListView
TabOrder = 1
end
end
object btnPlay: TBitBtn
AnchorSideLeft.Control = pnlButtons
AnchorSideTop.Control = btnDelete
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = pnlButtons
AnchorSideRight.Side = asrBottom
Left = 6
Height = 33
Top = 207
Width = 98
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Left = 6
BorderSpacing.Top = 12
BorderSpacing.Right = 6
BorderSpacing.Bottom = 3
Caption = 'btnPlay'
OnClick = btnPlayClick
TabOrder = 1
end
object btnDelete: TBitBtn
AnchorSideLeft.Control = pnlButtons
AnchorSideTop.Control = btnEdit
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = pnlButtons
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Side = asrBottom
Left = 6
Height = 33
Top = 162
Width = 98
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Left = 6
BorderSpacing.Top = 6
BorderSpacing.Right = 6
Caption = 'btnDelete'
OnClick = btnDeleteClick
TabOrder = 2
end
object btnEdit: TBitBtn
AnchorSideLeft.Control = pnlButtons
AnchorSideTop.Control = btnSetKeys
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = pnlButtons
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Side = asrBottom
Left = 6
Height = 33
Top = 123
Width = 98
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Left = 6
BorderSpacing.Top = 6
BorderSpacing.Right = 6
Caption = 'btnEdit'
OnClick = btnEditClick
TabOrder = 3
end
object btnSetKeys: TBitBtn
AnchorSideLeft.Control = pnlButtons
AnchorSideTop.Control = btnRename
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = pnlButtons
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Side = asrBottom
Left = 6
Height = 33
Top = 84
Width = 98
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Left = 6
BorderSpacing.Top = 6
BorderSpacing.Right = 6
Caption = 'btnSetKeys'
OnClick = btnSetKeysClick
TabOrder = 4
end
object btnRename: TBitBtn
AnchorSideLeft.Control = pnlButtons
AnchorSideTop.Control = btnSelect
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = pnlButtons
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Side = asrBottom
Left = 6
Height = 33
Top = 45
Width = 98
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Left = 6
BorderSpacing.Top = 6
BorderSpacing.Right = 6
Caption = 'btnRename'
OnClick = btnRenameClick
TabOrder = 5
end
object btnSelect: TBitBtn
AnchorSideLeft.Control = pnlButtons
AnchorSideTop.Control = pnlButtons
AnchorSideRight.Control = pnlButtons
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Side = asrBottom
Left = 6
Height = 33
Top = 6
Width = 98
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Left = 6
BorderSpacing.Top = 6
BorderSpacing.Right = 6
Caption = 'btnSelect'
OnClick = btnSelectClick
TabOrder = 6
end
end
object PanelWarnings: TPanel
Left = 0
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = ButtonPanel1
Left = 6
Height = 22
Top = 319
Width = 424
Align = alBottom
AutoSize = True
Top = 411
Width = 443
Anchors = [akLeft, akRight, akBottom]
BevelOuter = bvNone
ClientHeight = 22
ClientWidth = 424
ClientWidth = 443
TabOrder = 3
Visible = False
object LabelWarning: TLabel
AnchorSideTop.Control = PanelWarnings
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = BtnWarnClose
Left = 0
Height = 22
Top = 0
Width = 401
Align = alClient
Height = 19
Top = 2
Width = 412
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Right = 3
Caption = 'LabelWarning'
Font.Color = clRed
ParentColor = False
ParentFont = False
WordWrap = True
end
object PnlWarnClose: TPanel
Left = 401
object BtnWarnClose: TSpeedButton
AnchorSideTop.Control = PanelWarnings
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = PanelWarnings
AnchorSideRight.Side = asrBottom
Left = 415
Height = 22
Top = 0
Width = 23
Align = alRight
Width = 26
Anchors = [akTop, akRight]
BorderSpacing.Right = 2
OnClick = BtnWarnCloseClick
end
end
object gbAddMacro: TGroupBox
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = pnlButtons
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = PanelWarnings
Left = 6
Height = 56
Top = 355
Width = 449
Anchors = [akLeft, akRight, akBottom]
AutoSize = True
BorderSpacing.Top = 3
Caption = 'gbAddMacro'
ClientHeight = 36
ClientWidth = 447
TabOrder = 4
object btnRecord: TBitBtn
AnchorSideTop.Side = asrBottom
AnchorSideRight.Side = asrBottom
Left = 6
Height = 33
Top = 0
Width = 76
AutoSize = True
BevelOuter = bvNone
ClientHeight = 22
ClientWidth = 23
BorderSpacing.Left = 6
BorderSpacing.Bottom = 3
Caption = 'btnRecord'
OnClick = btnRecordClick
TabOrder = 0
object BtnWarnClose: TSpeedButton
Left = 0
Height = 22
Top = 0
Width = 23
OnClick = BtnWarnCloseClick
end
end
object btnRecordStop: TBitBtn
AnchorSideLeft.Control = btnRecord
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = btnRecord
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Side = asrBottom
Left = 88
Height = 33
Top = 0
Width = 104
AutoSize = True
BorderSpacing.Left = 6
Caption = 'btnRecordStop'
OnClick = btnRecordStopClick
TabOrder = 1
end
object btnAddEditNew: TBitBtn
AnchorSideLeft.Control = btnRecordStop
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = btnRecordStop
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Side = asrBottom
Left = 219
Height = 33
Top = 0
Width = 109
AutoSize = True
BorderSpacing.Left = 27
Caption = 'btnAddEditNew'
OnClick = btnAddEditNewClick
TabOrder = 2
end
end
object PopupMenu1: TPopupMenu
left = 144
top = 72
Left = 144
Top = 72
object mnExport: TMenuItem
Caption = 'New Item1'
OnClick = mnExportClick
@ -443,14 +466,14 @@ object MacroListView: TMacroListView
DefaultExt = '.xml'
Filter = 'xml|*.xml|*|*'
Options = [ofOverwritePrompt, ofHideReadOnly, ofPathMustExist, ofNoReadOnlyReturn, ofEnableSizing, ofViewDetail]
left = 24
top = 56
Left = 24
Top = 56
end
object OpenDialog1: TOpenDialog
DefaultExt = '.xml'
Filter = 'xml|*.xml|*|*'
Options = [ofFileMustExist, ofEnableSizing, ofViewDetail]
left = 88
top = 64
Left = 88
Top = 64
end
end

View File

@ -1,3 +1,26 @@
{
***************************************************************************
* *
* 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., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1335, USA. *
* *
***************************************************************************
Abstract:
A GUI for managing editor macros.
}
unit EditorMacroListViewer;
{$mode objfpc}{$H+}
@ -55,7 +78,6 @@ type
destructor Destroy; override;
procedure AssignEventsFrom(AMacroRecorder: TEditorMacro); override;
function AddEditor(AValue: TCustomSynEdit): integer;
procedure Clear; override;
function GetAsSource: String; override;
@ -170,17 +192,19 @@ type
{ TMacroListView }
TMacroListView = class(TForm)
btnEdit: TButton;
btnSetKeys: TButton;
btnPlay: TButton;
btnRecord: TButton;
btnRecordStop: TButton;
btnDelete: TButton;
btnSelect: TButton;
btnRename: TButton;
btnDelete: TBitBtn;
btnEdit: TBitBtn;
btnPlay: TBitBtn;
btnRecord: TBitBtn;
btnRecordStop: TBitBtn;
btnAddEditNew: TBitBtn;
btnRename: TBitBtn;
btnSelect: TBitBtn;
btnSetKeys: TBitBtn;
BtnWarnClose: TSpeedButton;
ButtonPanel1: TButtonPanel;
chkRepeat: TCheckBox;
GroupBox1: TGroupBox;
gbAddMacro: TGroupBox;
LabelWarning: TLabel;
lbMoveTo: TLabel;
lbMacroView: TListView;
@ -188,7 +212,6 @@ type
mnImport: TMenuItem;
OpenDialog1: TOpenDialog;
Panel1: TPanel;
PnlWarnClose: TPanel;
PanelWarnings: TPanel;
PanelRepeat: TPanel;
pnlButtons: TPanel;
@ -196,7 +219,6 @@ type
RenameButton: TPanelBitBtn;
edRepeat: TSpinEdit;
SaveDialog1: TSaveDialog;
BtnWarnClose: TSpeedButton;
ToolBar1: TToolBar;
tbRecorded: TToolButton;
tbProject: TToolButton;
@ -210,6 +232,7 @@ type
procedure btnEditClick(Sender: TObject);
procedure btnPlayClick(Sender: TObject);
procedure btnRecordClick(Sender: TObject);
procedure btnAddEditNewClick(Sender: TObject);
procedure btnRecordStopClick(Sender: TObject);
procedure btnRenameClick(Sender: TObject);
procedure btnSelectClick(Sender: TObject);
@ -226,6 +249,7 @@ type
procedure tbProjectClick(Sender: TObject);
procedure tbRecordedClick(Sender: TObject);
private
FImageReady: Integer;
FImageRec: Integer;
FImagePlay: Integer;
FImageSel: Integer;
@ -295,22 +319,19 @@ var
const
GlobalConfFileName = 'EditorMacros.xml';
procedure DoMacroListViewerWarningChanged({%H-}Sender: TObject);
begin
if MacroListView = nil then exit;
MacroListView.LabelWarning.Caption := MacroListViewerWarningText;
MacroListView.PanelWarnings.Visible := MacroListViewerWarningText <> '';
end;
function MacroListViewer: TMacroListView;
begin
if MacroListView = nil then
MacroListView := TMacroListView.Create(Application);
Result := MacroListView;
MacroListView.LabelWarning.Caption := MacroListViewerWarningText;
MacroListView.PanelWarnings.Visible := MacroListViewerWarningText <> '';
end;
procedure DoMacroListViewerWarningChanged({%H-}ASender: TObject);
begin
if MacroListView <> nil then begin
MacroListView.LabelWarning.Caption := MacroListViewerWarningText;
MacroListView.PanelWarnings.Visible := MacroListViewerWarningText <> '';
end;
DoMacroListViewerWarningChanged(nil);
end;
procedure ShowMacroListViewer;
@ -678,7 +699,6 @@ end;
procedure TIdeEditorMacro.Clear;
begin
FSynMacro.Clear;
DoChanged;
end;
@ -1119,7 +1139,8 @@ begin
if se = nil then Exit;
i := 1;
if chkRepeat.Checked then i := edRepeat.Value;
if chkRepeat.Checked then
i := edRepeat.Value;
FIsPlaying := True;
UpdateButtons;
@ -1143,12 +1164,11 @@ var
m: TEditorMacro;
begin
if lbMacroView.ItemIndex < 0 then exit;
if IDEMessageDialog(lisReallyDelete, lisDeleteSelectedMacro, mtConfirmation, [
mbYes, mbNo]) = mrYes
if IDEMessageDialog(lisReallyDelete, lisDeleteSelectedMacro, mtConfirmation,
[mbYes, mbNo]) = mrYes
then begin
if SelectedEditorMacro = CurrentEditorMacroList.Macros[lbMacroView.ItemIndex] then begin
if SelectedEditorMacro = CurrentEditorMacroList.Macros[lbMacroView.ItemIndex] then
SelectedEditorMacro := nil;
end;
m := CurrentEditorMacroList.Macros[lbMacroView.ItemIndex];
CurrentEditorMacroList.Delete(lbMacroView.ItemIndex);
m.Free;
@ -1176,8 +1196,14 @@ var
begin
se := SourceEditorManagerIntf.ActiveEditor;
if se = nil then Exit;
if CurrentEditorMacroList <> EditorMacroListRec then
begin
tbRecorded.Down := True; // Switch to "recorded" page when recording.
tbRecorded.Click;
end;
lbMacroView.ItemIndex := -1;
if (ActiveEditorMacro = nil) and (EditorMacroForRecording.State = emStopped) then
EditorMacroForRecording.RecordMacro(TCustomSynEdit(se.EditorControl))
EditorMacroForRecording.RecordMacro(se.EditorControl)
else
if EditorMacroForRecording.State = emRecording then
EditorMacroForRecording.Pause
@ -1191,6 +1217,30 @@ procedure TMacroListView.btnRecordStopClick(Sender: TObject);
begin
FIsPlaying := False;
EditorMacroForRecording.Stop;
UpdateButtons;
end;
procedure TMacroListView.btnAddEditNewClick(Sender: TObject);
var
se: TSourceEditorInterface;
M: TEditorMacro;
begin
se := SourceEditorManagerIntf.ActiveEditor;
Assert(Assigned(se) and (ActiveEditorMacro=nil) and (EditorMacroForRecording.State=emStopped),
'TMacroListView.btnAddEditNewClick: Problem');
lbMacroView.ItemIndex := -1;
M := TIdeEditorMacro.Create(nil);
M.OnStateChange := @MacroListViewer.DoMacroStateChanged;
M.OnChange := @MacroListViewer.DoMacroContentChanged;
M.MacroName := Format(lisNewMacroName, [MacroRecCounter]);
inc(MacroRecCounter);
CurrentEditorMacroList.Add(M);
Assert(not FIsPlaying, 'TMacroListView.btnAddEditNewClick: IsPlaying');
LazarusIDE.DoOpenEditorFile(
EditorMacroVirtualDrive+MacroListToName(CurrentEditorMacroList)+'|'+M.MacroName,
-1, -1, [ofVirtualFile, ofInternalFile]);
UpdateDisplay;
end;
procedure TMacroListView.btnSelectClick(Sender: TObject);
@ -1239,7 +1289,9 @@ end;
procedure TMacroListView.FormActivate(Sender: TObject);
begin
lbMacroView.HideSelection := Active;
DebugLn(['TMacroListView.FormActivate: Active=', Active]);
lbMacroView.HideSelection := Active; // Active = False always ?
UpdateButtons;
end;
procedure TMacroListView.HelpButtonClick(Sender: TObject);
@ -1343,7 +1395,6 @@ end;
procedure TMacroListView.DoOnMacroListChange(Sender: TObject);
begin
UpdateDisplay;
if Sender = EditorMacroListProj then
Project1.SessionModified := True;
end;
@ -1428,14 +1479,24 @@ begin
btnRecord.Enabled := Assigned(SourceEditorManagerIntf.ActiveEditor)
and (RecState in [emStopped, emRecPaused, emRecording])
and (not FIsPlaying);
btnAddEditNew.Enabled := Assigned(SourceEditorManagerIntf.ActiveEditor)
and (RecState = emStopped) and not FIsPlaying;
btnRecordStop.Enabled := (not IsStopped) or FIsPlaying;
if (RecState = emRecording) then
btnRecord.Caption := lisPause
begin
btnRecord.Caption := lisPause;
btnRecord.ImageIndex := FImageRec;
end
else if (RecState = emRecPaused) then
btnRecord.Caption := lisContinue
else
begin
btnRecord.Caption := lisContinue;
btnRecord.ImageIndex := FImageReady;
end
else begin
btnRecord.Caption := lisRecord;
btnRecord.ImageIndex := FImageReady;
end;
mnImport.Enabled := IsStopped and (not FIsPlaying);
mnExport.Enabled := IsStopped and IsSel and (not FIsPlaying);
@ -1492,32 +1553,64 @@ begin
tbMoveIDE.Caption := lisIDE;
lbMoveTo.Caption := lisMoveTo + ' '; // Anchors do not work here. Use spaces.
// Preloaded images
lbMacroView.SmallImages := IDEImages.Images_16;
FImageReady := IDEImages.LoadImage('InactiveBreakPoint'); // green dot
FImageRec := IDEImages.LoadImage('Record'); // red dot
FImagePlay := IDEImages.LoadImage('menu_run'); // green triangle
FImageSel := IDEImages.LoadImage('arrow_right');
FImageErr := IDEImages.LoadImage('state_error');
// Controls in pnlButtons
btnSelect.Caption := lisMakeCurrent;
btnSelect.Images := IDEImages.Images_16;
btnSelect.ImageIndex := IDEImages.LoadImage('btn_ok');
btnRename.Caption := lisRename2;
btnRename.Images := IDEImages.Images_16;
btnRename.ImageIndex := IDEImages.LoadImage('laz_edit');
btnSetKeys.Caption := lisEditKey;
btnEdit.Caption := lisEdit;
btnSetKeys.Images := IDEImages.Images_16;
btnSetKeys.ImageIndex := IDEImages.LoadImage('item_character');
btnEdit.Caption := lisEdit;
btnEdit.Images := IDEImages.Images_16;
btnEdit.ImageIndex := IDEImages.LoadImage('show_source');
btnDelete.Caption := lisDelete;
btnDelete.Images := IDEImages.Images_16;
btnDelete.ImageIndex := IDEImages.LoadImage('laz_delete');
btnPlay.Caption := lisPlay;
btnPlay.Images := IDEImages.Images_16;
btnPlay.ImageIndex := IDEImages.LoadImage('menu_run');
chkRepeat.Caption := lisRepeat;
// Add new macro
gbAddMacro.Caption := lisAddNewMacro;
btnRecord.Caption := lisRecord;
btnRecord.Images := IDEImages.Images_16;
btnRecord.ImageIndex := FImageReady;
btnRecordStop.Caption := lisStop;
btnRecordStop.Images := IDEImages.Images_16;
btnRecordStop.ImageIndex := IDEImages.LoadImage('menu_stop');
btnAddEditNew.Caption := lisCreateAndEdit;
btnAddEditNew.Images := IDEImages.Images_16;
btnAddEditNew.ImageIndex := IDEImages.LoadImage('laz_add');
// Warning
BtnWarnClose.Images := IDEImages.Images_16;
BtnWarnClose.ImageIndex := IDEImages.LoadImage('menu_close');
SaveDialog1.Title := lisSaveMacroAs;
OpenDialog1.Title := lisLoadMacroFrom;
mnImport.Caption := lisDlgImport;
mnExport.Caption := lisDlgExport;
lbMacroView.SmallImages := IDEImages.Images_16;
FImageRec := IDEImages.LoadImage('Record'); // red dot
FImagePlay := IDEImages.LoadImage('menu_run'); // green triangle
FImageSel := IDEImages.LoadImage('arrow_right');
FImageErr := IDEImages.LoadImage('state_error');
FIsPlaying := False;
BtnWarnClose.Images := IDEImages.Images_16;
BtnWarnClose.ImageIndex := IDEImages.LoadImage('menu_close');
UpdateDisplay;
end;
destructor TMacroListView.Destroy;

View File

@ -6383,6 +6383,7 @@ resourcestring
lisPlay = 'Play';
lisRecord = 'Record';
lisRepeat = 'Repeat';
lisCreateAndEdit = 'Create and edit';
lisDeleteSelectedMacro = 'Delete selected macro?';
lisReallyDelete = 'Really delete?';
lisSaveMacroAs = 'Save macro as';

View File

@ -276,8 +276,8 @@ type
procedure EditorMouseMoved(Sender: TObject; Shift: TShiftState; X,Y:Integer);
procedure EditorMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X,Y: Integer);
procedure EditorMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure EditorMouseUp(Sender: TObject; {%H-}Button: TMouseButton;
{%H-}Shift: TShiftState; {%H-}X, {%H-}Y: Integer);
procedure EditorMouseWheel(Sender: TObject; Shift: TShiftState;
WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
procedure EditorKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);