diff --git a/symja_android_library/matheclipse-io/src/main/java/org/matheclipse/io/eval/Console.java b/symja_android_library/matheclipse-io/src/main/java/org/matheclipse/io/eval/Console.java index c0c5c0a8b8..0d2d7e4bb2 100644 --- a/symja_android_library/matheclipse-io/src/main/java/org/matheclipse/io/eval/Console.java +++ b/symja_android_library/matheclipse-io/src/main/java/org/matheclipse/io/eval/Console.java @@ -41,6 +41,12 @@ * See {@link MMAConsole} */ public class Console { + + private final static String RESET = "\u001B[0m"; + private final static String GREEN = "\033[0;32m"; + private final static String RED = "\033[0;31m"; + private final static String BLUE = "\033[0;34m"; + /** No timeout limit as the default value for Symja expression evaluation. */ private long fSeconds = -1; @@ -123,7 +129,7 @@ public static void main(final String args[]) { while (true) { try { - String inputExpression = console.readString(stdout, ">> "); + String inputExpression = console.readString(stdout, "\n" + BLUE + ">> " + RESET); if (inputExpression != null) { trimmedInput = inputExpression.trim(); if (inputExpression.length() > 1 @@ -200,7 +206,7 @@ public static void main(final String args[]) { stderr.println("Automatically closing brackets: " + postfix); trimmedInput = trimmedInput + postfix; } - stdout.println("In[" + COUNTER + "]:= " + trimmedInput); + stdout.println(GREEN + "In[" + COUNTER + "]:= " + RESET + trimmedInput); stdout.flush(); // if (console.fPrettyPrinter) { // console.prettyPrinter(inputExpression); @@ -222,7 +228,7 @@ public static void main(final String args[]) { private String resultPrinter(String inputExpression) { String outputExpression = interpreter(inputExpression); if (outputExpression.length() > 0) { - stdout.print("Out[" + COUNTER + "]= "); + stdout.print(RED + "Out[" + COUNTER + "]= " + RESET); stdout.flush(); stdout.println(Errors.shorten(outputExpression, 1000)); stdout.flush(); diff --git a/symja_android_library/matheclipse-io/src/main/java/org/matheclipse/io/eval/MMAConsole.java b/symja_android_library/matheclipse-io/src/main/java/org/matheclipse/io/eval/MMAConsole.java index 6c1d06a341..652146bb66 100644 --- a/symja_android_library/matheclipse-io/src/main/java/org/matheclipse/io/eval/MMAConsole.java +++ b/symja_android_library/matheclipse-io/src/main/java/org/matheclipse/io/eval/MMAConsole.java @@ -42,6 +42,12 @@ * See {@link Console} */ public class MMAConsole { + + private final static String RESET = "\u001B[0m"; + private final static String GREEN = "\033[0;32m"; + private final static String RED = "\033[0;31m"; + private final static String BLUE = "\033[0;34m"; + /** No timeout limit as the default value for Symja expression evaluation. */ private long fSeconds = -1; @@ -127,7 +133,7 @@ public static void main(final String args[]) { while (true) { try { - String inputExpression = console.readString(stdout, ">> "); + String inputExpression = console.readString(stdout, "\n" + BLUE + ">> " + RESET); if (inputExpression != null) { trimmedInput = inputExpression.trim(); if (inputExpression.length() > 1 @@ -186,7 +192,7 @@ public static void main(final String args[]) { stderr.println("Automatically closing brackets: " + postfix); trimmedInput = trimmedInput + postfix; } - stdout.println("In[" + COUNTER + "]:= " + trimmedInput); + stdout.println(GREEN + "In[" + COUNTER + "]:= " + RESET + trimmedInput); stdout.flush(); // if (outputExpression.length() > 0) { // stdout.println("Out[" + COUNTER + "]: " + outputExpression); @@ -208,10 +214,11 @@ public static void main(final String args[]) { } } + private String resultPrinter(String inputExpression) { String outputExpression = interpreter(inputExpression); if (outputExpression.length() > 0) { - stdout.print("Out[" + COUNTER + "]= "); + stdout.print(RED + "Out[" + COUNTER + "]= " + RESET); stdout.flush(); stdout.println(Errors.shorten(outputExpression, 1000)); stdout.flush();