EditorMacros: Allow editing of macros

git-svn-id: trunk@38360 -
This commit is contained in:
martin 2012-08-25 01:02:55 +00:00
parent e191d86627
commit 48333d8333
6 changed files with 225 additions and 54 deletions

View File

@ -1,12 +1,12 @@
object MacroListView: TMacroListView object MacroListView: TMacroListView
Left = 390 Left = 390
Height = 330 Height = 365
Top = 249 Top = 249
Width = 340 Width = 340
Caption = 'MacroListView' Caption = 'MacroListView'
ClientHeight = 330 ClientHeight = 365
ClientWidth = 340 ClientWidth = 340
Constraints.MinHeight = 330 Constraints.MinHeight = 365
Constraints.MinWidth = 300 Constraints.MinWidth = 300
OnActivate = FormActivate OnActivate = FormActivate
OnDeactivate = FormActivate OnDeactivate = FormActivate
@ -14,7 +14,7 @@ object MacroListView: TMacroListView
object Panel1: TPanel object Panel1: TPanel
AnchorSideRight.Control = pnlButtons AnchorSideRight.Control = pnlButtons
Left = 6 Left = 6
Height = 278 Height = 313
Top = 6 Top = 6
Width = 211 Width = 211
Align = alLeft Align = alLeft
@ -23,12 +23,12 @@ object MacroListView: TMacroListView
BorderSpacing.Top = 6 BorderSpacing.Top = 6
BorderSpacing.Right = 6 BorderSpacing.Right = 6
BevelOuter = bvNone BevelOuter = bvNone
ClientHeight = 278 ClientHeight = 313
ClientWidth = 211 ClientWidth = 211
TabOrder = 0 TabOrder = 0
object lbRecordedView: TListView object lbRecordedView: TListView
Left = 0 Left = 0
Height = 229 Height = 264
Top = 24 Top = 24
Width = 211 Width = 211
Align = alClient Align = alClient
@ -89,7 +89,7 @@ object MacroListView: TMacroListView
object ToolBar2: TToolBar object ToolBar2: TToolBar
Left = 0 Left = 0
Height = 22 Height = 22
Top = 256 Top = 291
Width = 211 Width = 211
Align = alBottom Align = alBottom
AutoSize = True AutoSize = True
@ -125,7 +125,7 @@ object MacroListView: TMacroListView
object ButtonPanel1: TButtonPanel object ButtonPanel1: TButtonPanel
Left = 6 Left = 6
Height = 34 Height = 34
Top = 290 Top = 325
Width = 328 Width = 328
OKButton.Name = 'OKButton' OKButton.Name = 'OKButton'
OKButton.DefaultCaption = True OKButton.DefaultCaption = True
@ -141,13 +141,13 @@ object MacroListView: TMacroListView
end end
object pnlButtons: TPanel object pnlButtons: TPanel
Left = 223 Left = 223
Height = 284 Height = 319
Top = 0 Top = 0
Width = 117 Width = 117
Align = alRight Align = alRight
AutoSize = True AutoSize = True
BevelOuter = bvNone BevelOuter = bvNone
ClientHeight = 284 ClientHeight = 319
ClientWidth = 117 ClientWidth = 117
Constraints.MinHeight = 250 Constraints.MinHeight = 250
TabOrder = 2 TabOrder = 2
@ -172,14 +172,14 @@ object MacroListView: TMacroListView
end end
object btnRename: TButton object btnRename: TButton
AnchorSideLeft.Control = pnlButtons AnchorSideLeft.Control = pnlButtons
AnchorSideTop.Control = btnSetKeys AnchorSideTop.Control = btnSelect
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = pnlButtons AnchorSideRight.Control = pnlButtons
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 6 Left = 6
Height = 25 Height = 25
Top = 68 Top = 37
Width = 105 Width = 105
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
AutoSize = True AutoSize = True
@ -198,7 +198,7 @@ object MacroListView: TMacroListView
AnchorSideBottom.Control = chkRepeat AnchorSideBottom.Control = chkRepeat
Left = 6 Left = 6
Height = 25 Height = 25
Top = 145 Top = 180
Width = 105 Width = 105
Anchors = [akLeft, akRight, akBottom] Anchors = [akLeft, akRight, akBottom]
AutoSize = True AutoSize = True
@ -218,7 +218,7 @@ object MacroListView: TMacroListView
AnchorSideBottom.Control = btnRecordStop AnchorSideBottom.Control = btnRecordStop
Left = 6 Left = 6
Height = 25 Height = 25
Top = 228 Top = 263
Width = 105 Width = 105
Anchors = [akLeft, akRight, akBottom] Anchors = [akLeft, akRight, akBottom]
AutoSize = True AutoSize = True
@ -239,7 +239,7 @@ object MacroListView: TMacroListView
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 6 Left = 6
Height = 25 Height = 25
Top = 259 Top = 294
Width = 105 Width = 105
Anchors = [akLeft, akRight, akBottom] Anchors = [akLeft, akRight, akBottom]
AutoSize = True AutoSize = True
@ -258,7 +258,7 @@ object MacroListView: TMacroListView
AnchorSideBottom.Control = edRepeat AnchorSideBottom.Control = edRepeat
Left = 6 Left = 6
Height = 19 Height = 19
Top = 173 Top = 208
Width = 105 Width = 105
Anchors = [akLeft, akRight, akBottom] Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 6 BorderSpacing.Left = 6
@ -277,7 +277,7 @@ object MacroListView: TMacroListView
AnchorSideBottom.Control = btnRecord AnchorSideBottom.Control = btnRecord
Left = 6 Left = 6
Height = 23 Height = 23
Top = 195 Top = 230
Width = 105 Width = 105
Anchors = [akLeft, akRight, akBottom] Anchors = [akLeft, akRight, akBottom]
AutoSize = False AutoSize = False
@ -291,6 +291,26 @@ object MacroListView: TMacroListView
Value = 1 Value = 1
end end
object btnDelete: TButton 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 = 7
end
object btnSetKeys: TButton
AnchorSideLeft.Control = pnlButtons AnchorSideLeft.Control = pnlButtons
AnchorSideTop.Control = btnRename AnchorSideTop.Control = btnRename
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
@ -299,6 +319,26 @@ object MacroListView: TMacroListView
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 6 Left = 6
Height = 25 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 = 8
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 Top = 99
Width = 105 Width = 105
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
@ -306,29 +346,9 @@ object MacroListView: TMacroListView
BorderSpacing.Left = 6 BorderSpacing.Left = 6
BorderSpacing.Top = 6 BorderSpacing.Top = 6
BorderSpacing.Right = 6 BorderSpacing.Right = 6
Caption = 'btnDelete' Caption = 'btnEdit'
OnClick = btnDeleteClick OnClick = btnEditClick
TabOrder = 7 TabOrder = 9
end
object btnSetKeys: 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 = 'btnSetKeys'
OnClick = btnSetKeysClick
TabOrder = 8
end end
end end
object PopupMenu1: TPopupMenu object PopupMenu1: TPopupMenu

View File

@ -9,7 +9,7 @@ uses
FileProcs, Forms, Controls, Graphics, Dialogs, StdCtrls, ButtonPanel, ComCtrls, ExtCtrls, FileProcs, Forms, Controls, Graphics, Dialogs, StdCtrls, ButtonPanel, ComCtrls, ExtCtrls,
Spin, Menus, LCLType, MainBar, IDEWindowIntf, IDEImagesIntf, LazarusIDEStrConsts, Spin, Menus, LCLType, MainBar, IDEWindowIntf, IDEImagesIntf, LazarusIDEStrConsts,
ProjectDefs, LazConf, Project, KeyMapping, KeyMapShortCutDlg, SrcEditorIntf, IDEHelpIntf, ProjectDefs, LazConf, Project, KeyMapping, KeyMapShortCutDlg, SrcEditorIntf, IDEHelpIntf,
IDECommands; IDECommands, LazIDEIntf;
type type
@ -36,8 +36,6 @@ type
property HasError: Boolean read FHasError; property HasError: Boolean read FHasError;
end; end;
{ TSynMacroEventWriter }
{ TIdeMacroEventWriter } { TIdeMacroEventWriter }
TIdeMacroEventWriter = class(TSynMacroEventWriter) TIdeMacroEventWriter = class(TSynMacroEventWriter)
@ -105,6 +103,8 @@ type
procedure ClearAndFreeMacros; procedure ClearAndFreeMacros;
function Count: Integer; function Count: Integer;
function IndexOf(AMacro: TEditorMacro): Integer; function IndexOf(AMacro: TEditorMacro): Integer;
function IndexOfName(AName: String): Integer;
function UniqName(AName: String): String;
function Add(AMacro: TEditorMacro): Integer; function Add(AMacro: TEditorMacro): Integer;
procedure Delete(AnIndex: Integer); procedure Delete(AnIndex: Integer);
procedure Remove(AMacro: TEditorMacro); procedure Remove(AMacro: TEditorMacro);
@ -117,6 +117,7 @@ type
{ TMacroListView } { TMacroListView }
TMacroListView = class(TForm) TMacroListView = class(TForm)
btnEdit: TButton;
btnSetKeys: TButton; btnSetKeys: TButton;
btnPlay: TButton; btnPlay: TButton;
btnRecord: TButton; btnRecord: TButton;
@ -145,6 +146,7 @@ type
tbMoveProject: TToolButton; tbMoveProject: TToolButton;
tbMoveIDE: TToolButton; tbMoveIDE: TToolButton;
procedure btnDeleteClick(Sender: TObject); procedure btnDeleteClick(Sender: TObject);
procedure btnEditClick(Sender: TObject);
procedure btnPlayClick(Sender: TObject); procedure btnPlayClick(Sender: TObject);
procedure btnRecordClick(Sender: TObject); procedure btnRecordClick(Sender: TObject);
procedure btnRecordStopClick(Sender: TObject); procedure btnRecordStopClick(Sender: TObject);
@ -168,15 +170,17 @@ type
FImageErr: Integer; FImageErr: Integer;
FIsPlaying: Boolean; FIsPlaying: Boolean;
procedure DoOnMacroListChange(Sender: TObject); procedure DoOnMacroListChange(Sender: TObject);
procedure UpdateDisplay;
procedure UpdateButtons; procedure UpdateButtons;
protected protected
procedure DoEditorMacroStateChanged; procedure DoEditorMacroStateChanged;
public public
constructor Create(TheOwner: TComponent); override; constructor Create(TheOwner: TComponent); override;
destructor Destroy; override; destructor Destroy; override;
function MacroByFullName(AName: String): TEditorMacro;
procedure UpdateDisplay;
end; end;
function MacroListViewer: TMacroListView;
procedure ShowMacroListViewer; procedure ShowMacroListViewer;
procedure UpdateMacroListViewer; procedure UpdateMacroListViewer;
procedure DoEditorMacroStateChanged; procedure DoEditorMacroStateChanged;
@ -204,11 +208,16 @@ var
const const
GlobalConfFileName = 'EditorMacros.xml'; GlobalConfFileName = 'EditorMacros.xml';
procedure ShowMacroListViewer; function MacroListViewer: TMacroListView;
begin begin
if MacroListView = nil then if MacroListView = nil then
MacroListView := TMacroListView.Create(Application); MacroListView := TMacroListView.Create(Application);
IDEWindowCreators.ShowForm(MacroListView, True); Result := MacroListView;
end;
procedure ShowMacroListViewer;
begin
IDEWindowCreators.ShowForm(MacroListViewer, True);
end; end;
procedure UpdateMacroListViewer; procedure UpdateMacroListViewer;
@ -217,6 +226,22 @@ begin
MacroListView.UpdateDisplay; MacroListView.UpdateDisplay;
end; end;
function MacroListToName(AList: TEditorMacroList): string;
begin
Result := '';
if AList = EditorMacroListRec then Result := 'Rec'
else if AList = EditorMacroListProj then Result := 'Prj'
else if AList = EditorMacroListGlob then Result := 'Ide';
end;
function NameToMacroList(AName: string): TEditorMacroList;
begin
Result := nil;
if AName = 'Rec' then Result := EditorMacroListRec
else if AName = 'Prj' then Result := EditorMacroListProj
else if AName = 'Ide' then Result := EditorMacroListGlob;
end;
procedure DoEditorMacroStateChanged; procedure DoEditorMacroStateChanged;
begin begin
if EditorMacroRecorder= nil then exit; if EditorMacroRecorder= nil then exit;
@ -383,6 +408,7 @@ var
begin begin
Stop; Stop;
Clear; Clear;
FHasError := False;
fEvents := TList.Create; fEvents := TList.Create;
R := TIdeMacroEventReader.Create(AText); R := TIdeMacroEventReader.Create(AText);
@ -726,9 +752,21 @@ begin
if lbRecordedView.ItemIndex < 0 then exit; if lbRecordedView.ItemIndex < 0 then exit;
M := CurrentEditorMacroList.Macros[lbRecordedView.ItemIndex]; M := CurrentEditorMacroList.Macros[lbRecordedView.ItemIndex];
s := M.MacroName; s := M.MacroName;
if InputQuery('New Macroname', Format('Enter new mawe for Macro "%s"', [m.MacroName]), s) if InputQuery(lisNewMacroname2, Format(lisEnterNewMaweForMacroS, [m.MacroName]), s)
then begin then begin
M.MacroName := s; while (s <> '') and (CurrentEditorMacroList.IndexOfName(s) >= 0) do begin
case MessageDlg(lisDuplicateName, lisAMacroWithThisNameAlreadyExists, mtWarning,
mbOKCancel, 0) of
mrOK:
if not InputQuery(lisNewMacroname2, Format(lisEnterNewMaweForMacroS, [m.MacroName]), s)
then s := '';
else
s := '';
end;
end;
if s <> '' then
M.MacroName := s;
UpdateDisplay; UpdateDisplay;
end; end;
end; end;
@ -780,6 +818,18 @@ begin
end; end;
end; end;
procedure TMacroListView.btnEditClick(Sender: TObject);
var
M: TEditorMacro;
begin
if lbRecordedView.ItemIndex < 0 then exit;
M := CurrentEditorMacroList.Macros[lbRecordedView.ItemIndex];
if M = nil then exit;
LazarusIDE.DoOpenEditorFile(
'//EMacro:/'+MacroListToName(CurrentEditorMacroList)+'/'+M.MacroName,
-1, -1, [ofVirtualFile, ofEditorMacro]);
end;
procedure TMacroListView.btnRecordClick(Sender: TObject); procedure TMacroListView.btnRecordClick(Sender: TObject);
begin begin
if EditorMacroRecorder.State = msStopped then begin if EditorMacroRecorder.State = msStopped then begin
@ -980,10 +1030,11 @@ begin
IsErr := IsSel and M.HasError; IsErr := IsSel and M.HasError;
btnSelect.Enabled := IsStopped and IsSel and (not FIsPlaying) and (not IsErr); btnSelect.Enabled := IsStopped and IsSel and (not FIsPlaying) and (not IsErr);
btnRename.Enabled := IsStopped and IsSel and (not FIsPlaying) and (not IsErr);
btnEdit.Enabled := IsStopped and IsSel and (not FIsPlaying);
btnSetKeys.Enabled := IsStopped and IsSel and (not FIsPlaying) and (not IsErr); btnSetKeys.Enabled := IsStopped and IsSel and (not FIsPlaying) and (not IsErr);
btnRename.Enabled := IsStopped and IsSel and (not FIsPlaying) and (not IsErr); btnDelete.Enabled := IsStopped and IsSel and (not FIsPlaying);
btnDelete.Enabled := IsStopped and IsSel and (not FIsPlaying);
btnPlay.Enabled := IsStopped and IsSel and (not FIsPlaying) and (not IsErr); btnPlay.Enabled := IsStopped and IsSel and (not FIsPlaying) and (not IsErr);
chkRepeat.Enabled := IsStopped and (not FIsPlaying); chkRepeat.Enabled := IsStopped and (not FIsPlaying);
@ -1008,6 +1059,22 @@ begin
tbMoveIDE.Enabled := IsStopped and IsSel and (not FIsPlaying); tbMoveIDE.Enabled := IsStopped and IsSel and (not FIsPlaying);
end; end;
function TMacroListView.MacroByFullName(AName: String): TEditorMacro;
var
Alist: TEditorMacroList;
i: Integer;
begin
Result := nil;
If (copy(AName, 1, 10) <> '//EMacro:/') or
(copy(AName, 14, 1) <> '/')
then exit;
Alist := NameToMacroList(copy(AName, 11, 3));
if (Alist = nil) then exit;
i := Alist.IndexOfName(copy(AName, 15, length(AName)));
if i < 0 then exit;
Result := Alist.Macros[i]
end;
procedure TMacroListView.DoEditorMacroStateChanged; procedure TMacroListView.DoEditorMacroStateChanged;
begin begin
UpdateDisplay; UpdateDisplay;
@ -1032,8 +1099,9 @@ begin
lbMoveTo.Caption := lisMoveTo; lbMoveTo.Caption := lisMoveTo;
btnSelect.Caption := lisMenuSelect; btnSelect.Caption := lisMenuSelect;
btnSetKeys.Caption := lisEditKey;
btnRename.Caption := lisRename2; btnRename.Caption := lisRename2;
btnSetKeys.Caption := lisEditKey;
btnEdit.Caption := lisEdit;
btnDelete.Caption := lisDelete; btnDelete.Caption := lisDelete;
btnPlay.Caption := lisPlay; btnPlay.Caption := lisPlay;
chkRepeat.Caption := lisRepeat; chkRepeat.Caption := lisRepeat;
@ -1142,8 +1210,29 @@ begin
Result := FList.IndexOf(AMacro); Result := FList.IndexOf(AMacro);
end; end;
function TEditorMacroList.IndexOfName(AName: String): Integer;
begin
Result := Count - 1;
while Result >= 0 do
if Macros[Result].MacroName = AName
then break
else dec(Result);
end;
function TEditorMacroList.UniqName(AName: String): String;
var
i: Integer;
begin
Result := AName;
if IndexOfName(AName) < 0 then exit;
i := 1;
while IndexOfName(AName+'_'+IntToStr(i)) >= 0 do inc(i);
Result := AName+'_'+IntToStr(i);
end;
function TEditorMacroList.Add(AMacro: TEditorMacro): Integer; function TEditorMacroList.Add(AMacro: TEditorMacro): Integer;
begin begin
AMacro.MacroName := UniqName(AMacro.MacroName);
Result := FList.Add(AMacro); Result := FList.Add(AMacro);
DoAdded(AMacro); DoAdded(AMacro);
DoChanged; DoChanged;

View File

@ -5565,6 +5565,10 @@ resourcestring
lisMoveTo = 'Move to: '; lisMoveTo = 'Move to: ';
lisFailedToSaveFile = 'Failed to save file.'; lisFailedToSaveFile = 'Failed to save file.';
lisEditKey = 'Edit Key'; lisEditKey = 'Edit Key';
lisDuplicateName = 'Duplicate Name';
lisAMacroWithThisNameAlreadyExists = 'A macro with this name already exists.';
lisNewMacroname2 = 'New Macroname';
lisEnterNewMaweForMacroS = 'Enter new mawe for Macro "%s"';
implementation implementation

View File

@ -9286,6 +9286,7 @@ begin
// do not save a unit which is currently reverting // do not save a unit which is currently reverting
if AnUnitInfo.IsReverting then if AnUnitInfo.IsReverting then
exit(mrOk); exit(mrOk);
WasVirtual:=AnUnitInfo.IsVirtual; WasVirtual:=AnUnitInfo.IsVirtual;
WasPascalSource:=FilenameIsPascalSource(AnUnitInfo.Filename); WasPascalSource:=FilenameIsPascalSource(AnUnitInfo.Filename);
@ -9305,6 +9306,17 @@ begin
if not (sfProjectSaving in Flags) then if not (sfProjectSaving in Flags) then
SaveSourceEditorChangesToCodeCache(nil); SaveSourceEditorChangesToCodeCache(nil);
if uifEditorMacro in AnUnitInfo.Flags then begin
// save to macros
if MacroListViewer.MacroByFullName(AnUnitInfo.Filename) <> nil then
MacroListViewer.MacroByFullName(AnUnitInfo.Filename).SetFromText(AEditor.SourceText);
MacroListViewer.UpdateDisplay;
AnUnitInfo.ClearModifieds;
AEditor.Modified:=false;
Result := mrOK;
exit;
end;
// if this is a new unit then a simple Save becomes a SaveAs // if this is a new unit then a simple Save becomes a SaveAs
if (not (sfSaveToTestDir in Flags)) and (AnUnitInfo.IsVirtual) then if (not (sfSaveToTestDir in Flags)) and (AnUnitInfo.IsVirtual) then
Include(Flags,sfSaveAs); Include(Flags,sfSaveAs);
@ -9701,6 +9713,50 @@ begin
if (ofRevert in Flags) and (PageIndex>=0) then if (ofRevert in Flags) and (PageIndex>=0) then
AFilename := SourceEditorManager.SourceEditorsByPage[WindowIndex, PageIndex].FileName; AFilename := SourceEditorManager.SourceEditorsByPage[WindowIndex, PageIndex].FileName;
if (ofRevert in Flags) then begin
UnitIndex:=Project1.IndexOfFilename(AFilename);
if (UnitIndex > 0) then begin
NewUnitInfo:=Project1.Units[UnitIndex];
if (uifEditorMacro in NewUnitInfo.Flags) then begin
if MacroListViewer.MacroByFullName(AFileName) <> nil then
NewUnitInfo.Source.Source := MacroListViewer.MacroByFullName(AFileName).GetAsText;
Result:=mrOK;
exit;
end;
end;
end;
if (ofEditorMacro in Flags) then begin
FilenameNoPath := AFileName;
UnitIndex:=Project1.IndexOfFilename(AFilename);
if (UnitIndex < 0) then begin
NewBuf := CodeToolBoss.SourceCache.CreateFile(AFileName);
NewBuf.FileName:=AFileName;
if MacroListViewer.MacroByFullName(AFileName) <> nil then
NewBuf.Source := MacroListViewer.MacroByFullName(AFileName).GetAsText;
NewUnitInfo:=TUnitInfo.Create(NewBuf);
NewUnitInfo.DefaultSyntaxHighlighter := lshFreePascal;
Project1.AddFile(NewUnitInfo,false);
end
else begin
NewUnitInfo:=Project1.Units[UnitIndex];
end;
NewUnitInfo.Flags := NewUnitInfo.Flags + [uifEditorMacro];
if NewUnitInfo.OpenEditorInfoCount > 0 then begin
NewEditorInfo := NewUnitInfo.OpenEditorInfo[0];
SourceEditorManager.ActiveSourceWindowIndex := NewEditorInfo.WindowIndex;
SourceEditorManager.ActiveSourceWindow.PageIndex:= NewEditorInfo.PageIndex;
end
else begin
NewEditorInfo := NewUnitInfo.GetClosedOrNewEditorInfo;
Result:=DoOpenFileInSourceEditor(NewEditorInfo, PageIndex, WindowIndex, Flags);
end;
Result:=mrOK;
exit;
end;
// normalize filename // normalize filename
AFilename:=TrimFilename(AFilename); AFilename:=TrimFilename(AFilename);
DiskFilename:=CodeToolBoss.DirectoryCachePool.FindDiskFilename(AFilename); DiskFilename:=CodeToolBoss.DirectoryCachePool.FindDiskFilename(AFilename);

View File

@ -159,7 +159,8 @@ type
TUnitInfoFlag = ( TUnitInfoFlag = (
uifComponentUsedByDesigner, uifComponentUsedByDesigner,
uifComponentIndirectlyUsedByDesigner, uifComponentIndirectlyUsedByDesigner,
uifMarked uifMarked,
uifEditorMacro
); );
TUnitInfoFlags = set of TUnitInfoFlag; TUnitInfoFlags = set of TUnitInfoFlag;

View File

@ -41,7 +41,8 @@ type
ofDoNotLoadResource,// do not open form, datamodule, ... (overriding default) ofDoNotLoadResource,// do not open form, datamodule, ... (overriding default)
ofDoLoadResource,// do open form, datamodule, ... (overriding default) ofDoLoadResource,// do open form, datamodule, ... (overriding default)
ofLoadHiddenResource,// load component hidden ofLoadHiddenResource,// load component hidden
ofAddToProject // add file to project (if exists) ofAddToProject, // add file to project (if exists)
ofEditorMacro // opening an editor macro (pascal script) from memory
); );
TOpenFlags = set of TOpenFlag; TOpenFlags = set of TOpenFlag;