Improve code formatting

This commit is contained in:
Stone_Red
2022-11-17 11:40:51 +01:00
parent 533ad23c4d
commit 1ced6f393c
11 changed files with 39 additions and 109 deletions
+2 -9
View File
@@ -23,7 +23,7 @@ namespace YesNt.CodeEditor
{
if (File.Exists(path))
{
Load(path);
_ = Load(path);
}
}
@@ -131,14 +131,7 @@ namespace YesNt.CodeEditor
if (CurrentPath.Trim() != path.Trim() && loadIfExists)
{
if (Load(path))
{
return true;
}
else
{
return false;
}
return Load(path);
}
if (string.IsNullOrEmpty(Path.GetExtension(path)))
{
+9 -16
View File
@@ -16,7 +16,7 @@ namespace YesNt.CodeEditor
{
while (Console.KeyAvailable)
{
Console.ReadKey(true);
_ = Console.ReadKey(true);
}
if (textEditor.EditMode == Mode.Edit)
{
@@ -50,14 +50,7 @@ namespace YesNt.CodeEditor
return true;
case ConsoleKey.E:
if (textEditor.Lines.Count > textEditor.CursorPosition.Y)
{
textEditor.CursorPosition.X = textEditor.Lines[textEditor.CursorPosition.Y].TrimEnd().Length;
}
else
{
textEditor.CursorPosition.X = 0;
}
textEditor.CursorPosition.X = textEditor.Lines.Count > textEditor.CursorPosition.Y ? textEditor.Lines[textEditor.CursorPosition.Y].TrimEnd().Length : 0;
return true;
}
}
@@ -128,7 +121,7 @@ namespace YesNt.CodeEditor
StringBuilder lineBuilder = new StringBuilder(textEditor.Lines[textEditor.CursorPosition.Y]);
while (lineBuilder.Length <= textEditor.CursorPosition.X)
{
lineBuilder.Append(' ');
_ = lineBuilder.Append(' ');
}
textEditor.Lines[textEditor.CursorPosition.Y] = lineBuilder.ToString();
@@ -228,7 +221,7 @@ namespace YesNt.CodeEditor
break;
case "save":
textEditor.Save(input, false);
_ = textEditor.Save(input, false);
break;
case "run":
@@ -240,9 +233,9 @@ namespace YesNt.CodeEditor
textEditor.YesNtInterpreter.Execute(textEditor.CurrentPath);
while (Console.KeyAvailable)
{
Console.ReadKey(true);
_ = Console.ReadKey(true);
}
Console.ReadKey();
_ = Console.ReadKey();
WriteStatus(string.Empty);
textEditor.EditMode = Mode.Command;
}
@@ -257,9 +250,9 @@ namespace YesNt.CodeEditor
textEditor.YesNtInterpreter.Execute(textEditor.CurrentPath, true);
while (Console.KeyAvailable)
{
Console.ReadKey(true);
_ = Console.ReadKey(true);
}
Console.ReadKey();
_ = Console.ReadKey();
WriteStatus(string.Empty);
textEditor.EditMode = Mode.Command;
}
@@ -278,7 +271,7 @@ namespace YesNt.CodeEditor
try
{
textEditor.Load(path);
_ = textEditor.Load(path);
}
catch (Exception ex)
{
+1 -11
View File
@@ -4,17 +4,7 @@
{
private static void Main(string[] args)
{
TextEditor textEditor;
if (args.Length > 0)
{
textEditor = new TextEditor(args[0]);
}
else
{
textEditor = new TextEditor();
}
TextEditor textEditor = args.Length > 0 ? new TextEditor(args[0]) : new TextEditor();
textEditor.Run();
}
}