mirror of
https://github.com/Stone-Red-Code/YesNt-Interpreter.git
synced 2026-09-09 23:43:16 +02:00
Fix exec statement and syntax highlighter
This commit is contained in:
@@ -134,7 +134,7 @@ internal partial class SyntaxHighlighter(ReadOnlyCollection<StatementInformation
|
|||||||
bool succ = int.TryParse(stringColor, out int colorIndex);
|
bool succ = int.TryParse(stringColor, out int colorIndex);
|
||||||
if (succ && colorIndex >= 0 && colorIndex < 16)
|
if (succ && colorIndex >= 0 && colorIndex < 16)
|
||||||
{
|
{
|
||||||
messagePart = Base64Decode(messagePart.Replace($"\r{stringColor}\r", string.Empty));
|
messagePart = Base64Decode(messagePart.Replace($"\v{stringColor}\v", string.Empty));
|
||||||
consoleColor = (ConsoleColor)colorIndex;
|
consoleColor = (ConsoleColor)colorIndex;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -160,9 +160,9 @@ internal partial class SyntaxHighlighter(ReadOnlyCollection<StatementInformation
|
|||||||
|
|
||||||
string result = searchMode switch
|
string result = searchMode switch
|
||||||
{
|
{
|
||||||
SearchMode.StartOfLine => originalString.ReplaceFirstOccurrence(value, $"\0\r{(int)color}\r{base64Value}\0" + new string(' ', spacesAtEnd)),
|
SearchMode.StartOfLine => originalString.ReplaceFirstOccurrence(value, $"\0\v{(int)color}\v{base64Value}\0" + new string(' ', spacesAtEnd)),
|
||||||
SearchMode.EndOfLine => originalString.ReplaceLastOccurrence(value, $"\0\r{(int)color}\r{base64Value}\0" + new string(' ', spacesAtEnd)),
|
SearchMode.EndOfLine => originalString.ReplaceLastOccurrence(value, $"\0\v{(int)color}\v{base64Value}\0" + new string(' ', spacesAtEnd)),
|
||||||
_ => originalString.Replace(value, $"\0\r{(int)color}\r{base64Value}\0" + new string(' ', spacesAtEnd))
|
_ => originalString.Replace(value, $"\0\v{(int)color}\v{base64Value}\0" + new string(' ', spacesAtEnd))
|
||||||
};
|
};
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -176,6 +176,6 @@ internal partial class SyntaxHighlighter(ReadOnlyCollection<StatementInformation
|
|||||||
[GeneratedRegex(">[a-zA-Z0-9]+")]
|
[GeneratedRegex(">[a-zA-Z0-9]+")]
|
||||||
private static partial Regex VariableRegex();
|
private static partial Regex VariableRegex();
|
||||||
|
|
||||||
[GeneratedRegex("(?<=(\\r))(.*)(?=\\r)")]
|
[GeneratedRegex("(?<=(\\v))(.*)(?=\\v)")]
|
||||||
private static partial Regex StringColorRegex();
|
private static partial Regex StringColorRegex();
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
@@ -60,10 +61,34 @@ internal class SystemStatements : StatementRuntimeInformation
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void Process_ErrorDataReceived(Utilities.DataReceivedEventArgs e, Stack<string> outputStack)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(e.Data))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
outputStack.Push(e.Data.ToSafeString());
|
||||||
|
Console.Write("Error: " + e.Data);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void Process_OutputDataReceived(Utilities.DataReceivedEventArgs e, Stack<string> outputStack)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(e.Data))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
outputStack.Push(e.Data.ToSafeString());
|
||||||
|
Console.Write(e.Data);
|
||||||
|
}
|
||||||
|
|
||||||
private void StartProcess(string name, string args)
|
private void StartProcess(string name, string args)
|
||||||
{
|
{
|
||||||
RuntimeInfo.OutParametersStack.Clear();
|
RuntimeInfo.OutParametersStack.Clear();
|
||||||
|
|
||||||
|
Stack<string> outputStack = new Stack<string>();
|
||||||
|
|
||||||
FixedProcess process = new FixedProcess
|
FixedProcess process = new FixedProcess
|
||||||
{
|
{
|
||||||
StartInfo = new ProcessStartInfo()
|
StartInfo = new ProcessStartInfo()
|
||||||
@@ -75,8 +100,8 @@ internal class SystemStatements : StatementRuntimeInformation
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
process.OutputDataReceived += Process_OutputDataReceived;
|
process.OutputDataReceived += (s, e) => Process_OutputDataReceived(e, outputStack);
|
||||||
process.ErrorDataReceived += Process_ErrorDataReceived;
|
process.ErrorDataReceived += (s, e) => Process_ErrorDataReceived(e, outputStack);
|
||||||
|
|
||||||
_ = process.Start();
|
_ = process.Start();
|
||||||
process.BeginOutputReadLine();
|
process.BeginOutputReadLine();
|
||||||
@@ -85,28 +110,7 @@ internal class SystemStatements : StatementRuntimeInformation
|
|||||||
|
|
||||||
RuntimeInfo.InParametersStack.Clear();
|
RuntimeInfo.InParametersStack.Clear();
|
||||||
|
|
||||||
|
RuntimeInfo.OutParametersStack = new(outputStack);
|
||||||
RuntimeInfo.OutParametersStack.Push(process.ExitCode.ToString());
|
RuntimeInfo.OutParametersStack.Push(process.ExitCode.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Process_ErrorDataReceived(object sender, Utilities.DataReceivedEventArgs e)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrWhiteSpace(e.Data))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
RuntimeInfo.OutParametersStack.Push(e.Data);
|
|
||||||
Console.Write("Error: " + e.Data);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Process_OutputDataReceived(object sender, Utilities.DataReceivedEventArgs e)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrWhiteSpace(e.Data))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
RuntimeInfo.OutParametersStack.Push(e.Data);
|
|
||||||
Console.Write(e.Data);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user