diff --git a/ConsoleMain.java b/ConsoleMain.java
new file mode 100644
index 0000000..9a6c06e
--- /dev/null
+++ b/ConsoleMain.java
@@ -0,0 +1,99 @@
+package com.devkev.devscript.raw;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.URLDecoder;
+
+import com.devkev.gui.Window;
+
+/**@author Philipp Gersch
+ * @version 1.8.2 (stable)
+ * Valid arguments are:
-e or --execute [some code] - Executes the String
+ * -f or --file [path] - Reads the file and executes the code from it.
+ * If no argument was passed, the default Editor GUI will open.*/
+public class ConsoleMain {
+
+ /*Argument schema: -f -e --nogui >
+ * When nogui is not given, the gui program will start with the given script from the command line
+ * */
+
+ public static void main(String[] args) throws IOException {
+ boolean initGUI = true;
+ String scriptToExecute = null;
+ String filePath = null;
+ //ALL arguments need to be checked
+
+ for(int i = 0; i < args.length; i++) {
+ if((args[i].equals("-e") || args[i].equals("--execute")) && scriptToExecute == null) {
+ if(i + 1 < args.length) {
+ if(!isArgument(args[i+1])) {
+ scriptToExecute = args[i+1];
+ i++; //Skip the next iteration
+ continue;
+ }
+ }
+ throw new IllegalArgumentException("Expecting string after " + args[i] + " [script_to_execute]");
+ } else if((args[i].equals("-f") || args[i].equals("--file")) && filePath == null) {
+ if(i + 1 < args.length) {
+ if(!isArgument(args[i+1])) {
+ filePath = args[i+1];
+ i++;
+ continue;
+ }
+ }
+ throw new IllegalArgumentException("Expecting string after " + args[i] + " [path_to_file]");
+ } else if(args[i].equals("--nogui")) {
+ initGUI = false;
+ continue;
+ }
+ throw new IllegalArgumentException("Unknown argument " + args[i] + "Valid arguments are:\n-f or --file\tOpens the file in the editor (If --nogui is set, the file is executed)\n-e or --execute\tOpens the script with the editor (If --nogui is set, the script is executed)\n--nogui\tOpens the command line editor");
+ }
+
+ System.out.println("InitGUI? " + initGUI + "\n" + "Script zo execute? " + scriptToExecute + "\nFilePath? " + filePath);
+ return;
+ //Apply rules
+
+// Process p = new Process(true);
+// p.addSystemOutput();
+// p.setInput(System.in);
+//
+// if(args.length == 0) {
+// if(ConsoleMain.class.getResourceAsStream("/Editor.txt") == null) {
+// System.err.println("Editor file is missing at: " + URLDecoder.decode(ConsoleMain.class.getProtectionDomain().getCodeSource().getLocation().getPath(), "UTF-8"));
+// return;
+// }
+// BufferedReader reader = new BufferedReader(new InputStreamReader(ConsoleMain.class.getResourceAsStream("/Editor.txt")));
+// String code = "";
+// String line = reader.readLine();
+// while(line != null) {
+// code += line;
+// line = reader.readLine();
+// }
+// reader.close();
+// p.execute(code, false);
+// return;
+// }
+//
+// if(args[0].equals("-e") || args[0].equals("--execute")) {
+// if(args.length < 2) {
+// System.err.println("Argument " + args[0] + " expects an executable script, e.g.: -e \"println \"Hello World;\"\"");
+// System.exit(-1);
+// }
+// p.execute(args[1], true);
+// } else if(args[0].equals("-f") || args[0].equals("--file")) {
+// if(args.length < 2) {
+// System.err.println("Argument " + args[0] + " expects a path to a text file containing the script");
+// System.exit(-1);
+// }
+// p.execute(new File(args[1]), true);
+// } else if(args[0].equals("--gui") || args[0].equals("-g")) {
+// new Window();
+// }
+ }
+
+ private static boolean isArgument(String arg) {
+ return arg.equals("-f") || arg.equals("--file") || arg.equals("-e") || arg.equals("--execute") || arg.equals("--nogui");
+ }
+}
diff --git a/changelog.txt b/changelog.txt
index 12e59e6..81b5423 100644
--- a/changelog.txt
+++ b/changelog.txt
@@ -5,6 +5,16 @@ NOTICE:
Another future plan: Command: "include " a command to include external compiled libraries "plug in style".
Added in 1.8.0 with the command: import "path_to_jar";
+1.9.0:
+ - This big Update gives you an Editor GUI! It runs, if you run the program without arguments. However, if you specify arguments inside the
+ command line this will happen: -e or --execute: Loads this script into the editor. -f or --file Loads the file into the editor.
+ To launch the jar file without a GUI, you need to put an --nogui argument.
+ Example: java -jar devscript_1.9.0.jar --file "path_to_file" --nogui -> Executes the file inside the command line
+ java -jar devscript_1.9.0.jar --execute "println foo;" -> Opens the editor window with "println foo;" as the content.
+ - Easier input setting. Before 1.9.0, it is very complicated to implement a custom InputStream. This update provides an abstract
+ com.devscript.raw.ApplicationInput class, to make it easier to create inputs other than the System.in: process.setInput(new ApplicationInput() {...});
+ -
+
1.8.3:
- New Command: use [STRING]; This command replaces the location of the command with code from the given string as the first argument.
This command is especially useful, if you want to include code from a separate file without creating a whole new library.
diff --git a/com/devkev/devscript/raw/ApplicationInput.java b/com/devkev/devscript/raw/ApplicationInput.java
new file mode 100644
index 0000000..0f35c94
--- /dev/null
+++ b/com/devkev/devscript/raw/ApplicationInput.java
@@ -0,0 +1,52 @@
+package com.devkev.devscript.raw;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+public abstract class ApplicationInput extends InputStream {
+
+ private volatile boolean inputReqested = false;
+
+ private String data = "";
+ private int index = 0;
+
+ @Override
+ public int read() throws IOException {
+ if(!inputReqested) {
+ inputReqested = true;
+ awaitInput();
+ synchronized (this) {
+ try {
+ wait();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ index++;
+ if(index < data.length() && !data.isEmpty()) {
+ return data.getBytes()[index-1];
+ } else {
+ inputReqested = false;
+ data = "";
+ index = 0;
+ return -1;
+ }
+ }
+
+ /**This function is called, before */
+ public abstract void awaitInput();
+
+ public synchronized boolean inputRequested() {
+ return inputReqested;
+ }
+
+ public void flush(String data) {
+ if(inputReqested) {
+ this.data = data == null ? "" : data;
+ synchronized (this) {
+ notify();
+ }
+ }
+ }
+}
diff --git a/com/devkev/devscript/raw/ApplicationListener.java b/com/devkev/devscript/raw/ApplicationListener.java
new file mode 100644
index 0000000..9d866b1
--- /dev/null
+++ b/com/devkev/devscript/raw/ApplicationListener.java
@@ -0,0 +1,6 @@
+package com.devkev.devscript.raw;
+
+public interface ApplicationListener {
+ /**Exit codes are:
{@link Block#DONE}
{@link Block#ERROR}*/
+ public void done(int exitCode);
+}
diff --git a/com/devkev/devscript/raw/Array.java b/com/devkev/devscript/raw/Array.java
index f3a96be..344aaf3 100644
--- a/com/devkev/devscript/raw/Array.java
+++ b/com/devkev/devscript/raw/Array.java
@@ -1,67 +1,67 @@
-package com.devkev.devscript.raw;
-
-import java.util.ArrayList;
-
-import com.devkev.devscript.raw.ApplicationBuilder.Type;
-
-public class Array { //For dataContainers
- private final ArrayList