本文整理匯總了Java中org.fusesource.jansi.Ansi.reset方法的典型用法代碼示例。如果您正苦於以下問題:Java Ansi.reset方法的具體用法?Java Ansi.reset怎麽用?Java Ansi.reset使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.fusesource.jansi.Ansi
的用法示例。
在下文中一共展示了Ansi.reset方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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;
}
示例2: 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();
}
示例3: format
import org.fusesource.jansi.Ansi; //導入方法依賴的package包/類
@Override
public String format(LogRecord record) {
if (record.getThrown() != null) {
record.getThrown().printStackTrace();
}
Ansi ansi = Ansi.ansi();
if (Visage.ansi) {
ansi.fgBright(Color.BLACK);
}
Date date = new Date(record.getMillis());
ansi.a("@");
ansi.a(format.format(date));
if (Visage.ansi) {
ansi.reset();
}
ansi.a(Strings.padStart(Thread.currentThread().getName(), 22, ' '));
ansi.a(" ");
if (Visage.ansi && colors.containsKey(record.getLevel())) {
ansi.fgBright(colors.get(record.getLevel()));
}
ansi.a(names.get(record.getLevel()));
if (Visage.ansi) {
ansi.reset();
}
ansi.a(": ");
if (Visage.ansi && colors.containsKey(record.getLevel()) && record.getLevel().intValue() >= Level.SEVERE.intValue()) {
ansi.bold();
ansi.fgBright(colors.get(record.getLevel()));
}
ansi.a(record.getMessage());
if (Visage.ansi) {
ansi.reset();
}
ansi.a("\n");
return ansi.toString();
}
示例4: renderErrorLocation
import org.fusesource.jansi.Ansi; //導入方法依賴的package包/類
private static void renderErrorLocation(String query, ErrorLocation location, PrintStream out)
{
List<String> lines = ImmutableList.copyOf(Splitter.on('\n').split(query).iterator());
String errorLine = lines.get(location.getLineNumber() - 1);
String good = errorLine.substring(0, location.getColumnNumber() - 1);
String bad = errorLine.substring(location.getColumnNumber() - 1);
if ((location.getLineNumber() == lines.size()) && bad.trim().isEmpty()) {
bad = " <EOF>";
}
if (REAL_TERMINAL) {
Ansi ansi = Ansi.ansi();
ansi.fg(Ansi.Color.CYAN);
for (int i = 1; i < location.getLineNumber(); i++) {
ansi.a(lines.get(i - 1)).newline();
}
ansi.a(good);
ansi.fg(Ansi.Color.RED);
ansi.a(bad).newline();
for (int i = location.getLineNumber(); i < lines.size(); i++) {
ansi.a(lines.get(i)).newline();
}
ansi.reset();
out.print(ansi);
}
else {
String prefix = format("LINE %s: ", location.getLineNumber());
String padding = Strings.repeat(" ", prefix.length() + (location.getColumnNumber() - 1));
out.println(prefix + errorLine);
out.println(padding + "^");
}
}
示例5: createAnsiCode
import org.fusesource.jansi.Ansi; //導入方法依賴的package包/類
Ansi createAnsiCode(JobRunResult result){
Ansi ansi = ansi();
Color currentColor;
if (result.isIgnored()){
currentColor = BLUE;
}else if (result.getSuccessed())
currentColor = GREEN;
else
currentColor = RED;
ansi.fg(currentColor);
ansi.bold().a("Story Name: ").a(result.getStoryName()).boldOff()
.a("\n").bold().a("| -- Scenario Name: ").boldOff().a(result.getScenarioName());
if (result.isIgnored()){
ansi.a("\n").bold().a("| -- Ignored: Yes").boldOff();
}else{
ansi.a("\n").bold().a("| -- Successed: ").boldOff().a(result.getSuccessed() ? "Yes" : "Failed" );
}
ansi.a("\n");
renderSteps(ansi, result.getSteps(), currentColor);
if (result.getError() != null){
ansi.bold().a("| -- Error: ").a(result.getError().getMessage()).boldOff().a("\n");
ansi.bold().a("| -- Error Callstack:").boldOff().a(Utils.getStackTrace(result.getError())).a("\n");
}
ansi.reset();
return ansi;
}
示例6: suffix
import org.fusesource.jansi.Ansi; //導入方法依賴的package包/類
protected Ansi suffix(final Ansi ansi, final LogRecord record) {
return ansi.reset();
}
示例7: execute
import org.fusesource.jansi.Ansi; //導入方法依賴的package包/類
@Override
public Object execute() throws Exception {
Ansi buffer = Ansi.ansi();
boolean found = false;
for (Factory factory : managerService.getFactories()) {
if (name.equals(factory.getName())) {
printFactoryDetails(buffer, factory);
found = true;
}
}
PrintStream stream = System.out;
if (!found) {
// Use error stream
stream = System.err;
// Creates an error message
buffer.a(" [");
buffer.a(Ansi.Color.RED);
buffer.a("ERROR");
buffer.reset();
buffer.a("] ");
buffer.a("Factory '");
buffer.a(Ansi.Attribute.ITALIC);
buffer.a(name);
buffer.a(Ansi.Attribute.ITALIC_OFF);
buffer.a("' was not found.\n");
}
// Flush buffer's content
stream.println(buffer.toString());
return null;
}
示例8: printFactoryDetails
import org.fusesource.jansi.Ansi; //導入方法依賴的package包/類
private void printFactoryDetails(Ansi buffer, Factory factory) {
String status = "INVALID";
Ansi.Color color = Ansi.Color.RED;
// Check Factory state
if (factory.getState() == Factory.VALID) {
status = "VALID";
color = Ansi.Color.GREEN;
}
// Print factory name first
buffer.a(factory.getName());
buffer.a(" ");
// Then its status
buffer.a("[");
buffer.fg(color);
buffer.a(status);
buffer.reset();
buffer.a("]\n");
// Finally display the factory description
AnsiPrintToolkit toolkit = new AnsiPrintToolkit(buffer);
toolkit.printElement(0, factory.getDescription());
}