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


Java Ansi.fg方法代码示例

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


在下文中一共展示了Ansi.fg方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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

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

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

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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: readBoolean

import org.fusesource.jansi.Ansi; //导入方法依赖的package包/类
/**
 * Displays a message and reads a boolean from the user input.
 * The mapping of the user input to a boolean value is specified by the implementation.
 *
 * @param message
 * @param defaultValue
 * @return
 */
@Override
public boolean readBoolean(String message, Boolean defaultValue) throws IOException {
    saveCursorPosition();
    Ansi style = ansi();
    if (getTheme().getPromptBackground() != null) {
        style.bg(getTheme().getPromptBackground());
    }
    if (getTheme().getPromptForeground() != null) {
        style.fg(getTheme().getPromptForeground());
    }
    for (int i = 1; i <= getFooterSize(); i++) {
        JlEditConsole.out.print(ansi().cursor(terminal.getHeight() - getFooterSize() + i, 1));
        JlEditConsole.out.print(style.eraseLine(Ansi.Erase.FORWARD));
    }
    JlEditConsole.out.print(ansi().cursor(terminal.getHeight(), 1));
    JlEditConsole.out.print(style.a(message).bold().eraseLine(Ansi.Erase.FORWARD));
    restoreCursorPosition();
    flush();
    try {
        EditorOperation operation;
        while (true) {
            operation = readOperation();
            switch (operation.getType()) {
                case NEWLINE:
                    return defaultValue;
                case TYPE:
                    if ("y".equals(operation.getInput()) || "Y".equals(operation.getInput())) {
                        return true;
                    } else if ("n".equals(operation.getInput()) || "N".equals(operation.getInput())) {
                        return false;
                    }
            }
        }
    } finally {
        redrawFooter();
    }
}
 
开发者ID:jledit,项目名称:jledit,代码行数:46,代码来源:AbstractConsoleEditor.java

示例11: readLine

import org.fusesource.jansi.Ansi; //导入方法依赖的package包/类
public String readLine(String message) throws IOException {
    String result = null;
    saveCursorPosition();
    Ansi style = ansi();
    if (getTheme().getPromptBackground() != null) {
        style.bg(getTheme().getPromptBackground());
    }
    if (getTheme().getPromptForeground() != null) {
        style.fg(getTheme().getPromptForeground());
    }
    for (int i = 1; i <= getFooterSize(); i++) {
        JlEditConsole.out.print(ansi().cursor(terminal.getHeight() - getFooterSize() + i, 1));
        JlEditConsole.out.print(style.eraseLine(Ansi.Erase.FORWARD));
    }
    JlEditConsole.out.print(ansi().cursor(terminal.getHeight(), 1));
    JlEditConsole.out.print(ansi().cursor(terminal.getHeight(), 1));
    JlEditConsole.out.print(style.a(message).bold().eraseLine(Ansi.Erase.FORWARD));
    flush();
    try {
        result = readLine();
    } finally {
        JlEditConsole.out.print(ansi().reset());
        restoreCursorPosition();
        redrawFooter();
    }
    return result;
}
 
开发者ID:jledit,项目名称:jledit,代码行数:28,代码来源:AbstractConsoleEditor.java

示例12: 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

示例13: on

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

示例14: off

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

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

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


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