Run configuration for Cucumber with steps written in JRuby & Java : ANSI coloring support

This commit is contained in:
Roman Chernyatchik
2011-10-17 13:28:12 +04:00
parent 8dc5d4c64b
commit 6bcaa08875
5 changed files with 21 additions and 2 deletions
@@ -39,7 +39,11 @@ public abstract class JavaCommandLineState extends CommandLineState implements J
@NotNull
protected OSProcessHandler startProcess() throws ExecutionException {
return JavaCommandLineStateUtil.startProcess(createCommandLine());
return JavaCommandLineStateUtil.startProcess(createCommandLine(), ansiColoringEnabled());
}
protected boolean ansiColoringEnabled() {
return false;
}
protected abstract JavaParameters createJavaParameters() throws ExecutionException;
@@ -15,6 +15,7 @@
*/
package com.intellij.execution.configurations;
import com.intellij.execution.process.ColoredProcessHandler;
import com.intellij.execution.process.DefaultJavaProcessHandler;
import com.intellij.execution.process.OSProcessHandler;
import com.intellij.execution.process.ProcessTerminatedListener;
@@ -30,7 +31,15 @@ public class JavaCommandLineStateUtil {
@NotNull
public static OSProcessHandler startProcess(@NotNull final GeneralCommandLine commandLine) throws ExecutionException {
final DefaultJavaProcessHandler processHandler = new DefaultJavaProcessHandler(commandLine);
return startProcess(commandLine, false);
}
@NotNull
public static OSProcessHandler startProcess(@NotNull final GeneralCommandLine commandLine,
final boolean ansiColoring) throws ExecutionException {
final OSProcessHandler processHandler = ansiColoring ? new ColoredProcessHandler(commandLine)
: new DefaultJavaProcessHandler(commandLine);
ProcessTerminatedListener.attach(processHandler);
return processHandler;
}
@@ -16,6 +16,8 @@
package com.intellij.execution.process;
import com.intellij.execution.ExecutionException;
import com.intellij.execution.configurations.GeneralCommandLine;
import com.intellij.openapi.editor.colors.EditorColorsManager;
import com.intellij.openapi.editor.colors.TextAttributesKey;
import com.intellij.openapi.editor.markup.TextAttributes;
@@ -45,6 +47,10 @@ public class ColoredProcessHandler extends OSProcessHandler {
// TODO use new Maia API in ConsoleViewContentType to apply ANSI color changes without
// restarting RM / Idea + Ruby Plugin
public ColoredProcessHandler(final GeneralCommandLine commandLine) throws ExecutionException {
this(commandLine.createProcess(), commandLine.getCommandLineString(), commandLine.getCharset());
}
public ColoredProcessHandler(Process process, String commandLine) {
this(process, commandLine, null);
}