package dyvil.io;

import java.io.*;
import java.util.function.BooleanSupplier;

public final class Console
{
	private static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
	private static PrintStream    out    = System.out;
	
	private Console()
	{

	}
	
	public static void setOut(PrintStream out)
	{
		Console.out = out;
	}
	
	public static void setIn(InputStream in)
	{
		Console.reader = new BufferedReader(new InputStreamReader(in));
	}
	
	// Write
	
	public static void writeLine()
	{
		out.println();
	}
	
	public static void writeLine(Object o)
	{
		out.println(o);
	}
	
	public static void writeLine(String s)
	{
		out.println(s);
	}
	
	// Read
	
	public static String readLine()
	{
		try
		{
			return reader.readLine();
		}
		catch (IOException ex)
		{
			return null;
		}
	}
	
	public static String read(int count)
	{
		char[] chars = new char[count];
		try
		{
			reader.read(chars);
		}
		catch (IOException ex)
		{
			return null;
		}
		return new String(chars);
	}
	
	public static String read(BooleanSupplier predicate)
	{
		try
		{
			StringBuilder buf = new StringBuilder();
			while (predicate.getAsBoolean())
			{
				buf.appendCodePoint(reader.read());
			}
			return buf.toString();
		}
		catch (IOException ex)
		{
			return null;
		}
	}
	
	public static byte readByte()
	{
		return (byte) java.lang.Integer.parseInt(readLine());
	}
	
	public static short readShort()
	{
		return (short) java.lang.Integer.parseInt(readLine());
	}
	
	public static char readChar()
	{
		try
		{
			return (char) reader.read();
		}
		catch (IOException ex)
		{
			return 0;
		}
	}
	
	public static int readCodePoint()
	{
		try
		{
			return reader.read();
		}
		catch (IOException ex)
		{
			return 0;
		}
	}
	
	public static int readInt()
	{
		return java.lang.Integer.parseInt(readLine());
	}
	
	public static long readLong()
	{
		return java.lang.Long.parseLong(readLine());
	}
	
	public static float readFloat()
	{
		return java.lang.Float.parseFloat(readLine());
	}
	
	public static double readDouble()
	{
		return java.lang.Double.parseDouble(readLine());
	}
}

@@ -103,16 +103,571 @@
 nsole%0A%7B%0A
+%09public static final char ANSI_ESCAPE = '%5Cu001B';%0A%0A%09public static final String ANSI_RESET  = %22%5Cu001B%5B0m%22;%0A%09public static final String ANSI_BLACK  = %22%5Cu001B%5B30m%22;%0A%09public static final String ANSI_RED    = %22%5Cu001B%5B31m%22;%0A%09public static final String ANSI_GREEN  = %22%5Cu001B%5B32m%22;%0A%09public static final String ANSI_YELLOW = %22%5Cu001B%5B33m%22;%0A%09public static final String ANSI_BLUE   = %22%5Cu001B%5B34m%22;%0A%09public static final String ANSI_PURPLE = %22%5Cu001B%5B35m%22;%0A%09public static final String ANSI_CYAN   = %22%5Cu001B%5B36m%22;%0A%09public static final String ANSI_WHITE  = %22%5Cu001B%5B37m%22;%0A%0A
 %09private
@@ -831,16 +831,100 @@
 )%0A%09%7B%0A%0A%09%7D
+%0A%0A%09public static boolean isTerminalOutput()%0A%09%7B%0A%09%09return System.console() != null;%0A%09%7D
 %0A%09%0A%09publ

Add ANSI Color Codes to dyvil.io.Console