Now converts 16-bit tables that uses an underline attribute to define a row separator (instead of the dash character)

Uncommented the Script Caution tab logic.  Needed for initial NSP compares
This commit is contained in:
2012-07-12 13:09:16 +00:00
parent 2c10b3843b
commit ce21565a15
2 changed files with 93 additions and 8 deletions

View File

@@ -3470,9 +3470,94 @@ namespace Volian.Controls.Library
stepText = stepText.Replace(@"\u9830?", "\xA9"); // diamond, 2666
stepText = stepText.Replace(@"\u8593?", "\x18"); // Up Arrow - changes to \xff
stepText = stepText.Replace(@"\u8595?", "\x19"); // Down Arrow - changes to \xd6
// Fix "|" followed by a newline - this confuses the table converter
stepText = stepText.Replace(@"|\r\n", @"| \r\n");
stepText = stepText.Replace(@"|\n\r", @"| \n\r");
stepText = stepText.Replace(@"|\n", @"| \n");
// if the entire row is underlined, then remove the underline and insert a row of dashes
stepText = ConvertUnderlineToRow(stepText);
return stepText;
}
private bool IsPrintableTableChar(char c)
{
string printablSymbols = "\xB3\xA0\x7F\xF2\xF3\xE4\xE7\xFE\x07\xF7\xF0\xFB\xE2\xE3\xE6\xEB\xE5\x90\xEE\xE9\xEC\xA8\xA9\x18\x19";
return (((c > '\x1F') && (c < '\x80')) || (printablSymbols.IndexOf(c) >= 0));
}
private string ConvertUnderlineToRow(string stepText)
{
string rtnStr = "";
char[] sep = { '\n' };
string[] lines = stepText.Split(sep);
foreach (string line in lines)
{
int idx = 0;
int chrCnt = 0;
int uOnPos = -1;
int uOffPos = -1;
bool ulineOn = false;
char curChar = line[idx];
string dashRow = "";
while (idx < line.Length && !IsPrintableTableChar(line[idx]))
{
if (line[idx] == '\xAB') //underline ON
{
ulineOn = true;
uOnPos = idx;
}
idx++;
}
while (ulineOn && idx < line.Length)
{
if (IsPrintableTableChar(line[idx]))
{
if (line[idx] == '|' || line[idx] == '\xB3')
{
dashRow += new string('-', chrCnt);
dashRow += "|";
chrCnt = 0;
}
else
chrCnt++;
idx++;
}
else
{
if (line[idx] == '\xBB') //underline OFF
{
uOffPos = idx;
ulineOn = false;
while ((idx < line.Length) && !IsPrintableTableChar(line[idx]))
{
if (line[idx] == '\xAB')
ulineOn = true;
idx++;
}
if (idx == line.Length)
ulineOn = true;
if (!ulineOn)
dashRow = "";
}
else
idx++;
}
}
string curLine = line;
curLine = curLine.Replace('\xB3', '|'); // replace graphic vert bar with DOS vert bar
if (ulineOn && idx == line.Length) // entire line is underlined, remove underline, insert row of dashes
{
curLine = curLine.Replace("\xAB", ""); // remove Underline ON
curLine = curLine.Replace("\xBB", ""); // remove Underline OFF
dashRow += new string('-', chrCnt);
dashRow = "\n" + dashRow;
}
if (rtnStr.Length > 0) rtnStr += "\n";
rtnStr += curLine;
rtnStr += dashRow;
}
return rtnStr;
}
/// <summary>
/// This will parse a string containing the ascii text of the old style VE-PROMS (16-bit) tables.