1
0
mirror of https://github.com/fadden/6502bench.git synced 2024-05-31 22:41:37 +00:00

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.
This commit is contained in:
Andy McFadden 2022-01-12 15:28:59 -08:00
parent 60b024d24e
commit 55c80fb642
2 changed files with 32 additions and 10 deletions

View File

@ -3192,18 +3192,38 @@ namespace SourceGen {
}
/// <summary>
/// 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.
/// </summary>
/// <param name="sym">Label symbol.</param>
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() {

View File

@ -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();
}