mirror of
https://github.com/fadden/6502bench.git
synced 2025-08-05 09:25:39 +00:00
Add "copy out" button to References window
The References window is handy for seeing everything that refers to a particular address or symbol, but walking through the list is annoying because the window gets reset every time you double-click on an entry and the selection moves. This adds a "copy out" button that copies the references to a floating window. References can be double-clicked as usual, but the list doesn't update unless you click "copy out" again. This might be better if it were somehow integrated into the main window, e.g. as a tab in the Info panel, so that the focus isn't bouncing between two independently Z-ordered windows.
This commit is contained in:
@@ -115,6 +115,11 @@ namespace SourceGen {
|
||||
/// </summary>
|
||||
public bool IsInstructionChartOpen { get { return mInstructionChartDialog != null; } }
|
||||
|
||||
/// <summary>
|
||||
/// Reference table window. Tied to the current project.
|
||||
/// </summary>
|
||||
private ReferenceTable mReferenceTableDialog;
|
||||
|
||||
/// <summary>
|
||||
/// List of recently-opened projects.
|
||||
/// </summary>
|
||||
@@ -1701,6 +1706,7 @@ namespace SourceGen {
|
||||
mAsciiChartDialog?.Close();
|
||||
mInstructionChartDialog?.Close();
|
||||
mHexDumpDialog?.Close();
|
||||
mReferenceTableDialog?.Close();
|
||||
mShowAnalysisTimersDialog?.Close();
|
||||
mShowAnalyzerOutputDialog?.Close();
|
||||
mShowUndoRedoHistoryDialog?.Close();
|
||||
@@ -1742,6 +1748,7 @@ namespace SourceGen {
|
||||
|
||||
// Close modeless dialogs that depend on project.
|
||||
mHexDumpDialog?.Close();
|
||||
mReferenceTableDialog?.Close();
|
||||
mShowAnalysisTimersDialog?.Close();
|
||||
mShowAnalyzerOutputDialog?.Close();
|
||||
mShowUndoRedoHistoryDialog?.Close();
|
||||
@@ -4448,7 +4455,7 @@ namespace SourceGen {
|
||||
/// be a problem.
|
||||
/// </summary>
|
||||
private void UpdateReferencesPanel() {
|
||||
mMainWin.ReferencesList.Clear();
|
||||
mMainWin.ReferencesListClear();
|
||||
|
||||
if (mMainWin.CodeListView_GetSelectionCount() != 1) {
|
||||
// Nothing selected, or multiple lines selected.
|
||||
@@ -4545,7 +4552,7 @@ namespace SourceGen {
|
||||
(xr.IsByName ? "Sym " : "Oth ") + typeStr + idxStr +
|
||||
formatter.FormatAdjustment(-xr.Adjustment));
|
||||
|
||||
mMainWin.ReferencesList.Add(rli);
|
||||
mMainWin.ReferencesListAdd(rli);
|
||||
}
|
||||
|
||||
// TODO(maybe): set the selection to something, instead of just inheriting it?
|
||||
@@ -5226,6 +5233,24 @@ namespace SourceGen {
|
||||
dlg.ShowDialog();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shows a table of references in a non-modial dialog window. If the window is already
|
||||
/// being displayed, the contents are replaced.
|
||||
/// </summary>
|
||||
public void ShowReferenceTable(List<ReferenceTable.ReferenceTableItem> items) {
|
||||
if (mReferenceTableDialog == null) {
|
||||
// Create without owner so it doesn't have to be in front of main window.
|
||||
mReferenceTableDialog = new ReferenceTable(null, this);
|
||||
mReferenceTableDialog.Closing += (sender, e) => {
|
||||
Debug.WriteLine("Reference table dialog closed");
|
||||
mReferenceTableDialog = null;
|
||||
};
|
||||
mReferenceTableDialog.Show();
|
||||
}
|
||||
|
||||
mReferenceTableDialog.SetItems(items);
|
||||
}
|
||||
|
||||
#endregion Tools
|
||||
|
||||
#region Debug features
|
||||
|
@@ -241,6 +241,9 @@
|
||||
<Compile Include="WpfGui\RecoveryChoice.xaml.cs">
|
||||
<DependentUpon>RecoveryChoice.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="WpfGui\ReferenceTable.xaml.cs">
|
||||
<DependentUpon>ReferenceTable.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="WpfGui\ShowWireframeAnimation.xaml.cs">
|
||||
<DependentUpon>ShowWireframeAnimation.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@@ -483,6 +486,10 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="WpfGui\ReferenceTable.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="WpfGui\ShowWireframeAnimation.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
|
@@ -152,7 +152,7 @@ namespace SourceGen.WpfGui {
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
this.Title += " (" + formatter.FormatAddress(address, true) + ")";
|
||||
this.Title += " ($" + formatter.FormatAddress(address, address > 0xffff) + ")";
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@@ -591,6 +591,7 @@ limitations under the License.
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<GroupBox Grid.Row="0" Header="References">
|
||||
<Grid>
|
||||
<DataGrid Name="referencesGrid" IsReadOnly="True"
|
||||
ItemsSource="{Binding ReferencesList}"
|
||||
FontFamily="{StaticResource GeneralMonoFont}"
|
||||
@@ -608,6 +609,11 @@ limitations under the License.
|
||||
<DataGridTextColumn Header="Type" Width="119" Binding="{Binding Type}"/>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
<Button Content="Copy Out" Width="70" Height="19" Margin="2"
|
||||
HorizontalAlignment="Right" VerticalAlignment="Top"
|
||||
IsEnabled="{Binding IsEnabledReferencesListCopyOut}"
|
||||
Click="ReferencesListCopyOut_Click"/>
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
|
||||
<GroupBox Grid.Row="2" Header="Notes">
|
||||
|
@@ -1701,6 +1701,12 @@ namespace SourceGen.WpfGui {
|
||||
|
||||
#region References panel
|
||||
|
||||
public bool IsEnabledReferencesListCopyOut {
|
||||
get { return mIsEnabledReferencesListCopyOut; }
|
||||
set { mIsEnabledReferencesListCopyOut = value; OnPropertyChanged(); }
|
||||
}
|
||||
private bool mIsEnabledReferencesListCopyOut = false;
|
||||
|
||||
public class ReferencesListItem {
|
||||
public int OffsetValue { get; private set; }
|
||||
public string Offset { get; private set; }
|
||||
@@ -1723,6 +1729,16 @@ namespace SourceGen.WpfGui {
|
||||
public ObservableCollection<ReferencesListItem> ReferencesList { get; private set; } =
|
||||
new ObservableCollection<ReferencesListItem>();
|
||||
|
||||
internal void ReferencesListClear() {
|
||||
ReferencesList.Clear();
|
||||
IsEnabledReferencesListCopyOut = false;
|
||||
}
|
||||
|
||||
internal void ReferencesListAdd(ReferencesListItem newItem) {
|
||||
ReferencesList.Add(newItem);
|
||||
IsEnabledReferencesListCopyOut = true;
|
||||
}
|
||||
|
||||
private void ReferencesList_MouseDoubleClick(object sender, MouseButtonEventArgs e) {
|
||||
if (!referencesGrid.GetClickRowColItem(e, out int unusedRow, out int unusedCol,
|
||||
out object item)) {
|
||||
@@ -1737,6 +1753,17 @@ namespace SourceGen.WpfGui {
|
||||
//codeListView.Focus();
|
||||
}
|
||||
|
||||
// Copy everything in the references list to a stand-alone window.
|
||||
private void ReferencesListCopyOut_Click(object sender, RoutedEventArgs e) {
|
||||
List<ReferenceTable.ReferenceTableItem> newItems =
|
||||
new List<ReferenceTable.ReferenceTableItem>();
|
||||
foreach (ReferencesListItem item in ReferencesList) {
|
||||
newItems.Add(new ReferenceTable.ReferenceTableItem(item.OffsetValue,
|
||||
item.Offset, item.Addr, item.Type));
|
||||
}
|
||||
mMainCtrl.ShowReferenceTable(newItems);
|
||||
}
|
||||
|
||||
#endregion References panel
|
||||
|
||||
#region Notes panel
|
||||
|
48
SourceGen/WpfGui/ReferenceTable.xaml
Normal file
48
SourceGen/WpfGui/ReferenceTable.xaml
Normal file
@@ -0,0 +1,48 @@
|
||||
<!--
|
||||
Copyright 2025 faddenSoft
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<Window x:Class="SourceGen.WpfGui.ReferenceTable"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:SourceGen.WpfGui"
|
||||
mc:Ignorable="d"
|
||||
Title="Reference List"
|
||||
Width="400" Height="300" MinWidth="180" MinHeight="120" ResizeMode="CanResizeWithGrip"
|
||||
ShowInTaskbar="True"
|
||||
PreviewKeyDown="Window_KeyEventHandler">
|
||||
|
||||
<Grid Margin="8">
|
||||
<DataGrid Name="tableDataGrid" IsReadOnly="True"
|
||||
ItemsSource="{Binding ReferencesList}"
|
||||
FontFamily="{StaticResource GeneralMonoFont}"
|
||||
SnapsToDevicePixels="True"
|
||||
GridLinesVisibility="Vertical"
|
||||
VerticalGridLinesBrush="#FF7F7F7F"
|
||||
AutoGenerateColumns="False"
|
||||
HeadersVisibility="Column"
|
||||
CanUserReorderColumns="False"
|
||||
SelectionMode="Single"
|
||||
MouseDoubleClick="ReferencesList_MouseDoubleClick">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="Offset" Width="53" Binding="{Binding Offset}"/>
|
||||
<DataGridTextColumn Header="Addr" Width="53" Binding="{Binding Addr}"/>
|
||||
<DataGridTextColumn Header="Type" Width="119" Binding="{Binding Type}"/>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</Grid>
|
||||
</Window>
|
94
SourceGen/WpfGui/ReferenceTable.xaml.cs
Normal file
94
SourceGen/WpfGui/ReferenceTable.xaml.cs
Normal file
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Copyright 2025 faddenSoft
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
|
||||
using CommonWPF;
|
||||
|
||||
namespace SourceGen.WpfGui {
|
||||
/// <summary>
|
||||
/// Side window with references to the project. This could be copied out of the References
|
||||
/// panel or generated from a "find all" command.
|
||||
/// </summary>
|
||||
public partial class ReferenceTable : Window {
|
||||
public class ReferenceTableItem {
|
||||
public int OffsetValue { get; private set; }
|
||||
public string Offset { get; private set; }
|
||||
public string Addr { get; private set; }
|
||||
public string Type { get; private set; }
|
||||
|
||||
public ReferenceTableItem(int offsetValue, string offset, string addr, string type) {
|
||||
OffsetValue = offsetValue;
|
||||
Offset = offset;
|
||||
Addr = addr;
|
||||
Type = type;
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return "[ReferenceTableItem: off=" + Offset + " addr=" + Addr + " type=" +
|
||||
Type + "]";
|
||||
}
|
||||
}
|
||||
|
||||
public ObservableCollection<ReferenceTableItem> ReferencesList { get; private set; } =
|
||||
new ObservableCollection<ReferenceTableItem>();
|
||||
|
||||
private MainController mMainCtrl;
|
||||
|
||||
public ReferenceTable(Window owner, MainController mainCtrl) {
|
||||
InitializeComponent();
|
||||
Owner = owner;
|
||||
DataContext = this;
|
||||
|
||||
mMainCtrl = mainCtrl;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Replaces the existing list of items with a new list.
|
||||
/// </summary>
|
||||
public void SetItems(List<ReferenceTableItem> items) {
|
||||
ReferencesList.Clear();
|
||||
foreach (ReferenceTableItem item in items) {
|
||||
ReferencesList.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
// Catch ESC key.
|
||||
private void Window_KeyEventHandler(object sender, KeyEventArgs e) {
|
||||
if (e.Key == Key.Escape) {
|
||||
Close();
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void ReferencesList_MouseDoubleClick(object sender, MouseButtonEventArgs e) {
|
||||
if (!tableDataGrid.GetClickRowColItem(e, out int unusedRow, out int unusedCol,
|
||||
out object item)) {
|
||||
// Header or empty area; ignore.
|
||||
return;
|
||||
}
|
||||
ReferenceTableItem rli = (ReferenceTableItem)item;
|
||||
|
||||
// Jump to the offset, then shift the focus back to the code list.
|
||||
mMainCtrl.GoToLocation(new NavStack.Location(rli.OffsetValue, 0,
|
||||
NavStack.GoToMode.JumpToCodeData), true);
|
||||
}
|
||||
}
|
||||
}
|
@@ -353,7 +353,9 @@ provided. For example, sometimes jump tables will encode (address - 1)
|
||||
for the benefit of a PHA/RTS combination, so the entry for <code>FOO</code>
|
||||
will appear as <samp>FOO-1</samp>. The operand target is actually
|
||||
<code>FOO-1</code>, so using this feature won't edit the <code>FOO</code>
|
||||
label but instead try to add a new one at the previous address.</p>
|
||||
label but instead try to add a new one at the previous address. The
|
||||
feature does back up to the start of a line, however, so it won't try
|
||||
to split an instruction or multi-byte data item.</p>
|
||||
|
||||
|
||||
<h2 id="comment">Edit Comment</h2>
|
||||
|
@@ -343,6 +343,13 @@ or project symbol, an equate directive will not be generated for it.</p>
|
||||
<p>Double-clicking on a reference moves the code list selection to that
|
||||
reference, and adds the previous selection to the navigation stack.</p>
|
||||
|
||||
<p>To make it easier to explore a set of references, the contents can
|
||||
be copied out to a floating window by clicking the <samp>Copy Out</samp>
|
||||
button. The contents of the window don't update until the next time
|
||||
<samp>Copy Out</samp> is clicked. Double-clicking an entry will move
|
||||
the code list selection the same way it would when a double-clicking
|
||||
an entry in the References window.</p>
|
||||
|
||||
|
||||
<h3 id="notes">Notes Window</h3>
|
||||
|
||||
|
Reference in New Issue
Block a user