This commit is contained in:
Basile Burg 2014-08-18 20:38:39 +02:00
parent 4a43e6200d
commit c4ec74e3e1
20 changed files with 644 additions and 261 deletions

View File

@ -215,9 +215,9 @@
<UnitName Value="ce_project"/>
</Unit11>
<Unit12>
<Filename Value="..\src\ce_widgettypes.pas"/>
<Filename Value="..\src\ce_interfaces.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="ce_widgettypes"/>
<UnitName Value="ce_interfaces"/>
</Unit12>
<Unit13>
<Filename Value="..\src\ce_staticexplorer.pas"/>

View File

@ -7,7 +7,7 @@ uses
cthreads,
{$ENDIF}{$ENDIF}
Interfaces, Forms, lazcontrols, runtimetypeinfocontrols,
ce_main, ce_dcd, ce_observer;
ce_dcd, ce_observer, ce_main;
{$R *.res}

View File

@ -1,6 +1,7 @@
unit ce_customtools;
{$MODE OBJFPC}{$H+}
{$INTERFACES CORBA}
interface

View File

@ -1,6 +1,7 @@
unit ce_editor;
{$MODE OBJFPC}{$H+}
{$INTERFACES CORBA}
interface
@ -8,22 +9,21 @@ uses
Classes, SysUtils, FileUtil, ExtendedNotebook, Forms, Controls, lcltype,
Graphics, SynEditKeyCmds, ComCtrls, SynEditHighlighter, ExtCtrls, Menus,
SynEditHighlighterFoldBase, SynMacroRecorder, SynPluginSyncroEdit, SynEdit,
SynHighlighterLFM, SynCompletion, AnchorDocking, ce_widget, ce_d2syn, ce_widgettypes,
SynHighlighterLFM, SynCompletion, AnchorDocking, ce_widget, ce_d2syn, ce_interfaces,
ce_synmemo, ce_dlang, ce_project, ce_common, types, ce_dcd, ce_observer;
type
{ TCEEditorWidget }
TCEEditorWidget = class(TCEWidget)
TCEEditorWidget = class(TCEWidget, ICEProjectObserver)
imgList: TImageList;
PageControl: TExtendedNotebook;
macRecorder: TSynMacroRecorder;
editorStatus: TStatusBar;
completion: TSynCompletion;
procedure completionCodeCompletion(var Value: string; SourceValue: string;
var SourceStart, SourceEnd: TPoint; KeyChar: TUTF8Char; Shift: TShiftState
);
var SourceStart, SourceEnd: TPoint; KeyChar: TUTF8Char; Shift: TShiftState);
procedure completionExecute(Sender: TObject);
procedure PageControlChange(Sender: TObject);
procedure PageControlCloseTabClicked(Sender: TObject);
@ -33,7 +33,6 @@ type
private
fKeyChanged: boolean;
fProj: TCEProject;
fMultiDocSubject: TCEMultiDocSubject;
// http://bugs.freepascal.org/view.php?id=26329
fSyncEdit: TSynPluginSyncroEdit;
@ -59,11 +58,14 @@ type
procedure focusedEditorChanged;
function getEditorHint: string;
//
procedure projNew(const aProject: TCEProject); override;
procedure projClose(const aProject: TCEProject); override;
procedure projFocused(const aProject: TCEProject); override;
procedure projCompile(const aProject: TCEProject); override;
procedure projRun(const aProject: TCEProject); override;
procedure projNew(const aProject: TCEProject);
procedure projClosing(const aProject: TCEProject);
procedure projFocused(const aProject: TCEProject);
procedure projChanged(const aProject: TCEProject);
procedure projCompile(const aProject: TCEProject); //warning: removed from itf
procedure projRun(const aProject: TCEProject); //warning: removed from itf
//
property currentEditor: TCESynMemo read getCurrentEditor;
property editor[index: NativeInt]: TCESynMemo read getEditor;
@ -95,14 +97,10 @@ begin
finally
bmp.Free;
end;
//
fMultiDocSubject := TCEMultiDocSubject.create;
EntitiesConnector.addSubject(fMultiDocSubject);
end;
destructor TCEEditorWidget.destroy;
begin
fMultiDocSubject.Free;
tokLst.Free;
errLst.Free;
inherited;
@ -142,15 +140,13 @@ begin
//
if pageControl.ActivePageIndex <> -1 then
begin
CEMainForm.docFocusedNotify(Self, pageControl.ActivePageIndex);
//CEMainForm.docFocusedNotify(Self, pageControl.ActivePageIndex);
if (pageControl.ActivePage.Caption = '') then
begin
fKeyChanged := true;
beginUpdateByDelay;
end;
end;
self.fMultiDocSubject.docFocused(curr);
end;
procedure TCEEditorWidget.PageControlChange(Sender: TObject);
@ -264,7 +260,7 @@ begin
fProj := aProject;
end;
procedure TCEEditorWidget.projClose(const aProject: TCEProject);
procedure TCEEditorWidget.projClosing(const aProject: TCEProject);
begin
fProj := nil;
end;
@ -274,14 +270,18 @@ begin
fProj := aProject;
end;
procedure TCEEditorWidget.projChanged(const aProject: TCEProject);
begin
end;
procedure TCEEditorWidget.projCompile(const aProject: TCEProject);
begin
endUpdateByDelay;
endUpdateByDelay; // warning not trigered anymore
end;
procedure TCEEditorWidget.projRun(const aProject: TCEProject);
begin
endUpdateByDelay;
endUpdateByDelay; // warning not trigered anymore
end;
procedure TCEEditorWidget.getSymbolLoc;
@ -396,7 +396,7 @@ begin
if not fKeyChanged then exit;
//
fKeyChanged := false;
CEMainForm.docChangeNotify(Self, editorIndex);
//CEMainForm.docChangeNotify(Self, editorIndex);
if ed.Lines.Count = 0 then exit;
//
if fProj = nil then

227
src/ce_interfaces.pas Normal file
View File

@ -0,0 +1,227 @@
unit ce_interfaces;
{$MODE OBJFPC}{$H+}
{$INTERFACES CORBA}
interface
uses
Classes, SysUtils, actnList, menus, ce_synmemo, ce_project, ce_observer;
type
(**
* An implementer can save and load some stuffs on application start/quit
*)
ICEWidgetPersist = interface
['ICEWidgetPersist']
// Coedit options are about to be saved.
procedure beforeSave(sender: TObject);
// some custom properties can be declared to aFiler.
procedure declareProperties(aFiler: TFiler);
// Coedit options has just been reloaded.
procedure afterLoad(sender: TObject);
end;
(**
* An implementer declares some actions on demand.
* TODO-cfeature: improve the interface so that a widget can declare a complete main menu category.
*)
ICEContextualActions = interface
['ICEContextualActions']
// declares a context name for the actions
function contextName: string;
// action count, called before contextAction()
function contextActionCount: integer;
// declares actions, called in loop, from 0 to contextActionCount-1
function contextAction(index: integer): TAction;
end;
(**
* An implementer is informed about the current file(s).
*)
ICEMultiDocObserver = interface
['ICEMultiDocObserver']
// the new document aDoc has been created (empty, runnable, project source, ...).
procedure docNew(const aDoc: TCESynMemo);
// aDoc is the document being edited.
procedure docFocused(const aDoc: TCESynMemo); // rename to: docSelected or docActivated
// aDoc content has just been modified (edited, saved).
procedure docChanged(const aDoc: TCESynMemo);
// aDoc is about to be closed.
procedure docClosing(const aDoc: TCESynMemo);
end;
(**
* An implementer informs some ICEMultiDocObserver about the current file(s)
*)
TCEMultiDocSubject = class(TCECustomSubject)
protected
function acceptObserver(aObject: TObject): boolean; override;
end;
(**
* An implementer is informed about the current project(s).
*)
ICEProjectObserver = interface
['ICEProjectObserver']
// the new project aProject has been created/opened
procedure projNew(const aProject: TCEProject);
// aProject has been modified: switches, source name, ...
procedure projChanged(const aProject: TCEProject);
// aProject is about to be closed.
procedure projClosing(const aProject: TCEProject);
// not used yet: the active project is now aProject
procedure projFocused(const aProject: TCEProject); // rename: projSelected or projActivated
// aProject is about to be compiled.
//procedure projCompile(const aProject: TCEProject);
// aProject is about to be executed.
//procedure projRun(const aProject: TCEProject);
end;
(**
* An implementer informs some ICEMultiDocObserver about the current file(s)
*)
TCEProjectSubject = class(TCECustomSubject)
protected
function acceptObserver(aObject: TObject): boolean; override;
end;
(**
* An implementer can add a mainmenu entry.
*)
ICEMainMenuProvider = interface
['ICEMainMenuProvider']
// item must contain the full items tree to be added
procedure menuDeclare(out item: TMenuItem);
end;
{
subject Primitives:
A subject has not necessarly all the informations the observers expect.
It can compose using the following "primitives".
}
(**
* TCEMultiDocSubject primitives.
*)
procedure subjDocNew(aSubject: TCEMultiDocSubject; aDoc: TCESynMemo); {$IFDEF RELEASE}inline;{$ENDIF}
procedure subjDocClosing(aSubject: TCEMultiDocSubject; aDoc: TCESynMemo); {$IFDEF RELEASE}inline;{$ENDIF}
procedure subjDocFocused(aSubject: TCEMultiDocSubject; aDoc: TCESynMemo); {$IFDEF RELEASE}inline;{$ENDIF}
procedure subjDocChanged(aSubject: TCEMultiDocSubject; aDoc: TCESynMemo); {$IFDEF RELEASE}inline;{$ENDIF}
(**
* TCEProjectSubject primitives.
*)
procedure subjProjNew(aSubject: TCEProjectSubject; aProj: TCEProject); {$IFDEF RELEASE}inline;{$ENDIF}
procedure subjProjClosing(aSubject: TCEProjectSubject; aProj: TCEProject); {$IFDEF RELEASE}inline;{$ENDIF}
procedure subjProjFocused(aSubject: TCEProjectSubject; aProj: TCEProject); {$IFDEF RELEASE}inline;{$ENDIF}
procedure subjProjChanged(aSubject: TCEProjectSubject; aProj: TCEProject); {$IFDEF RELEASE}inline;{$ENDIF}
//procedure subjProjCompile(aSubject: TCEProjectSubject; aProj: TCEProject); //{$IFDEF RELEASE}inline;{$ENDIF}
//procedure subjProjRun(aSubject: TCEProjectSubject; aProj: TCEProject); //{$IFDEF RELEASE}inline;{$ENDIF}
implementation
function TCEMultiDocSubject.acceptObserver(aObject: TObject): boolean;
begin
result := (aObject is ICEMultiDocObserver);
end;
procedure subjDocNew(aSubject: TCEMultiDocSubject; aDoc: TCESynMemo);
var
i: Integer;
begin
with aSubject do for i:= 0 to fObservers.Count-1 do
(fObservers.Items[i] as ICEMultiDocObserver).docNew(aDoc);
end;
procedure subjDocClosing(aSubject: TCEMultiDocSubject; aDoc: TCESynMemo);
var
i: Integer;
begin
with aSubject do for i:= 0 to fObservers.Count-1 do
(fObservers.Items[i] as ICEMultiDocObserver).docClosing(aDoc);
end;
procedure subjDocFocused(aSubject: TCEMultiDocSubject; aDoc: TCESynMemo);
var
i: Integer;
begin
with aSubject do for i:= 0 to fObservers.Count-1 do
(fObservers.Items[i] as ICEMultiDocObserver).docFocused(aDoc);
end;
procedure subjDocChanged(aSubject: TCEMultiDocSubject; aDoc: TCESynMemo);
var
i: Integer;
begin
with aSubject do for i:= 0 to fObservers.Count-1 do
(fObservers.Items[i] as ICEMultiDocObserver).docChanged(aDoc);
end;
function TCEProjectSubject.acceptObserver(aObject: TObject): boolean;
begin
result := (aObject is ICEProjectObserver);
end;
procedure subjProjNew(aSubject: TCEProjectSubject; aProj: TCEProject);
var
i: Integer;
begin
with aSubject do for i:= 0 to fObservers.Count-1 do
(fObservers.Items[i] as ICEProjectObserver).ProjNew(aProj);
end;
procedure subjProjClosing(aSubject: TCEProjectSubject; aProj: TCEProject);
var
i: Integer;
begin
with aSubject do for i:= 0 to fObservers.Count-1 do
(fObservers.Items[i] as ICEProjectObserver).projClosing(aProj);
end;
procedure subjProjFocused(aSubject: TCEProjectSubject; aProj: TCEProject);
var
i: Integer;
begin
with aSubject do for i:= 0 to fObservers.Count-1 do
(fObservers.Items[i] as ICEProjectObserver).projFocused(aProj);
end;
procedure subjProjChanged(aSubject: TCEProjectSubject; aProj: TCEProject);
var
i: Integer;
begin
with aSubject do for i:= 0 to fObservers.Count-1 do
(fObservers.Items[i] as ICEProjectObserver).projChanged(aProj);
end;
//procedure subjProjCompile(aSubject: TCEProjectSubject; aProj: TCEProject);
//var
// i: Integer;
//begin
// with aSubject do for i:= 0 to fObservers.Count-1 do
// (fObservers.Items[i] as ICEProjectObserver).projCompile(aProj);
//end;
//
//procedure subjProjRun(aSubject: TCEProjectSubject; aProj: TCEProject);
//var
// i: Integer;
//begin
// with aSubject do for i:= 0 to fObservers.Count-1 do
// (fObservers.Items[i] as ICEProjectObserver).projRun(aProj);
//end;
end.

View File

@ -1,6 +1,7 @@
unit ce_libman;
{$MODE OBJFPC}{$H+}
{$INTERFACES CORBA}
interface

View File

@ -1,6 +1,7 @@
unit ce_libmaneditor;
{$MODE OBJFPC}{$H+}
{$INTERFACES CORBA}
interface

View File

@ -1,6 +1,7 @@
unit ce_main;
{$mode objfpc}{$H+}
{$MODE OBJFPC}{$H+}
{$INTERFACES CORBA}
interface
@ -9,7 +10,7 @@ uses
AnchorDocking, AnchorDockStorage, AnchorDockOptionsDlg, Controls, Graphics,
Dialogs, Menus, ActnList, ExtCtrls, process, XMLPropStorage, ComCtrls, dynlibs,
ce_common, ce_dmdwrap, ce_project, ce_dcd, ce_plugin, ce_synmemo, ce_widget,
ce_messages, ce_widgettypes, ce_editor, ce_projinspect, ce_projconf, ce_search,
ce_messages, ce_interfaces, ce_editor, ce_projinspect, ce_projconf, ce_search,
ce_staticexplorer, ce_miniexplorer, ce_libman, ce_libmaneditor, ce_customtools,
ce_observer;
@ -60,7 +61,7 @@ type
end;
{ TCEMainForm }
TCEMainForm = class(TForm)
TCEMainForm = class(TForm, ICEMultiDocObserver)
actFileCompAndRun: TAction;
actFileSaveAll: TAction;
actFileClose: TAction;
@ -210,9 +211,8 @@ type
procedure FormDropFiles(Sender: TObject; const FileNames: array of String);
private
// oh no...a field which is not a class.^^
fDoc: TCESynMemo;
fUpdateCount: NativeInt;
fProject: TCEProject;
fPlugList: TCEPlugDescriptorList;
fWidgList: TCEWidgetList;
@ -229,6 +229,12 @@ type
fLibMan: TLibraryManager;
fTools: TCETools;
// ICEMultiDocObserver
procedure docNew(const aDoc: TCESynMemo);
procedure docClosing(const aDoc: TCESynMemo);
procedure docFocused(const aDoc: TCESynMemo);
procedure docChanged(const aDoc: TCESynMemo);
//Init - Fina
procedure getCMdParams;
procedure checkCompilo;
@ -262,7 +268,6 @@ type
// project sub routines
procedure saveProjSource(const aEditor: TCESynMemo);
procedure projChange(sender: TObject);
procedure newProj;
procedure saveProj;
procedure saveProjAs(const aFilename: string);
@ -282,8 +287,6 @@ type
procedure UpdateDockCaption(Exclude: TControl = nil); override;
//
procedure openFile(const aFilename: string);
procedure docChangeNotify(Sender: TObject; const aIndex: Integer);
procedure docFocusedNotify(Sender: TObject; const aIndex: Integer);
function expandSymbolicString(const symString: string): string;
//
property WidgetList: TCEWidgetList read fWidgList;
@ -309,6 +312,7 @@ uses
constructor TCEMainForm.create(aOwner: TComponent);
begin
inherited create(aOwner);
EntitiesConnector.addObserver(self);
//
InitMRUs;
InitLibMan;
@ -726,7 +730,6 @@ end;
procedure TCEMainForm.ActionsUpdate(AAction: TBasicAction; var Handled: Boolean);
var
curr: TCESynMemo;
hasEd: boolean;
hasProj: boolean;
begin
@ -734,25 +737,24 @@ begin
if fUpdateCount > 0 then exit;
Inc(fUpdateCount);
try
curr := fEditWidg.currentEditor;
hasEd := curr <> nil;
hasEd := fDoc <> nil;
if hasEd then
begin
actEdCopy.Enabled := curr.SelAvail and fEditWidg.Focused; // allows copy/cut/paste by shortcut on widgets
actEdCut.Enabled := curr.SelAvail and fEditWidg.Focused; //
actEdPaste.Enabled := curr.CanPaste and fEditWidg.Focused;
actEdCopy.Enabled := fDoc.SelAvail and fEditWidg.Focused; // allows copy/cut/paste by shortcut on widgets
actEdCut.Enabled := fDoc.SelAvail and fEditWidg.Focused; //
actEdPaste.Enabled := fDoc.CanPaste and fEditWidg.Focused;
{$IFDEF MSWINDOWS}
// close file : raises a segfault on linux UndoStuff.>>fList<<.Count...
actEdUndo.Enabled := curr.CanUndo;
actEdRedo.Enabled := curr.CanRedo;
actEdUndo.Enabled := fDoc.CanUndo;
actEdRedo.Enabled := fDoc.CanRedo;
{$ENDIF}
actEdMacPlay.Enabled := true;
actEdMacStartStop.Enabled := true;
actEdIndent.Enabled := true;
actEdUnIndent.Enabled := true;
//
actFileCompAndRun.Enabled := curr.isDSource;
actFileCompAndRunWithArgs.Enabled := curr.isDSource;
actFileCompAndRun.Enabled := fDoc.isDSource;
actFileCompAndRunWithArgs.Enabled := fDoc.isDSource;
actFileSave.Enabled := true;
actFileSaveAs.Enabled := true;
actFileClose.Enabled := true;
@ -890,12 +892,32 @@ begin
end;
{$ENDREGION}
{$REGION ICEMultiDocMonitor ----------------------------------------------------}
procedure TCEMainForm.docNew(const aDoc: TCESynMemo);
begin
fDoc := aDoc;
end;
procedure TCEMainForm.docClosing(const aDoc: TCESynMemo);
begin
fDoc := nil;
end;
procedure TCEMainForm.docFocused(const aDoc: TCESynMemo);
begin
fDoc := aDoc;
end;
procedure TCEMainForm.docChanged(const aDoc: TCESynMemo);
begin
end;
{$ENDREGION}
{$REGION file ------------------------------------------------------------------}
procedure TCEMainForm.newFile;
begin
if fEditWidg = nil then exit;
fEditWidg.addEditor;
fEditWidg.focusedEditorChanged;
end;
function TCEMainForm.findFile(const aFilename: string): NativeInt;
@ -930,7 +952,6 @@ end;
procedure TCEMainForm.saveFile(const edIndex: NativeInt);
var
str: string;
i: NativeInt;
begin
if fEditWidg = nil then exit;
if edIndex >= fEditWidg.editorCount then exit;
@ -944,9 +965,6 @@ begin
str := fEditWidg.editor[edIndex].fileName;
if str = '' then exit;
fEditWidg.editor[edIndex].save;
//
for i := 0 to fWidgList.Count-1 do
fWidgList.widget[i].docChanged(fEditWidg.editor[edIndex]);
end;
procedure TCEMainForm.saveFileAs(const edIndex: NativeInt; const aFilename: string);
@ -959,24 +977,6 @@ begin
fFileMru.Insert(0, aFilename);
end;
procedure TCEMainForm.docChangeNotify(Sender: TObject; const aIndex: Integer);
var
i: NativeInt;
begin
for i := 0 to fWidgList.Count-1 do
if fWidgList.widget[i] <> Sender then
fWidgList.widget[i].docChanged(fEditWidg.editor[aIndex]);
end;
procedure TCEMainForm.docFocusedNotify(Sender: TObject; const aIndex: Integer);
var
i: NativeInt;
begin
for i := 0 to fWidgList.Count-1 do
if fWidgList.widget[i] <> Sender then
fWidgList.widget[i].docFocused(fEditWidg.editor[aIndex]);
end;
procedure TCEMainForm.mruFileItemClick(Sender: TObject);
begin
openFile(TMenuItem(Sender).Hint);
@ -1046,14 +1046,11 @@ end;
procedure TCEMainForm.actFileSaveExecute(Sender: TObject);
var
str: string;
ed: TCESynMemo;
begin
if fEditWidg = nil then exit;
ed := fEditWidg.currentEditor;
if ed = nil then exit;
if fDoc = nil then exit;
//
str := ed.fileName;
if (str <> ed.tempFilename) and (fileExists(str)) then
str := fDoc.fileName;
if (str <> fDoc.tempFilename) and (fileExists(str)) then
saveFile(fEditWidg.editorIndex)
else actFileSaveAs.Execute;
end;
@ -1073,18 +1070,12 @@ begin
end;
procedure TCEMainForm.actFileCloseExecute(Sender: TObject);
var
curr: TCESynMemo;
i: NativeInt;
begin
curr := fEditWidg.currentEditor;
if curr.modified then if dlgOkCancel(
if fDoc = nil then exit;
if fDoc.modified then if dlgOkCancel(
'The latest mdofifications are not saved, continue ?') = mrCancel
then exit;
//
for i := 0 to fWidgList.Count-1 do
fWidgList.widget[i].docClose(fEditWidg.currentEditor);
//
fEditWidg.removeEditor(fEditWidg.editorIndex);
end;
@ -1092,7 +1083,8 @@ procedure TCEMainForm.actFileSaveAllExecute(Sender: TObject);
var
i: NativeInt;
begin
for i:= 0 to fEditWidg.editorCount-1 do saveFile(i);
for i:= 0 to fEditWidg.editorCount-1 do
saveFile(i);
end;
procedure TCEMainForm.FormDropFiles(Sender: TObject;const FileNames: array of String);
@ -1327,8 +1319,8 @@ begin
fMesgWidg.ClearAllMessages;
for i := 0 to fWidgList.Count-1 do
fWidgList.widget[i].projCompile(aProject);
//for i := 0 to fWidgList.Count-1 do
//fWidgList.widget[i].projCompile(aProject);
with fProject.currentConfiguration do
begin
@ -1425,8 +1417,8 @@ begin
if aProject.currentConfiguration.outputOptions.binaryKind <>
executable then exit;
for i := 0 to fWidgList.Count-1 do
fWidgList.widget[i].projRun(aProject);
//for i := 0 to fWidgList.Count-1 do
//fWidgList.widget[i].projRun(aProject);
runproc := TProcess.Create(nil);
try
@ -1584,14 +1576,6 @@ end;
{$ENDREGION}
{$REGION project ---------------------------------------------------------------}
procedure TCEMainForm.projChange(sender: TObject);
var
i: NativeInt;
begin
for i := 0 to WidgetList.Count-1 do
WidgetList.widget[i].projChange(fProject);
end;
procedure TCEMainForm.saveProjSource(const aEditor: TCESynMemo);
begin
if fProject = nil then exit;
@ -1602,24 +1586,15 @@ begin
end;
procedure TCEMainForm.closeProj;
var
i: NativeInt;
begin
for i := 0 to WidgetList.Count-1 do
WidgetList.widget[i].projClose(fProject);
fProject.Free;
fProject := nil;
end;
procedure TCEMainForm.newProj;
var
i: NativeInt;
begin
fProject := TCEProject.Create(nil);
fProject.Name := 'CurrentProject';
for i := 0 to WidgetList.Count-1 do
WidgetList.widget[i].projNew(fProject);
fProject.onChange := @projChange;
fProject.libraryManager := fLibMan;
end;

View File

@ -1,13 +1,14 @@
unit ce_messages;
{$MODE OBJFPC}{$H+}
{$INTERFACES CORBA}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, ComCtrls,
lcltype, ce_widget, ActnList, Menus, clipbrd, AnchorDocking, ce_project,
ce_synmemo, ce_dlangutils;
ce_synmemo, ce_dlangutils, ce_interfaces, ce_observer;
type
@ -21,7 +22,7 @@ type
position: TPoint;
end;
TCEMessagesWidget = class(TCEWidget)
TCEMessagesWidget = class(TCEWidget, ICEMultiDocObserver, ICEProjectObserver)
imgList: TImageList;
List: TTreeView;
procedure ListDblClick(Sender: TObject);
@ -66,12 +67,15 @@ type
function contextActionCount: integer; override;
function contextAction(index: integer): TAction; override;
//
procedure projNew(const aProject: TCEProject); override;
procedure projClose(const aProject: TCEProject); override;
procedure projFocused(const aProject: TCEProject); override;
procedure projNew(const aProject: TCEProject);
procedure projClosing(const aProject: TCEProject);
procedure projFocused(const aProject: TCEProject);
procedure projChanged(const aProject: TCEProject);
//
procedure docFocused(const aDoc: TCESynMemo); override;
procedure docClose(const aDoc: TCESynMemo); override;
procedure docNew(const aDoc: TCESynMemo);
procedure docClosing(const aDoc: TCESynMemo);
procedure docFocused(const aDoc: TCESynMemo);
procedure docChanged(const aDoc: TCESynMemo);
//
procedure ClearAllMessages;
procedure ClearMessages(aCtxt: TMessageContext);
@ -115,6 +119,8 @@ begin
//
List.PopupMenu := contextMenu;
List.OnDeletion := @ListDeletion;
//
EntitiesConnector.addObserver(self);
end;
procedure TCEMessagesWidget.listDeletion(Sender: TObject; Node: TTreeNode);
@ -251,7 +257,7 @@ begin
filterMessages;
end;
procedure TCEMessagesWidget.projClose(const aProject: TCEProject);
procedure TCEMessagesWidget.projClosing(const aProject: TCEProject);
begin
if fProj = aProject then
ClearMessages(mcProject);
@ -264,21 +270,35 @@ begin
fProj := aProject;
filterMessages;
end;
procedure TCEMessagesWidget.projChanged(const aProject: TCEProject);
begin
end;
{$ENDREGION}
{$REGION ICEMultiDocMonitor ----------------------------------------------------}
procedure TCEMessagesWidget.docNew(const aDoc: TCESynMemo);
begin
fDoc := aDoc;
filterMessages;
end;
procedure TCEMessagesWidget.docClosing(const aDoc: TCESynMemo);
begin
if aDoc <> fDoc then exit;
ClearMessages(mcEditor);
fDoc := nil;
filterMessages;
end;
procedure TCEMessagesWidget.docFocused(const aDoc: TCESynMemo);
begin
fDoc := aDoc;
filterMessages;
end;
procedure TCEMessagesWidget.docClose(const aDoc: TCESynMemo);
procedure TCEMessagesWidget.docChanged(const aDoc: TCESynMemo);
begin
if aDoc <> fDoc then exit;
ClearMessages(mcEditor);
fDoc := nil;
filterMessages;
end;
{$ENDREGION}

View File

@ -1,6 +1,7 @@
unit ce_miniexplorer;
{$MODE OBJFPC}{$H+}
{$INTERFACES CORBA}
interface

View File

@ -35,6 +35,7 @@ type
* Interface for a Coedit subject. Basically designed to hold a list of observer
*)
ICESubject = interface
['ICESubject']
// an observer is proposed. anObserver is not necessarly compatible.
procedure addObserver(anObserver: TObject);
// anObserver must be removed.
@ -52,7 +53,7 @@ type
// test for a specific interface when adding an observer.
function acceptObserver(aObject: TObject): boolean; virtual;
public
constructor create;
constructor create; virtual;
destructor destroy; override;
//
procedure addObserver(anObserver: TObject);
@ -60,10 +61,6 @@ type
procedure updateObservers; virtual;
end;
ICEObserver = interface
//function subjectType: ICESubject;
end;
var
EntitiesConnector: TCEEntitiesConnector = nil;
@ -90,13 +87,12 @@ begin
fUpdating := false;
for i := 0 to fSubjects.Count-1 do
begin
if (fSubjects[i] as ICESubject) = nil then
if not (fSubjects[i] is ICESubject) then
continue;
for j := 0 to fObservers.Count-1 do
begin
if (fSubjects[i] as ICEObserver) <> nil then
if fSubjects[i] <> fObservers[j] then
(fSubjects[i] as ICESubject).addObserver(fObservers[j]);
if fSubjects[i] <> fObservers[j] then
(fSubjects[i] as ICESubject).addObserver(fObservers[j]);
end;
end;
end;
@ -113,8 +109,6 @@ end;
procedure TCEEntitiesConnector.addObserver(anObserver: TObject);
begin
if (anObserver as ICEObserver) = nil then
exit;
if fObservers.IndexOf(anObserver) <> -1 then
exit;
fUpdating := true;
@ -132,9 +126,13 @@ begin
end;
procedure TCEEntitiesConnector.removeObserver(anObserver: TObject);
var
i: Integer;
begin
fUpdating := true;
fObservers.Remove(anObserver);
for i := 0 to fSubjects.Count-1 do
(fSubjects[i] as ICESubject).removeObserver(anObserver);
end;
procedure TCEEntitiesConnector.removeSubject(aSubject: TObject);
@ -148,10 +146,14 @@ end;
constructor TCECustomSubject.create;
begin
fObservers := TObjectList.create(false);
EntitiesConnector.addSubject(Self);
EntitiesConnector.endUpdate;
end;
destructor TCECustomSubject.destroy;
begin
EntitiesConnector.removeSubject(Self);
EntitiesConnector.endUpdate;
fObservers.Free;
Inherited;
end;

View File

@ -1,6 +1,7 @@
unit ce_plugin;
{$MODE OBJFPC}{$H+}
{$INTERFACES CORBA}
interface

View File

@ -1,16 +1,17 @@
unit ce_projconf;
{$MODE OBJFPC}{$H+}
{$INTERFACES CORBA}
interface
uses
Classes, SysUtils, FileUtil, RTTIGrids, Forms, Controls, Graphics, Dialogs,
ExtCtrls, ComCtrls, StdCtrls, Menus, Buttons, PropEdits, ObjectInspector,
ce_dmdwrap, ce_project, ce_widget, AnchorDocking;
ce_dmdwrap, ce_project, ce_widget, ce_interfaces, ce_observer;
type
TCEProjectConfigurationWidget = class(TCEWidget)
TCEProjectConfigurationWidget = class(TCEWidget, ICEProjectObserver)
imgList: TImageList;
selConf: TComboBox;
Panel1: TPanel;
@ -35,9 +36,10 @@ type
public
constructor create(aOwner: TComponent); override;
//
procedure projNew(const aProject: TCEProject); override;
procedure projChange(const aProject: TCEProject); override;
procedure projClose(const aProject: TCEProject); override;
procedure projNew(const aProject: TCEProject);
procedure projClosing(const aProject: TCEProject);
procedure projChanged(const aProject: TCEProject);
procedure projFocused(const aProject: TCEProject);
end;
implementation
@ -48,6 +50,8 @@ begin
inherited;
Tree.Selected := Tree.Items.GetLastNode;
Grid.OnEditorFilter := @GridFilter;
//
EntitiesConnector.addObserver(self);
end;
procedure TCEProjectConfigurationWidget.projNew(const aProject: TCEProject);
@ -57,18 +61,25 @@ begin
endUpdateByEvent;
end;
procedure TCEProjectConfigurationWidget.projChange(const aProject: TCEProject);
procedure TCEProjectConfigurationWidget.projClosing(const aProject: TCEProject);
begin
Grid.TIObject := nil;
Grid.ItemIndex := -1;
fProj := nil;
end;
procedure TCEProjectConfigurationWidget.projChanged(const aProject: TCEProject);
begin
beginUpdateByEvent;
fProj := aProject;
endUpdateByEvent;
end;
procedure TCEProjectConfigurationWidget.projClose(const aProject: TCEProject);
procedure TCEProjectConfigurationWidget.projFocused(const aProject: TCEProject);
begin
Grid.TIObject := nil;
Grid.ItemIndex := -1;
fProj := nil;
beginUpdateByEvent;
fProj := aProject;
endUpdateByEvent;
end;
procedure TCEProjectConfigurationWidget.selConfChange(Sender: TObject);

View File

@ -1,11 +1,12 @@
unit ce_project;
{$MODE OBJFPC}{$H+}
{$INTERFACES CORBA}
interface
uses
Classes, SysUtils, ce_dmdwrap, ce_libman;
Classes, SysUtils, ce_dmdwrap, ce_libman, ce_observer;
type
@ -30,6 +31,7 @@ type
fConfIx: Integer;
fLibMan: TLibraryManager;
fChangedCount: NativeInt;
fProjectSubject: TCECustomSubject;
procedure doChanged;
procedure setLibAliases(const aValue: TStringList);
procedure subMemberChanged(sender : TObject);
@ -77,23 +79,32 @@ type
implementation
uses
ce_common, dialogs;
ce_common, ce_interfaces, dialogs;
constructor TCEProject.create(aOwner: TComponent);
begin
inherited create(aOwner);
fProjectSubject := TCEProjectSubject.create;
//
fLibAliases := TStringList.Create;
fSrcs := TStringList.Create;
fSrcs.OnChange := @subMemberChanged;
fSrcsCop := TStringList.Create;
fOptsColl := TCollection.create(TCompilerConfiguration);
//
//subjProjNew(TCEProjectSubject(fProjectSubject), self);
//
reset;
addDefaults;
//
fModified := false;
end;
destructor TCEProject.destroy;
begin
subjProjClosing(TCEProjectSubject(fProjectSubject), self);
fProjectSubject.Free;
//
fOnChange := nil;
fLibAliases.Free;
fSrcs.free;
@ -218,6 +229,7 @@ var
{$ENDIF}
begin
fModified := true;
subjProjChanged(TCEProjectSubject(fProjectSubject), self);
if assigned(fOnChange) then fOnChange(Self);
{$IFDEF DEBUG}
lst := TStringList.Create;

View File

@ -1,16 +1,17 @@
unit ce_projinspect;
{$MODE OBJFPC}{$H+}
{$INTERFACES CORBA}
interface
uses
Classes, SysUtils, FileUtil, TreeFilterEdit, Forms, Controls, Graphics,
actnlist, Dialogs, ExtCtrls, ComCtrls, Menus, Buttons, ce_project,
ce_common, ce_widget, AnchorDocking;
Classes, SysUtils, FileUtil, TreeFilterEdit, Forms, Controls, Graphics, actnlist,
Dialogs, ExtCtrls, ComCtrls, Menus, Buttons, ce_project, ce_interfaces, ce_common,
ce_widget, ce_observer;
type
TCEProjectInspectWidget = class(TCEWidget)
TCEProjectInspectWidget = class(TCEWidget, ICEProjectObserver)
imgList: TImageList;
Panel1: TPanel;
btnAddFile: TSpeedButton;
@ -38,9 +39,11 @@ type
public
constructor create(aOwner: TComponent); override;
//
procedure projNew(const aProject: TCEProject); override;
procedure projChange(const aProject: TCEProject); override;
procedure projClose(const aProject: TCEProject); override;
procedure projNew(const aProject: TCEProject);
procedure projClosing(const aProject: TCEProject);
procedure projFocused(const aProject: TCEProject);
procedure projChanged(const aProject: TCEProject);
//
function contextName: string; override;
function contextActionCount: integer; override;
@ -70,6 +73,8 @@ begin
fConfNode := Tree.Items[1];
//
Tree.PopupMenu := contextMenu;
//
EntitiesConnector.addObserver(self);
end;
{$ENDREGION}
@ -102,21 +107,27 @@ end;
{$REGION ICEProjectMonitor -----------------------------------------------------}
procedure TCEProjectInspectWidget.projNew(const aProject: TCEProject);
begin
fProject := aProject;
UpdateByEvent;
//fProject := aProject;
//UpdateByEvent;
end;
procedure TCEProjectInspectWidget.projChange(const aProject: TCEProject);
begin
fProject := aProject;
UpdateByEvent;
end;
procedure TCEProjectInspectWidget.projClose(const aProject: TCEProject);
procedure TCEProjectInspectWidget.projClosing(const aProject: TCEProject);
begin
fProject := nil;
UpdateByEvent;
end;
procedure TCEProjectInspectWidget.projFocused(const aProject: TCEProject);
begin
fProject := aProject;
UpdateByEvent;
end;
procedure TCEProjectInspectWidget.projChanged(const aProject: TCEProject);
begin
fProject := aProject;
UpdateByEvent;
end;
{$ENDREGION}
procedure TCEProjectInspectWidget.TreeKeyDown(Sender: TObject; var Key: Word;Shift: TShiftState);

View File

@ -1,16 +1,17 @@
unit ce_search;
{$MODE OBJFPC}{$H+}
{$INTERFACES CORBA}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
Menus, StdCtrls, actnList, Buttons, SynEdit, SynEditSearch, SynEditTypes, ce_common,
ce_widget, ce_synmemo, AnchorDocking;
ce_widget, ce_synmemo, ce_interfaces, ce_observer;
type
TCESearchWidget = class(TCEWidget)
TCESearchWidget = class(TCEWidget, ICEMultiDocObserver)
btnFind: TBitBtn;
btnReplace: TBitBtn;
btnReplaceAll: TBitBtn;
@ -52,8 +53,10 @@ type
constructor Create(aOwner: TComponent); override;
destructor Destroy; override;
//
procedure docFocused(const aDoc: TCESynMemo); override;
procedure docClose(const aDoc: TCESynMemo); override;
procedure docNew(const aDoc: TCESynMemo);
procedure docClosing(const aDoc: TCESynMemo);
procedure docFocused(const aDoc: TCESynMemo);
procedure docChanged(const aDoc: TCESynMemo);
//
function contextName: string; override;
function contextActionCount: integer; override;
@ -88,6 +91,8 @@ begin
//
fSearchMru := TMruList.Create;
fReplaceMru:= TMruList.Create;
//
EntitiesConnector.addObserver(self);
end;
destructor TCESearchWidget.Destroy;
@ -270,16 +275,26 @@ end;
{$ENDREGION}
{$REGION ICEMultiDocMonitor ----------------------------------------------------}
procedure TCESearchWidget.docNew(const aDoc: TCESynMemo);
begin
fEditor := aDoc;
UpdateByEvent;
end;
procedure TCESearchWidget.docClosing(const aDoc: TCESynMemo);
begin
if fEditor = aDoc then fEditor := nil;
UpdateByEvent;
end;
procedure TCESearchWidget.docFocused(const aDoc: TCESynMemo);
begin
fEditor := aDoc;
UpdateByEvent;
end;
procedure TCESearchWidget.docClose(const aDoc: TCESynMemo);
procedure TCESearchWidget.docChanged(const aDoc: TCESynMemo);
begin
if fEditor = aDoc then fEditor := nil;
UpdateByEvent;
end;
{$ENDREGION}

View File

@ -1,18 +1,19 @@
unit ce_staticexplorer;
{$MODE OBJFPC}{$H+}
{$INTERFACES CORBA}
interface
uses
Classes, SysUtils, FileUtil, TreeFilterEdit, Forms, Controls, Graphics,
Dialogs, ExtCtrls, Menus, ComCtrls, ce_widget, jsonparser, fpjson,
ce_synmemo, process, actnlist, Buttons, ce_common, ce_project, AnchorDocking;
ce_synmemo, process, actnlist, Buttons, ce_common, ce_project, ce_observer,
ce_interfaces;
type
{ TCEStaticExplorerWidget }
TCEStaticExplorerWidget = class(TCEWidget)
btnRefresh: TBitBtn;
imgList: TImageList;
@ -59,19 +60,23 @@ type
public
constructor create(aOwner: TComponent); override;
//
procedure docFocused(const aDoc: TCESynMemo); override;
procedure docChanged(const aDoc: TCESynMemo); override;
procedure docClose(const aDoc: TCESynMemo); override;
procedure docNew(const aDoc: TCESynMemo);
procedure docClosing(const aDoc: TCESynMemo);
procedure docFocused(const aDoc: TCESynMemo);
procedure docChanged(const aDoc: TCESynMemo);
//
function contextName: string; override;
function contextActionCount: integer; override;
function contextAction(index: integer): TAction; override;
//
procedure projNew(const aProject: TCEProject); override;
procedure projChange(const aProject: TCEProject); override;
procedure projClose(const aProject: TCEProject); override;
procedure projCompile(const aProject: TCEProject); override;
procedure projRun(const aProject: TCEProject); override;
procedure projNew(const aProject: TCEProject);
procedure projClosing(const aProject: TCEProject);
procedure projFocused(const aProject: TCEProject);
procedure projChanged(const aProject: TCEProject);
procedure projCompile(const aProject: TCEProject); // warning: removed from itf
procedure projRun(const aProject: TCEProject); // warning: removed from itf
//
procedure declareProperties(aFiler: TFiler); override;
end;
@ -124,6 +129,8 @@ begin
//
Tree.OnDblClick := @TreeDblClick;
Tree.PopupMenu := contextMenu;
//
EntitiesConnector.addObserver(self);
end;
{$ENDREGION}
@ -216,6 +223,17 @@ end;
{$ENDREGION}
{$REGION ICEMultiDocMonitor ----------------------------------------------------}
procedure TCEStaticExplorerWidget.docNew(const aDoc: TCESynMemo);
begin
end;
procedure TCEStaticExplorerWidget.docClosing(const aDoc: TCESynMemo);
begin
if fDoc <> aDoc then exit;
fDoc := nil;
beginUpdateByDelay;
end;
procedure TCEStaticExplorerWidget.docFocused(const aDoc: TCESynMemo);
begin
fDoc := aDoc;
@ -229,13 +247,6 @@ begin
if fAutoRefresh then beginUpdateByDelay
else if fRefreshOnChange then Rescan;
end;
procedure TCEStaticExplorerWidget.docClose(const aDoc: TCESynMemo);
begin
if fDoc <> aDoc then exit;
fDoc := nil;
beginUpdateByDelay;
end;
{$ENDREGION}
{$REGION ICEProjectMonitor -----------------------------------------------------}
@ -244,24 +255,29 @@ begin
fProj := aProject;
end;
procedure TCEStaticExplorerWidget.projChange(const aProject: TCEProject);
begin
fProj := aProject;
end;
procedure TCEStaticExplorerWidget.projClose(const aProject: TCEProject);
procedure TCEStaticExplorerWidget.projClosing(const aProject: TCEProject);
begin
fProj := nil;
end;
procedure TCEStaticExplorerWidget.projFocused(const aProject: TCEProject);
begin
fProj := aProject;
end;
procedure TCEStaticExplorerWidget.projChanged(const aProject: TCEProject);
begin
fProj := aProject;
end;
procedure TCEStaticExplorerWidget.projCompile(const aProject: TCEProject);
begin
stopUpdateByDelay;
stopUpdateByDelay; // warning: not triggered anymore
end;
procedure TCEStaticExplorerWidget.projRun(const aProject: TCEProject);
begin
stopUpdateByDelay;
stopUpdateByDelay; // warning: not triggered anymore
end;
{$ENDREGION}

View File

@ -1,13 +1,14 @@
unit ce_synmemo;
{$MODE OBJFPC}{$H+}
{$INTERFACES CORBA}
interface
uses
Classes, SysUtils, SynEdit, SynMemo, ce_d2syn, SynEditHighlighter, controls,
lcltype, LazSynEditText, SynPluginSyncroEdit, SynEditKeyCmds, ce_project,
SynEditMouseCmds, ce_common;
SynEditMouseCmds, ce_common, ce_observer;
type
TCESynMemo = class(TSynMemo)
@ -20,6 +21,7 @@ type
fIsConfig: boolean;
fIdentifier: string;
fTempFileName: string;
fMultiDocSubject: TCECustomSubject;
procedure changeNotify(Sender: TObject);
procedure identifierToD2Syn;
protected
@ -55,7 +57,7 @@ var
implementation
uses
graphics, ce_main, forms;
graphics, ce_main, forms, ce_interfaces;
constructor TCESynMemo.Create(aOwner: TComponent);
begin
@ -88,10 +90,16 @@ begin
// avoid many call to get envir.string
fTempFileName := GetTempDir(false) + 'temp_' + uniqueObjStr(self) + '.d';
fMultiDocSubject := TCEMultiDocSubject.create;
subjDocNew(TCEMultiDocSubject(fMultiDocSubject), self);
end;
destructor TCESynMemo.destroy;
begin
subjDocClosing(TCEMultiDocSubject(fMultiDocSubject), self);
fMultiDocSubject.Free;
//
if fileExists(fTempFileName) then
sysutils.DeleteFile(fTempFileName);
inherited;
@ -102,6 +110,7 @@ begin
inherited;
checkFileDate;
identifierToD2Syn;
subjDocFocused(TCEMultiDocSubject(fMultiDocSubject), self);
end;
procedure TCESynMemo.UpdateShowing;
@ -135,6 +144,7 @@ procedure TCESynMemo.changeNotify(Sender: TObject);
begin
identifierToD2Syn;
fModified := true;
subjDocChanged(TCEMultiDocSubject(fMultiDocSubject), self);
end;
procedure TCESynMemo.loadFromFile(const aFilename: string);
@ -148,6 +158,7 @@ begin
fFilename := aFilename;
FileAge(fFilename, fFileDate);
fModified := false;
subjDocChanged(TCEMultiDocSubject(fMultiDocSubject), self);
end;
procedure TCESynMemo.saveToFile(const aFilename: string);
@ -156,6 +167,7 @@ begin
fFilename := aFilename;
FileAge(fFilename, fFileDate);
fModified := false;
subjDocChanged(TCEMultiDocSubject(fMultiDocSubject), self);
end;
procedure TCESynMemo.save;
@ -163,6 +175,7 @@ begin
Lines.SaveToFile(fFilename);
FileAge(fFilename, fFileDate);
fModified := false;
subjDocChanged(TCEMultiDocSubject(fMultiDocSubject), self);
end;
procedure TCESynMemo.checkFileDate;

View File

@ -5,9 +5,8 @@ unit ce_widget;
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, ExtCtrls,
AnchorDocking, AnchorDockStorage, ActnList, Menus,
ce_synmemo, ce_widgettypes, ce_project;
Classes, SysUtils, FileUtil, Forms, Controls, ExtCtrls, ActnList, Menus,
ce_interfaces;
type
@ -15,7 +14,7 @@ type
* Base type for an UI module.
*)
PTCEWidget = ^TCEWidget;
TCEWidget = class(TForm, ICEContextualActions, ICEProjectMonitor, ICEMultiDocObserver, ICEWidgetPersist)
TCEWidget = class(TForm, ICEContextualActions, ICEWidgetPersist)
Content: TPanel;
Back: TPanel;
contextMenu: TPopupMenu;
@ -66,18 +65,6 @@ type
// immediate call 'UpdateByEvent'
procedure forceUpdateByEvent;
//
procedure docNew(const aDoc: TCESynMemo); virtual;
procedure docFocused(const aDoc: TCESynMemo); virtual;
procedure docChanged(const aDoc: TCESynMemo); virtual;
procedure docClose(const aDoc: TCESynMemo); virtual;
//
procedure projNew(const aProject: TCEProject); virtual;
procedure projChange(const aProject: TCEProject); virtual;
procedure projClose(const aProject: TCEProject); virtual;
procedure projCompile(const aProject: TCEProject); virtual;
procedure projRun(const aProject: TCEProject); virtual;
procedure projFocused(const aProject: TCEProject); virtual;
//
function contextName: string; virtual;
function contextActionCount: integer; virtual;
function contextAction(index: integer): TAction; virtual;
@ -204,47 +191,47 @@ end;
{$ENDREGION}
{$REGION ICEMultiDocObserver ----------------------------------------------------}
procedure TCEWidget.docNew(const aDoc: TCESynMemo);
begin
end;
procedure TCEWidget.docFocused(const aDoc: TCESynMemo);
begin
end;
procedure TCEWidget.docChanged(const aDoc: TCESynMemo);
begin
end;
procedure TCEWidget.docClose(const aDoc: TCESynMemo);
begin
end;
//procedure TCEWidget.docNew(const aDoc: TCESynMemo);
//begin
//end;
//
//procedure TCEWidget.docFocused(const aDoc: TCESynMemo);
//begin
//end;
//
//procedure TCEWidget.docChanged(const aDoc: TCESynMemo);
//begin
//end;
//
//procedure TCEWidget.docClose(const aDoc: TCESynMemo);
//begin
//end;
{$ENDREGION}
{$REGION ICEProjectMonitor -----------------------------------------------------}
procedure TCEWidget.projNew(const aProject: TCEProject);
begin
end;
procedure TCEWidget.projChange(const aProject: TCEProject);
begin
end;
procedure TCEWidget.projClose(const aProject: TCEProject);
begin
end;
procedure TCEWidget.projCompile(const aProject: TCEProject);
begin
end;
procedure TCEWidget.projRun(const aProject: TCEProject);
begin
end;
procedure TCEWidget.projFocused(const aProject: TCEProject);
begin
end;
{$REGION ICEProjectObserver -----------------------------------------------------}
//procedure TCEWidget.projNew(const aProject: TCEProject);
//begin
//end;
//
//procedure TCEWidget.projChange(const aProject: TCEProject);
//begin
//end;
//
//procedure TCEWidget.projClose(const aProject: TCEProject);
//begin
//end;
//
//procedure TCEWidget.projCompile(const aProject: TCEProject);
//begin
//end;
//
//procedure TCEWidget.projRun(const aProject: TCEProject);
//begin
//end;
//
//procedure TCEWidget.projFocused(const aProject: TCEProject);
//begin
//end;
{$ENDREGION}
{$REGION Updaters---------------------------------------------------------------}

View File

@ -8,12 +8,13 @@ interface
uses
Classes, SysUtils, actnList, menus, ce_synmemo, ce_project, ce_observer;
type
(**
* An implementer can save and load some stuffs on application start/quit
*)
ICEWidgetPersist = interface
ICEWidgetPersist = interface(ICEObserver)
// Coedit options are about to be saved.
procedure beforeSave(sender: TObject);
// some custom properties can be declared to aFiler.
@ -26,7 +27,7 @@ type
* An implementer declares some actions on demand.
* TODO-cfeature: improve the interface so that a widget can declare a complete main menu category.
*)
ICEContextualActions = interface
ICEContextualActions = interface(ICEObserver)
// declares a context name for the actions
function contextName: string;
// action count, called before contextAction()
@ -52,32 +53,35 @@ type
(**
* An implementer informs some ICEMultiDocObserver about the current file(s)
*)
TCEMultiDocSubject = class(TCECustomSubject, ICEMultiDocObserver)
TCEMultiDocSubject = class(TCECustomSubject)
protected
function acceptObserver(aObject: TObject): boolean; override;
public
procedure docNew(const aDoc: TCESynMemo);
procedure docFocused(const aDoc: TCESynMemo);
procedure docChanged(const aDoc: TCESynMemo);
procedure docClose(const aDoc: TCESynMemo);
end;
(**
* An implementer is informed about the current project(s).
*)
ICEProjectMonitor = interface
ICEProjectObserver = interface(ICEObserver)
// the new project aProject has been created/opened
procedure projNew(const aProject: TCEProject);
// aProject has been modified: switches, source name, ...
procedure projChange(const aProject: TCEProject);
// aProject is about to be closed.
procedure projClose(const aProject: TCEProject);
// not used yet: the active project is now aProject
procedure projFocused(const aProject: TCEProject); // rename: projSelected or projActivated
// aProject is about to be compiled.
procedure projCompile(const aProject: TCEProject);
// aProject is about to be executed.
procedure projRun(const aProject: TCEProject);
// not used yet: the active project is now aProject
procedure projFocused(const aProject: TCEProject); // rename: projSelected or projActivated
end;
(**
* An implementer informs some ICEMultiDocObserver about the current file(s)
*)
TCEProjectSubject = class(TCECustomSubject)
protected
function acceptObserver(aObject: TObject): boolean; override;
end;
(**
@ -88,43 +92,128 @@ type
procedure menuDeclare(out item: TMenuItem);
end;
{
subject Primitives:
A subject has not necessarly all the informations the observers expect.
It can compose using the following "primitives".
}
(**
* TCEMultiDocSubject primitives.
*)
procedure subjDocNew(aSubject: TCEMultiDocSubject; aDoc: TCESynMemo); {$IFDEF RELEASE}inline;{$ENDIF}
procedure subjDocFocused(aSubject: TCEMultiDocSubject; aDoc: TCESynMemo); {$IFDEF RELEASE}inline;{$ENDIF}
procedure subjDocChanged(aSubject: TCEMultiDocSubject; aDoc: TCESynMemo); {$IFDEF RELEASE}inline;{$ENDIF}
procedure subjDocClosed(aSubject: TCEMultiDocSubject; aDoc: TCESynMemo); {$IFDEF RELEASE}inline;{$ENDIF}
(**
* TCEProjectSubject primitives.
*)
procedure subjProjNew(aSubject: TCEProjectSubject; aProj: TCEProject); {$IFDEF RELEASE}inline;{$ENDIF}
procedure subjProjFocused(aSubject: TCEProjectSubject; aProj: TCEProject); {$IFDEF RELEASE}inline;{$ENDIF}
procedure subjProjChanged(aSubject: TCEProjectSubject; aProj: TCEProject); {$IFDEF RELEASE}inline;{$ENDIF}
procedure subjProjClose(aSubject: TCEProjectSubject; aProj: TCEProject); {$IFDEF RELEASE}inline;{$ENDIF}
procedure subjProjCompile(aSubject: TCEProjectSubject; aProj: TCEProject); {$IFDEF RELEASE}inline;{$ENDIF}
procedure subjProjRun(aSubject: TCEProjectSubject; aProj: TCEProject); {$IFDEF RELEASE}inline;{$ENDIF}
implementation
function TCEMultiDocSubject.acceptObserver(aObject: TObject): boolean;
begin
result := (aObject as ICEMultiDocObserver) <> nil;
end;
procedure TCEMultiDocSubject.docNew(const aDoc: TCESynMemo);
procedure subjDocNew(aSubject: TCEMultiDocSubject; aDoc: TCESynMemo);
var
i: Integer;
begin
for i:= 0 to fObservers.Count-1 do
with aSubject do for i:= 0 to fObservers.Count-1 do
(fObservers.Items[i] as ICEMultiDocObserver).docNew(aDoc);
end;
procedure TCEMultiDocSubject.docFocused(const aDoc: TCESynMemo);
procedure subjDocFocused(aSubject: TCEMultiDocSubject; aDoc: TCESynMemo);
var
i: Integer;
begin
for i:= 0 to fObservers.Count-1 do
with aSubject do for i:= 0 to fObservers.Count-1 do
(fObservers.Items[i] as ICEMultiDocObserver).docFocused(aDoc);
end;
procedure TCEMultiDocSubject.docChanged(const aDoc: TCESynMemo);
procedure subjDocChanged(aSubject: TCEMultiDocSubject; aDoc: TCESynMemo);
var
i: Integer;
begin
for i:= 0 to fObservers.Count-1 do
with aSubject do for i:= 0 to fObservers.Count-1 do
(fObservers.Items[i] as ICEMultiDocObserver).docChanged(aDoc);
end;
procedure TCEMultiDocSubject.docClose(const aDoc: TCESynMemo);
procedure subjDocClosed(aSubject: TCEMultiDocSubject; aDoc: TCESynMemo);
var
i: Integer;
begin
for i:= 0 to fObservers.Count-1 do
with aSubject do for i:= 0 to fObservers.Count-1 do
(fObservers.Items[i] as ICEMultiDocObserver).docClose(aDoc);
end;
function TCEProjectSubject.acceptObserver(aObject: TObject): boolean;
begin
result := (aObject as ICEProjectObserver) <> nil;
end;
procedure subjProjNew(aSubject: TCEProjectSubject; aProj: TCEProject);
var
i: Integer;
begin
with aSubject do for i:= 0 to fObservers.Count-1 do
(fObservers.Items[i] as ICEProjectObserver).ProjNew(aProj);
end;
procedure subjProjFocused(aSubject: TCEProjectSubject; aProj: TCEProject);
var
i: Integer;
begin
with aSubject do for i:= 0 to fObservers.Count-1 do
(fObservers.Items[i] as ICEProjectObserver).projFocused(aProj);
end;
procedure subjProjChanged(aSubject: TCEProjectSubject; aProj: TCEProject);
var
i: Integer;
begin
with aSubject do for i:= 0 to fObservers.Count-1 do
(fObservers.Items[i] as ICEProjectObserver).projChange(aProj);
end;
procedure subjProjClose(aSubject: TCEProjectSubject; aProj: TCEProject);
var
i: Integer;
begin
with aSubject do for i:= 0 to fObservers.Count-1 do
(fObservers.Items[i] as ICEProjectObserver).projClose(aProj);
end;
procedure subjProjCompile(aSubject: TCEProjectSubject; aProj: TCEProject);
var
i: Integer;
begin
with aSubject do for i:= 0 to fObservers.Count-1 do
(fObservers.Items[i] as ICEProjectObserver).projCompile(aProj);
end;
procedure subjProjRun(aSubject: TCEProjectSubject; aProj: TCEProject);
var
i: Integer;
begin
with aSubject do for i:= 0 to fObservers.Count-1 do
(fObservers.Items[i] as ICEProjectObserver).projRun(aProj);
end;
end.