mirror of
https://github.com/fadden/6502bench.git
synced 2025-02-06 23:30:56 +00:00
Eliminate BoxLineCommentDelimiter
This was used to prefix boxed lines with a comment delimiter, but in practice we just need to do this whenever the box character doesn't match the full-line comment delimiter. This has no effect on generated assembly output, but the on-screen (and exported HTML) form will now reflect the current settings.
This commit is contained in:
parent
54d559ad50
commit
14cacb4274
@ -106,8 +106,6 @@ namespace Asm65 {
|
||||
public string EndOfLineCommentDelimiter { get; set; } = string.Empty;
|
||||
/// <summary>String to prefix a full-line comment.</summary>
|
||||
public string FullLineCommentDelimiterBase { get; set; } = string.Empty;
|
||||
/// <summary>String to prefix a box comment line.</summary>
|
||||
public string BoxLineCommentDelimiter { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>Delimiter patterns for single-character constants.</summary>
|
||||
public DelimiterSet CharDelimiters { get; set; } = new DelimiterSet();
|
||||
@ -182,7 +180,6 @@ namespace Asm65 {
|
||||
|
||||
EndOfLineCommentDelimiter = src.EndOfLineCommentDelimiter;
|
||||
FullLineCommentDelimiterBase = src.FullLineCommentDelimiterBase;
|
||||
BoxLineCommentDelimiter = src.BoxLineCommentDelimiter;
|
||||
|
||||
CharDelimiters = new DelimiterSet(src.CharDelimiters);
|
||||
StringDelimiters = new DelimiterSet(src.StringDelimiters);
|
||||
@ -502,6 +499,7 @@ namespace Asm65 {
|
||||
// Generated format strings for hex values.
|
||||
private string[] mHexValueFormats = new string[4];
|
||||
|
||||
// Comment delimiter char plus optional space.
|
||||
private string mFullLineCommentDelimiterPlus;
|
||||
|
||||
// Buffer to use when generating hex dump lines.
|
||||
@ -520,26 +518,25 @@ namespace Asm65 {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// String to put between the operand and the end-of-line comment.
|
||||
/// String to put between the operand and the end-of-line comment. Usually one character.
|
||||
/// </summary>
|
||||
public string EndOfLineCommentDelimiter {
|
||||
get { return mFormatConfig.EndOfLineCommentDelimiter; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// String to put at the start of a line with a full-line comment.
|
||||
/// Full-line comment delimiter. Usually one character.
|
||||
/// </summary>
|
||||
public string FullLineCommentDelimiter {
|
||||
get { return mFullLineCommentDelimiterPlus; }
|
||||
public string FullLineCommentDelimiterBase {
|
||||
get { return mFormatConfig.FullLineCommentDelimiterBase; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// String to put at the start of a line that has a box comment. This is usually
|
||||
/// blank, as it's only needed if the assembler doesn't recognize the box character
|
||||
/// as a comment.
|
||||
/// String to put at the start of a line with a full-line comment. Delimiter plus
|
||||
/// optional space.
|
||||
/// </summary>
|
||||
public string BoxLineCommentDelimiter {
|
||||
get { return mFormatConfig.BoxLineCommentDelimiter; }
|
||||
public string FullLineCommentDelimiterPlus {
|
||||
get { return mFullLineCommentDelimiterPlus; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -242,7 +242,6 @@ namespace SourceGen.AsmGen {
|
||||
config.LocalVariableLabelPrefix = ".";
|
||||
config.EndOfLineCommentDelimiter = ";";
|
||||
config.FullLineCommentDelimiterBase = ";";
|
||||
config.BoxLineCommentDelimiter = ";";
|
||||
config.NonUniqueLabelPrefix = "@";
|
||||
config.CommaSeparatedDense = false;
|
||||
config.ExprMode = Formatter.FormatConfig.ExpressionMode.Common;
|
||||
@ -286,14 +285,14 @@ namespace SourceGen.AsmGen {
|
||||
mOutStream = sw;
|
||||
|
||||
if (Settings.GetBool(AppSettings.SRCGEN_ADD_IDENT_COMMENT, false)) {
|
||||
OutputLine(SourceFormatter.FullLineCommentDelimiter +
|
||||
OutputLine(SourceFormatter.FullLineCommentDelimiterPlus +
|
||||
string.Format(Res.Strings.GENERATED_FOR_VERSION_FMT,
|
||||
"acme", mAsmVersion, AsmAcme.OPTIONS));
|
||||
}
|
||||
|
||||
if (HasNonZeroBankCode()) {
|
||||
// don't try
|
||||
OutputLine(SourceFormatter.FullLineCommentDelimiter +
|
||||
OutputLine(SourceFormatter.FullLineCommentDelimiterPlus +
|
||||
"ACME can't handle 65816 code that lives outside bank zero");
|
||||
int firstAddr = Project.AddrMap.OffsetToAddress(0);
|
||||
AddressMap.AddressRegion fakeRegion = new AddressMap.AddressRegion(0,
|
||||
|
@ -216,7 +216,6 @@ namespace SourceGen.AsmGen {
|
||||
config.ForceLongOperandPrefix = "f:"; // far
|
||||
config.EndOfLineCommentDelimiter = ";";
|
||||
config.FullLineCommentDelimiterBase = ";";
|
||||
config.BoxLineCommentDelimiter = ";";
|
||||
config.NonUniqueLabelPrefix = "@";
|
||||
config.CommaSeparatedDense = true;
|
||||
config.ExprMode = Formatter.FormatConfig.ExpressionMode.Cc65;
|
||||
@ -259,7 +258,7 @@ namespace SourceGen.AsmGen {
|
||||
mOutStream = sw;
|
||||
|
||||
if (Settings.GetBool(AppSettings.SRCGEN_ADD_IDENT_COMMENT, false)) {
|
||||
OutputLine(SourceFormatter.FullLineCommentDelimiter +
|
||||
OutputLine(SourceFormatter.FullLineCommentDelimiterPlus +
|
||||
string.Format(Res.Strings.GENERATED_FOR_VERSION_FMT,
|
||||
"cc65", mAsmVersion,
|
||||
AsmCc65.OPTIONS + " -C " + Path.GetFileName(cfgName)));
|
||||
|
@ -202,7 +202,6 @@ namespace SourceGen.AsmGen {
|
||||
config.LocalVariableLabelPrefix = "]";
|
||||
config.EndOfLineCommentDelimiter = ";";
|
||||
config.FullLineCommentDelimiterBase = "*";
|
||||
config.BoxLineCommentDelimiter = string.Empty;
|
||||
config.NonUniqueLabelPrefix = ":";
|
||||
config.CommaSeparatedDense = false;
|
||||
config.ExprMode = Formatter.FormatConfig.ExpressionMode.Merlin;
|
||||
@ -240,7 +239,7 @@ namespace SourceGen.AsmGen {
|
||||
|
||||
if (Settings.GetBool(AppSettings.SRCGEN_ADD_IDENT_COMMENT, false)) {
|
||||
// No version-specific stuff yet. We're generating code for v1.0.
|
||||
OutputLine(SourceFormatter.FullLineCommentDelimiter +
|
||||
OutputLine(SourceFormatter.FullLineCommentDelimiterPlus +
|
||||
string.Format(Res.Strings.GENERATED_FOR_VERSION_FMT,
|
||||
"Merlin 32", mAsmVersion, string.Empty));
|
||||
}
|
||||
|
@ -270,7 +270,6 @@ namespace SourceGen.AsmGen {
|
||||
config.ForceLongOperandPrefix = "@l"; // long
|
||||
config.EndOfLineCommentDelimiter = ";";
|
||||
config.FullLineCommentDelimiterBase = ";";
|
||||
config.BoxLineCommentDelimiter = ";";
|
||||
config.NonUniqueLabelPrefix = ""; // should be '_', but that's a valid label char
|
||||
config.CommaSeparatedDense = true;
|
||||
config.ExprMode = Formatter.FormatConfig.ExpressionMode.Common;
|
||||
@ -321,7 +320,7 @@ namespace SourceGen.AsmGen {
|
||||
mOutStream = sw;
|
||||
|
||||
if (Settings.GetBool(AppSettings.SRCGEN_ADD_IDENT_COMMENT, false)) {
|
||||
OutputLine(SourceFormatter.FullLineCommentDelimiter +
|
||||
OutputLine(SourceFormatter.FullLineCommentDelimiterPlus +
|
||||
string.Format(Res.Strings.GENERATED_FOR_VERSION_FMT,
|
||||
"64tass", mAsmVersion, AsmTass64.BASE_OPTIONS + extraOptions));
|
||||
}
|
||||
|
@ -488,12 +488,11 @@ namespace SourceGen {
|
||||
Debug.WriteLine("ApplyAppSettings...");
|
||||
AppSettings settings = AppSettings.Global;
|
||||
|
||||
// Set up the formatter.
|
||||
// Set up the formatter with default values.
|
||||
mFormatterConfig = new Formatter.FormatConfig();
|
||||
AsmGen.GenCommon.ConfigureFormatterFromSettings(AppSettings.Global,
|
||||
ref mFormatterConfig);
|
||||
mFormatterConfig.EndOfLineCommentDelimiter = ";";
|
||||
mFormatterConfig.BoxLineCommentDelimiter = string.Empty;
|
||||
|
||||
mFormatterConfig.NonUniqueLabelPrefix =
|
||||
settings.GetString(AppSettings.FMT_NON_UNIQUE_LABEL_PREFIX, string.Empty);
|
||||
|
@ -52,6 +52,11 @@ namespace SourceGen {
|
||||
/// </summary>
|
||||
public Color BackgroundColor { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Box character to use for "basic" formatting.
|
||||
/// </summary>
|
||||
private const char BASIC_BOX_CHAR = '*';
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Constructor. Object will have a max width of 80 and not be boxed.
|
||||
@ -94,7 +99,6 @@ namespace SourceGen {
|
||||
/// is non-empty, comment delimiters aren't emitted. (Used for notes.)</param>
|
||||
/// <returns>Array of formatted strings.</returns>
|
||||
public List<string> FormatText(Asm65.Formatter formatter, string textPrefix) {
|
||||
const char boxChar = '*';
|
||||
const char spcRep = '\u2219'; // BULLET OPERATOR
|
||||
string workString = string.IsNullOrEmpty(textPrefix) ? Text : textPrefix + Text;
|
||||
List<string> lines = new List<string>();
|
||||
@ -103,9 +107,14 @@ namespace SourceGen {
|
||||
if (!string.IsNullOrEmpty(textPrefix)) {
|
||||
linePrefix = string.Empty;
|
||||
} else if (BoxMode) {
|
||||
linePrefix = formatter.BoxLineCommentDelimiter;
|
||||
if (formatter.FullLineCommentDelimiterBase.Length == 1 &&
|
||||
formatter.FullLineCommentDelimiterBase[0] == BASIC_BOX_CHAR) {
|
||||
linePrefix = string.Empty;
|
||||
} else {
|
||||
linePrefix = formatter.FullLineCommentDelimiter;
|
||||
linePrefix = formatter.FullLineCommentDelimiterBase;
|
||||
}
|
||||
} else {
|
||||
linePrefix = formatter.FullLineCommentDelimiterPlus;
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder(MaxWidth);
|
||||
@ -119,7 +128,7 @@ namespace SourceGen {
|
||||
string boxLine, spaces;
|
||||
if (BoxMode) {
|
||||
for (int i = 0; i < MaxWidth - linePrefix.Length; i++) {
|
||||
sb.Append(boxChar);
|
||||
sb.Append(BASIC_BOX_CHAR);
|
||||
}
|
||||
boxLine = sb.ToString();
|
||||
sb.Clear();
|
||||
@ -159,13 +168,13 @@ namespace SourceGen {
|
||||
string str = workString.Substring(startIndex, i - startIndex);
|
||||
if (DebugShowRuler) { str = str.Replace(' ', spcRep); }
|
||||
if (BoxMode) {
|
||||
if (str == "" + boxChar) {
|
||||
if (str == "" + BASIC_BOX_CHAR) {
|
||||
// asterisk on a line by itself means "output row of asterisks"
|
||||
str = linePrefix + boxLine;
|
||||
} else {
|
||||
int padLen = lineWidth - str.Length;
|
||||
str = linePrefix + boxChar + " " + str +
|
||||
spaces.Substring(0, padLen + 1) + boxChar;
|
||||
str = linePrefix + BASIC_BOX_CHAR + " " + str +
|
||||
spaces.Substring(0, padLen + 1) + BASIC_BOX_CHAR;
|
||||
}
|
||||
} else {
|
||||
str = linePrefix + str;
|
||||
@ -191,7 +200,7 @@ namespace SourceGen {
|
||||
string str = workString.Substring(startIndex, i - startIndex);
|
||||
if (DebugShowRuler) { str = str.Replace(' ', spcRep); }
|
||||
if (BoxMode) {
|
||||
str = linePrefix + boxChar + " " + str + " " + boxChar;
|
||||
str = linePrefix + BASIC_BOX_CHAR + " " + str + " " + BASIC_BOX_CHAR;
|
||||
} else {
|
||||
str = linePrefix + str;
|
||||
}
|
||||
@ -209,8 +218,8 @@ namespace SourceGen {
|
||||
if (DebugShowRuler) { str = str.Replace(' ', spcRep); }
|
||||
if (BoxMode) {
|
||||
int padLen = lineWidth - str.Length;
|
||||
str = linePrefix + boxChar + " " + str +
|
||||
spaces.Substring(0, padLen + 1) + boxChar;
|
||||
str = linePrefix + BASIC_BOX_CHAR + " " + str +
|
||||
spaces.Substring(0, padLen + 1) + BASIC_BOX_CHAR;
|
||||
} else {
|
||||
str = linePrefix + str;
|
||||
}
|
||||
@ -239,8 +248,8 @@ namespace SourceGen {
|
||||
if (DebugShowRuler) { str = str.Replace(' ', spcRep); }
|
||||
if (BoxMode) {
|
||||
int padLen = lineWidth - str.Length;
|
||||
str = linePrefix + boxChar + " " + str +
|
||||
spaces.Substring(0, padLen + 1) + boxChar;
|
||||
str = linePrefix + BASIC_BOX_CHAR + " " + str +
|
||||
spaces.Substring(0, padLen + 1) + BASIC_BOX_CHAR;
|
||||
} else {
|
||||
str = linePrefix + str;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user