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


Java Ansi类代码示例

本文整理汇总了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);
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:26,代码来源:AnsiConsole.java

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

示例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;
}
 
开发者ID:LoopPerfect,项目名称:buckaroo,代码行数:21,代码来源:TerminalBuffer.java

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

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

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

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

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

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

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

示例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
			}
		});
	}
 
开发者ID:manuelz120,项目名称:tetris4j,代码行数:28,代码来源:Main.java

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

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

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

示例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;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:23,代码来源:DefaultColorMap.java

示例15: createAnsi

import org.fusesource.jansi.Ansi; //导入依赖的package包/类
Ansi createAnsi() {
    if (forceAnsi) {
        return new Ansi();
    } else {
        return Ansi.ansi();
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:8,代码来源:AnsiConsole.java


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