本文整理汇总了Java中org.fusesource.jansi.AnsiConsole类的典型用法代码示例。如果您正苦于以下问题:Java AnsiConsole类的具体用法?Java AnsiConsole怎么用?Java AnsiConsole使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AnsiConsole类属于org.fusesource.jansi包,在下文中一共展示了AnsiConsole类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.fusesource.jansi.AnsiConsole; //导入依赖的package包/类
public void main(String[] args) {
//Activate ANSI on Windows
AnsiConsole.systemInstall();
System.setProperty("picocli.ansi", "true");
//System Property gets set here, because picocli.trace must be set before CommandLine starts
String input = String.join("", args);
if (input.contains("-m")) {
System.setProperty("picocli.trace", "DEBUG");
} else if (input.contains("-v")) {
System.setProperty("picocli.trace", "INFO");
}
CommandLine commandLine = new CommandLine(new CliMain(), new CliPropertiesFactory(apiController));
commandLine.parseWithHandler(new CommandLine.RunLast(), System.err, args);
AnsiConsole.systemUninstall();
}
示例2: winScreen
import org.fusesource.jansi.AnsiConsole; //导入依赖的package包/类
/**
* Draw a Win screen
*/
@Override
public void winScreen() {
clear();
show(" ");
drawLifeInvader();
drawSeparator();
show("__ _____ _ _ __ _____ _ _ _", YELLOW);
show("\\ \\ / / _ \\| | | | \\ \\ / / _ \\| \\| | | |", YELLOW);
show(" \\ V / (_) | |_| | \\ \\/\\/ / (_) | .` | |_|", YELLOW);
show(" |_| \\___/ \\___/ \\_/\\_/ \\___/|_|\\_| (_)", YELLOW);
AnsiConsole.systemUninstall();
}
示例3: initializeGame
import org.fusesource.jansi.AnsiConsole; //导入依赖的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
}
});
}
示例4: main
import org.fusesource.jansi.AnsiConsole; //导入依赖的package包/类
public static void main(String[] args) {
// On Windows without Cygwin or similar, picocli will not emit ANSI escape codes by default.
// Force ANSI ON if no user preference, otherwise let user decide.
Ansi ansi = System.getProperty("picocli.ansi") == null ? Ansi.ON : Ansi.AUTO;
AnsiConsole.systemInstall(); // Jansi magic
CommandLine.run(new WindowsJansiDemo(), System.err, ansi, args);
AnsiConsole.systemUninstall();
}
示例5: print
import org.fusesource.jansi.AnsiConsole; //导入依赖的package包/类
/**
* Prints a Uniform Fuzzy Hash in a visual way.
*
* @param hash The Uniform Fuzzy Hash.
* @param base The characters base which will be used to represent the blocks.
* @param factorDivisor Amount of characters per factor size for each block.
* @param lineWrap Amount of characters per line. If this argument is lower than 1, no line wrap
* is performed and the full representation is printed in one line.
* @param concatenatePercent In case line wrap is performed, true to concatenate to each line
* its relative percent to the total length.
*/
public static void print(
UniformFuzzyHash hash,
char[] base,
int factorDivisor,
int lineWrap,
boolean concatenatePercent) {
// Representation.
String representation = represent(hash, base, factorDivisor);
List<String> wrappedRepresentation =
wrapString(representation, lineWrap, concatenatePercent);
// Print.
final PrintStream printStream = System.out;
if (printStream == AnsiConsole.out) {
AnsiConsole.systemInstall();
}
printStream.println();
for (String line : wrappedRepresentation) {
printStream.println(line);
}
printStream.println();
if (printStream == AnsiConsole.out) {
AnsiConsole.systemUninstall();
}
}
示例6: printColumn
import org.fusesource.jansi.AnsiConsole; //导入依赖的package包/类
/**
* Prints a string followed by an amount of spaces such that columnSize characters are printed.
*
* @param text The string to print.
* @param columnSize Amount of characters to print.
* @param printStream Print stream that will be used to print.
*/
private static void printColumn(
String text,
int columnSize,
PrintStream printStream) {
int textLength = 0;
if (printStream == AnsiConsole.out) {
textLength = AnsiCodeColors.remove(text).length();
} else {
textLength = text.length();
}
printStream.print(text + spaces(columnSize - textLength));
}
示例7: disable
import org.fusesource.jansi.AnsiConsole; //导入依赖的package包/类
/**
* Disables the logger and shutdowns the ansi console
*/
public void disable() {
if(baseLogger instanceof MooLogger) {
((MooLogger) baseLogger).close();
}
AnsiConsole.systemUninstall();
executor.shutdownNow();
}
示例8: destroy
import org.fusesource.jansi.AnsiConsole; //导入依赖的package包/类
public void destroy(){
AnsiConsole.systemUninstall();
try {
logWriter.close();
}catch(IOException ex){
System.out.println("Unable to close log file! Perhaps it was deleted?");
}
}
示例9: main
import org.fusesource.jansi.AnsiConsole; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
AnsiConsole.systemInstall();
Logger.init();
logoStr = logoStr.replace("█", ansi().fg(Ansi.Color.GREEN).a("█").reset().toString());
System.out.println(ansi().eraseScreen().render(logoStr));
System.out.println(ANSI_PURPLE + "Welcome to JustEL Debug Tools~~" + ANSI_RESET);
System.out.println(ansi().fgBrightGreen().render(help).reset().toString());
if (args.length < 1) {
System.out.println(ansi().fgBrightRed().render("need more args").reset().toString());
return;
}
String type = args[0];
resolveCommandFlag(type, true);
run();
// close executor
executor.shutdown();
}
示例10: start
import org.fusesource.jansi.AnsiConsole; //导入依赖的package包/类
public void start() throws LoginException, InterruptedException, RateLimitedException {
running = true;
// init logger
AnsiConsole.systemInstall();
log = Logger.getLogger("Kyoko");
log.setUseParentHandlers(false);
ColoredFormatter formatter = new ColoredFormatter();
ConsoleHandler handler = new ConsoleHandler();
handler.setFormatter(formatter);
log.addHandler(handler);
log.info("Kyoko v" + Constants.VERSION + " is starting...");
i18n.loadMessages();
JDABuilder builder = new JDABuilder(AccountType.BOT);
if (settings.getToken() != null) {
if (settings.getToken().equalsIgnoreCase("Change me")) {
System.out.println("No token specified, please set it in config.json");
System.exit(1);
}
builder.setToken(settings.getToken());
}
boolean gameEnabled = false;
if (settings.getGame() != null && !settings.getGame().isEmpty()) {
gameEnabled = true;
builder.setGame(Game.of("booting..."));
}
builder.setAutoReconnect(true);
builder.setBulkDeleteSplittingEnabled(false);
builder.addEventListener(eventHandler);
builder.setAudioEnabled(true);
builder.setStatus(OnlineStatus.IDLE);
jda = builder.buildBlocking();
log.info("Invite link: " + "https://discordapp.com/oauth2/authorize?&client_id=" + jda.getSelfUser().getId() + "&scope=bot&permissions=" + Constants.PERMISSIONS);
if (gameEnabled) {
Thread t = new Thread(new Kyoko.BlinkThread());
t.start();
}
registerCommands();
}
示例11: MainLogger
import org.fusesource.jansi.AnsiConsole; //导入依赖的package包/类
public MainLogger(String logFile, Boolean logDebug) {
AnsiConsole.systemInstall();
if (logger != null) {
throw new RuntimeException("MainLogger has been already created");
}
logger = this;
this.logFile = new File(logFile);
if (!this.logFile.exists()) {
try {
this.logFile.createNewFile();
} catch (IOException e) {
this.logException(e);
}
}
this.logDebug = logDebug;
this.start();
}
示例12: main
import org.fusesource.jansi.AnsiConsole; //导入依赖的package包/类
public static void main(String[] args) {
for (String arg : args) {
switch (arg) {
case "-disable-ansi":
ANSI = false;
break;
case "-dev":
DEV_MODE = true;
break;
default:
System.out.println("WarpEngine: \"" + arg + "\" is not a WarpEngine start parameter.");
}
}
if (ANSI) {
//Enable ANSI
AnsiConsole.systemInstall();
}
new WarpEngine();
}
示例13: gameOverScreen
import org.fusesource.jansi.AnsiConsole; //导入依赖的package包/类
/**
* Draw a game over screen
*/
@Override
public void gameOverScreen() {
clear();
show(" ");
drawLifeInvader();
drawSeparator();
show(" ___ _ __ __ ___ _____ _____ ___ _", RED);
show(" / __| /_\\ | \\/ | __| / _ \\ \\ / / __| _ \\ | |", RED);
show("| (_ |/ _ \\| |\\/| | _| | (_) \\ V /| _|| / |_|", RED);
show(" \\___/_/ \\_\\_| |_|___| \\___/ \\_/ |___|_|_\\ (_)", RED);
AnsiConsole.systemUninstall();
}
示例14: main
import org.fusesource.jansi.AnsiConsole; //导入依赖的package包/类
/**
* Entry method from command line
*
* @param args Arguments from command line
* @throws ParseException Exit directly if there are command line problems. This is dependent on the terminal that
* started this program, so it is applicable to return the error to terminal directly.
*/
public static void main(String[] args) throws ParseException {
long serverStartTime = System.currentTimeMillis();
Options options = new Options()
.addOption("m", "module-path", true, "Path to the directory to load module files in")
.addOption("d", "data-path", true, "Path to the directory to store data in");
CommandLine line = new DefaultParser().parse(options, args);
AnsiConsole.systemInstall();
File modules = new File(line.getOptionValue("m", "modules")).getAbsoluteFile();
modules.mkdirs();
File data = new File(line.getOptionValue("d", ".")).getAbsoluteFile();
data.mkdirs();
Nyx.builder()
.modulePath(modules)
.dataPath(data)
.serverStartTime(serverStartTime)
.build();
}
示例15: run
import org.fusesource.jansi.AnsiConsole; //导入依赖的package包/类
private boolean run(final String user, final String password, final String apiKey, final String epic) {
InputStreamReader reader = new InputStreamReader(System.in);
try(BufferedReader in = new BufferedReader(reader)) {
AnsiConsole.systemInstall();
System.out.println(ansi().eraseScreen());
connect(user, password, apiKey);
if(StringUtils.isNotBlank(epic)) {
tradeableEpic = getTradeableEpic(epic);
} else {
tradeableEpic = getTradableEpicFromWatchlist();
}
subscribeToLighstreamerAccountUpdates();
subscribeToLighstreamerHeartbeat();
subscribeToLighstreamerPriceUpdates();
subscribeToLighstreamerTradeUpdates();
logStatusMessage("Press ENTER to BUY");
ConversationContextV3 contextV3 = (ConversationContextV3) authenticationContext.getConversationContext();
while(true) {
if(new Date().getTime() + 5000 > contextV3.getAccessTokenExpiry()) { // Refresh the access token 5 seconds before expiry
logStatusMessage("Refreshing access token");
contextV3 = refreshAccessToken(contextV3);
}
Thread.sleep(20);
if (in.ready()) {
in.readLine();
createPosition();
}
}
} catch (Exception e) {
logStatusMessage("Failure: " + e.getMessage());
return false;
} finally {
disconnect();
AnsiConsole.systemUninstall();
}
}