Skip to content

Commit

Permalink
code beautification
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjbreisch committed Jun 22, 2022
1 parent 170fc75 commit 7819ed3
Show file tree
Hide file tree
Showing 101 changed files with 562 additions and 636 deletions.
4 changes: 3 additions & 1 deletion Trs80.Level1Basic.Application/Bootstrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Microsoft.Extensions.Logging;

using NLog.Extensions.Logging;

using Trs80.Level1Basic.Command;
using Trs80.Level1Basic.Command.Commands;
using Trs80.Level1Basic.CommandModels;
Expand All @@ -19,6 +20,7 @@
using Trs80.Level1Basic.VirtualMachine.Parser;
using Trs80.Level1Basic.VirtualMachine.Scanner;
using Trs80.Level1Basic.Workflow;

using WorkflowCore.Interface;
using WorkflowCore.Models;
using WorkflowCore.Services.DefinitionStorage;
Expand Down Expand Up @@ -55,7 +57,7 @@ public Bootstrapper()
CreateServiceProvider();

GetAppSettings();

GetApplicationName();

LogConfiguredServices();
Expand Down
1 change: 1 addition & 0 deletions Trs80.Level1Basic.Application/ConsoleApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;

using Trs80.Level1Basic.CommandModels;
using Trs80.Level1Basic.VirtualMachine.Machine;

Expand Down
19 changes: 12 additions & 7 deletions Trs80.Level1Basic.Command/Commands/InputCommand.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
using Trs80.Level1Basic.CommandModels;
using System.Diagnostics.CodeAnalysis;

using Trs80.Level1Basic.CommandModels;
using Trs80.Level1Basic.Common;
using Trs80.Level1Basic.VirtualMachine.Machine;

namespace Trs80.Level1Basic.Command.Commands;

[SuppressMessage("ReSharper", "UnusedMember.Global")]
public class InputCommand : ICommand<InputModel>
{
private readonly ITrs80 _trs80;
Expand All @@ -28,6 +31,7 @@ private SourceLine GetInputLine()
char[] line = new char[1024];
int charCount = 0;
bool inQuote = false;
bool inCommand = true;

while (true)
{
Expand All @@ -36,14 +40,12 @@ private SourceLine GetInputLine()
if (key.Key == ConsoleKey.Enter)
{
_trs80.WriteLine();
inQuote = false;
break;
}

if (key.KeyChar == '"')
{
if (key.KeyChar == '"' && inCommand)
inQuote = !inQuote;
}

if (key.Key == ConsoleKey.Backspace)
{
if (charCount > 0)
Expand All @@ -58,10 +60,13 @@ private SourceLine GetInputLine()
}
else
{
if (inCommand && char.IsDigit(key.KeyChar) && (charCount <= 0 || original.All(char.IsWhiteSpace)))
inCommand = false;

original[charCount] = key.KeyChar;
char upper = Upper(key.KeyChar);
line[charCount++] = upper;
if (!inQuote)
if (!inQuote || !inCommand)
_trs80.Write($"\b{upper}");
}
}
Expand All @@ -70,7 +75,7 @@ private SourceLine GetInputLine()
? new SourceLine()
: new SourceLine
{
Line = new string(line, 0, charCount),
Line = new string(line, 0, charCount),
Original = new string(original, 0, charCount)
};
}
Expand Down
6 changes: 2 additions & 4 deletions Trs80.Level1Basic.Command/Commands/InterpretCommand.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
using Trs80.Level1Basic.CommandModels;
using Trs80.Level1Basic.VirtualMachine.Interpreter;
using Trs80.Level1Basic.VirtualMachine.Machine;
using Trs80.Level1Basic.VirtualMachine.Parser.Statements;

namespace Trs80.Level1Basic.Command.Commands;

// ReSharper disable once UnusedMember.Global
public class InterpretCommand : ICommand<InterpretModel>
{
private readonly IInterpreter _interpreter;
private readonly ITrs80 _trs80;

public InterpretCommand(IInterpreter interpreter, ITrs80 trs80)
public InterpretCommand(IInterpreter interpreter)
{
_interpreter = interpreter ?? throw new ArgumentNullException(nameof(interpreter));
_trs80 = trs80 ?? throw new ArgumentNullException(nameof(trs80));
}

public void Execute(InterpretModel parameterObject)
Expand Down
5 changes: 4 additions & 1 deletion Trs80.Level1Basic.Command/Commands/ParseCommand.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
using Trs80.Level1Basic.CommandModels;
using System.Diagnostics.CodeAnalysis;

using Trs80.Level1Basic.CommandModels;
using Trs80.Level1Basic.VirtualMachine.Parser;
using Trs80.Level1Basic.VirtualMachine.Parser.Statements;
using Trs80.Level1Basic.VirtualMachine.Scanner;

namespace Trs80.Level1Basic.Command.Commands;

[SuppressMessage("ReSharper", "UnusedMember.Global")]
public class ParseCommand : ICommand<ParseModel>
{
private readonly IParser _parser;
Expand Down
5 changes: 4 additions & 1 deletion Trs80.Level1Basic.Command/Commands/SetupTrs80Command.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
using Trs80.Level1Basic.CommandModels;
using System.Diagnostics.CodeAnalysis;

using Trs80.Level1Basic.CommandModels;
using Trs80.Level1Basic.VirtualMachine.Machine;

namespace Trs80.Level1Basic.Command.Commands;

[SuppressMessage("ReSharper", "UnusedMember.Global")]
public class SetupTrs80Command : ICommand<SetupTrs80Model>
{
private readonly ITrs80 _trs80;
Expand Down
5 changes: 4 additions & 1 deletion Trs80.Level1Basic.Command/Commands/ShutdownTrs80Command.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
using Trs80.Level1Basic.CommandModels;
using System.Diagnostics.CodeAnalysis;

using Trs80.Level1Basic.CommandModels;
using Trs80.Level1Basic.VirtualMachine.Machine;

namespace Trs80.Level1Basic.Command.Commands;

[SuppressMessage("ReSharper", "UnusedMember.Global")]
public class ShutdownTrs80Command : ICommand<ShutdownTrs80Model>
{
private readonly ITrs80 _trs80;
Expand Down
2 changes: 2 additions & 0 deletions Trs80.Level1Basic.CommandModels/WorkflowDataModel.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
using System.Diagnostics.CodeAnalysis;

using Trs80.Level1Basic.Common;
using Trs80.Level1Basic.VirtualMachine.Parser.Statements;
using Trs80.Level1Basic.VirtualMachine.Scanner;

namespace Trs80.Level1Basic.CommandModels;

[SuppressMessage("ReSharper", "EmptyConstructor")]
[SuppressMessage("ReSharper", "UnusedMember.Global")]
public sealed class WorkflowDataModel
{
public bool WritePrompt { get; set; } = false;
Expand Down
Loading

0 comments on commit 7819ed3

Please sign in to comment.