1
0
mirror of https://github.com/fadden/6502bench.git synced 2024-11-29 10:50:28 +00:00

Tweak address region edit dialog

Altered the address region edit UI a little to improve clarity.

Also, close the hex dump viewer window when Escape is hit.  (The
tool windows don't have "cancel" buttons, so the key has to be
handled explicitly.)
This commit is contained in:
Andy McFadden 2021-10-20 09:06:53 -07:00
parent 22c47e1d0b
commit cd937709fa
9 changed files with 65 additions and 33 deletions

View File

@ -4151,10 +4151,10 @@ namespace SourceGen {
esb.Append("End: ");
esb.Append(mFormatter.FormatOffset24(region.Offset + region.ActualLength - 1));
esb.Append(CRLF);
esb.Append("Length: " + region.ActualLength + " / " +
mFormatter.FormatHexValue(region.ActualLength, 2));
esb.Append("Length: " + region.ActualLength + " (" +
mFormatter.FormatHexValue(region.ActualLength, 2) + ")");
if (region.Length == AddressMap.FLOATING_LEN) {
esb.Append(" (floating)");
esb.Append(" [floating]");
}
esb.Append(CRLF);
esb.Append("Pre-label: ");
@ -4169,7 +4169,7 @@ namespace SourceGen {
!mProject.CpuDef.HasAddr16));
}
} else {
esb.Append("none");
esb.Append("(not set)");
}
esb.Append(CRLF);
esb.Append("Synthetic: " + isSynth);

View File

@ -25,7 +25,8 @@ limitations under the License.
Title="Hex Dump Viewer"
Width="542" Height="600" MinWidth="542" MinHeight="180" ResizeMode="CanResizeWithGrip"
ShowInTaskbar="True"
Loaded="Window_Loaded">
Loaded="Window_Loaded"
PreviewKeyDown="Window_KeyEventHandler">
<Window.Resources>
<system:String x:Key="str_AsciiOnly">Plain ASCII only</system:String>

View File

@ -19,6 +19,7 @@ using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using Asm65;
using CharConvMode = Asm65.Formatter.FormatConfig.CharConvMode;
@ -122,6 +123,13 @@ namespace SourceGen.Tools.WpfGui {
charConvComboBox.SelectedIndex = index;
}
// Catch ESC key.
private void Window_KeyEventHandler(object sender, KeyEventArgs e) {
if (e.Key == Key.Escape) {
Close();
}
}
/// <summary>
/// Sets the filename associated with the data. This is for display purposes only.
/// </summary>

View File

@ -22,7 +22,7 @@ limitations under the License.
xmlns:system="clr-namespace:System;assembly=mscorlib"
xmlns:local="clr-namespace:SourceGen.WpfGui"
mc:Ignorable="d"
Title="Edit Address Region Properties"
Title="Edit Address Region"
Width="350" SizeToContent="Height" ResizeMode="NoResize"
ShowInTaskbar="False" WindowStartupLocation="CenterOwner"
ContentRendered="Window_ContentRendered">
@ -30,28 +30,32 @@ limitations under the License.
<Window.Resources>
<BooleanToVisibilityConverter x:Key="BoolToVis"/>
<system:String x:Key="str_HdrCreate">Creating new address region</system:String>
<system:String x:Key="str_HdrCreate">Creating new address region.</system:String>
<system:String x:Key="str_HdrEdit">Editing existing address region:</system:String>
<system:String x:Key="str_OptEditAsIsSummary">
Edit only.
Edit attributes.
</system:String>
<system:String x:Key="str_OptEditAsIs">
Edit the region's attributes. Region length will not be changed.
Edit the region's attributes. The region's length will not be changed.
</system:String>
<system:String x:Key="str_OptEditAndFixSummary">
Set fixed size.
Fix end point.
</system:String>
<system:String x:Key="str_OptEditAndFix">
Edit the region's attributes, and convert the floating end to a fixed end.
Convert the floating end to a fixed end, using the current length, and edit
the region's attributes.
</system:String>
<system:String x:Key="str_EditFixedAlreadyFixed">
Option to set fixed end not available: end point is already fixed.
</system:String>
<system:String x:Key="str_OptResizeSummary">
Resize.
</system:String>
<system:String x:Key="str_OptResize" xml:space="preserve"
>Edit the region's attributes, and resize it to the selection. The new end offset will be:&#x0a;End: {0}&#x0a;Length: {1}</system:String>
>Resize the region to the current selection, and edit the region's attributes. The new end point will be:&#x0a;Offset: {0}&#x0a;Length: {1}</system:String>
<system:String x:Key="str_OptResizeFail">
Resize not available: cannot resize to the selection. {0}
Option to resize not available: cannot resize to the selection. {0}
</system:String>
<system:String x:Key="str_CreateFixedSummary">
Create fixed.
@ -60,9 +64,6 @@ limitations under the License.
Create a new region, with a fixed end point. The region will start at {0}
and have a length of {1}.
</system:String>
<system:String x:Key="str_CreateFixedAlreadyFixed">
Create fixed not available: can't convert to fixed end point because it's already fixed.
</system:String>
<system:String x:Key="str_CreateFixedFail">
Create fixed not available: unable to create a new region with a fixed end point here.
</system:String>
@ -79,7 +80,7 @@ limitations under the License.
may change as other regions are added and removed.
</system:String>
<system:String x:Key="str_CreateFloatingFail">
Create floating not available: unable to create a new region with a floating end point here.
Option to create floating region not available: unable to create a new region with a floating end point here.
</system:String>
<system:String x:Key="str_ErrInternal">Internal error.</system:String>
@ -88,7 +89,7 @@ limitations under the License.
The new region would have the same start offset and length as an existing region.
</system:String>
<system:String x:Key="str_ErrOverlapFloating">
The start offset of the new region is the same as the start offset of an existing
The start offset of the new region would be the same as the start offset of an existing
region, and one or both have a floating end point.
</system:String>
<system:String x:Key="str_ErrStraddleExisting">
@ -109,13 +110,18 @@ limitations under the License.
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Grid.Column="0" Grid.Row="0" Margin="8,0,0,0" Text="Start:"/>
<TextBlock Grid.Column="0" Grid.Row="0" Margin="8,0,0,0" Text="Address:"/>
<TextBlock Grid.Column="1" Grid.Row="0" Margin="4,2,0,0"
Text="{Binding RegionStartOffsetStr, FallbackValue=+123456}"
Text="{Binding RegionAddressStr, FallbackValue=$1234}"
FontFamily="{StaticResource GeneralMonoFont}"/>
<TextBlock Grid.Column="0" Grid.Row="1" Margin="8,0,0,0" Text="End:"/>
<StackPanel Grid.Column="1" Grid.Row="1" Margin="4,0,0,0" Orientation="Horizontal">
<TextBlock Grid.Column="0" Grid.Row="1" Margin="8,0,0,0" Text="Start:"/>
<TextBlock Grid.Column="1" Grid.Row="1" Margin="4,2,0,0"
Text="{Binding RegionStartOffsetStr, FallbackValue=+123456}"
FontFamily="{StaticResource GeneralMonoFont}"/>
<TextBlock Grid.Column="0" Grid.Row="2" Margin="8,0,0,0" Text="End:"/>
<StackPanel Grid.Column="1" Grid.Row="2" Margin="4,0,0,0" Orientation="Horizontal">
<TextBlock Margin="0,2,0,0"
Text="{Binding RegionEndOffsetStr, FallbackValue=+123456}"
FontFamily="{StaticResource GeneralMonoFont}"/>
@ -123,8 +129,8 @@ limitations under the License.
Visibility="{Binding IsFloating, Converter={StaticResource BoolToVis}}"/>
</StackPanel>
<TextBlock Grid.Column="0" Grid.Row="2" Margin="8,0,0,0" Text="Length:"/>
<TextBlock Grid.Column="1" Grid.Row="2" Margin="4,2,0,0"
<TextBlock Grid.Column="0" Grid.Row="3" Margin="8,0,0,0" Text="Length:"/>
<TextBlock Grid.Column="1" Grid.Row="3" Margin="4,2,0,0"
Text="{Binding RegionLengthStr, FallbackValue=23456 ($1234)}"
FontFamily="{StaticResource GeneralMonoFont}"/>
</Grid>
@ -153,10 +159,10 @@ limitations under the License.
Text="{Binding ErrorMessageStr, FallbackValue=Error Message}"/>
</Border>
<Rectangle HorizontalAlignment="Stretch" Fill="LightGray" Height="2" Margin="0,8,0,0"/>
<!--<Rectangle HorizontalAlignment="Stretch" Fill="LightGray" Height="2" Margin="0,8,0,0"/>-->
<StackPanel IsEnabled="{Binding EnableAttributeControls}">
<StackPanel Orientation="Horizontal" Margin="0,8,0,0">
<StackPanel Orientation="Horizontal" Margin="0,16,0,0">
<TextBlock Text="Address (hex):"/>
<TextBox Name="addrTextBox" Width="100" Margin="4,1,0,0"
@ -177,12 +183,12 @@ limitations under the License.
</StackPanel>
<StackPanel IsEnabled="{Binding EnableAttributeControls}">
<GroupBox Header="Advanced" Padding="2,4" Margin="0,12,0,0">
<GroupBox Header="Advanced" Padding="2,4" Margin="0,16,0,0">
<StackPanel>
<CheckBox Content="Use relative addressing"
IsChecked="{Binding UseRelativeAddressing}"/>
<StackPanel Orientation="Horizontal" Margin="0,12,0,0">
<StackPanel Orientation="Horizontal" Margin="0,16,0,0">
<TextBlock Text="Pre-label:"/>
<TextBox Name="preLabelTextBox" Width="100" Margin="4,1,0,0"
FontFamily="{StaticResource GeneralMonoFont}"

View File

@ -43,6 +43,14 @@ namespace SourceGen.WpfGui {
}
private string mOperationStr;
/// <summary>
/// Initial address. (Does not change.)
/// </summary>
public string RegionAddressStr {
get { return "$" + mFormatter.FormatAddress(mRegionAddress, mShowBank); }
}
private int mRegionAddress;
/// <summary>
/// Offset of first selected byte. (Does not change.)
/// </summary>
@ -304,6 +312,7 @@ namespace SourceGen.WpfGui {
UseRelativeAddressing = curRegion.IsRelative;
OperationStr = (string)FindResource("str_HdrEdit");
mRegionAddress = curRegion.Address;
mRegionStartOffset = curRegion.Offset;
mRegionEndOffset = curRegion.Offset + curRegion.ActualLength - 1;
mPreLabelAddress = curRegion.PreLabelAddress;
@ -326,7 +335,7 @@ namespace SourceGen.WpfGui {
curRegion.IsRelative);
} else {
option2Summ = string.Empty;
option2Msg = (string)FindResource("str_CreateFixedAlreadyFixed");
option2Msg = (string)FindResource("str_EditFixedAlreadyFixed");
mResultEntry2 = null;
EnableOption2 = false; // show it, but disabled
}
@ -363,6 +372,14 @@ namespace SourceGen.WpfGui {
EnableOption1 = false;
CheckOption2 = true;
}
if (curRegion.ActualLength == selectionLen) {
// The selection size matches the region's length, which means they
// have the entire region selected, so "resize" and "edit" do the same
// thing. No real need to disable the resize option, but we can default
// to "edit only" to emphasize that there's no actual change.
CheckOption2 = true;
}
}
} else {

View File

@ -71,7 +71,7 @@ limitations under the License.
<KeyGesture>Del</KeyGesture>
</RoutedUICommand.InputGestures>
</RoutedUICommand>
<RoutedUICommand x:Key="EditAddressCmd" Text="Define Address Region..."/>
<RoutedUICommand x:Key="EditAddressCmd" Text="Create/Edit Address Region..."/>
<RoutedUICommand x:Key="EditAppSettingsCmd" Text="Settings..."/>
<RoutedUICommand x:Key="EditCommentCmd" Text="Edit Comment...">
<RoutedUICommand.InputGestures>

View File

@ -15,7 +15,7 @@
<p><a href="index.html">Back to index</a></p>
<h2 id="address">Define Address Region</h2>
<h2 id="address">Create/Edit Address Region</h2>
<p><a href="intro-details.html#address-regions">Address regions</a>
may be created, edited, resized, or removed. Which

View File

@ -94,7 +94,7 @@ using the <samp>Help &gt; Help</samp> menu item or by hitting
<li><a href="editors.html">Editors</a>
<ul>
<li><a href="editors.html#address">Define Address Region</a></li>
<li><a href="editors.html#address">Create/Edit Address Region</a></li>
<li><a href="editors.html#flags">Override Status Flags</a></li>
<li><a href="editors.html#label">Edit Label</a></li>
<li><a href="editors.html#instruction-operand">Edit Operand (Instruction)</a>

View File

@ -187,7 +187,7 @@ that are enabled will depend on what you have selected in the main window.</p>
<li><a href="editors.html#note">Edit Note</a>. Sets the note at
that offset. Enabled when a single instruction or data line, or
an existing note, is selected.</li>
<li><a href="editors.html#address">Define Address Region</a>.
<li><a href="editors.html#address">Create/Edit Address Region</a>.
Sets the assembly address at the selected offset. Can be used
to set a start point with a floating end, or specify a region
with a fixed end point (useful for code that get relocated).