mirror of https://gitlab.com/basile.b/dexed.git
Add IDE interface for observing the mini explorer
allowing the symstring expander to update more smartly
This commit is contained in:
parent
e675198118
commit
918388e9ef
|
@ -186,6 +186,18 @@ type
|
|||
*)
|
||||
TCEEditableShortCutSubject = specialize TCECustomSubject<ICEEditableShortCut>;
|
||||
|
||||
(**
|
||||
* Listen to mini explorer changes. Mostly made to prevent redundant updates
|
||||
* of the symbolic string translater.
|
||||
*)
|
||||
ICEMiniExplorerObserver = interface(IObserverType)
|
||||
['ICEMiniExplorerObserver']
|
||||
procedure mnexDirectoryChanged(const directory: string);
|
||||
end;
|
||||
(**
|
||||
* Mini-explorer implements this.
|
||||
*)
|
||||
TCEMiniExplorerSubject = specialize TCECustomSubject<ICEMiniExplorerObserver>;
|
||||
|
||||
|
||||
// the option editor uses this value as a hint to display an option container.
|
||||
|
@ -454,6 +466,11 @@ type
|
|||
procedure subjProjCompiling(aSubject: TCEProjectSubject; project: ICECommonProject);{$IFDEF RELEASE}inline;{$ENDIF}
|
||||
procedure subjProjCompiled(aSubject: TCEProjectSubject; project: ICECommonProject; success: boolean);{$IFDEF RELEASE}inline;{$ENDIF}
|
||||
|
||||
(**
|
||||
* TCEMiniExplorerSubject primitives.
|
||||
*)
|
||||
procedure subjMnexDirectoryChanged(aSubject: TCEMiniExplorerSubject; const directory: string); {$IFDEF RELEASE}inline;{$ENDIF}
|
||||
|
||||
|
||||
{
|
||||
Service getters:
|
||||
|
@ -507,6 +524,16 @@ begin
|
|||
end;
|
||||
{$ENDREGION}
|
||||
|
||||
{$REGION TCEMiniExplorerSubject ------------------------------------------------}
|
||||
procedure subjMnexDirectoryChanged(aSubject: TCEMiniExplorerSubject; const directory: string);
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
with aSubject do for i:= 0 to fObservers.Count-1 do
|
||||
(fObservers[i] as ICEMiniExplorerObserver).mnexDirectoryChanged(directory);
|
||||
end;
|
||||
{$ENDREGION}
|
||||
|
||||
{$REGION TCEProjectSubject -----------------------------------------------------}
|
||||
procedure subjProjNew(aSubject: TCEProjectSubject; project: ICECommonProject);
|
||||
var
|
||||
|
@ -555,7 +582,6 @@ begin
|
|||
with aSubject do for i:= 0 to fObservers.Count-1 do
|
||||
(fObservers[i] as ICEProjectObserver).projCompiled(project, success);
|
||||
end;
|
||||
|
||||
{$ENDREGION}
|
||||
|
||||
{$REGION ICESingleService getters ----------------------------------------------}
|
||||
|
|
|
@ -102,6 +102,7 @@ type
|
|||
procedure treeFoldersGetImageIndex(Sender: TObject; Node: TTreeNode);
|
||||
procedure treeFoldersGetSelectedIndex(Sender: TObject; Node: TTreeNode);
|
||||
private
|
||||
fMnxSubj: TCEMiniExplorerSubject;
|
||||
fProj: ICECommonProject;
|
||||
fFreeProj: ICECommonProject;
|
||||
fFavorites: TStringList;
|
||||
|
@ -363,12 +364,14 @@ begin
|
|||
free;
|
||||
end;
|
||||
|
||||
fMnxSubj:= TCEMiniExplorerSubject.Create;
|
||||
EntitiesConnector.addObserver(self);
|
||||
EntitiesConnector.addSingleService(self);
|
||||
end;
|
||||
|
||||
destructor TCEMiniExplorerWidget.destroy;
|
||||
begin
|
||||
fMnxSubj.free;
|
||||
EntitiesConnector.removeObserver(self);
|
||||
with TCEMiniExplorerOptions.create(nil) do
|
||||
try
|
||||
|
@ -781,6 +784,7 @@ begin
|
|||
if treeFolders.Selected.isNil then
|
||||
exit;
|
||||
fLastFold := treeFolders.Path.extractFileDir; // trailing path sep
|
||||
subjMnexDirectoryChanged(fMnxSubj, fLastFold);
|
||||
end;
|
||||
|
||||
procedure TCEMiniExplorerWidget.treeFoldersDblClick(Sender: TObject);
|
||||
|
|
|
@ -26,7 +26,7 @@ type
|
|||
* TCESymbolExpander is designed to expand Coedit symbolic strings,
|
||||
* using the information collected from several observer interfaces.
|
||||
*)
|
||||
TCESymbolExpander = class(ICEDocumentObserver, ICEProjectObserver, ICESymStringExpander)
|
||||
TCESymbolExpander = class(ICEDocumentObserver, ICEProjectObserver, ICESymStringExpander, ICEMiniExplorerObserver)
|
||||
private
|
||||
fProj: TCENativeProject;
|
||||
fProjInterface: ICECommonProject;
|
||||
|
@ -35,19 +35,21 @@ type
|
|||
fExp: ICEExplorer;
|
||||
fSymbols: array[TCESymbol] of string;
|
||||
procedure updateSymbols;
|
||||
//
|
||||
|
||||
procedure projNew(project: ICECommonProject);
|
||||
procedure projClosing(project: ICECommonProject);
|
||||
procedure projFocused(project: ICECommonProject);
|
||||
procedure projChanged(project: ICECommonProject);
|
||||
procedure projCompiling(project: ICECommonProject);
|
||||
procedure projCompiled(project: ICECommonProject; success: boolean);
|
||||
//
|
||||
|
||||
procedure docNew(document: TCESynMemo);
|
||||
procedure docClosing(document: TCESynMemo);
|
||||
procedure docFocused(document: TCESynMemo);
|
||||
procedure docChanged(document: TCESynMemo);
|
||||
//
|
||||
|
||||
procedure mnexDirectoryChanged(const directory: string);
|
||||
|
||||
function singleServiceName: string;
|
||||
function expand(const value: string): string;
|
||||
public
|
||||
|
@ -163,6 +165,11 @@ begin
|
|||
exit;
|
||||
fNeedUpdate := true;
|
||||
end;
|
||||
|
||||
procedure TCESymbolExpander.mnexDirectoryChanged(const directory: string);
|
||||
begin
|
||||
fNeedUpdate := true;
|
||||
end;
|
||||
{$ENDREGION}
|
||||
|
||||
{$REGION Symbol things ---------------------------------------------------------}
|
||||
|
@ -178,9 +185,8 @@ var
|
|||
const
|
||||
na = '``';
|
||||
begin
|
||||
//commented : mini explorer doesn't emitt notif,
|
||||
//if not fNeedUpdate then
|
||||
// exit;
|
||||
if not fNeedUpdate then
|
||||
exit;
|
||||
fNeedUpdate := false;
|
||||
|
||||
hasNativeProj := fProj.isNotNil;
|
||||
|
|
Loading…
Reference in New Issue