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

Improve data operand editor

Added accelerator keys to Mixed and Null strings.  (Issue #67)

Added units to string counts.  (Issue #68)  Added proper handling
for plural/singular for bytes and strings.  Changed N/A indicator
from "xx" to "--".
This commit is contained in:
Andy McFadden 2020-02-18 13:57:35 -08:00
parent 0ab76ea1f7
commit b0278c9c51
2 changed files with 47 additions and 35 deletions

View File

@ -33,9 +33,15 @@ limitations under the License.
<system:String x:Key="str_SingleGroup">Select data format ({0} bytes selected):</system:String>
<system:String x:Key="str_MultiGroup">Select data format ({0} bytes selected in {1} groups):</system:String>
<system:String x:Key="str_StringMixed">Mixed character ({0} bytes) and non-character ({1} bytes)</system:String>
<system:String x:Key="str_StringMixedReverse">Reversed character ({0} bytes) and non-character ({1} bytes)</system:String>
<system:String x:Key="str_StringNullTerm">Null-terminated strings ({0})</system:String>
<system:String x:Key="str_NotApplicable">--</system:String>
<system:String x:Key="str_StringSingleFmt">{0} string</system:String>
<system:String x:Key="str_StringPluralFmt">{0} strings</system:String>
<system:String x:Key="str_ByteSingleFmt">{0} byte</system:String>
<system:String x:Key="str_BytePluralFmt">{0} bytes</system:String>
<system:String x:Key="str_StringMixed">_Mixed character ({0}) and non-character ({1})</system:String>
<system:String x:Key="str_StringMixedReverse">Reversed character ({0}) and non-character ({1})</system:String>
<system:String x:Key="str_StringNullTerm">_Null-terminated strings ({0})</system:String>
<system:String x:Key="str_StringLen8">Strings prefixed with 8-bit length ({0})</system:String>
<system:String x:Key="str_StringLen16">Strings prefixed with 16-bit length ({0})</system:String>
<system:String x:Key="str_StringDci">Dextral character inverted ({0})</system:String>
@ -129,7 +135,7 @@ limitations under the License.
<RadioButton Name="radioDenseHex" GroupName="Main" Content="Densely-_packed bytes" Margin="0,4,0,0"
Checked="MainGroup_CheckedChanged"/>
<StackPanel Orientation="Horizontal" Margin="20,4,0,0">
<RadioButton Name="radioDenseHexLimited" GroupName="Main" Content="...with a limit of"
<RadioButton Name="radioDenseHexLimited" GroupName="Main" Content="...with a _limit of"
Checked="MainGroup_CheckedChanged"/>
<TextBox Width="40" Margin="7,-3,0,0" MaxLength="2"
Text="{Binding MaxDenseBytesPerLine, UpdateSourceTrigger=PropertyChanged}"/>

View File

@ -670,57 +670,37 @@ namespace SourceGen.WpfGui {
// Update the dialog with string and character counts, summed across all regions.
string UNSUP_STR = (string)FindResource("str_NotApplicable");
string fmt;
const string UNSUP_STR = "xx";
fmt = (string)FindResource("str_StringMixed");
string revfmt = (string)FindResource("str_StringMixedReverse");
if (mixedCharOkCount > 0) {
Debug.Assert(radioStringMixed.IsEnabled);
radioStringMixed.Content = string.Format(fmt,
mixedCharOkCount, mixedCharNotCount);
FormatByteCount(mixedCharOkCount), FormatByteCount(mixedCharNotCount));
radioStringMixedReverse.Content = string.Format(revfmt,
mixedCharOkCount, mixedCharNotCount);
FormatByteCount(mixedCharOkCount), FormatByteCount(mixedCharNotCount));
} else {
Debug.Assert(!radioStringMixed.IsEnabled);
radioStringMixed.Content = string.Format(fmt, UNSUP_STR, UNSUP_STR);
radioStringMixedReverse.Content = string.Format(revfmt, UNSUP_STR, UNSUP_STR);
}
Debug.Assert((nullTermStringCount > 0) ^ (radioStringNullTerm.IsEnabled == false));
fmt = (string)FindResource("str_StringNullTerm");
if (nullTermStringCount > 0) {
Debug.Assert(radioStringNullTerm.IsEnabled);
radioStringNullTerm.Content = string.Format(fmt, nullTermStringCount);
} else {
Debug.Assert(!radioStringNullTerm.IsEnabled);
radioStringNullTerm.Content = string.Format(fmt, UNSUP_STR);
}
radioStringNullTerm.Content = FormatStringOption(fmt, nullTermStringCount);
Debug.Assert((len8StringCount > 0) ^ (radioStringLen8.IsEnabled == false));
fmt = (string)FindResource("str_StringLen8");
if (len8StringCount > 0) {
Debug.Assert(radioStringLen8.IsEnabled);
radioStringLen8.Content = string.Format(fmt, len8StringCount);
} else {
Debug.Assert(!radioStringLen8.IsEnabled);
radioStringLen8.Content = string.Format(fmt, UNSUP_STR);
}
radioStringLen8.Content = FormatStringOption(fmt, len8StringCount);
Debug.Assert((len16StringCount > 0) ^ (radioStringLen16.IsEnabled == false));
fmt = (string)FindResource("str_StringLen16");
if (len16StringCount > 0) {
Debug.Assert(radioStringLen16.IsEnabled);
radioStringLen16.Content = string.Format(fmt, len16StringCount);
} else {
Debug.Assert(!radioStringLen16.IsEnabled);
radioStringLen16.Content = string.Format(fmt, UNSUP_STR);
}
radioStringLen16.Content = FormatStringOption(fmt, len16StringCount);
Debug.Assert((dciStringCount > 0) ^ (radioStringDci.IsEnabled == false));
fmt = (string)FindResource("str_StringDci");
if (dciStringCount > 0) {
Debug.Assert(radioStringDci.IsEnabled);
radioStringDci.Content = string.Format(fmt, dciStringCount);
} else {
Debug.Assert(!radioStringDci.IsEnabled);
radioStringDci.Content = string.Format(fmt, UNSUP_STR);
}
radioStringDci.Content = FormatStringOption(fmt, dciStringCount);
// If this invalidated the selected item, reset to Default.
if ((radioStringMixed.IsChecked == true && !radioStringMixed.IsEnabled) ||
@ -735,6 +715,32 @@ namespace SourceGen.WpfGui {
}
}
private string FormatByteCount(int count) {
string fmt;
if (count <= 0) {
return (string)FindResource("str_NotApplicable");
} else if (count == 1) {
fmt = (string)FindResource("str_ByteSingleFmt");
} else {
fmt = (string)FindResource("str_BytePluralFmt");
}
return string.Format(fmt, count);
}
private string FormatStringOption(string fmt, int count) {
if (count <= 0) {
return string.Format(fmt, (string)FindResource("str_NotApplicable"));
} else if (count == 1) {
string fmtSingleString = (string)FindResource("str_StringSingleFmt");
return string.Format(fmt,
string.Format(fmtSingleString, count));
} else {
string fmtPluralString = (string)FindResource("str_StringPluralFmt");
return string.Format(fmt,
string.Format(fmtPluralString, count));
}
}
/// <summary>
/// Determines whether the data in the buffer can be represented as character values.
/// Using ".DD1 'A'" for 0x41 is obvious, but we also allow ".DD2 'A'" for