Escape invisible character is debug mode

This commit is contained in:
Stone_Red
2024-08-08 23:57:40 +02:00
parent ec2f294796
commit 9a6f1d7806
6 changed files with 42 additions and 34 deletions
@@ -52,20 +52,20 @@ public class YesNtInterpreter
Assembly assembly = Assembly.GetExecutingAssembly();
Type[] types = assembly.GetTypes();
IEnumerable<Type> statementRuntimeInfos = types.Where(t => t.IsSubclassOf(typeof(StatementRuntimeInformation)));
IEnumerable<Type> allStatementRuntimeInfo = types.Where(t => t.IsSubclassOf(typeof(StatementRuntimeInformation)));
statements.Clear();
foreach (Type type in statementRuntimeInfos)
foreach (Type type in allStatementRuntimeInfo)
{
object statementInfo = Activator.CreateInstance(type);
MethodInfo[] methodInfos = statementInfo.GetType().GetMethods();
MethodInfo[] allMethodInfo = statementInfo.GetType().GetMethods();
StatementRuntimeInformation statementRuntimeInfo = statementInfo as StatementRuntimeInformation;
statementRuntimeInfo.RuntimeInfo = runtimeInfo;
foreach (MethodInfo methodInfo in methodInfos)
foreach (MethodInfo methodInfo in allMethodInfo)
{
StatementAttribute statementAttribute = methodInfo.GetCustomAttribute<StatementAttribute>();
if (statementAttribute is not null)
@@ -51,7 +51,7 @@ internal class ConsoleStatements : StatementRuntimeInformation
args += " ";
while (args.Contains("%cr"))
{
string input = ConsoleExtentions.ReadKey(RuntimeInfo).ToString();
string input = ConsoleExtensions.ReadKey(RuntimeInfo).ToString();
args = args.ReplaceFirstOccurrence("%cr ", input.ToSafeString() + " ");
}
RuntimeInfo.CurrentLine = args.TrimEnd();
@@ -62,7 +62,7 @@ internal partial class ProcessingStatements : StatementRuntimeInformation
{
if (int.TryParse(args, out int millisecondsTimeout))
{
ConsoleExtentions.Sleep(millisecondsTimeout, RuntimeInfo);
ConsoleExtensions.Sleep(millisecondsTimeout, RuntimeInfo);
}
else
{
@@ -4,35 +4,34 @@ using System.Threading;
using YesNt.Interpreter.Runtime;
namespace YesNt.Interpreter.Utilities
{
internal static class ConsoleExtentions
{
public static char ReadKey(RuntimeInformation runtimeInformation)
{
while (!runtimeInformation.Stop)
{
if (Console.KeyAvailable)
{
return Console.ReadKey().KeyChar;
}
Thread.Sleep(10);
}
return ' ';
}
namespace YesNt.Interpreter.Utilities;
public static void Sleep(int millisecondsTimeout, RuntimeInformation runtimeInformation)
internal static class ConsoleExtensions
{
public static char ReadKey(RuntimeInformation runtimeInformation)
{
while (!runtimeInformation.Stop)
{
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
while (!runtimeInformation.Stop)
if (Console.KeyAvailable)
{
if (stopwatch.ElapsedMilliseconds > millisecondsTimeout)
{
return;
}
Thread.Sleep(10);
return Console.ReadKey().KeyChar;
}
Thread.Sleep(10);
}
return ' ';
}
public static void Sleep(int millisecondsTimeout, RuntimeInformation runtimeInformation)
{
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
while (!runtimeInformation.Stop)
{
if (stopwatch.ElapsedMilliseconds > millisecondsTimeout)
{
return;
}
Thread.Sleep(10);
}
}
}