當前位置: 首頁>>代碼示例>>Java>>正文


Java AnsiConsole類代碼示例

本文整理匯總了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();
    }
 
開發者ID:StuPro-TOSCAna,項目名稱:TOSCAna,代碼行數:19,代碼來源:CliMain.java

示例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();
}
 
開發者ID:KeydownR,項目名稱:lifeInvader-SchoolProject,代碼行數:16,代碼來源:CliView.java

示例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
			}
		});
	}
 
開發者ID:manuelz120,項目名稱:tetris4j,代碼行數:28,代碼來源:Main.java

示例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();
    }
 
開發者ID:remkop,項目名稱:picocli,代碼行數:11,代碼來源:WindowsJansiDemo.java

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

}
 
開發者ID:s3curitybug,項目名稱:similarity-uniform-fuzzy-hash,代碼行數:44,代碼來源:VisualRepresentation.java

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

}
 
開發者ID:s3curitybug,項目名稱:similarity-uniform-fuzzy-hash,代碼行數:23,代碼來源:UniformFuzzyHashes.java

示例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();
}
 
開發者ID:Superioz,項目名稱:MooProject,代碼行數:11,代碼來源:ExtendedLogger.java

示例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?");
    }
}
 
開發者ID:Clout-Team,項目名稱:JarCraftinator,代碼行數:9,代碼來源:Logger.java

示例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();
}
 
開發者ID:lfkdsk,項目名稱:Just-Evaluator,代碼行數:25,代碼來源:JustRepl.java

示例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();
}
 
開發者ID:gabixdev,項目名稱:Kyoko,代碼行數:48,代碼來源:Kyoko.java

示例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();
}
 
開發者ID:BukkitPE,項目名稱:BukkitPE,代碼行數:19,代碼來源:MainLogger.java

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

}
 
開發者ID:Nukkit,項目名稱:WarpEngine,代碼行數:23,代碼來源:WarpEngine.java

示例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();
}
 
開發者ID:KeydownR,項目名稱:lifeInvader-SchoolProject,代碼行數:17,代碼來源:CliView.java

示例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();
}
 
開發者ID:Project-Nyx,項目名稱:Nyx,代碼行數:26,代碼來源:Launcher.java

示例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();
   }
}
 
開發者ID:IG-Group,項目名稱:ig-webapi-java-sample,代碼行數:41,代碼來源:Application.java


注:本文中的org.fusesource.jansi.AnsiConsole類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。