");
sw.Write("");
StringBuilder sb = new StringBuilder(128);
@@ -421,7 +401,6 @@ namespace SourceGen {
}
sb.Clear();
}
- //sw.WriteLine("
\r\n");
sw.WriteLine("\r\n");
sw.Write(template2);
@@ -460,12 +439,12 @@ namespace SourceGen {
Debug.Assert(sb.Length == 0);
// Width of "bytes" field, without '+' or trailing space.
- int bytesWidth = mColEnd[(int)Col.Bytes] - mColEnd[(int)Col.Address] - 2;
+ int bytesWidth = mColStart[(int)Col.Bytes + 1] - mColStart[(int)Col.Bytes] - 2;
LineListGen.Line line = mCodeLineList[index];
DisplayList.FormattedParts parts = mCodeLineList.GetFormattedParts(index);
- int maxLabelLen = mColEnd[(int)Col.Label] - mColEnd[(int)Col.Attr] - 1;
+ int maxLabelLen = mColStart[(int)Col.Label + 1] - mColStart[(int)Col.Label] - 1;
string anchorLabel = null;
if ((line.LineType == LineListGen.Line.Type.Code ||
@@ -483,26 +462,26 @@ namespace SourceGen {
linkOperand = GetLinkOperand(index, parts.Operand);
}
- int colPos = 0;
-
bool suppressLabel = false;
if (mLongLabelNewLine && (line.LineType == LineListGen.Line.Type.Code ||
line.LineType == LineListGen.Line.Type.Data)) {
int labelLen = string.IsNullOrEmpty(parts.Label) ? 0 : parts.Label.Length;
if (labelLen > maxLabelLen) {
// put on its own line
- AddSpacedString(sb, colPos, mColEnd[(int)Col.Attr], string.Empty, 0);
+ string lstr;
if (anchorLabel != null) {
- sb.Append(anchorLabel);
+ lstr = anchorLabel;
} else {
- sb.Append(parts.Label);
+ lstr = parts.Label;
}
+ AddSpacedString(sb, 0, mColStart[(int)Col.Label], lstr, parts.Label.Length);
sb.Append("\r\n");
suppressLabel = true;
- Debug.Assert(colPos == 0);
}
}
+ int colPos = 0;
+
switch (line.LineType) {
case LineListGen.Line.Type.Code:
case LineListGen.Line.Type.Data:
@@ -513,91 +492,77 @@ namespace SourceGen {
if (parts.IsLongComment) {
// This happens for long comments embedded in LV tables, e.g.
// "clear table".
- colPos = AddSpacedString(sb, colPos, mColEnd[(int)Col.Attr],
- string.Empty, 0);
- sb.Append(TextUtil.EscapeHTML(parts.Comment));
+ AddSpacedString(sb, 0, mColStart[(int)Col.Label],
+ TextUtil.EscapeHTML(parts.Comment), parts.Comment.Length);
break;
}
// these columns are optional
if ((mLeftFlags & ActiveColumnFlags.Offset) != 0) {
- colPos = AddSpacedString(sb, colPos, mColEnd[(int)Col.Offset],
+ colPos = AddSpacedString(sb, colPos, mColStart[(int)Col.Offset],
parts.Offset, parts.Offset.Length);
}
if ((mLeftFlags & ActiveColumnFlags.Address) != 0) {
- string str;
if (!string.IsNullOrEmpty(parts.Addr)) {
- str = parts.Addr + ":";
- } else {
- str = string.Empty;
+ string str = parts.Addr + ":";
+ colPos = AddSpacedString(sb, colPos, mColStart[(int)Col.Address],
+ str, str.Length);
}
- colPos = AddSpacedString(sb, colPos, mColEnd[(int)Col.Address],
- str, str.Length);
}
if ((mLeftFlags & ActiveColumnFlags.Bytes) != 0) {
// Shorten the "...".
string bytesStr = parts.Bytes;
- if (bytesStr == null) {
- bytesStr = string.Empty;
+ if (bytesStr != null) {
+ if (bytesStr.Length > bytesWidth) {
+ bytesStr = bytesStr.Substring(0, bytesWidth) + "+";
+ }
+ colPos = AddSpacedString(sb, colPos, mColStart[(int)Col.Bytes],
+ bytesStr, bytesStr.Length);
}
- if (bytesStr.Length > bytesWidth) {
- bytesStr = bytesStr.Substring(0, bytesWidth) + "+";
- }
- colPos = AddSpacedString(sb, colPos, mColEnd[(int)Col.Bytes],
- bytesStr, bytesStr.Length);
}
if ((mLeftFlags & ActiveColumnFlags.Flags) != 0) {
- colPos = AddSpacedString(sb, colPos, mColEnd[(int)Col.Flags],
+ colPos = AddSpacedString(sb, colPos, mColStart[(int)Col.Flags],
parts.Flags, parts.Flags.Length);
}
if ((mLeftFlags & ActiveColumnFlags.Attr) != 0) {
- colPos = AddSpacedString(sb, colPos, mColEnd[(int)Col.Attr],
+ colPos = AddSpacedString(sb, colPos, mColStart[(int)Col.Attr],
TextUtil.EscapeHTML(parts.Attr), parts.Attr.Length);
}
// remaining columns are mandatory, but may be empty
if (suppressLabel) {
- colPos = AddSpacedString(sb, colPos, mColEnd[(int)Col.Label],
- string.Empty, 0);
+ // label on previous line
} else if (anchorLabel != null) {
- colPos = AddSpacedString(sb, colPos, mColEnd[(int)Col.Label],
+ colPos = AddSpacedString(sb, colPos, mColStart[(int)Col.Label],
anchorLabel, parts.Label.Length);
} else if (parts.Label != null) {
- colPos = AddSpacedString(sb, colPos, mColEnd[(int)Col.Label],
+ colPos = AddSpacedString(sb, colPos, mColStart[(int)Col.Label],
parts.Label, parts.Label.Length);
}
- colPos = AddSpacedString(sb, colPos, mColEnd[(int)Col.Opcode],
+ colPos = AddSpacedString(sb, colPos, mColStart[(int)Col.Opcode],
parts.Opcode, parts.Opcode.Length);
if (linkOperand != null) {
- colPos = AddSpacedString(sb, colPos, mColEnd[(int)Col.Operand],
+ colPos = AddSpacedString(sb, colPos, mColStart[(int)Col.Operand],
linkOperand, parts.Operand.Length);
} else {
- colPos = AddSpacedString(sb, colPos, mColEnd[(int)Col.Operand],
+ colPos = AddSpacedString(sb, colPos, mColStart[(int)Col.Operand],
TextUtil.EscapeHTML(parts.Operand), parts.Operand.Length);
}
- if (string.IsNullOrEmpty(parts.Comment)) {
- // Trim trailing spaces off opcode or operand. Would be more efficient
- // to just not generate the spaces, but this is simpler and we're not
- // in a hurry.
- TextUtil.TrimEnd(sb);
- } else {
- sb.Append(TextUtil.EscapeHTML(parts.Comment));
+ if (parts.Comment != null) {
+ colPos = AddSpacedString(sb, colPos, mColStart[(int)Col.Comment],
+ TextUtil.EscapeHTML(parts.Comment), parts.Comment.Length);
}
-
break;
case LineListGen.Line.Type.LongComment:
case LineListGen.Line.Type.Note:
if (line.LineType == LineListGen.Line.Type.Note && !IncludeNotes) {
return false;
}
- // Long comments aren't the left-most field, so pad it out.
- colPos = AddSpacedString(sb, colPos, mColEnd[(int)Col.Attr],
- string.Empty, 0);
// Notes have a background color. Use this to highlight the text. We
// don't apply it to the padding on the left columns.
@@ -608,13 +573,15 @@ namespace SourceGen {
rgb = (b.Color.R << 16) | (b.Color.G << 8) | (b.Color.B);
}
}
+ string cstr;
if (rgb != 0) {
- sb.AppendFormat("