From f211a585f405f91cf29872a2c931051b669b77dc Mon Sep 17 00:00:00 2001 From: Jesse McGrew Date: Sat, 16 Jan 2021 23:03:53 -0800 Subject: [PATCH] * remove monaco, disable trimming --- src/Zilf.Playground/Pages/OldIndex.razor | 175 ------------------ .../Shared/CompilerOutput.razor | 123 ------------ src/Zilf.Playground/Zilf.Playground.csproj | 6 +- src/Zilf.Playground/_Imports.razor | 4 +- src/Zilf.Playground/wwwroot/css/app.css | 4 +- src/Zilf.Playground/wwwroot/index.html | 6 +- 6 files changed, 12 insertions(+), 306 deletions(-) delete mode 100644 src/Zilf.Playground/Pages/OldIndex.razor delete mode 100644 src/Zilf.Playground/Shared/CompilerOutput.razor diff --git a/src/Zilf.Playground/Pages/OldIndex.razor b/src/Zilf.Playground/Pages/OldIndex.razor deleted file mode 100644 index 5beff71..0000000 --- a/src/Zilf.Playground/Pages/OldIndex.razor +++ /dev/null @@ -1,175 +0,0 @@ -@page "/oldindex" -@using Zapf -@using Zilf.Compiler -@using Zilf.Diagnostics -@inject TemplateService Templates - -

ZIL Playground

- -
-
- - -
- -
- - -
- - @**@ - -
- -
-
- - - - - -@code { - private MonacoEditor _editor { get; set; } - private string ValueToSet { get; set; } - private FrontEndResult CompileResult { get; set; } - private AssemblyResult? AssembleResult { get; set; } - private InMemoryFileSystem FileSystem { get; } = new InMemoryFileSystem(); - private IEnumerable AvailableTemplates { get; set; } = Enumerable.Empty(); - - protected override async Task OnInitializedAsync() - { - AvailableTemplates = await Templates.GetTemplateNamesAsync(); - } - - private StandaloneEditorConstructionOptions EditorConstructionOptions(MonacoEditor editor) - { - return new StandaloneEditorConstructionOptions - { - Language = "zil", - GlyphMargin = true, - Value = "\n" + - "\n" + - "\n" + - " >", - }; - } - - private async Task EditorOnDidInit(MonacoEditorBase editor) - { - await _editor.AddCommand((int)KeyMode.CtrlCmd | (int)KeyCode.KEY_H, (editor, keyCode) => - { - Console.WriteLine("Ctrl+H : Initial editor command is triggered."); - System.Diagnostics.Debugger.Break(); - }); - - //var newDecorations = new ModelDeltaDecoration[] - //{ - // new ModelDeltaDecoration - // { - // Range = new BlazorMonaco.Bridge.Range(3,1,3,1), - // Options = new ModelDecorationOptions - // { - // IsWholeLine = true, - // ClassName = "decorationContentClass", - // GlyphMarginClassName = "decorationGlyphMarginClass" - // } - // } - //}; - - //decorationIds = await _editor.DeltaDecorations(null, newDecorations); - // You can now use 'decorationIds' to change or remove the decorations - } - - //private string[] decorationIds; - - private void EditorOnContextMenu(EditorMouseEvent eventArg) - { - Console.WriteLine("OnContextMenu : " + System.Text.Json.JsonSerializer.Serialize(eventArg)); - } - - private async Task ChangeTheme(ChangeEventArgs e) - { - Console.WriteLine($"setting theme to: {e.Value.ToString()}"); - await MonacoEditor.SetTheme(e.Value.ToString()); - } - - private async Task SetValue() - { - Console.WriteLine($"setting value to: {ValueToSet}"); - await _editor.SetValue(ValueToSet); - } - - private async Task GetValue() - { - var val = await _editor.GetValue(); - Console.WriteLine($"value is: {val}"); - } - - private async Task AddCommand() - { - await _editor.AddCommand((int)KeyMode.CtrlCmd | (int)KeyCode.Enter, (editor, keyCode) => - { - Console.WriteLine("Ctrl+Enter : Editor command is triggered."); - }); - } - - private async Task AddAction() - { - await _editor.AddAction("testAction", "Test Action", new int[] { (int)KeyMode.CtrlCmd | (int)KeyCode.KEY_D, (int)KeyMode.CtrlCmd | (int)KeyCode.KEY_B }, null, null, "navigation", 1.5, (editor, keyCodes) => - { - Console.WriteLine("Ctrl+D : Editor action is triggered."); - }); - } - - private async Task Compile() - { - FileSystem.SetText("main.zil", await _editor.GetValue()); - - var compiler = new FrontEnd { FileSystem = FileSystem, Logger = NullDiagnosticLogger.Instance }; - var compResult = compiler.Compile("main.zil", "main.zap", false); - - CompileResult = compResult; - AssembleResult = null; - - if (compResult.Success) - { - var assembler = new Zapf.ZapfAssembler { FileSystem = FileSystem }; - AssembleResult = assembler.Assemble("main.zap", "main.z#"); - } - } - - private Task ChangeProject(ChangeEventArgs e) - { - return Task.CompletedTask; - - //if (e.Value is string name) - //{ - // var (template, fileContents) = await Templates.LoadTemplateAsync(name); - - // FileSystem.Clear(); - // foreach (var (path, content) in fileContents) - // FileSystem.SetText(path, content); - - // await _editor.SetValue(fileContents[0].content); - //} - } -} diff --git a/src/Zilf.Playground/Shared/CompilerOutput.razor b/src/Zilf.Playground/Shared/CompilerOutput.razor deleted file mode 100644 index dca1096..0000000 --- a/src/Zilf.Playground/Shared/CompilerOutput.razor +++ /dev/null @@ -1,123 +0,0 @@ -@inject JSInterop Interop -@using System.Text.RegularExpressions -@using Zapf -@using Zilf.Common -@using Zilf.Compiler - -

Compilation Results

- -@if (CompileResult == null) -{ -

No compilation requested.

-} -else -{ - @if (AssembleResult != null) - { -

Story File

- - if (!AssembleResult.Value.Success) - { -

Assembly failed. See below.

- } - else - { - - } - } - -

Details

- - - - - - - - - - - - - - -
Success?@CompileResult.Success
Errors@CompileResult.ErrorCount
Warnings@CompileResult.WarningCount (@CompileResult.SuppressedWarningCount suppressed)
- - @if (CompileResult.Diagnostics.Count > 0) - { -

Diagnostics

- - - - - - - - - - @foreach (var diag in CompileResult.Diagnostics) - { - - - - - - - } -
SeverityCodeDescriptionLocation
@diag.Severity@diag.Code@diag.GetFormattedMessage()@diag.Location.SourceInfo
- } - - @if (CompileResult.Success) - { -

Assembly Code

- - - @foreach (var (path, text) in GetZapOutput()) - { - - - - - } -
@path
@text
- } -} - -@code { - [Parameter] - public FrontEndResult CompileResult { get; set; } - - [Parameter] - public AssemblyResult? AssembleResult { get; set; } - - [Parameter] - public InMemoryFileSystem FileSystem { get; set; } - - private static Regex StoryFileRegExp = new Regex(@"\.z\d$", RegexOptions.IgnoreCase); - - private string StoryFileName => FileSystem?.Paths.FirstOrDefault(StoryFileRegExp.IsMatch); - - private IEnumerable<(string path, string text)> GetZapOutput() - { - if (CompileResult == null) - return Enumerable.Empty<(string, string)>(); - - return from path in FileSystem.Paths - where path.EndsWith(".zap") - select (path, FileSystem.GetText(path)); - } - - private void DownloadStoryFile() - { - var path = StoryFileName; - - if (path != null) - { - var file = FileSystem.GetBytes(path); - string filename = System.IO.Path.GetFileName(path); - string contentType = "application/x-zmachine"; - - Interop.DownloadBytesAsFile(file, filename, contentType); - } - } -} diff --git a/src/Zilf.Playground/Zilf.Playground.csproj b/src/Zilf.Playground/Zilf.Playground.csproj index 0b5505d..45938bf 100644 --- a/src/Zilf.Playground/Zilf.Playground.csproj +++ b/src/Zilf.Playground/Zilf.Playground.csproj @@ -2,10 +2,10 @@ net5.0 + false - @@ -18,6 +18,10 @@ + + diff --git a/src/Zilf.Playground/_Imports.razor b/src/Zilf.Playground/_Imports.razor index 656f5ae..ace40ee 100644 --- a/src/Zilf.Playground/_Imports.razor +++ b/src/Zilf.Playground/_Imports.razor @@ -13,5 +13,5 @@ @using Zilf.Playground.Services.Workspaces @using Zilf.Playground.Services.Repl @using Zilf.Playground.Services.Templates -@using BlazorMonaco -@using BlazorMonaco.Bridge \ No newline at end of file +@*@using BlazorMonaco +@using BlazorMonaco.Bridge*@ \ No newline at end of file diff --git a/src/Zilf.Playground/wwwroot/css/app.css b/src/Zilf.Playground/wwwroot/css/app.css index 1d28d16..07825f2 100644 --- a/src/Zilf.Playground/wwwroot/css/app.css +++ b/src/Zilf.Playground/wwwroot/css/app.css @@ -95,10 +95,10 @@ a, .btn-link { } }*/ -.monaco-editor-container { +/*.monaco-editor-container { height: 200px; border: 1px solid gray; -} +}*/ .decorationGlyphMarginClass { background: red; diff --git a/src/Zilf.Playground/wwwroot/index.html b/src/Zilf.Playground/wwwroot/index.html index 1c12d5f..a469668 100644 --- a/src/Zilf.Playground/wwwroot/index.html +++ b/src/Zilf.Playground/wwwroot/index.html @@ -12,7 +12,7 @@ - + @@ -35,10 +35,10 @@ - + -- GitLab