本文整理了Java中org.fusesource.jansi.Ansi.render()
方法的一些代码示例,展示了Ansi.render()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ansi.render()
方法的具体详情如下:
包路径:org.fusesource.jansi.Ansi
类名称:Ansi
方法名:render
[英]Uses the AnsiRendererto generate the ANSI escape sequences for the supplied text.
[中]使用AnsiRenderer为提供的文本生成ANSI转义序列。
代码示例来源:origin: sleekbyte/tailor
private void printColoredMessage(String msg) {
if (colorSettings.colorOutput) {
AnsiConsole.out.println(Ansi.ansi().render(msg));
} else {
System.out.println(msg);
}
}
}
代码示例来源:origin: Dreampie/Resty
private static String diy(String color, String value) {
if (devEnable) {
return String.valueOf(Ansi.ansi().eraseScreen().render("@|" + color + " " + value + "|@"));
} else {
return value;
}
}
代码示例来源:origin: sleekbyte/tailor
/**
* Print all rules along with their descriptions to STDOUT.
*/
public static void printRules() {
Rules[] rules = Rules.values();
AnsiConsole.out.println(Ansi.ansi().render(String.format("@|bold %d rules available|@%n", rules.length)));
for (Rules rule : rules) {
AnsiConsole.out.println(Ansi.ansi().render(String.format("@|bold %s|@%n"
+ "@|underline Description:|@ %s%n"
+ "@|underline Style Guide:|@ %s%n", rule.getName(), rule.getDescription(), rule.getLink())));
}
}
代码示例来源:origin: sleekbyte/tailor
@Override
public void displayViolationMessages(List<ViolationMessage> violationMessages, File inputFile) throws IOException {
if (violationMessages.size() > 0) {
printColoredMessage(getHeader(inputFile, colorSettings));
}
if (colorSettings.colorOutput) {
for (ViolationMessage output : violationMessages) {
output.setColorSettings(colorSettings);
output.setLineNumberWidth(String.valueOf(getHighestLineNumber(violationMessages)).length());
output.setColumnNumberWidth(String.valueOf(getHighestColumnNumber(violationMessages)).length());
AnsiConsole.out.println(Ansi.ansi().render(output.toString()));
}
} else {
violationMessages.forEach(System.out::println);
}
}
代码示例来源:origin: com.github.born2snipe/cli-pi
public void println(String message) {
System.out.println(Ansi.ansi().render(message));
}
}
代码示例来源:origin: javanna/elasticshell
@Override
public void print(String message) {
logger.debug("print: {}", message);
out.print(Ansi.ansi().render(message));
}
代码示例来源:origin: javanna/elasticshell
@Override
public void println(String message) {
logger.debug("println: {}", message);
out.println(Ansi.ansi().render(message));
}
代码示例来源:origin: neo4j/cypher-shell
@Override
public void printError(@Nonnull String s) {
err.println(Ansi.ansi().render(s).toString());
}
代码示例来源:origin: neo4j/cypher-shell
@Override
public void printOut(@Nonnull final String msg) {
out.println(Ansi.ansi().render(msg).toString());
}
代码示例来源:origin: com.cybermkd/ICEREST
private static String diy(String color, String value) {
if (Constant.devMode){
return String.valueOf(Ansi.ansi().eraseScreen().render("@|" + color + " " + value + "|@"));
}else {
return value;
}
}
代码示例来源:origin: T-baby/ICERest
private static String diy(String color, String value) {
if (Constant.devMode){
return String.valueOf(Ansi.ansi().eraseScreen().render("@|" + color + " " + value + "|@"));
}else {
return value;
}
}
代码示例来源:origin: neo4j/cypher-shell
/**
* @return the text as a string rendered with ANSI escape codes
*/
@Nonnull
public String renderedString() {
return Ansi.ansi().render(formattedString()).toString();
}
代码示例来源:origin: com.github.born2snipe/cli-pi
@Override
public void run(ArgumentParser parser, Argument arg, Map<String, Object> attrs, String flag, Object value) throws ArgumentParserException {
String colorizedText = colorizer.colorize(parser.formatHelp());
System.out.println(Ansi.ansi().render(colorizedText));
throw new HelpScreenException(parser);
}
代码示例来源:origin: org.actframework/act
private void list(String search, String label, String fmt, List<String> commands, CliDispatcher dispatcher, CliContext context) {
List<String> lines = new ArrayList<>();
boolean noSearch = S.blank(search);
if (noSearch) {
lines.add(label.toUpperCase());
lines.add("");
}
for (String cmd : commands) {
CliHandler handler = dispatcher.handler(cmd);
T2<String, String> commandLine = handler.commandLine();
if (noSearch || commandLine._1.contains(search)) {
lines.add(S.fmt(fmt, cmd, commandLine._2));
}
}
context.println(Ansi.ansi().render(S.join("\n", lines)).toString());
}
代码示例来源:origin: actframework/actframework
private void list(String search, String label, String fmt, List<String> commands, CliDispatcher dispatcher, CliContext context) {
List<String> lines = new ArrayList<>();
boolean noSearch = S.blank(search);
if (noSearch) {
lines.add(label.toUpperCase());
lines.add("");
}
for (String cmd : commands) {
CliHandler handler = dispatcher.handler(cmd);
T2<String, String> commandLine = handler.commandLine();
if (noSearch || commandLine._1.contains(search)) {
lines.add(S.fmt(fmt, cmd, commandLine._2));
}
}
context.println(Ansi.ansi().render(S.join("\n", lines)).toString());
}
代码示例来源:origin: actframework/actframework
private static String poweredBy(int width, String actVersion, boolean center) {
String poweredBy = "powered by ActFramework ";
int pw;
if (supportAnsi()) {
String raw = S.concat("powered by @|bold ActFramework|@ ", actVersion);
poweredBy = Ansi.ansi().render(raw).toString();
pw = raw.length() - 9;
} else {
poweredBy = poweredBy + actVersion;
pw = poweredBy.length();
}
int gap = width - pw;
gap = Math.max(gap, 0);
if (gap == 0) {
return poweredBy;
}
if (center) {
gap = (gap + 1) / 2;
}
return S.concat(S.times(" ", gap), poweredBy);
}
代码示例来源:origin: apache/tajo
public void reprintProgressLine(PrintWriter out, String progressBar, int progress, String responseTime,
QueryStatus status) {
// [=====>> ] 10% 3.18 sec
String lineFormat = "[%s] %d%% %s";
if (isRealTerminal()) {
boolean isLastLine = false;
if (status.getState() == TajoProtos.QueryState.QUERY_SUCCEEDED) {
progressBar = "@|green " + progressBar + "|@";
isLastLine = true;
}
else if (status.getState() == TajoProtos.QueryState.QUERY_ERROR ||
status.getState() == TajoProtos.QueryState.QUERY_FAILED ||
status.getState() == TajoProtos.QueryState.QUERY_KILLED) {
progressBar = "@|red " + progressBar + "|@";
isLastLine = true;
}
String line = String.format(lineFormat, progressBar, progress, responseTime);
out.print(ansi().eraseLine(Ansi.Erase.ALL).a('\r').render(line));
if (isLastLine) {
out.println();
}
}
else {
String line = String.format(lineFormat, progressBar, progress, responseTime);
out.println(line);
}
out.flush();
}
代码示例来源:origin: org.actframework/act
private static String poweredBy(int width, String actVersion, boolean center) {
String poweredBy = "powered by ActFramework ";
int pw;
if (supportAnsi()) {
String raw = S.concat("powered by @|bold ActFramework|@ ", actVersion);
poweredBy = Ansi.ansi().render(raw).toString();
pw = raw.length() - 9;
} else {
poweredBy = poweredBy + actVersion;
pw = poweredBy.length();
}
int gap = width - pw;
gap = Math.max(gap, 0);
if (gap == 0) {
return poweredBy;
}
if (center) {
gap = (gap + 1) / 2;
}
return S.concat(S.times(" ", gap), poweredBy);
}
代码示例来源:origin: actframework/actframework
context.println(Ansi.ansi().render(S.join("\n", lines)).toString());
return true;
代码示例来源:origin: org.apache.felix.karaf.shell/org.apache.felix.karaf.shell.commands
@Override
protected Object doExecute() throws Exception {
History history = (History) session.get(".jline.history");
List<String> elements = history.getHistoryList();
int i = 0;
for (String element : elements) {
System.out.println(
Ansi.ansi()
.a(" ")
.a(Ansi.Attribute.INTENSITY_BOLD).render("%3d", i).a(Ansi.Attribute.INTENSITY_BOLD_OFF)
.a(" ")
.a(element)
.toString());
i++;
}
return null;
}
}
内容来源于网络,如有侵权,请联系作者删除!