From 0d75282756a0d29ad58acb9d66ec686a6d986b99 Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Sat, 13 Jul 2019 11:29:05 -0700 Subject: [PATCH] Minor tweaks --- Asm65/Formatter.cs | 9 +++++++-- SourceGenWPF/ProjectFile.cs | 2 +- SourceGenWPF/Res/Strings.xaml | 4 +++- SourceGenWPF/Res/Strings.xaml.cs | 6 +++--- SourceGenWPF/Tools/VirtualHexDump.cs | 17 +++++++++-------- SourceGenWPF/Tools/WpfGui/HexDumpViewer.xaml.cs | 13 +++++++++++-- 6 files changed, 34 insertions(+), 17 deletions(-) diff --git a/Asm65/Formatter.cs b/Asm65/Formatter.cs index 4be0e96..c7a5b17 100644 --- a/Asm65/Formatter.cs +++ b/Asm65/Formatter.cs @@ -820,13 +820,18 @@ namespace Asm65 { } else if (mFormatConfig.mHexDumpAsciiOnly) { return '.'; } else { - // These values makes the hex dump ListView freak out. + // Certain values make the hex dump ListView freak out in WinForms, but work + // fine in WPF. The "control pictures" are a nice idea, but in practice they're + // unreadably small and provide no benefit. The black-diamond "replacement + // character" is dark and makes everything feel noisy. Middle-dot is subtle, + // but sufficiently different from a '.' to be useful. + //if (ch < 0x20) { // return (char)(ch + '\u2400'); // Unicode "control pictures" block //} //return '\ufffd'; // Unicode "replacement character" - //return '\u00bf'; // INVERTED QUESTION MARK + return '\u00b7'; // MIDDLE DOT } } diff --git a/SourceGenWPF/ProjectFile.cs b/SourceGenWPF/ProjectFile.cs index 98108bb..cf67682 100644 --- a/SourceGenWPF/ProjectFile.cs +++ b/SourceGenWPF/ProjectFile.cs @@ -620,7 +620,7 @@ namespace SourceGenWPF { } if (intKey < 0 || intKey + dfd.Length > spf.FileDataLength) { report.Add(FileLoadItem.Type.Warning, - string.Format(Res.Strings.ERR_BAD_FD, intKey)); + string.Format(Res.Strings.ERR_BAD_FD_FMT, intKey)); continue; } diff --git a/SourceGenWPF/Res/Strings.xaml b/SourceGenWPF/Res/Strings.xaml index 4487692..a18f518 100644 --- a/SourceGenWPF/Res/Strings.xaml +++ b/SourceGenWPF/Res/Strings.xaml @@ -14,6 +14,8 @@ See the License for the specific language governing permissions and limitations under the License. --> + Assembler Source Disassembly Default - Bad format descriptor at +{0:x6}. + Bad format descriptor at +{0:x6}. Bad format descriptor type Bad file length Invalid file identifier diff --git a/SourceGenWPF/Res/Strings.xaml.cs b/SourceGenWPF/Res/Strings.xaml.cs index 3e5885a..bd2621e 100644 --- a/SourceGenWPF/Res/Strings.xaml.cs +++ b/SourceGenWPF/Res/Strings.xaml.cs @@ -20,7 +20,7 @@ namespace SourceGenWPF.Res { /// /// This is a bridge between the XAML definitions and the C# code that uses the strings. /// FindResource() throws an exception if the resource isn't found, so typos and missing - /// resources will cause the app to fail at launch. + /// resources will cause the app to fail the first time any string is referenced. /// public static class Strings { public static string ABBREV_ADDRESS = @@ -47,8 +47,8 @@ namespace SourceGenWPF.Res { (string)Application.Current.FindResource("str_ClipformatAssemblerSource"); public static string CLIPFORMAT_DISASSEMBLY = (string)Application.Current.FindResource("str_ClipformatDisassembly"); - public static string ERR_BAD_FD = - (string)Application.Current.FindResource("str_ErrBadFd"); + public static string ERR_BAD_FD_FMT = + (string)Application.Current.FindResource("str_ErrBadFdFmt"); public static string ERR_BAD_FD_FORMAT = (string)Application.Current.FindResource("str_ErrBadFdFormat"); public static string ERR_BAD_FILE_LENGTH = diff --git a/SourceGenWPF/Tools/VirtualHexDump.cs b/SourceGenWPF/Tools/VirtualHexDump.cs index 53b5346..f7b3218 100644 --- a/SourceGenWPF/Tools/VirtualHexDump.cs +++ b/SourceGenWPF/Tools/VirtualHexDump.cs @@ -45,14 +45,13 @@ namespace SourceGenWPF.Tools { /// /// Data formatter object. - /// - /// There's currently no way to update this after the dialog is opened, which means - /// we won't track changes to hex case preference. I'm okay with that. /// private Formatter mFormatter; private string[] mLines; + // Tracks the number of lines we've generated, so we can see if virtualization is + // actually happening. private int mDebugGenLineCount; @@ -87,9 +86,9 @@ namespace SourceGenWPF.Tools { if (mLines[index] == null) { mLines[index] = mFormatter.FormatHexDump(mData, index * 16); - //if ((++mDebugGenLineCount % 1000) == 0) { - // Debug.WriteLine("DebugGenLineCount: " + mDebugGenLineCount); - //} + if ((++mDebugGenLineCount % 1000) == 0) { + //Debug.WriteLine("DebugGenLineCount: " + mDebugGenLineCount); + } } //Debug.WriteLine("GET LINE " + index + ": " + mLines[index]); return mLines[index]; @@ -155,13 +154,15 @@ namespace SourceGenWPF.Tools { //Debug.WriteLine("VHD IndexOf " + value); // This gets called sometimes when the selection changes, because the selection // mechanism tracks objects rather than indices. Fortunately we can convert the - // value string to an index by parsing the first six characters. + // value string to an index by parsing the first six characters. (This is + // somewhat fragile as it relies on the way Formatter formats the string. Might + // want to make offset-from-hexdump-string a Formatter method.) int offset = Convert.ToInt32(((string)value).Substring(0, 6), 16); int index = offset / 16; // Either the object at the target location matches, or it doesn't; no need to // search. We'll get requests for nonexistent objects after we reformat the - // collection. + // collection, when the list control tries to find the selected items. // // Object equality is what's desired; no need for string comparison if ((object)mLines[index] == value) { diff --git a/SourceGenWPF/Tools/WpfGui/HexDumpViewer.xaml.cs b/SourceGenWPF/Tools/WpfGui/HexDumpViewer.xaml.cs index a7f93ab..de21459 100644 --- a/SourceGenWPF/Tools/WpfGui/HexDumpViewer.xaml.cs +++ b/SourceGenWPF/Tools/WpfGui/HexDumpViewer.xaml.cs @@ -39,14 +39,18 @@ namespace SourceGenWPF.Tools.WpfGui { public VirtualHexDump HexDumpLines { get; private set; } /// - /// Hex formatter. + /// Formatter that handles the actual string formatting. + /// + /// There's currently no way to update this after the dialog is opened, which means + /// we won't track changes to hex case preference if the app settings are updated. + /// I'm okay with that. /// private Formatter mFormatter; /// /// If true, don't include non-ASCII characters in text area. (Without this we might - /// use Unicode bullets or other glyphs for unprintable text.) + /// use Unicode bullets or other glyphs for unprintable text.) Bound to a CheckBox. /// public bool AsciiOnlyDump { get { return mAsciiOnlyDump; } @@ -64,6 +68,10 @@ namespace SourceGenWPF.Tools.WpfGui { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } + /// + /// Character conversion modes. These determine how we interpret bytes for the + /// ASCII portion of the dump. + /// public enum CharConvMode { Unknown = 0, PlainAscii, @@ -188,6 +196,7 @@ namespace SourceGenWPF.Tools.WpfGui { // Make sure it's visible. hexDumpData.ScrollIntoView(HexDumpLines[endLine]); hexDumpData.ScrollIntoView(HexDumpLines[startLine]); + hexDumpData.Focus(); } #if false // DataGrid provides this automatically