added symbol list 'smart expander'

The symbol list automatically expand to the nearest declaration, as an option
This commit is contained in:
Basile Burg 2015-09-24 00:23:51 +02:00
parent a7866eb88f
commit edb3030264
1 changed files with 20 additions and 9 deletions

View File

@ -81,6 +81,7 @@ type
fAutoRefreshDelay: Integer; fAutoRefreshDelay: Integer;
fSmartFilter: boolean; fSmartFilter: boolean;
fAutoExpandErrors: boolean; fAutoExpandErrors: boolean;
fSmartExpander: boolean;
fSortSymbols: boolean; fSortSymbols: boolean;
published published
property autoRefresh: boolean read fAutoRefresh write fAutoRefresh; property autoRefresh: boolean read fAutoRefresh write fAutoRefresh;
@ -91,6 +92,7 @@ type
property smartFilter: boolean read fSmartFilter write fSmartFilter; property smartFilter: boolean read fSmartFilter write fSmartFilter;
property autoExpandErrors: boolean read fAutoExpandErrors write fAutoExpandErrors; property autoExpandErrors: boolean read fAutoExpandErrors write fAutoExpandErrors;
property sortSymbols: boolean read fSortSymbols write fSortSymbols; property sortSymbols: boolean read fSortSymbols write fSortSymbols;
property smartExpander: boolean read fSmartExpander write fSmartExpander;
public public
constructor Create(AOwner: TComponent); override; constructor Create(AOwner: TComponent); override;
procedure Assign(Source: TPersistent); override; procedure Assign(Source: TPersistent); override;
@ -131,6 +133,7 @@ type
fSmartFilter: boolean; fSmartFilter: boolean;
fAutoExpandErrors: boolean; fAutoExpandErrors: boolean;
fSortSymbols: boolean; fSortSymbols: boolean;
fSmartExpander: boolean;
ndAlias, ndClass, ndEnum, ndFunc, ndUni: TTreeNode; ndAlias, ndClass, ndEnum, ndFunc, ndUni: TTreeNode;
ndImp, ndIntf, ndMix, ndStruct, ndTmp: TTreeNode; ndImp, ndIntf, ndMix, ndStruct, ndTmp: TTreeNode;
ndVar, ndWarn, ndErr: TTreeNode; ndVar, ndWarn, ndErr: TTreeNode;
@ -142,7 +145,7 @@ type
procedure actCopyIdentExecute(Sender: TObject); procedure actCopyIdentExecute(Sender: TObject);
procedure updateVisibleCat; procedure updateVisibleCat;
procedure clearTree; procedure clearTree;
procedure expandCurrentDeclaration; procedure smartExpand;
// //
procedure checkIfHasToolExe; procedure checkIfHasToolExe;
procedure callToolProc; procedure callToolProc;
@ -275,6 +278,7 @@ begin
fSmartFilter := widg.fSmartFilter; fSmartFilter := widg.fSmartFilter;
fAutoExpandErrors := widg.fAutoExpandErrors; fAutoExpandErrors := widg.fAutoExpandErrors;
fSortSymbols := widg.fSortSymbols; fSortSymbols := widg.fSortSymbols;
fSmartExpander := widg.fSmartExpander;
end end
else inherited; else inherited;
end; end;
@ -295,15 +299,11 @@ begin
widg.fSmartFilter := fSmartFilter; widg.fSmartFilter := fSmartFilter;
widg.fAutoExpandErrors := fAutoExpandErrors; widg.fAutoExpandErrors := fAutoExpandErrors;
widg.fSortSymbols := fSortSymbols; widg.fSortSymbols := fSortSymbols;
widg.fSmartExpander := fSmartExpander;
// //
widg.fActAutoRefresh.Checked := fAutoRefresh; widg.fActAutoRefresh.Checked := fAutoRefresh;
widg.fActRefreshOnChange.Checked:= fRefreshOnChange; widg.fActRefreshOnChange.Checked:= fRefreshOnChange;
widg.fActRefreshOnFocus.Checked := fRefreshOnFocus; widg.fActRefreshOnFocus.Checked := fRefreshOnFocus;
//
//if fSortSymbols then
// widg.Tree.SortType := stText
//else
// widg.Tree.SortType:= stNone;
end end
else inherited; else inherited;
end; end;
@ -525,7 +525,8 @@ begin
if fAutoRefresh then beginDelayedUpdate if fAutoRefresh then beginDelayedUpdate
else if fRefreshOnChange then callToolProc; else if fRefreshOnChange then callToolProc;
// //
//expandCurrentDeclaration; if fSmartExpander then
smartExpand;
end; end;
{$ENDREGION} {$ENDREGION}
@ -759,11 +760,12 @@ begin
if Tree.Items[i].Count > 0 then if Tree.Items[i].Count > 0 then
tree.Items[i].CustomSort(nil); tree.Items[i].CustomSort(nil);
//expandCurrentDeclaration; if fSmartExpander then
smartExpand;
tree.EndUpdate; tree.EndUpdate;
end; end;
procedure TCESymbolListWidget.expandCurrentDeclaration; procedure TCESymbolListWidget.smartExpand;
var var
i: integer; i: integer;
nearest, target: NativeUint; nearest, target: NativeUint;
@ -779,6 +781,12 @@ var
if root.Items[i].Data = nil then if root.Items[i].Data = nil then
continue; continue;
{$HINTS OFF} {$HINTS OFF}
if root.Items[i].Parent = nil then
continue;
case root.Items[i].Parent.Text of
'Alias', 'Enum', 'Import', 'Variable':
continue;
end;
l := NativeUInt(root.Items[i].Data); l := NativeUInt(root.Items[i].Data);
{$HINTS ON} {$HINTS ON}
if l > target then if l > target then
@ -800,7 +808,10 @@ begin
for i := 0 to tree.Items.Count-1 do for i := 0 to tree.Items.Count-1 do
look(tree.Items[i]); look(tree.Items[i]);
if toExpand <> nil then if toExpand <> nil then
begin
tree.Selected := toExpand; tree.Selected := toExpand;
toExpand.MakeVisible;
end;
end; end;
{$ENDREGION --------------------------------------------------------------------} {$ENDREGION --------------------------------------------------------------------}