mirror of
https://github.com/Stone-Red-Code/YesNt-Interpreter.git
synced 2026-09-04 09:06:41 +02:00
Upgrade to .NET 8 and code cleanup
This commit is contained in:
@@ -11,12 +11,12 @@ internal class TextEditor
|
||||
{
|
||||
private readonly InputHandler inputHandler;
|
||||
private readonly SyntaxHighlighter syntaxHighlighter;
|
||||
private readonly List<string> debugOutput = new();
|
||||
private readonly List<string> debugOutput = [];
|
||||
|
||||
private readonly Point oldSize = new Point(0, 0);
|
||||
public YesNtInterpreter YesNtInterpreter { get; } = new();
|
||||
public int LineOffset { get; set; } = 0;
|
||||
public List<string> Lines { get; } = new();
|
||||
public List<string> Lines { get; } = [];
|
||||
public Point CursorPosition { get; } = new(0, 0);
|
||||
public Mode EditMode { get; set; } = Mode.Command;
|
||||
public string CurrentPath { get; set; } = string.Empty;
|
||||
@@ -263,16 +263,10 @@ internal class TextEditor
|
||||
}
|
||||
}
|
||||
|
||||
internal class Point
|
||||
internal class Point(int x, int y)
|
||||
{
|
||||
public int X { get; set; }
|
||||
public int Y { get; set; }
|
||||
|
||||
public Point(int x, int y)
|
||||
{
|
||||
X = x;
|
||||
Y = y;
|
||||
}
|
||||
public int X { get; set; } = x;
|
||||
public int Y { get; set; } = y;
|
||||
}
|
||||
|
||||
internal enum Mode
|
||||
|
||||
@@ -5,4 +5,4 @@
|
||||
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
[assembly: SuppressMessage("Critical Code Smell", "S3998:Threads should not lock on objects with weak identity", Justification = "<Pending>", Scope = "member", Target = "~M:YesNt.CodeEditor.TextEditor.YesNtInterpreter_OnLineExecuted(YesNt.Interpreter.Runtime.DebugEventArgs)")]
|
||||
[assembly: SuppressMessage("Critical Code Smell", "S3998:Threads should not lock on objects with weak identity", Justification = "<Pending>", Scope = "member", Target = "~M:YesNt.CodeEditor.TextEditor.YesNtInterpreter_OnLineExecuted(YesNt.Interpreter.Runtime.DebugEventArgs)")]
|
||||
@@ -3,14 +3,9 @@ using System.Text;
|
||||
|
||||
namespace YesNt.CodeEditor;
|
||||
|
||||
internal class InputHandler
|
||||
internal class InputHandler(TextEditor textEditor)
|
||||
{
|
||||
private readonly TextEditor textEditor;
|
||||
|
||||
public InputHandler(TextEditor textEditor)
|
||||
{
|
||||
this.textEditor = textEditor;
|
||||
}
|
||||
private readonly TextEditor textEditor = textEditor;
|
||||
|
||||
public bool HandleInput()
|
||||
{
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"profiles": {
|
||||
"YesNt.CodeEditor": {
|
||||
"commandName": "Project"
|
||||
},
|
||||
"WSL": {
|
||||
"commandName": "WSL2",
|
||||
"environmentVariables": {},
|
||||
"distributionName": ""
|
||||
"profiles": {
|
||||
"YesNt.CodeEditor": {
|
||||
"commandName": "Project"
|
||||
},
|
||||
"WSL": {
|
||||
"commandName": "WSL2",
|
||||
"environmentVariables": {},
|
||||
"distributionName": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,16 +9,10 @@ using YesNt.Interpreter.Utilities;
|
||||
|
||||
namespace YesNt.CodeEditor;
|
||||
|
||||
internal partial class SyntaxHighlighter
|
||||
internal partial class SyntaxHighlighter(ReadOnlyCollection<StatementInformation> statementInformation)
|
||||
{
|
||||
private readonly ReadOnlyCollection<StatementInformation> statementInformation;
|
||||
private readonly string[] replacementValues;
|
||||
|
||||
public SyntaxHighlighter(ReadOnlyCollection<StatementInformation> statementInformation)
|
||||
{
|
||||
this.statementInformation = statementInformation;
|
||||
replacementValues = StringExtentions.ReplacementRules.Values.ToArray();
|
||||
}
|
||||
private readonly ReadOnlyCollection<StatementInformation> statementInformation = statementInformation;
|
||||
private readonly string[] replacementValues = StringExtensions.ReplacementRules.Values.ToArray();
|
||||
|
||||
public static string Base64Encode(string plainText)
|
||||
{
|
||||
@@ -64,11 +58,11 @@ internal partial class SyntaxHighlighter
|
||||
input = input.TrimEnd(' ');
|
||||
if (statement.SearchMode == SearchMode.StartOfLine && input.StartsWith(name))
|
||||
{
|
||||
if (statement.Seperator is not null && input.Contains(statement.Seperator))
|
||||
if (statement.Separator is not null && input.Contains(statement.Separator))
|
||||
{
|
||||
input = AddColorInformation(input, statement.Seperator, statement.Color, SearchMode.StartOfLine);
|
||||
input = AddColorInformation(input, statement.Separator, statement.Color, SearchMode.StartOfLine);
|
||||
}
|
||||
else if (statement.Seperator is not null)
|
||||
else if (statement.Separator is not null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -76,11 +70,11 @@ internal partial class SyntaxHighlighter
|
||||
}
|
||||
else if (statement.SearchMode == SearchMode.Contains && input.Contains(name))
|
||||
{
|
||||
if (statement.Seperator is not null && input.Contains(statement.Seperator))
|
||||
if (statement.Separator is not null && input.Contains(statement.Separator))
|
||||
{
|
||||
input = AddColorInformation(input, statement.Seperator, statement.Color, SearchMode.StartOfLine);
|
||||
input = AddColorInformation(input, statement.Separator, statement.Color, SearchMode.StartOfLine);
|
||||
}
|
||||
else if (statement.Seperator is not null)
|
||||
else if (statement.Separator is not null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -88,11 +82,11 @@ internal partial class SyntaxHighlighter
|
||||
}
|
||||
else if (statement.SearchMode == SearchMode.EndOfLine && input.EndsWith(name))
|
||||
{
|
||||
if (statement.Seperator is not null && input.Contains(statement.Seperator))
|
||||
if (statement.Separator is not null && input.Contains(statement.Separator))
|
||||
{
|
||||
input = AddColorInformation(input, statement.Seperator, statement.Color, SearchMode.StartOfLine);
|
||||
input = AddColorInformation(input, statement.Separator, statement.Color, SearchMode.StartOfLine);
|
||||
}
|
||||
else if (statement.Seperator is not null)
|
||||
else if (statement.Separator is not null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -100,11 +94,11 @@ internal partial class SyntaxHighlighter
|
||||
}
|
||||
else if (statement.SearchMode == SearchMode.Exact && input.Equals(name))
|
||||
{
|
||||
if (statement.Seperator is not null && input.Contains(statement.Seperator))
|
||||
if (statement.Separator is not null && input.Contains(statement.Separator))
|
||||
{
|
||||
input = AddColorInformation(input, statement.Seperator, statement.Color, SearchMode.StartOfLine);
|
||||
input = AddColorInformation(input, statement.Separator, statement.Color, SearchMode.StartOfLine);
|
||||
}
|
||||
else if (statement.Seperator is not null)
|
||||
else if (statement.Separator is not null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -164,13 +158,13 @@ internal partial class SyntaxHighlighter
|
||||
|
||||
string base64Value = Base64Encode(value.TrimEnd());
|
||||
|
||||
string reult = searchMode switch
|
||||
string result = searchMode switch
|
||||
{
|
||||
SearchMode.StartOfLine => originalString.ReplaceFirstOccurrence(value, $"\0\r{(int)color}\r{base64Value}\0" + new string(' ', spacesAtEnd)),
|
||||
SearchMode.EndOfLine => originalString.ReplaceLastOccurrence(value, $"\0\r{(int)color}\r{base64Value}\0" + new string(' ', spacesAtEnd)),
|
||||
_ => originalString.Replace(value, $"\0\r{(int)color}\r{base64Value}\0" + new string(' ', spacesAtEnd))
|
||||
};
|
||||
return reult;
|
||||
return result;
|
||||
}
|
||||
|
||||
[GeneratedRegex("^<[a-zA-Z0-9]+")]
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user