From 55c80fb6429b02bd163b6b251c202b277c159ba7 Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Wed, 12 Jan 2022 15:28:59 -0800 Subject: [PATCH] Improve double-click handling in symbols window Double-clicking on an entry in the symbols window is supposed to take you to the place where that symbol is defined. This worked for code labels but not for project/platform symbols. We now jump to the appropriate EQU statement, if one exists. --- SourceGen/MainController.cs | 36 ++++++++++++++++++++++------- SourceGen/WpfGui/MainWindow.xaml.cs | 6 +++-- 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/SourceGen/MainController.cs b/SourceGen/MainController.cs index 9dc3624..67879a9 100644 --- a/SourceGen/MainController.cs +++ b/SourceGen/MainController.cs @@ -3192,18 +3192,38 @@ namespace SourceGen { } /// - /// Scrolls the code list so that the specified label is shown. + /// Scrolls the code list so that the specified label is shown. If the label can't + /// be found, nothing happens. /// /// Label symbol. - public void GoToLabel(Symbol sym) { - int offset = mProject.FindLabelOffsetByName(sym.Label); - if (offset >= 0) { - // TODO(someday): jump to symbol line, not arstart, for address region pre-labels - GoToLocation(new NavStack.Location(offset, 0, NavStack.GoToMode.JumpToCodeData), - true); + public bool GoToSymbol(Symbol sym) { + bool found = false; + + if (sym.SymbolSource == Symbol.Source.Platform || + sym.SymbolSource == Symbol.Source.Project) { + // Look for an EQU line for the project or platform symbol. + for (int i = 0; i < mProject.ActiveDefSymbolList.Count; i++) { + if (mProject.ActiveDefSymbolList[i] == sym) { + int offset = LineListGen.DefSymOffsetFromIndex(i); + Debug.Assert(offset < 0); + GoToLocation(new NavStack.Location(offset, 0, + NavStack.GoToMode.JumpToCodeData), true); + found = true; + break; + } + } } else { - Debug.WriteLine("DClick symbol: " + sym + ": label not found"); + // Just look for a matching label. + int offset = mProject.FindLabelOffsetByName(sym.Label); + if (offset >= 0) { + // TODO(someday):jump to symbol line, not arstart, for address region pre-labels + GoToLocation(new NavStack.Location(offset, 0, NavStack.GoToMode.JumpToCodeData), + true); + found = true; + } } + + return found; } public void SelectionChanged() { diff --git a/SourceGen/WpfGui/MainWindow.xaml.cs b/SourceGen/WpfGui/MainWindow.xaml.cs index 72c2eab..3996180 100644 --- a/SourceGen/WpfGui/MainWindow.xaml.cs +++ b/SourceGen/WpfGui/MainWindow.xaml.cs @@ -1888,8 +1888,10 @@ namespace SourceGen.WpfGui { } SymbolsListItem sli = (SymbolsListItem)item; - // TODO: this should also work for project/platform symbols that have EQU directives - mMainCtrl.GoToLabel(sli.Sym); + if (!mMainCtrl.GoToSymbol(sli.Sym)) { + // TODO(maybe): indicate failure with a sound + Debug.WriteLine("DClick symbol list: '" + sli.Sym.Label + "' not found"); + } //codeListView.Focus(); }