|
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|
|
using System.Drawing;
|
|
|
using System.Linq;
|
|
|
using System.Reflection;
|
|
|
+using NTERA.Core;
|
|
|
using NTERA.Core.Interop;
|
|
|
using NTERA.Engine.Compiler;
|
|
|
|
|
@@ -228,30 +229,54 @@ namespace NTERA.Engine.Runtime.Base
|
|
|
|
|
|
runtime.Console.PrintHtml(htmlValue.String, false);
|
|
|
}
|
|
|
- [Keyword("PRINT", true, false)]
|
|
|
+
|
|
|
+ private static PrintFlags ParsePrintFlags(string opts)
|
|
|
+ {
|
|
|
+ return new PrintFlags {
|
|
|
+ NewLine = opts.Contains("L") || opts.Contains("W"),
|
|
|
+ Wait = opts.Contains("W"),
|
|
|
+ ForceKana = opts.Contains("K"),
|
|
|
+ NoColor = opts.Contains("D")
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
[Keyword("PRINTFORM", true, true)]
|
|
|
- public static void Print(EraRuntime runtime, StackFrame context, ExecutionNode node)
|
|
|
+ [Keyword("PRINTFORMK", true, true)]
|
|
|
+ [Keyword("PRINTFORMD", true, true)]
|
|
|
+ [Keyword("PRINTFORML", true, true)]
|
|
|
+ [Keyword("PRINTFORMW", true, true)]
|
|
|
+ [Keyword("PRINTFORMK", true, true)]
|
|
|
+ [Keyword("PRINTFORMKL", true, true)]
|
|
|
+ [Keyword("PRINTFORMKW", true, true)]
|
|
|
+ [Keyword("PRINTFORMD", true, true)]
|
|
|
+ [Keyword("PRINTFORMDL", true, true)]
|
|
|
+ [Keyword("PRINTFORMDW", true, true)]
|
|
|
+ public static void PrintForm(EraRuntime runtime, StackFrame context, ExecutionNode node)
|
|
|
{
|
|
|
+ var flags = ParsePrintFlags(node["name"].Substring(9));
|
|
|
var value = runtime.ComputeExpression(context, node.Single());
|
|
|
-
|
|
|
- runtime.Console.Write(value.ToString());
|
|
|
+ runtime.Console.Write(value.ToString(), flags);
|
|
|
}
|
|
|
|
|
|
- [Keyword("PRINTFORML", true, true)]
|
|
|
+ [Keyword("PRINT", true, false)]
|
|
|
[Keyword("PRINTL", true, false)]
|
|
|
- public static void PrintLine(EraRuntime runtime, StackFrame context, ExecutionNode node)
|
|
|
+ [Keyword("PRINTW", true, false)]
|
|
|
+ [Keyword("PRINTK", true, false)]
|
|
|
+ [Keyword("PRINTKL", true, false)]
|
|
|
+ [Keyword("PRINTKW", true, false)]
|
|
|
+ [Keyword("PRINTD", true, false)]
|
|
|
+ [Keyword("PRINTDL", true, false)]
|
|
|
+ [Keyword("PRINTDW", true, false)]
|
|
|
+ public static void Print(EraRuntime runtime, StackFrame context, ExecutionNode node)
|
|
|
{
|
|
|
+ var flags = ParsePrintFlags(node["name"].Substring(5));
|
|
|
var value = runtime.ComputeExpression(context, node.Single());
|
|
|
-
|
|
|
- runtime.Console.PrintSingleLine(value.ToString());
|
|
|
+ runtime.Console.Write(value.ToString(), flags);
|
|
|
}
|
|
|
|
|
|
private class PrintDataOptions
|
|
|
{
|
|
|
- public bool PrintLine = false;
|
|
|
- public bool Wait = false;
|
|
|
- public bool ForceKana = false;
|
|
|
- public bool NoColor = false;
|
|
|
+ public PrintFlags Flags = new PrintFlags();
|
|
|
public int Count = 0;
|
|
|
public ExecutionNode ChosenNode;
|
|
|
}
|
|
@@ -272,15 +297,7 @@ namespace NTERA.Engine.Runtime.Base
|
|
|
DATAFORMs followed by a ENDDATA and it picks one at random and prints that.
|
|
|
*/
|
|
|
CurrentPrintDataOptions = new PrintDataOptions();
|
|
|
- var opts = node["name"].Substring(9);
|
|
|
- if (opts.Contains("L"))
|
|
|
- CurrentPrintDataOptions.PrintLine = true;
|
|
|
- if (opts.Contains("W"))
|
|
|
- CurrentPrintDataOptions.Wait = true;
|
|
|
- if (opts.Contains("K"))
|
|
|
- CurrentPrintDataOptions.ForceKana = true;
|
|
|
- if (opts.Contains("D"))
|
|
|
- CurrentPrintDataOptions.NoColor = true;
|
|
|
+ CurrentPrintDataOptions.Flags = ParsePrintFlags(node["name"].Substring(9));
|
|
|
}
|
|
|
|
|
|
[Keyword("DATA", true, true)]
|
|
@@ -299,10 +316,7 @@ namespace NTERA.Engine.Runtime.Base
|
|
|
throw new ArgumentException("No DATAFORM found before ENDDATA");
|
|
|
}
|
|
|
var value = runtime.ComputeExpression(context, CurrentPrintDataOptions.ChosenNode);
|
|
|
- if (CurrentPrintDataOptions.PrintLine)
|
|
|
- runtime.Console.PrintSingleLine(value.ToString());
|
|
|
- else
|
|
|
- runtime.Console.Write(value.ToString());
|
|
|
+ runtime.Console.Write(value.ToString(), CurrentPrintDataOptions.Flags);
|
|
|
}
|
|
|
}
|
|
|
}
|