/** * @return Whether ansi is enabled */ public boolean isAnsiEnabled() { return Ansi.isEnabled() && (terminal != null && terminal.isAnsiSupported()) && ansiEnabled; }
private String colorize(String string) { if (string == null || string.indexOf(ChatColor.COLOR_CHAR) < 0) { return string; // no colors in the message } else if (!jline || !reader.getTerminal().isAnsiSupported()) { return ChatColor.stripColor(string); // color not supported } else { // colorize or strip all colors for (ChatColor color : colors) { if (replacements.containsKey(color)) { string = string.replaceAll("(?i)" + color, replacements.get(color)); // NON-NLS } else { string = string.replaceAll("(?i)" + color, ""); // NON-NLS } } return string + Ansi.ansi().reset(); } }
public boolean isAnsiSupported() { return terminal.isAnsiSupported(); }
@Override public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws IOException { // custom clear screen, so I don't have to redraw the prompt twice if (!shellState.getReader().getTerminal().isAnsiSupported()) { throw new IOException("Terminal does not support ANSI commands"); } // send the ANSI code to clear the screen shellState.getReader().print(((char) 27) + "[2J"); shellState.getReader().flush(); // then send the ANSI code to go to position 1,1 shellState.getReader().print(((char) 27) + "[1;1H"); shellState.getReader().flush(); return 0; }
private String processString(String value) { if (terminal.isAnsiSupported()) { return value; } else { return stripAnsiCharacters(value); } }
private void clearScreen() throws IOException { if (terminal.isAnsiSupported()) { consoleReader.clearScreen(); } }
private void clearScreen() throws IOException { if (terminal.isAnsiSupported()) { consoleReader.clearScreen(); } }
private String processString(String value) { if (terminal.isAnsiSupported()) { return value; } else { return stripAnsiCharacters(value); } }
public Boolean call() throws Exception { return TerminalFactory.get().isAnsiSupported(); } });
@Override public boolean isSupportColor() { return reader.getTerminal().isAnsiSupported(); }
public CompiledREPLRunner(PathConfig pcfg, InputStream stdin, OutputStream stdout, IDEServices ideServices, Terminal term) throws IOException, URISyntaxException { super(makeCompiledRascalREPL(pcfg, ideServices, term, new DebugREPLFrameObserver(pcfg, stdin, stdout, true, term.isAnsiSupported(), getHistoryFile(), term, ideServices)), pcfg, stdin, stdout, true, term.isAnsiSupported(), getHistoryFile(), term, ideServices); }
private String switchToColor(Ansi.Color color) { if (terminal.isAnsiSupported()) { return Ansi.ansi().fgBright(color).toString(); } else { return ""; } }
private String switchToColor(Ansi.Color color) { if (terminal.isAnsiSupported()) { return Ansi.ansi().fgBright(color).toString(); } else { return ""; } }
private String resetColor() { if (terminal.isAnsiSupported()) { return Ansi.ansi().reset().toString(); } else { return ""; } }
private String resetColor() { if (terminal.isAnsiSupported()) { return Ansi.ansi().reset().toString(); } else { return ""; } }
private String coloredString(String actual, Ansi.Color color) { if (terminal.isAnsiSupported()) { return Ansi.ansi().fgBright(color).a(actual).reset().toString(); } else { return actual; } }
private String coloredString(String actual, Ansi.Color color) { if (terminal.isAnsiSupported()) { return Ansi.ansi().fgBright(color).a(actual).reset().toString(); } else { return actual; } }
public ShellApplication() throws Exception { commandInterpreter = new CommandInterpreter(); commandInterpreter.addCommandScanner(new AnnotatedCommandScanner()); commandInterpreter.addCommandListener(commandInterpreter.new HelpCommands()); commandInterpreter.addCommandListener(this); hasConsole = System.console() != null; isAnsiSupported = console.getTerminal().isAnsiSupported() && hasConsole; }
@Test public void clearCls() throws Exception { // clear/cls if (ts.shell.getReader().getTerminal().isAnsiSupported()) { ts.exec("cls", true, "[1;1H"); ts.exec("clear", true, "[2J"); } else { ts.exec("cls", false, "does not support"); ts.exec("clear", false, "does not support"); } }
public static String[] getRawAnsiSettings() throws IOException { ConsoleReader reader = new ConsoleReader(); return new String[] { "Width: " + reader.getTerminal().getWidth(), "Height: " + reader.getTerminal().getHeight(), "Ansi: " + reader.getTerminal().isAnsiSupported(), "Echo: " + reader.getTerminal().isEchoEnabled(), "Supported: " + reader.getTerminal().isSupported() }; }