From 2008558870c591ce0f5d408addd0f741b233395c Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Thu, 14 Oct 2021 15:10:32 -0700 Subject: [PATCH] Add "quick set" menu to delimiter settings tab Added a pop-up menu with three options: default (curly quotes), straight, and Merlin. Removed the "reset to defaults" buttons. Also, slightly rearranged the Display Format tab so that the quick set pop-up is on the left, near the items it affects. Moved the "use comma-separated format for bulk data" checkbox over as well, since it's part of the set. --- Asm65/Formatter.cs | 67 ++- SourceGen/Res/Strings.xaml | 4 - SourceGen/Res/Strings.xaml.cs | 8 - SourceGen/WpfGui/EditAppSettings.xaml | 555 ++++++++++++----------- SourceGen/WpfGui/EditAppSettings.xaml.cs | 133 +++++- docs/sgmanual/settings.html | 25 +- 6 files changed, 482 insertions(+), 310 deletions(-) diff --git a/Asm65/Formatter.cs b/Asm65/Formatter.cs index 1160b92..984174b 100644 --- a/Asm65/Formatter.cs +++ b/Asm65/Formatter.cs @@ -164,15 +164,16 @@ namespace Asm65 { #region Text Delimiters /// - /// Container for character and string delimiter pieces. Instances are immutable. + /// Container for delimiter pieces for characters or strings. Instances are immutable. /// /// - /// For single-character operands, a simple concatenation of the four fields, with the - /// character in the middle, is performed. + /// For single-character operands, the generated format string will be a simple + /// concatenation of the four fields, with the character in the middle. /// /// For strings, the prefix is included at the start of the first line, but not included - /// on subsequent lines. This is primarily intended for the on-screen display, not - /// assembly source generation. The suffix is not used at all. + /// on subsequent lines in a multi-line operand. This is primarily intended for the + /// on-screen display, not assembly source generation (which doesn't generally make use + /// of a string prefix). The suffix is not used at all. /// public class DelimiterDef { public string Prefix { get; private set; } @@ -203,10 +204,37 @@ namespace Asm65 { public override string ToString() { return Prefix + OpenDelim + '#' + CloseDelim + Suffix; } + + public static bool operator ==(DelimiterDef a, DelimiterDef b) { + if (ReferenceEquals(a, b)) { + return true; // same object, or both null + } + if (ReferenceEquals(a, null) || ReferenceEquals(b, null)) { + return false; // one is null + } + // All fields must be equal. Ignore FormatStr, which is generated from the + // other fields. + return a.Prefix == b.Prefix && a.OpenDelim == b.OpenDelim && + a.CloseDelim == b.CloseDelim && a.Suffix == b.Suffix; + } + public static bool operator !=(DelimiterDef a, DelimiterDef b) { + return !(a == b); + } + public override bool Equals(object obj) { + return obj is DelimiterDef && this == (DelimiterDef)obj; + } + public override int GetHashCode() { + return Prefix.GetHashCode() ^ OpenDelim.GetHashCode() ^ CloseDelim.GetHashCode() ^ + Suffix.GetHashCode(); + } } public static readonly DelimiterDef SINGLE_QUOTE_DELIM = new DelimiterDef('\''); public static readonly DelimiterDef DOUBLE_QUOTE_DELIM = new DelimiterDef('"'); + /// + /// Set of DelimiterDef objects, indexed by character encoding. The objects may be + /// for character or string encoding. + /// public class DelimiterSet { private Dictionary mDelimiters = new Dictionary(); @@ -321,6 +349,35 @@ namespace Asm65 { offset = commaIndex + 1 + len; return resultStr; } + + public static bool operator ==(DelimiterSet a, DelimiterSet b) { + if (ReferenceEquals(a, b)) { + return true; // same object, or both null + } + if (ReferenceEquals(a, null) || ReferenceEquals(b, null)) { + return false; // one is null + } + // Compare set contents. + if (a.mDelimiters.Count != b.mDelimiters.Count) { + return false; + } + foreach (KeyValuePair kvp in a.mDelimiters) { + if (kvp.Value != b.Get(kvp.Key)) { + return false; + } + } + return true; + } + public static bool operator !=(DelimiterSet a, DelimiterSet b) { + return !(a == b); + } + public override bool Equals(object obj) { + return obj is DelimiterSet && this == (DelimiterSet)obj; + } + public override int GetHashCode() { + return mDelimiters.GetHashCode(); + } + } #endregion Text Delimiters diff --git a/SourceGen/Res/Strings.xaml b/SourceGen/Res/Strings.xaml index bae056e..1b92d8a 100644 --- a/SourceGen/Res/Strings.xaml +++ b/SourceGen/Res/Strings.xaml @@ -40,10 +40,6 @@ limitations under the License. {0} K 6502bench SourceGen v{0} - ‘#’ - “#” - pet:“#” - scr:“#” addr const stkrl diff --git a/SourceGen/Res/Strings.xaml.cs b/SourceGen/Res/Strings.xaml.cs index d0f9579..878f2c2 100644 --- a/SourceGen/Res/Strings.xaml.cs +++ b/SourceGen/Res/Strings.xaml.cs @@ -55,14 +55,6 @@ namespace SourceGen.Res { (string)Application.Current.FindResource("str_DataBankK"); public static string DEFAULT_HEADER_COMMENT_FMT = (string)Application.Current.FindResource("str_DefaultHeaderCommentFmt"); - public static string DEFAULT_ASCII_DELIM_PAT = - (string)Application.Current.FindResource("str_DefaultAsciiDelimPat"); - public static string DEFAULT_HIGH_ASCII_DELIM_PAT = - (string)Application.Current.FindResource("str_DefaultHighAsciiDelimPat"); - public static string DEFAULT_C64_PETSCII_DELIM_PAT = - (string)Application.Current.FindResource("str_DefaultC64PetsciiDelimPat"); - public static string DEFAULT_C64_SCREEN_CODE_DELIM_PAT = - (string)Application.Current.FindResource("str_DefaultC64ScreenCodeDelimPat"); public static string CLIPFORMAT_ALL_COLUMNS = (string)Application.Current.FindResource("str_ClipformatAllColumns"); public static string CLIPFORMAT_ASSEMBLER_SOURCE = diff --git a/SourceGen/WpfGui/EditAppSettings.xaml b/SourceGen/WpfGui/EditAppSettings.xaml index 5a580a1..30398de 100644 --- a/SourceGen/WpfGui/EditAppSettings.xaml +++ b/SourceGen/WpfGui/EditAppSettings.xaml @@ -28,11 +28,13 @@ limitations under the License. Loaded="Window_Loaded"> + Custom + Default Common cc65 Merlin - Custom - Default + Straight + Merlin @@ -143,282 +145,286 @@ limitations under the License. - - - - - - - - - - - - - - - - + + - + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + - - - - - + + + - - - - - + + + + + - - - - - + + + + + - - - - - + + + + + - - - - - + + + + + - + + + + + -