package xsbt.boot
import Pre._
object JAnsi {
def uninstall(loader: ClassLoader): Unit = callJAnsi("systemUninstall", loader)
def install(loader: ClassLoader): Unit = callJAnsi("systemInstall", loader)
private[this] def callJAnsi(methodName: String, loader: ClassLoader): Unit = if (isWindows && !isCygwin) callJAnsiMethod(methodName, loader)
private[this] def callJAnsiMethod(methodName: String, loader: ClassLoader): Unit =
try {
val c = Class.forName("org.fusesource.jansi.AnsiConsole", true, loader)
c.getMethod(methodName).invoke(null)
} catch {
case ignore: ClassNotFoundException =>
case ex: Throwable => println("Jansi found on class path but initialization failed: " + ex)
}
}