Java Code Examples for org.fusesource.jansi.Ansi#fg()

The following examples show how to use org.fusesource.jansi.Ansi#fg() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StyleRenderer.java    From helidon-build-tools with Apache License 2.0 6 votes vote down vote up
private static void apply(Ansi ansi, Code code, boolean bright) {
    if (code.isColor()) {
        final Color color = code.getColor();
        if (code.isBackground()) {
            if (bright) {
                ansi.bgBright(color);
            } else {
                ansi.bg(color);
            }
        } else {
            if (bright) {
                ansi.fgBright(color);
            } else {
                ansi.fg(color);
            }
        }
    } else if (code.isAttribute()) {
        ansi.a(code.getAttribute());
    }
}
 
Example 2
Source File: LogOutputSpec.java    From jkube with Eclipse Public License 2.0 5 votes vote down vote up
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;
    }
}
 
Example 3
Source File: Application.java    From ig-webapi-java-sample with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void logMessage(int x, int y, String message, Ansi.Color fgColor, Ansi.Color bgColor, Ansi.Attribute... attributes) {
   message = message.substring(0, Math.min(message.length(), 120));
   Ansi ansi = ansi().cursor(y, x).eraseLine();
   if(attributes != null) {
      for (Ansi.Attribute attribute : attributes) {
         ansi = ansi.a(attribute);
      }
   }
   ansi = ansi.fg(fgColor != null ? fgColor : Ansi.Color.DEFAULT);
   ansi = ansi.bg(bgColor != null ? bgColor : Ansi.Color.DEFAULT);
   System.out.println(ansi.a(message).reset());
}
 
Example 4
Source File: LogOutputSpec.java    From docker-maven-plugin with Apache License 2.0 5 votes vote down vote up
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;
    }
}
 
Example 5
Source File: JAnsiTextRenderer.java    From logging-log4j2 with Apache License 2.0 5 votes vote down vote up
private void render(final Ansi ansi, final Code code) {
    if (code.isColor()) {
        if (code.isBackground()) {
            ansi.bg(code.getColor());
        } else {
            ansi.fg(code.getColor());
        }
    } else if (code.isAttribute()) {
        ansi.a(code.getAttribute());
    }
}
 
Example 6
Source File: DefaultColorMap.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void on(Ansi ansi) {
    ansi.fg(ansiColor);
}
 
Example 7
Source File: DefaultColorMap.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void off(Ansi ansi) {
    ansi.fg(DEFAULT);
}
 
Example 8
Source File: DefaultColorMap.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void on(Ansi ansi) {
    ansi.fg(ansiColor);
}
 
Example 9
Source File: DefaultColorMap.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void off(Ansi ansi) {
    ansi.fg(DEFAULT);
}
 
Example 10
Source File: FormatHelper.java    From Launcher with GNU General Public License v3.0 4 votes vote down vote up
public static Ansi rawAnsiFormat(LogHelper.Level level, String dateTime, boolean sub) {
    Ansi.Color levelColor;
    boolean bright = level != LogHelper.Level.DEBUG;
    switch (level) {
        case WARNING:
            levelColor = Ansi.Color.YELLOW;
            break;
        case ERROR:
            levelColor = Ansi.Color.RED;
            break;
        default: // INFO, DEBUG, Unknown
            levelColor = Ansi.Color.WHITE;
            break;
    }

    // Date-time
    Ansi ansi = new Ansi();
    ansi.fg(Ansi.Color.WHITE).a(dateTime);

    // Level
    ansi.fgBright(Ansi.Color.WHITE).a(" [").bold();
    if (bright) {
        ansi.fgBright(levelColor);
    } else {
        ansi.fg(levelColor);
    }
    ansi.a(level).boldOff().fgBright(Ansi.Color.WHITE).a("] ");

    // Message
    if (bright) {
        ansi.fgBright(levelColor);
    } else {
        ansi.fg(levelColor);
    }
    if (sub) {
        ansi.a(' ').a(Ansi.Attribute.ITALIC);
    }

    // Finish with reset code
    return ansi;
}
 
Example 11
Source File: DefaultColorMap.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void on(Ansi ansi) {
    ansi.fg(ansiColor);
}
 
Example 12
Source File: DefaultColorMap.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void off(Ansi ansi) {
    ansi.fg(DEFAULT);
}
 
Example 13
Source File: DefaultColorMap.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void on(Ansi ansi) {
    ansi.fg(ansiColor);
}
 
Example 14
Source File: DefaultColorMap.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void off(Ansi ansi) {
    ansi.fg(DEFAULT);
}