From e3ada827bb5ed17c1c08fd94578be0664b60a51c Mon Sep 17 00:00:00 2001 From: echo Date: Fri, 26 Jul 2024 14:06:13 +0330 Subject: [PATCH] fix shittyeditor so that it actually checks for multiple args - added getScreenSize helper --- src/main/java/dev/exhq/ajarc/vm/JsVm.java | 9 --------- .../java/dev/exhq/ajarc/vm/ScreenHelper.java | 19 +++++++++++++++++++ .../assets/ajarc/bin/shittyeditor.js | 8 +++++++- 3 files changed, 26 insertions(+), 10 deletions(-) create mode 100644 src/main/java/dev/exhq/ajarc/vm/ScreenHelper.java diff --git a/src/main/java/dev/exhq/ajarc/vm/JsVm.java b/src/main/java/dev/exhq/ajarc/vm/JsVm.java index ca4b264..500bdff 100644 --- a/src/main/java/dev/exhq/ajarc/vm/JsVm.java +++ b/src/main/java/dev/exhq/ajarc/vm/JsVm.java @@ -129,15 +129,6 @@ public class JsVm { } - public record ScreenHelper(ComputerBlockEntity entity) { - public void setScreenSize(int rows, int cols) { - entity.setTerminal(ComputerTerminal.ofSize(rows, cols)); - } - - public void print(String line) { - entity.addLine(line); - } - } public class Js { private final ComputerBlockEntity entity; diff --git a/src/main/java/dev/exhq/ajarc/vm/ScreenHelper.java b/src/main/java/dev/exhq/ajarc/vm/ScreenHelper.java new file mode 100644 index 0000000..b67aca4 --- /dev/null +++ b/src/main/java/dev/exhq/ajarc/vm/ScreenHelper.java @@ -0,0 +1,19 @@ +package dev.exhq.ajarc.vm; + +import dev.exhq.ajarc.computer.ComputerBlockEntity; +import dev.exhq.ajarc.computer.ComputerTerminal; + +public record ScreenHelper(ComputerBlockEntity entity) { + + public ComputerTerminal.Dimensions getScreenSize(){ + return entity.getTerminal().dimensions(); + } + + public void setScreenSize(int rows, int cols) { + entity.setTerminal(ComputerTerminal.ofSize(rows, cols)); + } + + public void print(String line) { + entity.addLine(line); + } +} \ No newline at end of file diff --git a/src/main/resources/assets/ajarc/bin/shittyeditor.js b/src/main/resources/assets/ajarc/bin/shittyeditor.js index 889f011..646e853 100644 --- a/src/main/resources/assets/ajarc/bin/shittyeditor.js +++ b/src/main/resources/assets/ajarc/bin/shittyeditor.js @@ -1,4 +1,10 @@ var args = process.args var file = args[0] -var content = args[1] +//var content = args[1] +var content = "" +for(var i = 0; i < args.length; i++){ + if (i !== 0) { + content = content + args[i] + " " + } +} fs.writeFile(file, content) \ No newline at end of file