当前位置: 首页>>代码示例>>Java>>正文


Java Ansi.a方法代码示例

本文整理汇总了Java中org.fusesource.jansi.Ansi.a方法的典型用法代码示例。如果您正苦于以下问题:Java Ansi.a方法的具体用法?Java Ansi.a怎么用?Java Ansi.a使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.fusesource.jansi.Ansi的用法示例。


在下文中一共展示了Ansi.a方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
 
开发者ID:LoopPerfect,项目名称:buckaroo,代码行数:21,代码来源:TerminalBuffer.java

示例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();
    }
 
开发者ID:dzikoysk,项目名称:NanoMaven,代码行数:21,代码来源:AnsiUtils.java

示例3: 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());

}
 
开发者ID:andyphillips404,项目名称:awplab-core,代码行数:22,代码来源:InstanceCommand.java

示例4: 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;
}
 
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:17,代码来源:AnsiConsole.java

示例5: 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();
}
 
开发者ID:apache,项目名称:tomee,代码行数:27,代码来源:ColorFormatter.java

示例6: redraw

import org.fusesource.jansi.Ansi; //导入方法依赖的package包/类
public void redraw() {
    boolean hasTextOnBottomLine = textCursor.row == 0 && textCursor.col > 0;
    if (writePos.row == 0 && writtenText.equals(text) && !hasTextOnBottomLine) {
        // Does not need to be redrawn
        return;
    }
    Ansi ansi = createAnsi();
    if (hasTextOnBottomLine) {
        int staleStatusChars = writePos.row > 0 ? 0 : writtenText.length();
        writePos.copyFrom(textCursor);
        positionCursorAt(writePos, ansi);
        if (staleStatusChars > textCursor.col) {
            ansi.eraseLine(Ansi.Erase.FORWARD);
        }
        ansi.newline();
        newLineWritten(writePos);
        writtenText = "";
    } else {
        writePos.bottomLeft();
        positionCursorAt(writePos, ansi);
    }
    if (text.length() > 0) {
        ColorMap.Color color = colorMap.getStatusBarColor();
        color.on(ansi);
        ansi.a(text);
        color.off(ansi);
    }
    if (text.length() < writtenText.length()) {
        ansi.eraseLine(Ansi.Erase.FORWARD);
    }
    write(ansi);
    charactersWritten(writePos, text.length());
    writtenText = text;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:35,代码来源:AnsiConsole.java

示例7: doLineText

import org.fusesource.jansi.Ansi; //导入方法依赖的package包/类
@Override
protected void doLineText(CharSequence text) {
    if (text.length() == 0) {
        return;
    }
    Ansi ansi = createAnsi();
    positionCursorAt(writePos, ansi);
    ColorMap.Color color = colorMap.getColourFor(getStyle());
    color.on(ansi);

    String textStr = text.toString();
    int pos = 0;
    while (pos < text.length()) {
        int next = textStr.indexOf('\t', pos);
        if (next == pos) {
            int charsToNextStop = CHARS_PER_TAB_STOP - (writePos.col % CHARS_PER_TAB_STOP);
            for(int i = 0; i < charsToNextStop; i++) {
                ansi.a(" ");
            }
            charactersWritten(writePos, charsToNextStop);
            pos++;
        } else if (next > pos) {
            ansi.a(textStr.substring(pos, next));
            charactersWritten(writePos, next - pos);
            pos = next;
        } else {
            ansi.a(textStr.substring(pos, textStr.length()));
            charactersWritten(writePos, textStr.length() - pos);
            pos = textStr.length();
        }
    }
    color.off(ansi);
    write(ansi);
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:35,代码来源:AnsiConsole.java

示例8: applyCode

import org.fusesource.jansi.Ansi; //导入方法依赖的package包/类
private Ansi applyCode(Ansi ansi, Code code) {
	if (code.isColor()) {
		if (code.isBackground()) {
			return ansi.bg(code.getColor());
		}
		return ansi.fg(code.getColor());
	}
	return ansi.a(code.getAttribute());
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:10,代码来源:AnsiString.java

示例9: logMessage

import org.fusesource.jansi.Ansi; //导入方法依赖的package包/类
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());
}
 
开发者ID:IG-Group,项目名称:ig-webapi-java-sample,代码行数:13,代码来源:Application.java

示例10: 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();
}
 
开发者ID:surgeplay,项目名称:Visage,代码行数:37,代码来源:VisageFormatter.java

示例11: 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 + "^");
    }
}
 
开发者ID:y-lan,项目名称:presto,代码行数:38,代码来源:Query.java

示例12: 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;
}
 
开发者ID:detectiveframework,项目名称:detective,代码行数:36,代码来源:ResultRenderAnsiConsoleImpl.java

示例13: withColor

import org.fusesource.jansi.Ansi; //导入方法依赖的package包/类
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;
}
 
开发者ID:TNG,项目名称:JGiven,代码行数:11,代码来源:PlainTextWriter.java

示例14: render

import org.fusesource.jansi.Ansi; //导入方法依赖的package包/类
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());
    }
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:12,代码来源:JAnsiTextRenderer.java

示例15: on

import org.fusesource.jansi.Ansi; //导入方法依赖的package包/类
public void on(Ansi ansi) {
    ansi.a(on);
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:4,代码来源:DefaultColorMap.java


注:本文中的org.fusesource.jansi.Ansi.a方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。