本文整理汇总了Java中org.fusesource.jansi.Ansi类的典型用法代码示例。如果您正苦于以下问题:Java Ansi类的具体用法?Java Ansi怎么用?Java Ansi使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Ansi类属于org.fusesource.jansi包,在下文中一共展示了Ansi类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: positionCursorAt
import org.fusesource.jansi.Ansi; //导入依赖的package包/类
private void positionCursorAt(Cursor position, Ansi ansi) {
if (writeCursor.row == position.row) {
if (writeCursor.col == position.col) {
return;
}
if (writeCursor.col < position.col) {
ansi.cursorRight(position.col - writeCursor.col);
} else {
ansi.cursorLeft(writeCursor.col - position.col);
}
} else {
if (writeCursor.col > 0) {
ansi.cursorLeft(writeCursor.col);
}
if (writeCursor.row < position.row) {
ansi.cursorUp(position.row - writeCursor.row);
} else {
ansi.cursorDown(writeCursor.row - position.row);
}
if (position.col > 0) {
ansi.cursorRight(position.col);
}
}
writeCursor.copyFrom(position);
}
示例2: acceptInternal
import org.fusesource.jansi.Ansi; //导入依赖的package包/类
@Override
public void acceptInternal(LogEvent event) {
Ansi.Color color = serviceColors.computeIfAbsent(event.getService(), (service) -> {
if (service.length() > this.longestServiceName) {
longestServiceName = service.length();
}
int colorIndex = serviceColors.size() % UNICORN_RAINBOW_MAGIC.size();
return UNICORN_RAINBOW_MAGIC.get(colorIndex);
});
System.out.println(ansi().
fg(color)
.a(padServiceName(event.getService()))
.a(" | ")
.reset()
.a(event.getLogEntry()));
}
示例3: render
import org.fusesource.jansi.Ansi; //导入依赖的package包/类
public static Ansi render(final Map2D<TerminalPixel> image) {
Preconditions.checkNotNull(image);
// TODO: Use a diffing algorithm to minimize re-writes
final Ansi ansi = Ansi.ansi().reset();
for (int y = 0; y < image.height(); y++) {
for (int x = 0; x < image.width(); x++) {
final TerminalPixel pixel = image.get(x, y);
final boolean updateStyle = x == 0 ||
!image.get(x - 1, y).hasSameStyling(pixel);
if (updateStyle) {
ansi.bg(pixel.background.toAnsi())
.fg(pixel.foreground.toAnsi());
}
ansi.a((char) pixel.character.characterCode);
}
ansi.reset().newline();
}
ansi.reset();
return ansi;
}
示例4: translate
import org.fusesource.jansi.Ansi; //导入依赖的package包/类
public static String translate(Object... elements) {
Ansi ansi = Ansi.ansi();
for (Object element : elements) {
if (element instanceof Ansi.Color) {
ansi.fg((Ansi.Color) element);
continue;
}
else if (element == RESET) {
ansi.reset();
continue;
}
ansi.a(element);
ansi.a(" ");
}
return ansi.toString();
}
示例5: getAnsiForState
import org.fusesource.jansi.Ansi; //导入依赖的package包/类
private Ansi getAnsiForState(RunStateDataPayload.RunStateData RunStateData) {
final String state = RunStateData.state();
switch (state) {
case "WAITING": return coloredBright(BLACK, state);
case "NEW": return coloredBright(BLACK, state);
case "QUEUED": return coloredBright(BLACK, state);
case "PREPARE": return colored(CYAN, state);
case "SUBMITTING": return colored(CYAN, state);
case "SUBMITTED": return colored(CYAN, state);
case "RUNNING": return coloredBright(BLUE, state);
case "TERMINATED": return coloredBright(BLACK, state);
case "FAILED": return colored(RED, state);
case "UNKNOWN": return coloredBright(RED, state);
case "ERROR": return coloredBright(RED, state);
case "DONE": return coloredBright(GREEN, state);
default: return colored(DEFAULT, state);
}
}
示例6: printInstanceDetails
import org.fusesource.jansi.Ansi; //导入依赖的package包/类
private void printInstanceDetails(AnsiPrintToolkit toolkit,
InstanceDescription instance) {
Ansi buffer = toolkit.getBuffer();
int state = instance.getState();
//toolkit.eol();
toolkit.bold(instance.getName());
// Print status in the first column
buffer.a(" [");
buffer.fg(getStateColor(state));
buffer.a(getStateName(state));
buffer.fg(Ansi.Color.DEFAULT);
buffer.a("]");
toolkit.eol();
toolkit.printElement(0, instance.getDescription());
}
示例7: createColor
import org.fusesource.jansi.Ansi; //导入依赖的package包/类
private Color createColor(String style) {
String colorSpec = System.getProperty(String.format("org.gradle.color.%s", style), defaults.get(style));
if (colorSpec != null) {
if (colorSpec.equalsIgnoreCase(BOLD)) {
return new AttributeColor(INTENSITY_BOLD, INTENSITY_BOLD_OFF);
}
if (colorSpec.equalsIgnoreCase("reverse")) {
return new AttributeColor(NEGATIVE_ON, NEGATIVE_OFF);
}
if (colorSpec.equalsIgnoreCase("italic")) {
return new AttributeColor(ITALIC, ITALIC_OFF);
}
Ansi.Color ansiColor = Ansi.Color.valueOf(colorSpec.toUpperCase());
if (ansiColor != DEFAULT) {
return new ForegroundColor(ansiColor);
}
}
return noDecoration;
}
示例8: draw
import org.fusesource.jansi.Ansi; //导入依赖的package包/类
public void draw(Ansi ansi) {
String prefix = StringUtils.getCommonPrefix(new String[]{text, displayedText});
if (prefix.length() < displayedText.length()) {
ansi.cursorLeft(displayedText.length() - prefix.length());
}
if (prefix.length() < text.length()) {
ColorMap.Color color = colorMap.getStatusBarColor();
color.on(ansi);
ansi.a(text.substring(prefix.length()));
color.off(ansi);
}
if (displayedText.length() > text.length()) {
ansi.eraseLine(Ansi.Erase.FORWARD);
}
displayedText = text;
}
示例9: renderSteps
import org.fusesource.jansi.Ansi; //导入依赖的package包/类
private void renderSteps(Ansi ansi, List<JobRunResultSteps> steps, Color originColor){
for (int i = 0; i < steps.size(); i++){
JobRunResultSteps step = steps.get(i);
if (step.isSuccessed())
ansi.fg(GREEN);
else
ansi.fg(RED);
try{
ansi.bold().a("| -- ").boldOff().a(step.getStepName()).a("\n");
for (String msg : step.getAdditionalMsgs()){
ansi.bold().a("| -- ").a(msg).boldOff().a("\n");
}
}finally{
ansi.fg(originColor);
}
}
}
示例10: initializeGame
import org.fusesource.jansi.Ansi; //导入依赖的package包/类
private static void initializeGame() {
AnsiConsole.systemInstall();
try {
GlobalScreen.registerNativeHook();
} catch (NativeHookException ex) {
System.err.println("There was a problem registering the native hook.");
System.err.println(ex.getMessage());
System.exit(1);
}
// registers a shutdown hook
// this shutdown hook is called before the jvm is shutdown and releases the dependencies
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
GlobalScreen.unregisterNativeHook();
System.out.println("unregister native hook");
AnsiConsole.out.print(Ansi.ansi().eraseScreen(Erase.FORWARD));
AnsiConsole.systemUninstall();
System.out.println("uninstall ansi console");
// network can be closed here
}
});
}
示例11: format
import org.fusesource.jansi.Ansi; //导入依赖的package包/类
@Override
public synchronized String format(final LogRecord record) {
final boolean exception = record.getThrown() != null;
final Ansi sbuf = prefix(record);
sbuf.a(record.getLevel().getLocalizedName());
sbuf.a(" - ");
sbuf.a(formatMessage(record));
if (!exception) {
suffix(sbuf, record);
}
sbuf.newline();
if (exception) {
try {
final StringWriter sw = new StringWriter();
final PrintWriter pw = new PrintWriter(sw);
record.getThrown().printStackTrace(pw);
pw.close();
sbuf.a(sw.toString());
} catch (final Exception ex) {
// no-op
} finally {
suffix(sbuf, record);
}
}
return sbuf.toString();
}
示例12: redrawHeader
import org.fusesource.jansi.Ansi; //导入依赖的package包/类
public void redrawHeader() {
saveCursorPosition();
JlEditConsole.out.print(ansi().cursor(1, 1));
Ansi style = ansi();
if (getTheme().getHeaderBackground() != null) {
style.bg(getTheme().getHeaderBackground());
}
if (getTheme().getHeaderForeground() != null) {
style.fg(getTheme().getHeaderForeground());
}
String textCoords = "L:" + getLine() + " C:" + getColumn();
int displayFileLength = getTerminal().getWidth() - getTitle().length() - textCoords.length() - 1;
JlEditConsole.out.print(style.a(getTitle()).a(":").a(Strings.tryToTrimToSize(getDisplayAs(), displayFileLength)).a(isDirty() ? DIRTY_SIGN : "").eraseLine(Ansi.Erase.FORWARD));
JlEditConsole.out.print(ansi().cursor(1, getTerminal().getWidth() - textCoords.length()));
JlEditConsole.out.print(ansi().a(textCoords).reset());
JlEditConsole.out.print(ansi().cursor(getTerminal().getHeight(), 1));
restoreCursorPosition();
}
示例13: redrawFooter
import org.fusesource.jansi.Ansi; //导入依赖的package包/类
/**
* Refreshes the footer that displays the current line and column.
*/
public void redrawFooter() {
saveCursorPosition();
Ansi style = ansi();
if (getTheme().getFooterBackground() != null) {
style.bg(getTheme().getFooterBackground());
}
if (getTheme().getFooterForeground() != null) {
style.fg(getTheme().getFooterForeground());
}
JlEditConsole.out.print(style);
JlEditConsole.out.print(ansi().cursor(getTerminal().getHeight() + 1 - getFooterSize(), 1).eraseLine(Ansi.Erase.FORWARD));
for (int i = 1; i <= helpLines.size(); i++) {
String helpLine = helpLines.get(i - 1);
int startColumn = (getTerminal().getWidth() - helpLine.length()) / 2;
JlEditConsole.out.print(ansi().cursor(getTerminal().getHeight() + 1 - getFooterSize() + i, 1).eraseLine(Ansi.Erase.FORWARD));
JlEditConsole.out.print(ansi().cursor(getTerminal().getHeight() + 1 - getFooterSize() + i, startColumn));
JlEditConsole.out.print(helpLine);
}
JlEditConsole.out.print(ansi().reset());
restoreCursorPosition();
}
示例14: createColor
import org.fusesource.jansi.Ansi; //导入依赖的package包/类
private Color createColor(String style) {
String colorSpec = System.getProperty("org.gradle.color." + style, defaults.get(style));
if (colorSpec != null) {
if (colorSpec.equalsIgnoreCase(BOLD)) {
return new AttributeColor(Attribute.INTENSITY_BOLD, Attribute.INTENSITY_BOLD_OFF);
}
if (colorSpec.equalsIgnoreCase("reverse")) {
return new AttributeColor(Attribute.NEGATIVE_ON, Attribute.NEGATIVE_OFF);
}
if (colorSpec.equalsIgnoreCase("italic")) {
return new AttributeColor(Attribute.ITALIC, Attribute.ITALIC_OFF);
}
Ansi.Color ansiColor = Ansi.Color.valueOf(colorSpec.toUpperCase());
if (ansiColor != DEFAULT) {
return new ForegroundColor(ansiColor);
}
}
return noDecoration;
}
示例15: createAnsi
import org.fusesource.jansi.Ansi; //导入依赖的package包/类
Ansi createAnsi() {
if (forceAnsi) {
return new Ansi();
} else {
return Ansi.ansi();
}
}