private String getEmphasisColor(String id) { Ansi.Color color = COLOR_MAP.get(id.toUpperCase()); if (color != null) { return id.toLowerCase().equals(id) ? // lower case letter means bright color ... ansi().fgBright(color).toString() : ansi().fg(color).toString(); } else { return ""; } } }
private Ansi outputCategory(Ansi ansi, String categoryName) { return ansi .a(Ansi.Attribute.INTENSITY_BOLD) .fgBright(BLUE) .a(categoryName) .a(SPACE) .a(Ansi.Attribute.INTENSITY_BOLD_OFF); }
private String formatTimestamp(Timestamp timestamp,boolean withColor) { if (timeFormatter == null) { return ""; } String date = timeFormatter.print(timestamp.getDate()); return (withColor ? ansi().fgBright(BLACK).a(date).reset().toString() : date) + " "; }
/** {@inheritDoc} */ public void verbose(String message, Object ... params) { if (verbose) { log.info(ansi().fgBright(BLACK).a(prefix).a(format(message, params)).reset().toString()); } }
private Ansi ansiPrompt(String prompt) { return ansi() .a(Ansi.Attribute.INTENSITY_BOLD) .fgBright(BLUE) .a(prompt) .a(Ansi.Attribute.INTENSITY_BOLD_OFF) .fg(DEFAULT); }
private String formatPrefix(String prefix,boolean withColor) { if (withColor) { Ansi ansi = ansi(); if (fgBright) { ansi.fgBright(color); } else { ansi.fg(color); } return ansi.a(prefix).reset().toString(); } else { return prefix; } }
public Ansi fgBrightMagenta() { return this.fgBright(Color.MAGENTA); }
public Ansi fgBrightRed() { return this.fgBright(Color.RED); }
public Ansi fgBrightYellow() { return this.fgBright(Color.YELLOW); }
public Ansi fgBrightDefault() { return this.fgBright(Color.DEFAULT); }
public Ansi bgBrightCyan() { return this.fgBright(Color.CYAN); }
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 formatTimestamp(Timestamp timestamp,boolean withColor) { if (timeFormatter == null) { return ""; } String date = timeFormatter.print(timestamp.getDate()); return (withColor ? ansi().fgBright(BLACK).a(date).reset().toString() : date) + " "; }
@Override public void verbose(String message) { if (verbose) { log.info(ansi().fgBright(BLACK).a(LOG_PREFIX).a(message).reset().toString()); } }
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; } }
private void askSafe(final String question, final Color color) { if (withColor) { try { write(console, false, Ansi.ansi().fgBright(color).bold().a(question + " ").boldOff().reset().toString()); return; } catch (NoSuchMethodError ignore) { warning("Incompatible jansi found on classpath. Reverting to no-color"); withColor = false; } } write(console, false, question + " "); }
/** * Generic method to render a message prompt. The message (displayed white) is prefixed by a * green question mark. * * @param message message to render as a colored prompt. * @return String with ANSI-Color printable prompt. */ protected String renderMessagePrompt(String message) { return (ansi().fg(Ansi.Color.GREEN).a("? ").fgBright(Ansi.Color.WHITE).a(message)).fg(Ansi.Color.DEFAULT).toString(); }
String withColor( Color color, boolean bright, Attribute attribute, String text ) { if( withColor ) { Ansi ansi = bright ? Ansi.ansi().fgBright( color ) : Ansi.ansi().fg( color ); if( attribute != null ) { ansi = ansi.a( attribute ); } return ansi.a( text ).reset().toString(); } return text; } }