From ae4c90d838905bdcee727e4cd6d267761823ce1d Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Thu, 15 Oct 2020 17:18:49 -0700 Subject: [PATCH] Warn about multi-line start/stop tags One of the most confusing things you can do is select a bunch of lines and apply a code start tag (nee "code hint"). We now ask for confirmation when applying start/stop hints to multiple lines. (issue #89) --- SourceGen/CodeAnalysis.cs | 3 +++ SourceGen/MainController.cs | 12 ++++++++++++ SourceGen/Res/Strings.xaml | 2 ++ SourceGen/Res/Strings.xaml.cs | 4 ++++ 4 files changed, 21 insertions(+) diff --git a/SourceGen/CodeAnalysis.cs b/SourceGen/CodeAnalysis.cs index 50f4536..82be70a 100644 --- a/SourceGen/CodeAnalysis.cs +++ b/SourceGen/CodeAnalysis.cs @@ -379,6 +379,9 @@ namespace SourceGen { // placed here. OpDef op = mCpuDef.GetOpDef(mFileData[offset]); if (op == OpDef.OpInvalid) { + // Might want to set the "has tag" value anyway, since it won't + // appear in the "Info" window if we don't. Or maybe we need a + // message about "invisible" code start tags? LogI(offset, "Ignoring code start tag on illegal opcode"); } else { mAnattribs[offset].HasAnalyzerTag = true; diff --git a/SourceGen/MainController.cs b/SourceGen/MainController.cs index 218fdf3..12ca998 100644 --- a/SourceGen/MainController.cs +++ b/SourceGen/MainController.cs @@ -3379,7 +3379,19 @@ namespace SourceGen { sel.Add(offset); } } + + // "first byte only" is used for code start/stop tags, which should only be + // placed at the start of a region. + if (sel.Count > 1) { + MessageBoxResult result = MessageBox.Show(Res.Strings.ANALYZER_TAG_MULTI_CHK, + Res.Strings.CONFIRMATION_NEEDED, + MessageBoxButton.OKCancel, MessageBoxImage.Question); + if (result == MessageBoxResult.Cancel) { + return; + } + } } else { + // Inline data or none. Select all bytes. sel = OffsetSetFromSelected(); } diff --git a/SourceGen/Res/Strings.xaml b/SourceGen/Res/Strings.xaml index dab306a..5c511b3 100644 --- a/SourceGen/Res/Strings.xaml +++ b/SourceGen/Res/Strings.xaml @@ -24,6 +24,7 @@ limitations under the License. Addr Const StkRl + Setting start/stop tags on multiple consecutive bytes is rarely a good idea. Continue? [latest version] output DOES NOT match data file output matches data file @@ -34,6 +35,7 @@ limitations under the License. All Columns Assembler Source Disassembly + Confirmation Needed {0} (auto) {0} K diff --git a/SourceGen/Res/Strings.xaml.cs b/SourceGen/Res/Strings.xaml.cs index d767707..1f05dc8 100644 --- a/SourceGen/Res/Strings.xaml.cs +++ b/SourceGen/Res/Strings.xaml.cs @@ -29,6 +29,8 @@ namespace SourceGen.Res { (string)Application.Current.FindResource("str_AbbrevConstant"); public static string ABBREV_STACK_RELATIVE = (string)Application.Current.FindResource("str_AbbrevStackRelative"); + public static string ANALYZER_TAG_MULTI_CHK = + (string)Application.Current.FindResource("str_AnalyzerTagMultiChk"); public static string ASM_LATEST_VERSION = (string)Application.Current.FindResource("str_AsmLatestVersion"); public static string ASM_MATCH_FAILURE = @@ -43,6 +45,8 @@ namespace SourceGen.Res { (string)Application.Current.FindResource("str_AsmMismatchLengthFmt"); public static string ASM_OUTPUT_NOT_FOUND = (string)Application.Current.FindResource("str_AsmOutputNotFound"); + public static string CONFIRMATION_NEEDED = + (string)Application.Current.FindResource("str_ConfirmationNeeded"); public static string DATA_BANK_AUTO_FMT = (string)Application.Current.FindResource("str_DataBankAutoFmt"); public static string DATA_BANK_USER_FMT =